├── LICENSE ├── README.md ├── device.go ├── doc.go ├── eeprom.go ├── error.go ├── examples ├── ftdi_bitbang │ └── main.go ├── ftdi_chipid │ └── main.go ├── ftdi_dcf77 │ └── main.go ├── ftdi_eeprom │ └── main.go ├── ftdi_lcd │ └── main.go ├── ftdi_naive_lcd │ └── main.go ├── ftdi_out │ └── main.go ├── ftdi_sbb_speed │ └── main.go └── ftdi_spi │ └── main.go ├── ftn ├── device_linux.go ├── ftdi.go ├── ftn_example │ └── main.go └── readme.txt ├── go.mod ├── go.sum └── libftdi1-1.5 ├── Copyright ├── libftdi │ ├── AUTHORS │ ├── COPYING-CMAKE-SCRIPTS │ ├── COPYING.GPL │ ├── COPYING.LIB │ ├── LICENSE │ ├── README │ ├── README.build │ └── README.mingw └── libusb │ ├── AUTHORS │ ├── COPYING │ └── README ├── Driver └── Driver.txt ├── Readme.txt ├── include ├── libftdi │ ├── ftdi.h │ └── ftdi.hpp └── libusb-1.0 │ └── libusb.h ├── lib32 ├── libftdi1.a └── libusb-1.0.a └── lib64 ├── libftdi1.a └── libusb-1.0.a /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Michal Derkacz 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 3. The name of the author may not be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Go bindings for libFTDI (http://www.intra2net.com/en/developer/libftdi/) 2 | 3 | [documentation](https://godoc.org/github.com/ziutek/ftdi) 4 | -------------------------------------------------------------------------------- /device.go: -------------------------------------------------------------------------------- 1 | package ftdi 2 | 3 | /* 4 | #include 5 | #include 6 | #include 7 | 8 | #cgo windows CFLAGS: -Ilibftdi1-1.5/include/libftdi -Ilibftdi1-1.5/include/libusb-1.0 9 | #cgo windows LDFLAGS: ${SRCDIR}/libftdi1-1.5/lib64/libftdi1.a ${SRCDIR}/libftdi1-1.5/lib64/libusb-1.0.a 10 | #cgo linux pkg-config: libftdi1 11 | #cgo darwin pkg-config: libftdi1 12 | 13 | // libftdi 1.5 deprecated the purge API. Use a wrapper to avoid the 14 | // deprecation warnings while still supporting 1.4. 15 | int libftdi_tciflush(struct ftdi_context *ftdi) { 16 | #ifdef SIO_TCIFLUSH 17 | return ftdi_tciflush(ftdi); 18 | #else 19 | return ftdi_usb_purge_rx_buffer(ftdi); 20 | #endif 21 | } 22 | 23 | int libftdi_tcoflush(struct ftdi_context *ftdi) { 24 | #ifdef SIO_TCIFLUSH 25 | return ftdi_tcoflush(ftdi); 26 | #else 27 | return ftdi_usb_purge_tx_buffer(ftdi); 28 | #endif 29 | } 30 | 31 | int libftdi_tcioflush(struct ftdi_context *ftdi) { 32 | #ifdef SIO_TCIFLUSH 33 | return ftdi_tcioflush(ftdi); 34 | #else 35 | return ftdi_usb_purge_buffers(ftdi); 36 | #endif 37 | } 38 | 39 | */ 40 | import "C" 41 | 42 | import ( 43 | "errors" 44 | "runtime" 45 | "unicode/utf16" 46 | "unsafe" 47 | ) 48 | 49 | func makeError(ctx *C.struct_ftdi_context, code C.int) error { 50 | if code >= 0 { 51 | return nil 52 | } 53 | return &Error{ 54 | code: int(code), 55 | str: C.GoString(C.ftdi_get_error_string(ctx)), 56 | } 57 | } 58 | 59 | type USBDev struct { 60 | Manufacturer, Description, Serial string 61 | 62 | d *C.struct_libusb_device 63 | } 64 | 65 | func (u *USBDev) unref() { 66 | if u.d == nil { 67 | panic("USBDev.unref on uninitialized device") 68 | } 69 | C.libusb_unref_device(u.d) 70 | u.d = nil // Help GC. 71 | } 72 | 73 | func (u *USBDev) Close() { 74 | runtime.SetFinalizer(u, nil) 75 | u.unref() 76 | } 77 | 78 | func getLangId(dh *C.libusb_device_handle) (C.uint16_t, error) { 79 | var buf [128]C.char 80 | e := C.libusb_get_string_descriptor( 81 | dh, 0, 0, 82 | (*C.uchar)(unsafe.Pointer(&buf[0])), C.int(len(buf)), 83 | ) 84 | if e < 0 { 85 | return 0, USBError(e) 86 | } 87 | if e < 4 { 88 | return 0, errors.New("not enough data in USB language IDs descriptor") 89 | } 90 | return C.uint16_t(uint(buf[2]) | uint(buf[3])<<8), nil 91 | } 92 | 93 | func getStringDescriptor(dh *C.libusb_device_handle, id C.uint8_t, langid C.uint16_t) (string, error) { 94 | var buf [128]C.char 95 | e := C.libusb_get_string_descriptor( 96 | dh, id, C.uint16_t(langid), 97 | (*C.uchar)(unsafe.Pointer(&buf[0])), C.int(len(buf)), 98 | ) 99 | if e < 0 { 100 | return "", USBError(e) 101 | } 102 | if e < 2 { 103 | return "", errors.New("not enough data for USB string descriptor") 104 | } 105 | l := C.int(buf[0]) 106 | if l > e { 107 | return "", errors.New("USB string descriptor is too short") 108 | } 109 | b := buf[2:l] 110 | uni16 := make([]uint16, len(b)/2) 111 | for i := range uni16 { 112 | uni16[i] = uint16(b[i*2]) | uint16(b[i*2+1])<<8 113 | } 114 | return string(utf16.Decode(uni16)), nil 115 | } 116 | 117 | // getStrings updates Manufacturer, Description, Serial strings descriptors 118 | // in unicode form. It doesn't use ftdi_usb_get_strings because libftdi 119 | // converts unicode strings to ASCII. 120 | func (u *USBDev) getStrings(dev *C.libusb_device, ds *C.struct_libusb_device_descriptor) error { 121 | var ( 122 | err error 123 | dh *C.libusb_device_handle 124 | ) 125 | if e := C.libusb_open(dev, &dh); e != 0 { 126 | return USBError(e) 127 | } 128 | defer C.libusb_close(dh) 129 | langid, err := getLangId(dh) 130 | if err != nil { 131 | return err 132 | } 133 | u.Manufacturer, err = getStringDescriptor(dh, ds.iManufacturer, langid) 134 | if err != nil { 135 | return err 136 | } 137 | u.Description, err = getStringDescriptor(dh, ds.iProduct, langid) 138 | if err != nil { 139 | return err 140 | } 141 | u.Serial, err = getStringDescriptor(dh, ds.iSerialNumber, langid) 142 | return err 143 | } 144 | 145 | /*func FindAll(vendor, product int) ([]*USBDev, error) { 146 | ctx := new(C.struct_ftdi_context) 147 | e := C.ftdi_init(ctx) 148 | // defer C.ftdi_deinit(ctx) 149 | if e < 0 { 150 | return nil, makeError(ctx, e) 151 | } 152 | var dl *C.struct_ftdi_device_list 153 | e = C.ftdi_usb_find_all(ctx, &dl, C.int(vendor), C.int(product)) 154 | if e < 0 { 155 | return nil, makeError(ctx, e) 156 | } 157 | defer C.ftdi_list_free2(dl) 158 | 159 | n := 0 160 | for el := dl; el != nil; el = el.next { 161 | n++ 162 | } 163 | ret := make([]*USBDev, n) 164 | i := 0 165 | for el := dl; el != nil; el = el.next { 166 | u := new(USBDev) 167 | u.d = el.dev 168 | C.libusb_ref_device(el.dev) 169 | runtime.SetFinalizer(u, (*USBDev).unref) 170 | if err := u.getStrings(ctx); err != nil { 171 | return nil, err 172 | } 173 | ret[i] = u 174 | i++ 175 | } 176 | return ret, nil 177 | }*/ 178 | 179 | // FindAll search for all USB devices with specified vendor and product id. 180 | // It returns slice od found devices. 181 | func FindAll(vendor, product int) ([]*USBDev, error) { 182 | if e := C.libusb_init(nil); e != 0 { 183 | return nil, USBError(e) 184 | } 185 | var dptr **C.struct_libusb_device 186 | if e := C.libusb_get_device_list(nil, &dptr); e < 0 { 187 | return nil, USBError(e) 188 | } 189 | defer C.libusb_free_device_list(dptr, 1) 190 | devs := (*[1 << 28]*C.libusb_device)(unsafe.Pointer(dptr)) 191 | 192 | var n int 193 | for i, dev := range devs[:] { 194 | if dev == nil { 195 | n = i 196 | break 197 | } 198 | } 199 | descr := make([]*C.struct_libusb_device_descriptor, n) 200 | for i, dev := range devs[:n] { 201 | var ds C.struct_libusb_device_descriptor 202 | if e := C.libusb_get_device_descriptor(dev, &ds); e < 0 { 203 | return nil, USBError(e) 204 | } 205 | if int(ds.idVendor) == vendor && int(ds.idProduct) == product { 206 | descr[i] = &ds 207 | continue 208 | } 209 | if vendor == 0 && product == 0 && ds.idVendor == 0x403 { 210 | switch ds.idProduct { 211 | case 0x6001, 0x6010, 0x6011, 0x6014, 0x6015: 212 | descr[i] = &ds 213 | continue 214 | } 215 | } 216 | n-- 217 | } 218 | if n == 0 { 219 | return nil, nil 220 | } 221 | ret := make([]*USBDev, n) 222 | n = 0 223 | for i, ds := range descr { 224 | if ds == nil { 225 | continue 226 | } 227 | u := new(USBDev) 228 | u.d = devs[i] 229 | C.libusb_ref_device(u.d) 230 | runtime.SetFinalizer(u, (*USBDev).unref) 231 | u.getStrings(u.d, ds) 232 | ret[n] = u 233 | n++ 234 | } 235 | return ret, nil 236 | } 237 | 238 | // Device represents FTDI device. 239 | type Device struct { 240 | ctx *C.struct_ftdi_context 241 | } 242 | 243 | // Type is numeric type id of FTDI device. 244 | type Type uint32 245 | 246 | const ( 247 | TypeAM Type = iota 248 | TypeBM 249 | Type2232C 250 | TypeR 251 | Type2232H 252 | Type4232H 253 | Type232H 254 | Type230x 255 | ) 256 | 257 | var types = []string{"AM", "BM", "2232C", "R", "2232H", "4232H", "232H", "230X"} 258 | 259 | // String returns text name that describes type id. 260 | func (t Type) String() string { 261 | if t >= Type(len(types)) { 262 | return "unknown" 263 | } 264 | return types[t] 265 | } 266 | 267 | // Type returns type of device d. 268 | func (d *Device) Type() Type { 269 | return Type(d.ctx._type) 270 | } 271 | 272 | func (d *Device) free() { 273 | if d.ctx == nil { 274 | panic("Device.free on uninitialized device") 275 | } 276 | C.ftdi_free(d.ctx) 277 | d.ctx = nil 278 | } 279 | 280 | func (d *Device) makeError(code C.int) error { 281 | return makeError(d.ctx, code) 282 | } 283 | 284 | func (d *Device) close() error { 285 | defer d.free() 286 | if e := C.ftdi_usb_close(d.ctx); e != 0 { 287 | return d.makeError(e) 288 | } 289 | return nil 290 | } 291 | 292 | // Close closes device 293 | func (d *Device) Close() error { 294 | runtime.SetFinalizer(d, nil) 295 | return d.close() 296 | } 297 | 298 | func makeDevice(c Channel) (*Device, error) { 299 | ctx, err := C.ftdi_new() 300 | if ctx == nil { 301 | return nil, err 302 | } 303 | d := &Device{ctx} 304 | if c != ChannelAny { 305 | if e := C.ftdi_set_interface(d.ctx, uint32(c)); e < 0 { 306 | defer d.free() 307 | return nil, d.makeError(e) 308 | } 309 | } 310 | return d, nil 311 | } 312 | 313 | // Channel represents channel (interface) of FTDI device. Some devices have more 314 | // than one channel (eg. FT2232 has 2 channels, FT4232 has 4 channels). 315 | type Channel uint32 316 | 317 | const ( 318 | ChannelAny Channel = iota 319 | ChannelA 320 | ChannelB 321 | ChannelC 322 | ChannelD 323 | ) 324 | 325 | // OpenUSBDev opens channel (interface) c of USB device u. 326 | // u must be FTDI device. 327 | func OpenUSBDev(u *USBDev, c Channel) (*Device, error) { 328 | d, err := makeDevice(c) 329 | if err != nil { 330 | return nil, err 331 | } 332 | if e := C.ftdi_usb_open_dev(d.ctx, u.d); e < 0 { 333 | defer d.free() 334 | return nil, d.makeError(e) 335 | } 336 | runtime.SetFinalizer(d, (*Device).close) 337 | return d, nil 338 | } 339 | 340 | // OpenFirst opens the first device with a given vendor and product ids. Uses 341 | // specified channel c. 342 | func OpenFirst(vendor, product int, c Channel) (*Device, error) { 343 | d, err := makeDevice(c) 344 | if err != nil { 345 | return nil, err 346 | } 347 | if e := C.ftdi_usb_open(d.ctx, C.int(vendor), C.int(product)); e < 0 { 348 | defer d.free() 349 | return nil, d.makeError(e) 350 | } 351 | runtime.SetFinalizer(d, (*Device).close) 352 | return d, nil 353 | } 354 | 355 | // Open opens the index-th device with a given vendor id, product id, 356 | // description and serial. Uses specified channel c. 357 | func Open(vendor, product int, description, serial string, index uint, 358 | c Channel) (*Device, error) { 359 | 360 | d, err := makeDevice(c) 361 | if err != nil { 362 | return nil, err 363 | } 364 | descr := C.CString(description) 365 | defer C.free(unsafe.Pointer(descr)) 366 | ser := C.CString(serial) 367 | defer C.free(unsafe.Pointer(ser)) 368 | 369 | e := C.ftdi_usb_open_desc_index( 370 | d.ctx, 371 | C.int(vendor), C.int(product), 372 | descr, ser, 373 | C.uint(index), 374 | ) 375 | if e < 0 { 376 | defer d.free() 377 | return nil, d.makeError(e) 378 | } 379 | runtime.SetFinalizer(d, (*Device).close) 380 | return d, nil 381 | } 382 | 383 | // OpenBusAddr opens the device at a given USB bus and device address. Uses 384 | // specified channel c. 385 | func OpenBusAddr(bus, address int, c Channel) (*Device, error) { 386 | d, err := makeDevice(c) 387 | if err != nil { 388 | return nil, err 389 | } 390 | e := C.ftdi_usb_open_bus_addr( 391 | d.ctx, 392 | C.uint8_t(bus), 393 | C.uint8_t(address), 394 | ) 395 | if e < 0 { 396 | defer d.free() 397 | return nil, d.makeError(e) 398 | } 399 | runtime.SetFinalizer(d, (*Device).close) 400 | return d, nil 401 | } 402 | 403 | // OpenString opens the ftdi-device described by a description-string. Uses 404 | // specified channel c. 405 | func OpenString(description string, c Channel) (*Device, error) { 406 | d, err := makeDevice(c) 407 | if err != nil { 408 | return nil, err 409 | } 410 | e := C.ftdi_usb_open_string( 411 | d.ctx, 412 | C.CString(description), 413 | ) 414 | if e < 0 { 415 | defer d.free() 416 | return nil, d.makeError(e) 417 | } 418 | runtime.SetFinalizer(d, (*Device).close) 419 | return d, nil 420 | } 421 | 422 | // Mode represents operation mode that FTDI device can work. 423 | type Mode byte 424 | 425 | const ( 426 | ModeReset Mode = (1 << iota) >> 1 427 | ModeBitbang 428 | ModeMPSSE 429 | ModeSyncBB 430 | ModeMCU 431 | ModeOpto 432 | ModeCBUS 433 | ModeSyncFF 434 | ModeFT1284 435 | ) 436 | 437 | // MPSSE commands 438 | // See https://www.ftdichip.com/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf 439 | // for full details 440 | const ( 441 | MPSSEWriteNeg byte = C.MPSSE_WRITE_NEG 442 | MPSSEBitMode byte = C.MPSSE_BITMODE 443 | MPSSEReadNeg byte = C.MPSSE_READ_NEG 444 | MPSSELSB byte = C.MPSSE_LSB 445 | MPSSEDoWrite byte = C.MPSSE_DO_WRITE 446 | MPSSEDoRead byte = C.MPSSE_DO_READ 447 | MPSSEWriteTMS byte = C.MPSSE_WRITE_TMS 448 | MPSSESetBitsLow byte = C.SET_BITS_LOW 449 | MPSSESetBitsHigh byte = C.SET_BITS_HIGH 450 | MPSSEGetBitsLow byte = C.GET_BITS_LOW 451 | MPSSELoopbackStart byte = C.LOOPBACK_START 452 | MPSSELoopbackEnd byte = C.LOOPBACK_END 453 | MPSSETCKDivisor byte = C.TCK_DIVISOR 454 | MPSSEDisableDiv5 byte = C.DIS_DIV_5 455 | MPSSEEnableDiv5 byte = C.EN_DIV_5 456 | MPSSEEnable3Phase byte = C.EN_3_PHASE 457 | MPSSEDisable3Phase byte = C.DIS_3_PHASE 458 | MPSSEClockBits byte = C.CLK_BITS 459 | MPSSEClockBytes byte = C.CLK_BYTES 460 | MPSSEClockWaitHigh byte = C.CLK_WAIT_HIGH 461 | MPSSEClockWaitLow byte = C.CLK_WAIT_LOW 462 | MPSSEEnableAdaptive byte = C.EN_ADAPTIVE 463 | MPSSEDisableAdaptive byte = C.DIS_ADAPTIVE 464 | MPSSEClockBytesOrHigh byte = C.CLK_BYTES_OR_HIGH 465 | MPSSEClockBytesOrLow byte = C.CLK_BYTES_OR_LOW 466 | MPSSEDriveOpenCollector byte = C.DRIVE_OPEN_COLLECTOR 467 | MPSSESendImmediate byte = C.SEND_IMMEDIATE 468 | MPSSEWaitOnHigh byte = C.WAIT_ON_HIGH 469 | MPSSEWaitOnLow byte = C.WAIT_ON_LOW 470 | MPSSEReadShort byte = C.READ_SHORT 471 | MPSSEReadExtended byte = C.READ_EXTENDED 472 | MPSSEWriteShort byte = C.WRITE_SHORT 473 | MPSSEWriteExtended byte = C.WRITE_EXTENDED 474 | ) 475 | 476 | // MPSSEDivValue calculates the two bytes that are required to be supplied after 477 | // MPSSETCKDivisor to get the desired clock speed (in Hz). 478 | // Set the dvi5 flag if MPSSEEnableDiv5 has been sent, to use a 12MHz base clock, 479 | // instead of 60MHz. 480 | func MPSSEDivValue(rate int, div5 bool) int { 481 | clk := 60_000_000 482 | if div5 { 483 | clk /= 5 484 | } 485 | if rate <= 0 || rate > clk { 486 | return 0 487 | } 488 | if (clk/rate)-1 > 0xffff { 489 | return 0xffff 490 | } 491 | return clk/rate - 1 492 | } 493 | 494 | // SetBitmode sets operation mode for device d to mode. iomask bitmask 495 | // configures lines corresponding to its bits as input (bit=0) or output (bit=1). 496 | func (d *Device) SetBitmode(iomask byte, mode Mode) error { 497 | e := C.ftdi_set_bitmode(d.ctx, C.uchar(iomask), C.uchar(mode)) 498 | return d.makeError(e) 499 | } 500 | 501 | // Reset resets device d. 502 | func (d *Device) Reset() error { 503 | return d.makeError(C.ftdi_usb_reset(d.ctx)) 504 | } 505 | 506 | // PurgeWriteBuffer clears Rx buffer (buffer for data received from USB?). 507 | func (d *Device) PurgeWriteBuffer() error { 508 | return d.makeError(C.libftdi_tciflush(d.ctx)) 509 | } 510 | 511 | // PurgeReadBuffer clears Tx buffer (buffer for data that will be sent to USB?). 512 | func (d *Device) PurgeReadBuffer() error { 513 | return d.makeError(C.libftdi_tcoflush(d.ctx)) 514 | } 515 | 516 | // PurgeBuffers clears both (Tx and Rx) buffers. 517 | func (d *Device) PurgeBuffers() error { 518 | return d.makeError(C.libftdi_tcioflush(d.ctx)) 519 | } 520 | 521 | // ReadChunkSize returns current value of read buffer chunk size. 522 | func (d *Device) ReadChunkSize() (int, error) { 523 | var cs C.uint 524 | e := C.ftdi_read_data_get_chunksize(d.ctx, &cs) 525 | return int(cs), d.makeError(e) 526 | } 527 | 528 | // SetReadChunkSize configure read chunk size for device (default is 4096B) and 529 | // size of software buffer dedicated for reading data from device... 530 | func (d *Device) SetReadChunkSize(cs int) error { 531 | return d.makeError(C.ftdi_read_data_set_chunksize(d.ctx, C.uint(cs))) 532 | } 533 | 534 | // WriteChunkSize returns current value of write chunk size. 535 | func (d *Device) WriteChunkSize() (int, error) { 536 | var cs C.uint 537 | e := C.ftdi_write_data_get_chunksize(d.ctx, &cs) 538 | return int(cs), d.makeError(e) 539 | } 540 | 541 | // SetWriteChunkSize configure write chunk size (default is 4096). If more than 542 | // cs bytes need to be send to device, they will be split to chunks of size cs. 543 | func (d *Device) SetWriteChunkSize(cs int) error { 544 | return d.makeError(C.ftdi_write_data_set_chunksize(d.ctx, C.uint(cs))) 545 | } 546 | 547 | // LatencyTimer returns latency timer value [ms]. 548 | func (d *Device) LatencyTimer() (int, error) { 549 | var lt C.uchar 550 | e := C.ftdi_get_latency_timer(d.ctx, <) 551 | return int(lt), d.makeError(e) 552 | } 553 | 554 | // SetLatencyTimer sets latency timer to lt (value beetwen 1 and 255). If FTDI 555 | // device has fewer data to completely fill one USB packet (<62 B) it waits for 556 | // lt ms before sending data to USB. 557 | func (d *Device) SetLatencyTimer(lt int) error { 558 | return d.makeError(C.ftdi_set_latency_timer(d.ctx, C.uchar(lt))) 559 | } 560 | 561 | // Read reads data from device to data. It returns number of bytes read. 562 | func (d *Device) Read(data []byte) (int, error) { 563 | n := C.ftdi_read_data( 564 | d.ctx, 565 | (*C.uchar)(unsafe.Pointer(&data[0])), 566 | C.int(len(data)), 567 | ) 568 | if n < 0 { 569 | return 0, d.makeError(n) 570 | } 571 | return int(n), nil 572 | } 573 | 574 | // Write writes data from buf to device. It retruns number of bytes written. 575 | func (d *Device) Write(data []byte) (int, error) { 576 | n := C.ftdi_write_data( 577 | d.ctx, 578 | (*C.uchar)(unsafe.Pointer(&data[0])), 579 | C.int(len(data)), 580 | ) 581 | if n < 0 { 582 | return 0, d.makeError(n) 583 | } 584 | return int(n), nil 585 | } 586 | 587 | // WriteString writes bytes from string s to device. It retruns number of bytes written. 588 | func (d *Device) WriteString(s string) (int, error) { 589 | // BUG: This will cause problems when string implementation changes. 590 | type stringHeader struct { 591 | data unsafe.Pointer 592 | len int 593 | } 594 | n := C.ftdi_write_data( 595 | d.ctx, 596 | (*C.uchar)((*stringHeader)(unsafe.Pointer(&s)).data), 597 | C.int(len(s)), 598 | ) 599 | if n < 0 { 600 | return 0, d.makeError(n) 601 | } 602 | return int(n), nil 603 | } 604 | 605 | // ReadByte reads one byte from device. 606 | func (d *Device) ReadByte() (byte, error) { 607 | var b byte 608 | if n := C.ftdi_read_data(d.ctx, (*C.uchar)(&b), 1); n != 1 { 609 | return 0, d.makeError(n) 610 | } 611 | return b, nil 612 | } 613 | 614 | // WriteByte writes one byte to device. 615 | func (d *Device) WriteByte(b byte) error { 616 | if n := C.ftdi_write_data(d.ctx, (*C.uchar)(&b), 1); n != 1 { 617 | return d.makeError(n) 618 | } 619 | return nil 620 | } 621 | 622 | // Pins returns current state of pins (circumventing the read buffer). 623 | func (d *Device) Pins() (b byte, err error) { 624 | if e := C.ftdi_read_pins(d.ctx, (*C.uchar)(&b)); e != 0 { 625 | err = d.makeError(e) 626 | } 627 | return 628 | } 629 | 630 | // SetBaudrate sets the rate of data transfer. 631 | // 632 | // For standard USB-UART adapter it sets UART baudrate. 633 | // 634 | // For bitbang mode the clock is actually 16 times the br. From the FTDI 635 | // documentation for FT232R bitbang mode: 636 | // "The clock for the Asynchronous Bit Bang mode is actually 16 times the 637 | // Baud rate. A value of 9600 Baud would transfer the data at (9600x16) = 153600 638 | // bytes per second, or 1 every 6.5 μS." 639 | // 640 | // FT232R suports baudrates from 183.1 baud to 3 Mbaud but for real applications 641 | // it should be <= 1 Mbaud: Actual baudrate is set to discrete value that 642 | // satisfies the equation br = 3000000 / (n + x) where n can be an integer 643 | // between 2 and 16384 and x can be a sub-integer of the value 0, 0.125, 0.25, 644 | // 0.375, 0.5, 0.625, 0.75, or 0.875. When n == 1 then x should be 0, i.e. 645 | // baud rate divisors with values between 1 and 2 are not possible. 646 | func (d *Device) SetBaudrate(br int) error { 647 | return d.makeError(C.ftdi_set_baudrate(d.ctx, C.int(br))) 648 | } 649 | 650 | // Parity represents the parity mode 651 | type Parity int 652 | 653 | const ( 654 | // ParityNone indicates no parity bit is used 655 | ParityNone Parity = C.NONE 656 | // ParityOdd indicates an odd parity bit is used 657 | ParityOdd Parity = C.ODD 658 | // ParityEven indicates an even parity bit is used 659 | ParityEven Parity = C.EVEN 660 | // ParityMark indicates that the parity bit should be a 1 661 | ParityMark Parity = C.MARK 662 | // ParitySpace indicates that the parity bit should be a 0 663 | ParitySpace Parity = C.SPACE 664 | ) 665 | 666 | // DataBits represents the number of data bits to expect 667 | type DataBits int 668 | 669 | const ( 670 | // DataBits7 indicates that 7 data bits are used 671 | DataBits7 DataBits = C.BITS_7 672 | // DataBits8 indicates that 8 data bits are used 673 | DataBits8 DataBits = C.BITS_8 674 | ) 675 | 676 | // StopBits represents the number of stop bits to expect 677 | type StopBits int 678 | 679 | const ( 680 | // StopBits1 indicates only one stop bit is expected 681 | StopBits1 StopBits = C.STOP_BIT_1 682 | // StopBits15 indicates one and a half stop bits are expected 683 | StopBits15 StopBits = C.STOP_BIT_15 684 | // StopBits2 indicates two stop bits are expected 685 | StopBits2 StopBits = C.STOP_BIT_2 686 | ) 687 | 688 | // Break represents the break mode 689 | type Break int 690 | 691 | const ( 692 | // BreakOff disables the use of a break signal 693 | BreakOff Break = C.BREAK_OFF 694 | // BreakOn enables the use of a break signal 695 | BreakOn Break = C.BREAK_ON 696 | ) 697 | 698 | // SetLineProperties sets the uart data bit count, stop bits count, and parity mode 699 | func (d *Device) SetLineProperties(bits DataBits, stopbits StopBits, parity Parity) error { 700 | e := C.ftdi_set_line_property( 701 | d.ctx, 702 | uint32(bits), 703 | uint32(stopbits), 704 | uint32(parity), 705 | ) 706 | return d.makeError(e) 707 | } 708 | 709 | // SetLineProperties2 sets the uart data bit count, stop bits count, parity mode, 710 | // and break usage 711 | func (d *Device) SetLineProperties2(bits DataBits, stopbits StopBits, parity Parity, breaks Break) error { 712 | e := C.ftdi_set_line_property2( 713 | d.ctx, 714 | uint32(bits), 715 | uint32(stopbits), 716 | uint32(parity), 717 | uint32(breaks), 718 | ) 719 | return d.makeError(e) 720 | } 721 | 722 | // FlowCtrl represents the flow control mode. 723 | type FlowCtrl int 724 | 725 | const ( 726 | // FlowCtrlDisable disables all automatic flow control. 727 | FlowCtrlDisable FlowCtrl = (1 << iota) >> 1 728 | // FlowCtrlRTSCTS enables RTS CTS flow control. 729 | FlowCtrlRTSCTS 730 | // FlowCtrlDTRDSR enables DTR DSR flow control. 731 | FlowCtrlDTRDSR 732 | // FlowCtrlXONXOFF enables XON XOF flow control. 733 | FlowCtrlXONXOFF 734 | ) 735 | 736 | // SetFlowControl sets the flow control parameter 737 | func (d *Device) SetFlowControl(flowctrl FlowCtrl) error { 738 | return d.makeError(C.ftdi_setflowctrl(d.ctx, C.int(flowctrl))) 739 | } 740 | 741 | // SetDTRRTS manually sets the DTR and RTS output lines from the 742 | // least significant bit of dtr and rts. 743 | func (d *Device) SetDTRRTS(dtr, rts int) error { 744 | return d.makeError(C.ftdi_setdtr_rts(d.ctx, C.int(dtr&1), C.int(rts&1))) 745 | } 746 | 747 | // SetDTR manually sets the DTR output line from the least significant 748 | // bit of dtr. 749 | func (d *Device) SetDTR(dtr int) error { 750 | return d.makeError(C.ftdi_setdtr(d.ctx, C.int(dtr&1))) 751 | } 752 | 753 | // SetRTS manually sets the RTS output line from the least significant 754 | // bit of rts. 755 | func (d *Device) SetRTS(rts int) error { 756 | return d.makeError(C.ftdi_setrts(d.ctx, C.int(rts&1))) 757 | } 758 | 759 | // ChipID reads FTDI Chip-ID (not all devices support this). 760 | func (d *Device) ChipID() (uint32, error) { 761 | var id C.uint 762 | if e := C.ftdi_read_chipid(d.ctx, &id); e < 0 { 763 | return 0, d.makeError(e) 764 | } 765 | return uint32(id), nil 766 | } 767 | 768 | // EEPROM returns a handler to the device internal EEPROM subsystem. 769 | func (d *Device) EEPROM() EEPROM { 770 | return EEPROM{d} 771 | } 772 | 773 | type Transfer struct { 774 | c C.struct_ftdi_transfer_control 775 | } 776 | 777 | var errSubmitTransfer = errors.New("libusb_submit_transfer") 778 | 779 | func (d *Device) SubmitRead(data []byte) (*Transfer, error) { 780 | tc, err := C.ftdi_read_data_submit( 781 | d.ctx, 782 | (*C.uchar)(unsafe.Pointer(&data[0])), 783 | C.int(len(data)), 784 | ) 785 | if tc == nil { 786 | if err == nil { 787 | err = errSubmitTransfer 788 | } 789 | return nil, err 790 | } 791 | return (*Transfer)(unsafe.Pointer(tc)), nil 792 | } 793 | 794 | func (d *Device) SubmitWrite(data []byte) (*Transfer, error) { 795 | tc, err := C.ftdi_write_data_submit( 796 | d.ctx, 797 | (*C.uchar)(unsafe.Pointer(&data[0])), 798 | C.int(len(data)), 799 | ) 800 | if tc == nil { 801 | if err == nil { 802 | err = errSubmitTransfer 803 | } 804 | return nil, err 805 | } 806 | return (*Transfer)(unsafe.Pointer(tc)), nil 807 | } 808 | 809 | func (t *Transfer) Done() (int, error) { 810 | n := C.ftdi_transfer_data_done(&t.c) 811 | if n < 0 { 812 | return 0, makeError(t.c.ftdi, n) 813 | } 814 | return int(n), nil 815 | } 816 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // Go binding for libFTDI library 2 | // http://http://www.intra2net.com/en/developer/libftdi/ 3 | package ftdi 4 | -------------------------------------------------------------------------------- /eeprom.go: -------------------------------------------------------------------------------- 1 | package ftdi 2 | 3 | /* 4 | #include 5 | */ 6 | import "C" 7 | import ( 8 | "fmt" 9 | "unsafe" 10 | ) 11 | 12 | func cbool(b bool) C.int { 13 | if b { 14 | return 1 15 | } 16 | return 0 17 | } 18 | 19 | type EEPROM struct { 20 | d *Device 21 | } 22 | 23 | func (e EEPROM) makeError(code C.int) error { 24 | if code >= 0 { 25 | return nil 26 | } 27 | return &Error{ 28 | code: int(code), 29 | str: C.GoString(C.ftdi_get_error_string(e.d.ctx)), 30 | } 31 | } 32 | 33 | func (e EEPROM) Read() error { 34 | return e.makeError(C.ftdi_read_eeprom(e.d.ctx)) 35 | } 36 | 37 | func (e EEPROM) Write() error { 38 | return e.makeError(C.ftdi_write_eeprom(e.d.ctx)) 39 | } 40 | 41 | func (e EEPROM) Decode() error { 42 | return e.makeError(C.ftdi_eeprom_decode(e.d.ctx, 0)) 43 | } 44 | 45 | func (e EEPROM) Build() error { 46 | return e.makeError(C.ftdi_eeprom_build(e.d.ctx)) 47 | } 48 | 49 | func (e EEPROM) VendorId() uint16 { 50 | var v C.int 51 | C.ftdi_get_eeprom_value(e.d.ctx, C.VENDOR_ID, &v) 52 | return uint16(v) 53 | } 54 | 55 | func (e EEPROM) SetVendorId(v uint16) { 56 | C.ftdi_set_eeprom_value(e.d.ctx, C.VENDOR_ID, C.int(v)) 57 | } 58 | 59 | func (e EEPROM) ProductId() uint16 { 60 | var v C.int 61 | C.ftdi_get_eeprom_value(e.d.ctx, C.PRODUCT_ID, &v) 62 | return uint16(v) 63 | } 64 | 65 | func (e EEPROM) SetProductId(v uint16) { 66 | C.ftdi_set_eeprom_value(e.d.ctx, C.PRODUCT_ID, C.int(v)) 67 | } 68 | 69 | func (e EEPROM) ReleaseNumber() uint16 { 70 | var v C.int 71 | C.ftdi_get_eeprom_value(e.d.ctx, C.RELEASE_NUMBER, &v) 72 | return uint16(v) 73 | } 74 | 75 | func (e EEPROM) SetReleaseNumber(v uint16) { 76 | C.ftdi_set_eeprom_value(e.d.ctx, C.RELEASE_NUMBER, C.int(v)) 77 | } 78 | 79 | func (e EEPROM) SelfPowered() bool { 80 | var v C.int 81 | C.ftdi_get_eeprom_value(e.d.ctx, C.SELF_POWERED, &v) 82 | return v != 0 83 | } 84 | 85 | func (e EEPROM) SetSelfPowered(v bool) { 86 | C.ftdi_set_eeprom_value(e.d.ctx, C.SELF_POWERED, cbool(v)) 87 | } 88 | 89 | func (e EEPROM) RemoteWakeup() bool { 90 | var v C.int 91 | C.ftdi_get_eeprom_value(e.d.ctx, C.REMOTE_WAKEUP, &v) 92 | return v != 0 93 | } 94 | 95 | func (e EEPROM) SetRemoteWakeup(v bool) { 96 | C.ftdi_set_eeprom_value(e.d.ctx, C.REMOTE_WAKEUP, cbool(v)) 97 | } 98 | 99 | func (e EEPROM) IsNotPNP() bool { 100 | var v C.int 101 | C.ftdi_get_eeprom_value(e.d.ctx, C.IS_NOT_PNP, &v) 102 | return v != 0 103 | } 104 | 105 | func (e EEPROM) SetIsNotPNP(v bool) { 106 | C.ftdi_set_eeprom_value(e.d.ctx, C.IS_NOT_PNP, cbool(v)) 107 | } 108 | 109 | func (e EEPROM) SuspendDBus7() bool { 110 | var v C.int 111 | C.ftdi_get_eeprom_value(e.d.ctx, C.SUSPEND_DBUS7, &v) 112 | return v != 0 113 | } 114 | 115 | func (e EEPROM) SetSuspendDBus7(v bool) { 116 | C.ftdi_set_eeprom_value(e.d.ctx, C.SUSPEND_DBUS7, cbool(v)) 117 | } 118 | 119 | func (e EEPROM) IsochronousInp() bool { 120 | var v C.int 121 | C.ftdi_get_eeprom_value(e.d.ctx, C.IN_IS_ISOCHRONOUS, &v) 122 | return v != 0 123 | } 124 | 125 | func (e EEPROM) SetIsochronousInp(v bool) { 126 | C.ftdi_set_eeprom_value(e.d.ctx, C.IN_IS_ISOCHRONOUS, cbool(v)) 127 | } 128 | 129 | func (e EEPROM) IsochronousOut() bool { 130 | var v C.int 131 | C.ftdi_get_eeprom_value(e.d.ctx, C.OUT_IS_ISOCHRONOUS, &v) 132 | return v != 0 133 | } 134 | 135 | func (e EEPROM) SetIsochronousOut(v bool) { 136 | C.ftdi_set_eeprom_value(e.d.ctx, C.OUT_IS_ISOCHRONOUS, cbool(v)) 137 | } 138 | 139 | func (e EEPROM) SuspendPullDowns() bool { 140 | var v C.int 141 | C.ftdi_get_eeprom_value(e.d.ctx, C.SUSPEND_PULL_DOWNS, &v) 142 | return v != 0 143 | } 144 | 145 | func (e EEPROM) SetSuspendPullDowns(v bool) { 146 | C.ftdi_set_eeprom_value(e.d.ctx, C.SUSPEND_PULL_DOWNS, cbool(v)) 147 | } 148 | 149 | func (e EEPROM) UseSerial() bool { 150 | var v C.int 151 | C.ftdi_get_eeprom_value(e.d.ctx, C.USE_SERIAL, &v) 152 | return v != 0 153 | } 154 | 155 | func (e EEPROM) SetUseSerial(v bool) { 156 | C.ftdi_set_eeprom_value(e.d.ctx, C.USE_SERIAL, cbool(v)) 157 | } 158 | 159 | func (e EEPROM) USBVersion() uint16 { 160 | var v C.int 161 | C.ftdi_get_eeprom_value(e.d.ctx, C.USB_VERSION, &v) 162 | return uint16(v) 163 | } 164 | 165 | func (e EEPROM) SetUSBVersion(v uint16) { 166 | C.ftdi_set_eeprom_value(e.d.ctx, C.USB_VERSION, C.int(v)) 167 | } 168 | 169 | func (e EEPROM) UseUSBVersion() bool { 170 | var v C.int 171 | C.ftdi_get_eeprom_value(e.d.ctx, C.USE_USB_VERSION, &v) 172 | return v != 0 173 | } 174 | 175 | func (e EEPROM) SetUseUSBVersion(v bool) { 176 | C.ftdi_set_eeprom_value(e.d.ctx, C.USE_USB_VERSION, cbool(v)) 177 | } 178 | 179 | // MaxPower returns maximum power consumption (max. current) from USB in mA 180 | func (e EEPROM) MaxPower() int { 181 | var v C.int 182 | C.ftdi_get_eeprom_value(e.d.ctx, C.MAX_POWER, &v) 183 | return int(v) 184 | } 185 | 186 | // SetMaxPower sets maximum power consumption (max. current) from USB in mA 187 | func (e EEPROM) SetMaxPower(v int) { 188 | C.ftdi_set_eeprom_value(e.d.ctx, C.MAX_POWER, C.int(v)) 189 | } 190 | 191 | func (e EEPROM) channelValue(names []C.enum_ftdi_eeprom_value, c Channel) ( 192 | v C.int) { 193 | n := int(c - ChannelA) 194 | if n < 0 || n >= len(names) { 195 | panic("bad channel") 196 | } 197 | C.ftdi_get_eeprom_value(e.d.ctx, uint32(names[n]), &v) 198 | return 199 | } 200 | 201 | func (e EEPROM) setChannelValue(names []C.enum_ftdi_eeprom_value, c Channel, 202 | v C.int) { 203 | 204 | n := int(c - ChannelA) 205 | if n < 0 || n >= len(names) { 206 | panic("bad channel") 207 | } 208 | C.ftdi_set_eeprom_value(e.d.ctx, uint32(names[n]), v) 209 | } 210 | 211 | type ChannelType byte 212 | 213 | const ( 214 | ChannelUART ChannelType = iota 215 | ChannelFIFO 216 | ChannelOPTO 217 | ChannelCPU 218 | ChannelFT1284 219 | ) 220 | 221 | var channelTypes = []string{"UART", "FIFO", "OPTO", "CPU", "FT1284"} 222 | 223 | func (ct ChannelType) String() string { 224 | if ct > ChannelFT1284 { 225 | return "unknown" 226 | } 227 | return channelTypes[ct] 228 | } 229 | 230 | var channelType = []C.enum_ftdi_eeprom_value{ 231 | C.CHANNEL_A_TYPE, 232 | C.CHANNEL_B_TYPE, 233 | } 234 | 235 | // ChannelType returns type of c channel. c can be: ChannelA, ChannelB 236 | func (e EEPROM) ChannelType(c Channel) ChannelType { 237 | return ChannelType(e.channelValue(channelType, c)) 238 | } 239 | 240 | func (e EEPROM) SetChannelType(c Channel, v ChannelType) { 241 | e.setChannelValue(channelType, c, C.int(v)) 242 | } 243 | 244 | var channelDriver = []C.enum_ftdi_eeprom_value{ 245 | C.CHANNEL_A_DRIVER, 246 | C.CHANNEL_B_DRIVER, 247 | C.CHANNEL_C_DRIVER, 248 | C.CHANNEL_B_DRIVER, 249 | } 250 | 251 | // ChannelDriver returns true if c channel has a driver. 252 | // c can be from range: ChannelA - ChannelD 253 | func (e EEPROM) ChannelDriver(c Channel) bool { 254 | return e.channelValue(channelDriver, c) != 0 255 | } 256 | 257 | func (e EEPROM) SetChannelDriver(c Channel, v bool) { 258 | e.setChannelValue(channelDriver, c, cbool(v)) 259 | } 260 | 261 | var channelRS485 = []C.enum_ftdi_eeprom_value{ 262 | C.CHANNEL_A_RS485, 263 | C.CHANNEL_B_RS485, 264 | C.CHANNEL_C_RS485, 265 | C.CHANNEL_D_RS485, 266 | } 267 | 268 | // ChannelDriver returns true if c is RS485 channel. 269 | // c can be from range: ChannelA - ChannelD 270 | func (e EEPROM) ChannelRS485(c Channel) bool { 271 | return e.channelValue(channelRS485, c) != 0 272 | } 273 | 274 | func (e EEPROM) SetChannelRS485(c Channel, v bool) { 275 | e.setChannelValue(channelRS485, c, cbool(v)) 276 | } 277 | 278 | var highCurrent = []C.enum_ftdi_eeprom_value{ 279 | C.HIGH_CURRENT, 280 | C.HIGH_CURRENT_A, 281 | C.HIGH_CURRENT_B, 282 | } 283 | 284 | // ChannelDriver returns true if c channel is in high current mode . 285 | // c can be from range: ChannAny - ChannelD (use ChannAny for TypeR device). 286 | func (e EEPROM) HighCurrent(c Channel) bool { 287 | return e.channelValue(highCurrent, c+ChannelA) != 0 288 | } 289 | 290 | func (e EEPROM) SetHighCurrent(c Channel, v bool) { 291 | var hc C.int 292 | if v { 293 | if e.d.Type() == TypeR { 294 | hc = C.HIGH_CURRENT_DRIVE_R 295 | } else { 296 | hc = C.HIGH_CURRENT_DRIVE 297 | } 298 | } 299 | e.setChannelValue(highCurrent, c+ChannelA, hc) 300 | } 301 | 302 | type CBusFunction byte 303 | 304 | const ( 305 | CBusTxEn CBusFunction = iota 306 | CBusPwrEn 307 | CBusRxLED 308 | CBusTxLED 309 | CBusTxRxLED 310 | CBusSleep 311 | CBusClk48 312 | CBusClk24 313 | CBusClk12 314 | CBusClk6 315 | CBusIOMode 316 | CBusBBWR 317 | CBusBBRD 318 | ) 319 | 320 | var cbusFunctions = []string{ 321 | "TxD enabled", 322 | "power enabled", 323 | "Rx LED", 324 | "Tx LED", 325 | "Tx/Rx LED", 326 | "sleep", 327 | "clock 48 MHz", 328 | "clock 24 MHz", 329 | "clock 12 MHz", 330 | "clock 6 MHz", 331 | "bitbang I/O", 332 | "bitbang write", 333 | "bitbang read", 334 | } 335 | 336 | func (c CBusFunction) String() string { 337 | if c > CBusBBRD { 338 | return "unknown" 339 | } 340 | return cbusFunctions[c] 341 | } 342 | 343 | var cbusFunction = []C.enum_ftdi_eeprom_value{ 344 | C.CBUS_FUNCTION_0, 345 | C.CBUS_FUNCTION_1, 346 | C.CBUS_FUNCTION_2, 347 | C.CBUS_FUNCTION_3, 348 | C.CBUS_FUNCTION_4, 349 | C.CBUS_FUNCTION_5, 350 | C.CBUS_FUNCTION_6, 351 | C.CBUS_FUNCTION_7, 352 | C.CBUS_FUNCTION_8, 353 | C.CBUS_FUNCTION_9, 354 | } 355 | 356 | func (e EEPROM) CBusFunction(n int) CBusFunction { 357 | if n < 0 || n >= len(cbusFunction) { 358 | panic("bad CBUS number") 359 | } 360 | var v C.int 361 | C.ftdi_get_eeprom_value(e.d.ctx, uint32(cbusFunction[n]), &v) 362 | return CBusFunction(v) 363 | } 364 | 365 | func (e EEPROM) SetCBusFunction(n int, v CBusFunction) { 366 | if n < 0 || n >= len(cbusFunction) { 367 | panic("bad CBUS number") 368 | } 369 | C.ftdi_set_eeprom_value(e.d.ctx, uint32(cbusFunction[n]), C.int(v)) 370 | } 371 | 372 | func (e EEPROM) Invert() int { 373 | var v C.int 374 | C.ftdi_get_eeprom_value(e.d.ctx, C.INVERT, &v) 375 | return int(v) 376 | } 377 | 378 | func (e EEPROM) SetInvert(v int) { 379 | C.ftdi_set_eeprom_value(e.d.ctx, C.INVERT, C.int(v)) 380 | } 381 | 382 | /* 383 | TODO: 384 | case GROUP0_DRIVE: 385 | *value = ftdi->eeprom->group0_drive; 386 | break; 387 | case GROUP0_SCHMITT: 388 | *value = ftdi->eeprom->group0_schmitt; 389 | break; 390 | case GROUP0_SLEW: 391 | *value = ftdi->eeprom->group0_slew; 392 | break; 393 | case GROUP1_DRIVE: 394 | *value = ftdi->eeprom->group1_drive; 395 | break; 396 | case GROUP1_SCHMITT: 397 | *value = ftdi->eeprom->group1_schmitt; 398 | break; 399 | case GROUP1_SLEW: 400 | *value = ftdi->eeprom->group1_slew; 401 | break; 402 | case GROUP2_DRIVE: 403 | *value = ftdi->eeprom->group2_drive; 404 | break; 405 | case GROUP2_SCHMITT: 406 | *value = ftdi->eeprom->group2_schmitt; 407 | break; 408 | case GROUP2_SLEW: 409 | *value = ftdi->eeprom->group2_slew; 410 | break; 411 | case GROUP3_DRIVE: 412 | *value = ftdi->eeprom->group3_drive; 413 | break; 414 | case GROUP3_SCHMITT: 415 | *value = ftdi->eeprom->group3_schmitt; 416 | break; 417 | case GROUP3_SLEW: 418 | *value = ftdi->eeprom->group3_slew; 419 | break; 420 | case POWER_SAVE: 421 | *value = ftdi->eeprom->powersave; 422 | break; 423 | case CLOCK_POLARITY: 424 | *value = ftdi->eeprom->clock_polarity; 425 | break; 426 | case DATA_ORDER: 427 | *value = ftdi->eeprom->data_order; 428 | break; 429 | case FLOW_CONTROL: 430 | *value = ftdi->eeprom->flow_control; 431 | break; 432 | */ 433 | 434 | func (e EEPROM) ChipType() byte { 435 | var v C.int 436 | C.ftdi_get_eeprom_value(e.d.ctx, C.CHIP_TYPE, &v) 437 | return byte(v) 438 | } 439 | 440 | func (e EEPROM) SetChipType(v byte) { 441 | C.ftdi_set_eeprom_value(e.d.ctx, C.CHIP_TYPE, C.int(v)) 442 | } 443 | 444 | func (e EEPROM) ChipSize() int { 445 | var v C.int 446 | C.ftdi_get_eeprom_value(e.d.ctx, C.CHIP_SIZE, &v) 447 | return int(v) 448 | } 449 | 450 | func (e EEPROM) ManufacturerString() string { 451 | var buf [128]C.char 452 | C.ftdi_eeprom_get_strings(e.d.ctx, (*C.char)(unsafe.Pointer(&buf[0])), C.int(len(buf)), nil, 0, nil, 0) 453 | return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))) 454 | } 455 | 456 | func (e EEPROM) SetManufacturerString(s string) { 457 | C.ftdi_eeprom_set_strings(e.d.ctx, C.CString(s), nil, nil) 458 | } 459 | 460 | func (e EEPROM) ProductString() string { 461 | var buf [128]C.char 462 | C.ftdi_eeprom_get_strings(e.d.ctx, nil, 0, (*C.char)(unsafe.Pointer(&buf[0])), C.int(len(buf)), nil, 0) 463 | return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))) 464 | } 465 | 466 | func (e EEPROM) SetProductString(s string) { 467 | C.ftdi_eeprom_set_strings(e.d.ctx, nil, C.CString(s), nil) 468 | } 469 | 470 | func (e EEPROM) SerialString() string { 471 | var buf [128]C.char 472 | C.ftdi_eeprom_get_strings(e.d.ctx, nil, 0, nil, 0, (*C.char)(unsafe.Pointer(&buf[0])), C.int(len(buf))) 473 | return C.GoString((*C.char)(unsafe.Pointer(&buf[0]))) 474 | } 475 | 476 | func (e EEPROM) SetSerialString(s string) { 477 | C.ftdi_eeprom_set_strings(e.d.ctx, nil, nil, C.CString(s)) 478 | } 479 | 480 | func (e EEPROM) String() string { 481 | return fmt.Sprintf(""+ 482 | "vendor id: %04xh\n"+ 483 | "product id: %04xh\n"+ 484 | "release number: %04xh\n"+ 485 | "self powered: %t\n"+ 486 | "remote wakeup: %t\n"+ 487 | "is not PNP: %t\n"+ 488 | "isochronous inp: %t\n"+ 489 | "isochronous out: %t\n"+ 490 | "suspend pull downs: %t\n"+ 491 | "use serial: %t\n"+ 492 | "USB version: %04xh\n"+ 493 | "use USB version: %t\n"+ 494 | "USB max. current: %d mA\n"+ 495 | "channel A type: %s\n"+ 496 | "channel B type: %s\n"+ 497 | "channel A driver: %t\n"+ 498 | "channel B driver: %t\n"+ 499 | "channel C driver: %t\n"+ 500 | "channel D driver: %t\n"+ 501 | "channel A RS485: %t\n"+ 502 | "channel B RS485: %t\n"+ 503 | "channel C RS485: %t\n"+ 504 | "channel D RS485: %t\n"+ 505 | "high current: %t\n"+ 506 | "high current A: %t\n"+ 507 | "high current B: %t\n"+ 508 | "CBUS[0]: %s\n"+ 509 | "CBUS[1]: %s\n"+ 510 | "CBUS[2]: %s\n"+ 511 | "CBUS[3]: %s\n"+ 512 | "CBUS[4]: %s\n"+ 513 | "CBUS[5]: %s\n"+ 514 | "CBUS[6]: %s\n"+ 515 | "CBUS[7]: %s\n"+ 516 | "CBUS[8]: %s\n"+ 517 | "CBUS[9]: %s\n"+ 518 | "invert: %010bb\n"+ 519 | "", 520 | e.VendorId(), 521 | e.ProductId(), 522 | e.ReleaseNumber(), 523 | e.SelfPowered(), 524 | e.RemoteWakeup(), 525 | e.IsNotPNP(), 526 | e.IsochronousInp(), 527 | e.IsochronousOut(), 528 | e.SuspendPullDowns(), 529 | e.UseSerial(), 530 | e.USBVersion(), 531 | e.UseUSBVersion(), 532 | e.MaxPower(), 533 | e.ChannelType(ChannelA), 534 | e.ChannelType(ChannelB), 535 | e.ChannelDriver(ChannelA), 536 | e.ChannelDriver(ChannelB), 537 | e.ChannelDriver(ChannelC), 538 | e.ChannelDriver(ChannelD), 539 | e.ChannelRS485(ChannelA), 540 | e.ChannelRS485(ChannelB), 541 | e.ChannelRS485(ChannelC), 542 | e.ChannelRS485(ChannelD), 543 | e.HighCurrent(ChannelAny), 544 | e.HighCurrent(ChannelA), 545 | e.HighCurrent(ChannelB), 546 | e.CBusFunction(0), 547 | e.CBusFunction(1), 548 | e.CBusFunction(2), 549 | e.CBusFunction(3), 550 | e.CBusFunction(4), 551 | e.CBusFunction(5), 552 | e.CBusFunction(6), 553 | e.CBusFunction(7), 554 | e.CBusFunction(8), 555 | e.CBusFunction(9), 556 | e.Invert(), 557 | ) 558 | } 559 | -------------------------------------------------------------------------------- /error.go: -------------------------------------------------------------------------------- 1 | package ftdi 2 | 3 | /* 4 | #include 5 | 6 | // Some versions of libusb.h define libusb_strerror as taking a "int", while 7 | // others take a "enum libusb_error". This doesn't matter for C but it matters 8 | // for Go. Create a wrapper with a fixed type, so that Go doesn't complain. 9 | const char* libusb_strerror_wrapper(enum libusb_error e) { 10 | return libusb_strerror(e); 11 | } 12 | 13 | 14 | */ 15 | import "C" 16 | 17 | type Error struct { 18 | code int 19 | str string 20 | } 21 | 22 | func (e *Error) Code() int { 23 | return e.code 24 | } 25 | 26 | func (e *Error) Error() string { 27 | return e.str 28 | } 29 | 30 | type USBError int 31 | 32 | func (e USBError) Error() string { 33 | return C.GoString(C.libusb_strerror_wrapper(C.enum_libusb_error(e))) 34 | } 35 | -------------------------------------------------------------------------------- /examples/ftdi_bitbang/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/ziutek/ftdi" 5 | "log" 6 | "time" 7 | ) 8 | 9 | func checkErr(err error) { 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | } 14 | 15 | func main() { 16 | d, err := ftdi.OpenFirst(0x0403, 0x6001, ftdi.ChannelAny) 17 | checkErr(err) 18 | defer d.Close() 19 | 20 | checkErr(d.SetBitmode(0xff, ftdi.ModeBitbang)) 21 | 22 | checkErr(d.SetBaudrate(192)) 23 | 24 | log.Print("WriteByte") 25 | for i := 0; i < 256; i++ { 26 | checkErr(d.WriteByte(byte(i))) 27 | } 28 | 29 | log.Print("Ok") 30 | time.Sleep(time.Second) 31 | 32 | buf := make([]byte, 256) 33 | for i := range buf { 34 | buf[i] = byte(i) 35 | } 36 | 37 | log.Print("Write") 38 | _, err = d.Write(buf) 39 | checkErr(err) 40 | 41 | log.Println("Ok") 42 | 43 | checkErr(d.WriteByte(255)) 44 | } 45 | -------------------------------------------------------------------------------- /examples/ftdi_chipid/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ziutek/ftdi" 6 | "os" 7 | ) 8 | 9 | func checkErr(err error) { 10 | if err != nil { 11 | fmt.Fprintln(os.Stderr, err) 12 | os.Exit(1) 13 | } 14 | } 15 | 16 | func main() { 17 | 18 | l, err := ftdi.FindAll(0, 0) 19 | checkErr(err) 20 | 21 | for i, u := range l { 22 | hexSerial := "0x" 23 | for i := 0; i < len(u.Serial); i++ { 24 | hexSerial += fmt.Sprintf("%02x", u.Serial[i]) 25 | } 26 | fmt.Printf( 27 | "#%d Manufacturer:'%s' Description:'%s' Serial:'%s' (%s)", 28 | i, u.Manufacturer, u.Description, u.Serial, hexSerial, 29 | ) 30 | d, err := ftdi.OpenUSBDev(u, ftdi.ChannelAny) 31 | if err != nil { 32 | fmt.Printf(" [can't open device: %s]\n", err) 33 | continue 34 | } 35 | 36 | if d.Type() == ftdi.TypeR { 37 | cid, err := d.ChipID() 38 | if err == nil { 39 | fmt.Printf(" ChipID:0x%08x\n", cid) 40 | } else { 41 | fmt.Printf("[can't read ChipID: %s]\n", err) 42 | } 43 | } else { 44 | fmt.Println() 45 | } 46 | 47 | d.Close() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/ftdi_dcf77/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/ziutek/ftdi" 5 | "log" 6 | "time" 7 | ) 8 | 9 | func checkErr(err error) { 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | } 14 | 15 | const ( 16 | baudrate = 192 17 | Bps = baudrate * 32 // for FT323R 18 | chunkSize = 2 * 64 19 | bufLen = 2 * 62 // 62 because of 2 status bytes in every 64B USB packet 20 | dt = time.Second / Bps 21 | ) 22 | 23 | func find1(buf []byte) int { 24 | for i, b := range buf { 25 | if b&0x02 != 0 { 26 | return i 27 | } 28 | } 29 | return -1 30 | } 31 | 32 | func find0(buf []byte) int { 33 | for i, b := range buf { 34 | if b&0x02 == 0 { 35 | return i 36 | } 37 | } 38 | return -1 39 | } 40 | 41 | func twoBits(b []byte) byte { 42 | b0 := b[0]&0x02 == 0 43 | b1 := b[1]&0x02 == 0 44 | if b0 && b1 { 45 | return '.' 46 | } else if !b0 && !b1 { 47 | return 'O' 48 | } else { 49 | return 'o' 50 | } 51 | } 52 | 53 | func main() { 54 | d, err := ftdi.OpenFirst(0x0403, 0x6001, ftdi.ChannelAny) 55 | checkErr(err) 56 | defer d.Close() 57 | 58 | checkErr(d.SetBitmode(0x00, ftdi.ModeReset)) 59 | checkErr(d.SetBitmode(0x01, ftdi.ModeBitbang)) 60 | 61 | checkErr(d.SetBaudrate(baudrate)) 62 | 63 | //checkErr(d.SetLatencyTimer(4)) 64 | lat, err := d.LatencyTimer() 65 | checkErr(err) 66 | log.Println("latency:", lat) 67 | 68 | checkErr(d.SetReadChunkSize(chunkSize)) 69 | 70 | checkErr(d.WriteByte(0)) 71 | 72 | buf := make([]byte, bufLen) 73 | pulseLen := 0 74 | for { 75 | n, err := d.Read(buf) 76 | checkErr(err) 77 | data := buf 78 | if n != len(buf) { 79 | log.Printf("Partial buffer: %d/%d", n, len(buf)) 80 | data = buf[:n] 81 | } 82 | show := make([]byte, len(data)/2) 83 | for i := range show { 84 | k := i * 2 85 | show[i] = twoBits(data[k : k+2]) 86 | } 87 | log.Printf("%s", show) 88 | continue 89 | 90 | analysis: 91 | if pulseLen > 0 { 92 | if i := find0(data); i != -1 { 93 | pulseLen += i 94 | 95 | ms := time.Duration(pulseLen) * dt / time.Millisecond 96 | c := '?' 97 | if ms >= 40 && ms <= 130 { 98 | c = '0' 99 | } else if ms >= 140 && ms <= 250 { 100 | c = '1' 101 | } 102 | log.Printf("%c (%s)", c, time.Duration(pulseLen)*dt) 103 | 104 | data = data[i+1:] 105 | pulseLen = 0 106 | goto analysis 107 | } else { 108 | pulseLen += len(data) 109 | } 110 | } else { 111 | if i := find1(data); i != -1 { 112 | data = data[i+1:] 113 | pulseLen = 1 114 | goto analysis 115 | } 116 | } 117 | } 118 | 119 | checkErr(d.SetBitmode(0x00, ftdi.ModeReset)) 120 | } 121 | -------------------------------------------------------------------------------- /examples/ftdi_eeprom/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "github.com/ziutek/ftdi" 7 | "os" 8 | ) 9 | 10 | func checkErr(err error) { 11 | if err != nil { 12 | fmt.Fprintln(os.Stderr, err) 13 | os.Exit(1) 14 | } 15 | } 16 | 17 | var ( 18 | set = flag.Bool("set", false, "Set EEPROM variables") 19 | vendor = flag.Int("vendor", 0x0403, "PCI vendor id") 20 | product = flag.Int("product", 0x6001, "PCI product id") 21 | invert = flag.Int( 22 | "invert", 23 | 0, 24 | "Set invert flags (use 0x15 to set all lines down)", 25 | ) 26 | cbusFunction = flag.Int( 27 | "cbus", 28 | int(ftdi.CBusIOMode), 29 | "Function id for all CBUS lines", 30 | ) 31 | maxCurrent = flag.Int("maxI", 200, "Maximum USB current (mA)") 32 | highCurrent = flag.Bool("highDrive", false, "Set high current drive flag") 33 | ) 34 | 35 | func main() { 36 | flag.Parse() 37 | 38 | d, err := ftdi.OpenFirst(*vendor, *product, ftdi.ChannelAny) 39 | checkErr(err) 40 | defer d.Close() 41 | 42 | e := d.EEPROM() 43 | checkErr(e.Read()) 44 | checkErr(e.Decode()) 45 | fmt.Println(e) 46 | 47 | if !*set { 48 | return 49 | } 50 | 51 | modified := false 52 | 53 | if e.Invert() != *invert { 54 | e.SetInvert(*invert) 55 | modified = true 56 | } 57 | if e.MaxPower() != *maxCurrent { 58 | e.SetMaxPower(*maxCurrent) 59 | modified = true 60 | } 61 | cbusf := ftdi.CBusFunction(*cbusFunction) 62 | for n := 0; n < 4; n++ { 63 | if e.CBusFunction(n) != cbusf { 64 | e.SetCBusFunction(n, cbusf) 65 | modified = true 66 | } 67 | } 68 | if e.HighCurrent(ftdi.ChannelAny) != *highCurrent { 69 | e.SetHighCurrent(ftdi.ChannelAny, *highCurrent) 70 | modified = true 71 | } 72 | 73 | if modified { 74 | checkErr(e.Build()) 75 | checkErr(e.Write()) 76 | 77 | checkErr(e.Read()) 78 | checkErr(e.Decode()) 79 | fmt.Println(e) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /examples/ftdi_lcd/main.go: -------------------------------------------------------------------------------- 1 | // Pin connection between FT232R and LCD (HD44780 compatible): 2 | // TxD (DBUS0) <--> D4 3 | // RxD (DBUS1) <--> D5 4 | // RTS# (DBUS2) <--> D6 5 | // CTS# (DBUS3) <--> D7 6 | // DTR# (DBUS4) <--> E 7 | // DSR# (DBUS5) <--> R/W# 8 | // DCD# (DBUS6) <--> RS 9 | package main 10 | 11 | import ( 12 | "fmt" 13 | "github.com/ziutek/ftdi" 14 | "github.com/ziutek/lcd/hdc" 15 | "os" 16 | "time" 17 | ) 18 | 19 | func checkErr(err error) { 20 | if err != nil { 21 | fmt.Println(err) 22 | os.Exit(1) 23 | } 24 | } 25 | 26 | func main() { 27 | // Good values for JHD204A (136 FPS on 4x20 display) 28 | baudrate := 1 << 17 29 | waitTicks := 6 30 | 31 | d, err := ftdi.OpenFirst(0x0403, 0x6001, ftdi.ChannelAny) 32 | checkErr(err) 33 | defer d.Close() 34 | checkErr(d.SetBitmode(0xff, ftdi.ModeBitbang)) 35 | checkErr(d.SetBaudrate(baudrate / 16)) 36 | 37 | w := hdc.NewBitbang(d, waitTicks) 38 | // In conservative mode baudrate can be 1 << 23 on JHD204A 39 | //w.FastMode(false) 40 | 41 | lcd := hdc.NewDevice(w, 20, 4) 42 | checkErr(lcd.Init()) 43 | checkErr(lcd.SetDisplay(hdc.DisplayOn | hdc.CursorOn)) 44 | 45 | buf1 := make([]byte, 80) 46 | for i := 0; i < 20; i++ { 47 | buf1[i] = '0' 48 | buf1[i+20] = '2' 49 | buf1[i+40] = '1' 50 | buf1[i+60] = '3' 51 | } 52 | buf2 := make([]byte, 80) 53 | for i := 0; i < 80; i++ { 54 | buf2[i] = ' ' 55 | } 56 | n := 20 57 | t := time.Now() 58 | for i := 0; i < n; i++ { 59 | _, err = lcd.Write(buf2) 60 | checkErr(err) 61 | _, err = lcd.Write(buf1) 62 | checkErr(err) 63 | } 64 | fmt.Printf( 65 | "%.2f FPS\n", 66 | float64(2*n)*float64(time.Second)/float64(time.Now().Sub(t)), 67 | ) 68 | } 69 | -------------------------------------------------------------------------------- /examples/ftdi_naive_lcd/main.go: -------------------------------------------------------------------------------- 1 | // Pin connection between FT232R and LCD (HD44780 compatible): 2 | // TxD (DBUS0) <--> D4 3 | // RxD (DBUS1) <--> D5 4 | // RTS# (DBUS2) <--> D6 5 | // CTS# (DBUS3) <--> D7 6 | // DTR# (DBUS4) <--> E 7 | // DSR# (DBUS5) <--> R/W# 8 | // DCD# (DBUS6) <--> RS 9 | package main 10 | 11 | import ( 12 | "github.com/ziutek/ftdi" 13 | "log" 14 | "time" 15 | ) 16 | 17 | func checkErr(err error) { 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | } 22 | 23 | const ( 24 | E = 1 << 4 25 | RW = 1 << 5 26 | RS = 1 << 6 27 | ) 28 | 29 | func wait() { 30 | time.Sleep(10 * time.Millisecond) 31 | } 32 | 33 | func init4bit(d *ftdi.Device) { 34 | checkErr(d.WriteByte(E | 0x02)) 35 | wait() 36 | checkErr(d.WriteByte(0x02)) 37 | wait() 38 | } 39 | 40 | func send(d *ftdi.Device, rs, b byte) { 41 | h := b >> 4 42 | l := b & 0x0f 43 | checkErr(d.WriteByte(E | rs | h)) 44 | wait() 45 | checkErr(d.WriteByte(rs | h)) 46 | wait() 47 | checkErr(d.WriteByte(E | rs | l)) 48 | wait() 49 | checkErr(d.WriteByte(rs | l)) 50 | wait() 51 | } 52 | 53 | func sendCmd(d *ftdi.Device, b byte) { 54 | send(d, 0, b) 55 | } 56 | 57 | func sendData(d *ftdi.Device, b byte) { 58 | send(d, RS, b) 59 | } 60 | 61 | func main() { 62 | d, err := ftdi.OpenFirst(0x0403, 0x6001, ftdi.ChannelAny) 63 | checkErr(err) 64 | defer d.Close() 65 | 66 | checkErr(d.SetBitmode(0xff, ftdi.ModeBitbang)) 67 | 68 | init4bit(d) 69 | sendCmd(d, 0x28) // Display ON, Cursor On, Cursor Blinking 70 | sendCmd(d, 0x0f) // Entry Mode, Increment cursor position, No display shift 71 | sendCmd(d, 0x06) // Cursor moving direction 72 | sendCmd(d, 0x01) // Clear screen 73 | for i := byte(0); i < 80; i++ { 74 | sendData(d, '0'+i) 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /examples/ftdi_out/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ziutek/ftdi" 6 | "os" 7 | "strconv" 8 | ) 9 | 10 | func errorExit(err error) { 11 | if err != nil { 12 | fmt.Fprintln(os.Stderr, err) 13 | os.Exit(1) 14 | } 15 | } 16 | 17 | func usageExit() { 18 | fmt.Fprintln(os.Stderr, "Usage:", os.Args[0], "BYTE") 19 | os.Exit(1) 20 | } 21 | 22 | func main() { 23 | if len(os.Args) != 2 { 24 | usageExit() 25 | } 26 | b, err := strconv.ParseUint(os.Args[1], 0, 8) 27 | errorExit(err) 28 | 29 | d, err := ftdi.OpenFirst(0x0403, 0x6001, ftdi.ChannelAny) 30 | errorExit(err) 31 | defer d.Close() 32 | 33 | errorExit(d.SetBitmode(0xff, ftdi.ModeBitbang)) 34 | 35 | errorExit(d.WriteByte(byte(b))) 36 | } 37 | -------------------------------------------------------------------------------- /examples/ftdi_sbb_speed/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "time" 8 | 9 | "github.com/ziutek/ftdi" 10 | ) 11 | 12 | func checkErr(err error) { 13 | if err == nil { 14 | return 15 | } 16 | fmt.Fprintln(os.Stderr, err) 17 | os.Exit(1) 18 | } 19 | 20 | func read(r io.Reader, in []byte) { 21 | os.Stdout.Write([]byte{'r'}) 22 | _, err := io.ReadFull(r, in) 23 | checkErr(err) 24 | } 25 | 26 | func main() { 27 | ft, err := ftdi.OpenFirst(0x0403, 0x6001, ftdi.ChannelAny) 28 | checkErr(err) 29 | 30 | checkErr(ft.SetBitmode(0x0f, ftdi.ModeSyncBB)) 31 | 32 | // Baudrate for synchronous bitbang mode. 33 | // 34 | // FT232R max baudrate is 3 MBaud but in bitbang mode it is additionally 35 | // limited by USB speed. 36 | // 37 | // USB full speed is: 38 | // 19*64 B / 1ms = 1216000 B/s. 39 | // Theoretical max. continuous sync bitbang baudrate is: 40 | // (1216000 - 2*overhead) Baud / 2 = (608000 - overhead) Baud 41 | // 42 | // TODO: Calculate overhead. 43 | // 44 | // FT232R has 256 B Tx buffer (for sending to USB host) and 128 B Rx buffer 45 | // (for receiving from USB host). So if the long term baudrate isn't exceed, 46 | // the short term (burst) baudrate (for no more than 256 symbols) can be 47 | // up to (1216000 - overhead) Baud. 48 | 49 | const cs = 64 * 1024 50 | const br = 65580 * 16 51 | checkErr(ft.SetReadChunkSize(cs)) 52 | checkErr(ft.SetWriteChunkSize(cs)) 53 | checkErr(ft.SetLatencyTimer(2)) 54 | checkErr(ft.SetBaudrate(br / 16)) 55 | 56 | checkErr(ft.PurgeBuffers()) 57 | 58 | in := make([]byte, cs) 59 | out := make([]byte, cs) 60 | const count = 10 61 | 62 | t1 := time.Now() 63 | for i := 0; i < count; i++ { 64 | go read(ft, in) 65 | // Uncoment following line to see speed for reverse order. 66 | //time.Sleep(time.Microsecond) 67 | os.Stdout.Write([]byte{'w'}) 68 | _, err := ft.Write(out) 69 | checkErr(err) 70 | } 71 | t2 := time.Now() 72 | 73 | fmt.Println( 74 | "\nbr =", br, 75 | "mes =", cs*count*int64(time.Second)/int64(t2.Sub(t1)), 76 | ) 77 | return 78 | } 79 | -------------------------------------------------------------------------------- /examples/ftdi_spi/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/ziutek/ftdi" 7 | ) 8 | 9 | func main() { 10 | d, err := ftdi.OpenFirst(0x0403, 0x6011, ftdi.ChannelA) 11 | if err != nil { 12 | log.Fatalf("Unable to open FTDI device: %s", err) 13 | } 14 | defer d.Close() 15 | 16 | // Channel A is the SPI bus 17 | if err := d.SetBitmode(0xff, ftdi.ModeMPSSE); err != nil { 18 | log.Fatalf("Unable to set Bitmode: %s", err) 19 | } 20 | 21 | // This pin numbering aligns with the standard pinout on the FT4232H 22 | clk := byte(1 << 0) 23 | mosi := byte(1 << 1) 24 | // miso := byte(1 << 2) 25 | cs := byte(1 << 3) 26 | 27 | outputs := clk | mosi | cs 28 | 29 | // We want a 3MHz clock, and we're not using div5 on the 60MHz clock 30 | speed := ftdi.MPSSEDivValue(3_000_000, false) 31 | //log.Printf("speed: 0x%4.4x\n", speed) 32 | 33 | // Set up the SPI Bus - all the pins will be idle high 34 | setup_spi_commands := []byte{ 35 | ftdi.MPSSEDisableDiv5, // Disable /5 divisor to use the 60MHz clock 36 | ftdi.MPSSETCKDivisor, // set the clock divisor 37 | byte(speed & 0xff), // low byte of clock rate 38 | byte(speed >> 8), // high byte of clock rate 39 | ftdi.MPSSESetBitsLow, // set low-bit values 40 | outputs, // What values to set (all 1) 41 | outputs, // Which pins to apply the above values to 42 | } 43 | if _, err := d.Write(setup_spi_commands); err != nil { 44 | log.Fatalf("Unable to write MPSSE commands: %s", err) 45 | } 46 | tx_data := []byte{1, 2, 3, 4} // Data bytes to appears on the SPI bus 47 | 48 | xfer := []byte{ 49 | ftdi.MPSSESetBitsLow, 50 | ^(cs | clk), // Set all outputs except the chipselect & clock to be high 51 | outputs, 52 | ftdi.MPSSEDoWrite | ftdi.MPSSEWriteNeg, 53 | byte((len(tx_data) - 1) & 0xff), 54 | byte((len(tx_data) - 1) >> 8), 55 | } 56 | // Add in the actual data we want to send 57 | xfer = append(xfer, tx_data...) 58 | 59 | // If we wanted to read a response, we would have to send that data off here, 60 | // and issue an ftdi.MPSSEDoRead|ftdi.MPSSEReadNeg) command here 61 | 62 | // After the transfer, put the pins high, except the clock 63 | xfer = append(xfer, ftdi.MPSSESetBitsLow) 64 | xfer = append(xfer, outputs&^clk) 65 | xfer = append(xfer, outputs) 66 | if _, err := d.Write(xfer); err != nil { 67 | log.Fatalf("Unable to write SPI transfer: %s", err) 68 | } 69 | 70 | log.Printf("Sent data %v to chipselect %d", tx_data, cs) 71 | } 72 | -------------------------------------------------------------------------------- /ftn/device_linux.go: -------------------------------------------------------------------------------- 1 | package ftn 2 | 3 | /* 4 | #include 5 | #include 6 | 7 | #cgo pkg-config: libusb-1.0 8 | */ 9 | import "C" 10 | 11 | import ( 12 | "bytes" 13 | "runtime" 14 | "unsafe" 15 | ) 16 | 17 | var ctx *C.libusb_context 18 | 19 | type USBError int 20 | 21 | func (e USBError) Error() string { 22 | return C.GoString(C.libusb_error_name(C.int(e))) 23 | } 24 | 25 | func init() { 26 | if e := C.libusb_init(&ctx); e < 0 { 27 | panic(USBError(e)) 28 | } 29 | } 30 | 31 | // Device represents some FTDI device 32 | type Device struct { 33 | d *C.libusb_device 34 | desc C.struct_libusb_device_descriptor 35 | } 36 | 37 | func (d *Device) unref() { 38 | C.libusb_unref_device(d.d) 39 | } 40 | 41 | func (d *Device) Connect() (*Conn, error) { 42 | var h *C.libusb_device_handle 43 | if e := C.libusb_open(d.d, &h); e < 0 { 44 | return nil, USBError(e) 45 | } 46 | return &Conn{h: h, d: d}, nil 47 | } 48 | 49 | func FindDevices(vendor, product int) ([]*Device, error) { 50 | var dl **C.libusb_device 51 | n := C.libusb_get_device_list(ctx, &dl) 52 | if n < 0 { 53 | return nil, USBError(n) 54 | } 55 | defer C.libusb_free_device_list(dl, 1) 56 | 57 | var found []*Device 58 | 59 | for _, d := range (*(*[1 << 30]*C.libusb_device)(unsafe.Pointer(dl)))[:n] { 60 | var desc C.struct_libusb_device_descriptor 61 | if e := C.libusb_get_device_descriptor(d, &desc); e < 0 { 62 | return nil, USBError(e) 63 | } 64 | if int(desc.idVendor) == vendor && int(desc.idProduct) == product { 65 | dev := &Device{d: C.libusb_ref_device(d), desc: desc} 66 | runtime.SetFinalizer(dev, (*Device).unref) 67 | found = append(found, dev) 68 | } 69 | } 70 | return found, nil 71 | } 72 | 73 | type Conn struct { 74 | h *C.libusb_device_handle 75 | d *Device 76 | } 77 | 78 | func bytes0str(b []byte) string { 79 | if i := bytes.IndexByte(b, 0); i != -1 { 80 | b = b[:i] 81 | } 82 | return string(b) 83 | } 84 | 85 | func (c *Conn) Description() (string, error) { 86 | buf := make([]byte, 256) 87 | e := C.libusb_get_string_descriptor_ascii( 88 | c.h, c.d.desc.iProduct, (*C.uchar)(&buf[0]), C.int(len(buf)), 89 | ) 90 | if e < 0 { 91 | return "", USBError(e) 92 | } 93 | return bytes0str(buf), nil 94 | } 95 | 96 | func (c *Conn) Serial() (string, error) { 97 | buf := make([]byte, 256) 98 | e := C.libusb_get_string_descriptor_ascii( 99 | c.h, c.d.desc.iSerialNumber, (*C.uchar)(&buf[0]), C.int(len(buf)), 100 | ) 101 | if e < 0 { 102 | return "", USBError(e) 103 | } 104 | return bytes0str(buf), nil 105 | } 106 | 107 | /*type Mode byte 108 | 109 | const ( 110 | ModeReset Mode = iota 111 | ModeBitbang 112 | ModeMPSSE 113 | ModeSyncBB 114 | ModeMCU 115 | ModeOpto 116 | ModeCBUS 117 | ModeSyncFF 118 | ModeFT1284 119 | ) 120 | 121 | func (d *Device) SetBitmode(iomask byte, mode Mode) error { 122 | e := C.ftdi_set_bitmode(d.ctx, C.uchar(iomask), C.uchar(mode)) 123 | return d.makeError(e) 124 | } 125 | 126 | func (d *Device) Reset() error { 127 | return d.makeError(C.ftdi_usb_reset(d.ctx)) 128 | } 129 | 130 | func (d *Device) PurgeRxBuffer() error { 131 | return d.makeError(C.ftdi_usb_purge_rx_buffer(d.ctx)) 132 | } 133 | 134 | func (d *Device) PurgeTxBuffer() error { 135 | return d.makeError(C.ftdi_usb_purge_tx_buffer(d.ctx)) 136 | } 137 | 138 | func (d *Device) PurgeBuffers() error { 139 | return d.makeError(C.ftdi_usb_purge_buffers(d.ctx)) 140 | } 141 | func (d *Device) WriteChunkSize() (int, error) { 142 | var cs C.uint 143 | e := C.ftdi_write_data_get_chunksize(d.ctx, &cs) 144 | return int(cs), d.makeError(e) 145 | } 146 | 147 | func (d *Device) SetWriteChunkSize(cs int) error { 148 | return d.makeError(C.ftdi_write_data_set_chunksize(d.ctx, C.uint(cs))) 149 | } 150 | 151 | func (d *Device) Write(buf []byte) (int, error) { 152 | n := C.ftdi_write_data( 153 | d.ctx, 154 | (*C.uchar)(unsafe.Pointer(&buf[0])), 155 | C.int(len(buf)), 156 | ) 157 | if n < 0 { 158 | return 0, d.makeError(n) 159 | } 160 | return int(n), nil 161 | } 162 | 163 | func (d *Device) WriteByte(b byte) error { 164 | n := C.ftdi_write_data(d.ctx, (*C.uchar)(&b), 1) 165 | if n != 1 { 166 | return d.makeError(n) 167 | } 168 | return nil 169 | } 170 | 171 | func (d *Device) SetBaudrate(br int) error { 172 | return d.makeError(C.ftdi_set_baudrate(d.ctx, C.int(br))) 173 | } 174 | 175 | // EEPROM returns a handler to the device internal EEPROM subsystem 176 | func (d *Device) EEPROM() EEPROM { 177 | return EEPROM{d} 178 | }*/ 179 | -------------------------------------------------------------------------------- /ftn/ftdi.go: -------------------------------------------------------------------------------- 1 | package ftn 2 | 3 | type Mode byte 4 | 5 | const ( 6 | ModeReset Mode = iota 7 | ModeBitbang 8 | ModeMPSSE 9 | ModeSyncBB 10 | ModeMCU 11 | ModeOpto 12 | ModeCBUS 13 | ModeSyncFF 14 | ModeFT1284 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /ftn/ftn_example/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/ziutek/ftdi/ftn" 6 | "os" 7 | ) 8 | 9 | func checkErr(err error) { 10 | if err != nil { 11 | fmt.Fprintln(os.Stderr, err) 12 | } 13 | } 14 | 15 | func main() { 16 | dl, err := ftn.FindDevices(0x0403, 0x6001) 17 | checkErr(err) 18 | fmt.Println("Found", len(dl), "devices:") 19 | for i, d := range dl { 20 | c, err := d.Connect() 21 | checkErr(err) 22 | desc, err := c.Description() 23 | checkErr(err) 24 | serial, err := c.Serial() 25 | checkErr(err) 26 | fmt.Printf("%d: desc='%s' serial='%s'\n", i, desc, serial) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ftn/readme.txt: -------------------------------------------------------------------------------- 1 | This is experimental driver fo newer FTDI chips 2 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ziutek/ftdi 2 | 3 | go 1.13 4 | 5 | require github.com/ziutek/lcd v0.0.0-20141212131202-924f223d0903 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/ziutek/lcd v0.0.0-20141212131202-924f223d0903 h1:xU/rzh36EMOgkzw3GaxPuVckwSTis4jRS3ZBowWb7XQ= 2 | github.com/ziutek/lcd v0.0.0-20141212131202-924f223d0903/go.mod h1:ZBCPhfHIcCtzsrXIcyEiSPDKHrjT9fXtJNKj2t1HCKw= 3 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/AUTHORS: -------------------------------------------------------------------------------- 1 | Main developers: 2 | 3 | Intra2net AG 4 | 5 | Contributors in alphabetical order, 6 | see Changelog for full details: 7 | 8 | Adam Malinowski 9 | Alain Abbas 10 | Alex Harford 11 | Alexander Lehmann 12 | Anders Larsen 13 | Andrei Errapart 14 | Andrew John Rogers 15 | Arnim Läuger 16 | Aurelien Jarno 17 | Benjamin Vanheuverzwijn 18 | Chris Morgan 19 | Chris Zeh 20 | Claudio Lanconelli 21 | Clifford Wolf 22 | Dan Dedrick 23 | Daniel Kirkham 24 | David Challis 25 | Davide Michelizza 26 | Denis Sirotkin 27 | Diego Elio Pettenò 28 | Emil 29 | Eneas U de Queiroz 30 | Eric Schott 31 | Eugene Hutorny 32 | Evan Nemerson 33 | Evgeny Sinelnikov 34 | Fabrice Fontaine 35 | Fahrzin Hemmati 36 | Flynn Marquardt 37 | Forest Crossman 38 | Frank Dana 39 | Holger Mößinger 40 | Ian Abbott 41 | Jared Boone 42 | Jarkko Sonninen 43 | Jean-Daniel Merkli 44 | Jochen Sprickerhof 45 | Joe Zbiciak 46 | Jon Beniston 47 | Jordan Rupprecht 48 | Juergen Beisert 49 | Lorenz Moesenlechner 50 | Marek Vavruša 51 | Marius Kintel 52 | Mark Hämmerling 53 | Matthias Janke 54 | Matthias Kranz 55 | Matthias Richter 56 | Matthijs ten Berge 57 | Max 58 | Maxwell Dreytser 59 | Michel Zou 60 | Mike Frysinger 61 | Nathael Pajani 62 | Nathan Fraser 63 | Oleg Seiljus 64 | Paul Fertser 65 | Pawel Jewstafjew 66 | Peter Holik 67 | Raphael Assenat 68 | Richard Shaw 69 | Robby McKilliam 70 | Robert Cox 71 | Robin Haberkorn 72 | Rodney Sinclair 73 | Rogier Wolff 74 | Rolf Fiedler 75 | Roman Lapin 76 | Salvador Eduardo Tropea 77 | Stephan Linz 78 | Steven Turner 79 | Tarek Heiland 80 | Thilo Schulz 81 | Thimo Eichstaedt 82 | Thomas Fischl 83 | Thomas Klose 84 | Tim Ansell 85 | Tom Saunders 86 | Uwe Bonnes 87 | Vladimir Yakovlev 88 | Wilfried Holzke 89 | Xiaofan Chen 90 | Yegor Yefremov 91 | Yi-Shin Li 92 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/COPYING-CMAKE-SCRIPTS: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/COPYING.GPL: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/COPYING.LIB: -------------------------------------------------------------------------------- 1 | GNU LIBRARY GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1991 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the library GPL. It is 10 | numbered 2 because it goes with version 2 of the ordinary GPL.] 11 | 12 | Preamble 13 | 14 | The licenses for most software are designed to take away your 15 | freedom to share and change it. By contrast, the GNU General Public 16 | Licenses are intended to guarantee your freedom to share and change 17 | free software--to make sure the software is free for all its users. 18 | 19 | This license, the Library General Public License, applies to some 20 | specially designated Free Software Foundation software, and to any 21 | other libraries whose authors decide to use it. You can use it for 22 | your libraries, too. 23 | 24 | When we speak of free software, we are referring to freedom, not 25 | price. Our General Public Licenses are designed to make sure that you 26 | have the freedom to distribute copies of free software (and charge for 27 | this service if you wish), that you receive source code or can get it 28 | if you want it, that you can change the software or use pieces of it 29 | in new free programs; and that you know you can do these things. 30 | 31 | To protect your rights, we need to make restrictions that forbid 32 | anyone to deny you these rights or to ask you to surrender the rights. 33 | These restrictions translate to certain responsibilities for you if 34 | you distribute copies of the library, or if you modify it. 35 | 36 | For example, if you distribute copies of the library, whether gratis 37 | or for a fee, you must give the recipients all the rights that we gave 38 | you. You must make sure that they, too, receive or can get the source 39 | code. If you link a program with the library, you must provide 40 | complete object files to the recipients so that they can relink them 41 | with the library, after making changes to the library and recompiling 42 | it. And you must show them these terms so they know their rights. 43 | 44 | Our method of protecting your rights has two steps: (1) copyright 45 | the library, and (2) offer you this license which gives you legal 46 | permission to copy, distribute and/or modify the library. 47 | 48 | Also, for each distributor's protection, we want to make certain 49 | that everyone understands that there is no warranty for this free 50 | library. If the library is modified by someone else and passed on, we 51 | want its recipients to know that what they have is not the original 52 | version, so that any problems introduced by others will not reflect on 53 | the original authors' reputations. 54 | 55 | Finally, any free program is threatened constantly by software 56 | patents. We wish to avoid the danger that companies distributing free 57 | software will individually obtain patent licenses, thus in effect 58 | transforming the program into proprietary software. To prevent this, 59 | we have made it clear that any patent must be licensed for everyone's 60 | free use or not licensed at all. 61 | 62 | Most GNU software, including some libraries, is covered by the ordinary 63 | GNU General Public License, which was designed for utility programs. This 64 | license, the GNU Library General Public License, applies to certain 65 | designated libraries. This license is quite different from the ordinary 66 | one; be sure to read it in full, and don't assume that anything in it is 67 | the same as in the ordinary license. 68 | 69 | The reason we have a separate public license for some libraries is that 70 | they blur the distinction we usually make between modifying or adding to a 71 | program and simply using it. Linking a program with a library, without 72 | changing the library, is in some sense simply using the library, and is 73 | analogous to running a utility program or application program. However, in 74 | a textual and legal sense, the linked executable is a combined work, a 75 | derivative of the original library, and the ordinary General Public License 76 | treats it as such. 77 | 78 | Because of this blurred distinction, using the ordinary General 79 | Public License for libraries did not effectively promote software 80 | sharing, because most developers did not use the libraries. We 81 | concluded that weaker conditions might promote sharing better. 82 | 83 | However, unrestricted linking of non-free programs would deprive the 84 | users of those programs of all benefit from the free status of the 85 | libraries themselves. This Library General Public License is intended to 86 | permit developers of non-free programs to use free libraries, while 87 | preserving your freedom as a user of such programs to change the free 88 | libraries that are incorporated in them. (We have not seen how to achieve 89 | this as regards changes in header files, but we have achieved it as regards 90 | changes in the actual functions of the Library.) The hope is that this 91 | will lead to faster development of free libraries. 92 | 93 | The precise terms and conditions for copying, distribution and 94 | modification follow. Pay close attention to the difference between a 95 | "work based on the library" and a "work that uses the library". The 96 | former contains code derived from the library, while the latter only 97 | works together with the library. 98 | 99 | Note that it is possible for a library to be covered by the ordinary 100 | General Public License rather than by this special one. 101 | 102 | GNU LIBRARY GENERAL PUBLIC LICENSE 103 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 104 | 105 | 0. This License Agreement applies to any software library which 106 | contains a notice placed by the copyright holder or other authorized 107 | party saying it may be distributed under the terms of this Library 108 | General Public License (also called "this License"). Each licensee is 109 | addressed as "you". 110 | 111 | A "library" means a collection of software functions and/or data 112 | prepared so as to be conveniently linked with application programs 113 | (which use some of those functions and data) to form executables. 114 | 115 | The "Library", below, refers to any such software library or work 116 | which has been distributed under these terms. A "work based on the 117 | Library" means either the Library or any derivative work under 118 | copyright law: that is to say, a work containing the Library or a 119 | portion of it, either verbatim or with modifications and/or translated 120 | straightforwardly into another language. (Hereinafter, translation is 121 | included without limitation in the term "modification".) 122 | 123 | "Source code" for a work means the preferred form of the work for 124 | making modifications to it. For a library, complete source code means 125 | all the source code for all modules it contains, plus any associated 126 | interface definition files, plus the scripts used to control compilation 127 | and installation of the library. 128 | 129 | Activities other than copying, distribution and modification are not 130 | covered by this License; they are outside its scope. The act of 131 | running a program using the Library is not restricted, and output from 132 | such a program is covered only if its contents constitute a work based 133 | on the Library (independent of the use of the Library in a tool for 134 | writing it). Whether that is true depends on what the Library does 135 | and what the program that uses the Library does. 136 | 137 | 1. You may copy and distribute verbatim copies of the Library's 138 | complete source code as you receive it, in any medium, provided that 139 | you conspicuously and appropriately publish on each copy an 140 | appropriate copyright notice and disclaimer of warranty; keep intact 141 | all the notices that refer to this License and to the absence of any 142 | warranty; and distribute a copy of this License along with the 143 | Library. 144 | 145 | You may charge a fee for the physical act of transferring a copy, 146 | and you may at your option offer warranty protection in exchange for a 147 | fee. 148 | 149 | 2. You may modify your copy or copies of the Library or any portion 150 | of it, thus forming a work based on the Library, and copy and 151 | distribute such modifications or work under the terms of Section 1 152 | above, provided that you also meet all of these conditions: 153 | 154 | a) The modified work must itself be a software library. 155 | 156 | b) You must cause the files modified to carry prominent notices 157 | stating that you changed the files and the date of any change. 158 | 159 | c) You must cause the whole of the work to be licensed at no 160 | charge to all third parties under the terms of this License. 161 | 162 | d) If a facility in the modified Library refers to a function or a 163 | table of data to be supplied by an application program that uses 164 | the facility, other than as an argument passed when the facility 165 | is invoked, then you must make a good faith effort to ensure that, 166 | in the event an application does not supply such function or 167 | table, the facility still operates, and performs whatever part of 168 | its purpose remains meaningful. 169 | 170 | (For example, a function in a library to compute square roots has 171 | a purpose that is entirely well-defined independent of the 172 | application. Therefore, Subsection 2d requires that any 173 | application-supplied function or table used by this function must 174 | be optional: if the application does not supply it, the square 175 | root function must still compute square roots.) 176 | 177 | These requirements apply to the modified work as a whole. If 178 | identifiable sections of that work are not derived from the Library, 179 | and can be reasonably considered independent and separate works in 180 | themselves, then this License, and its terms, do not apply to those 181 | sections when you distribute them as separate works. But when you 182 | distribute the same sections as part of a whole which is a work based 183 | on the Library, the distribution of the whole must be on the terms of 184 | this License, whose permissions for other licensees extend to the 185 | entire whole, and thus to each and every part regardless of who wrote 186 | it. 187 | 188 | Thus, it is not the intent of this section to claim rights or contest 189 | your rights to work written entirely by you; rather, the intent is to 190 | exercise the right to control the distribution of derivative or 191 | collective works based on the Library. 192 | 193 | In addition, mere aggregation of another work not based on the Library 194 | with the Library (or with a work based on the Library) on a volume of 195 | a storage or distribution medium does not bring the other work under 196 | the scope of this License. 197 | 198 | 3. You may opt to apply the terms of the ordinary GNU General Public 199 | License instead of this License to a given copy of the Library. To do 200 | this, you must alter all the notices that refer to this License, so 201 | that they refer to the ordinary GNU General Public License, version 2, 202 | instead of to this License. (If a newer version than version 2 of the 203 | ordinary GNU General Public License has appeared, then you can specify 204 | that version instead if you wish.) Do not make any other change in 205 | these notices. 206 | 207 | Once this change is made in a given copy, it is irreversible for 208 | that copy, so the ordinary GNU General Public License applies to all 209 | subsequent copies and derivative works made from that copy. 210 | 211 | This option is useful when you wish to copy part of the code of 212 | the Library into a program that is not a library. 213 | 214 | 4. You may copy and distribute the Library (or a portion or 215 | derivative of it, under Section 2) in object code or executable form 216 | under the terms of Sections 1 and 2 above provided that you accompany 217 | it with the complete corresponding machine-readable source code, which 218 | must be distributed under the terms of Sections 1 and 2 above on a 219 | medium customarily used for software interchange. 220 | 221 | If distribution of object code is made by offering access to copy 222 | from a designated place, then offering equivalent access to copy the 223 | source code from the same place satisfies the requirement to 224 | distribute the source code, even though third parties are not 225 | compelled to copy the source along with the object code. 226 | 227 | 5. A program that contains no derivative of any portion of the 228 | Library, but is designed to work with the Library by being compiled or 229 | linked with it, is called a "work that uses the Library". Such a 230 | work, in isolation, is not a derivative work of the Library, and 231 | therefore falls outside the scope of this License. 232 | 233 | However, linking a "work that uses the Library" with the Library 234 | creates an executable that is a derivative of the Library (because it 235 | contains portions of the Library), rather than a "work that uses the 236 | library". The executable is therefore covered by this License. 237 | Section 6 states terms for distribution of such executables. 238 | 239 | When a "work that uses the Library" uses material from a header file 240 | that is part of the Library, the object code for the work may be a 241 | derivative work of the Library even though the source code is not. 242 | Whether this is true is especially significant if the work can be 243 | linked without the Library, or if the work is itself a library. The 244 | threshold for this to be true is not precisely defined by law. 245 | 246 | If such an object file uses only numerical parameters, data 247 | structure layouts and accessors, and small macros and small inline 248 | functions (ten lines or less in length), then the use of the object 249 | file is unrestricted, regardless of whether it is legally a derivative 250 | work. (Executables containing this object code plus portions of the 251 | Library will still fall under Section 6.) 252 | 253 | Otherwise, if the work is a derivative of the Library, you may 254 | distribute the object code for the work under the terms of Section 6. 255 | Any executables containing that work also fall under Section 6, 256 | whether or not they are linked directly with the Library itself. 257 | 258 | 6. As an exception to the Sections above, you may also compile or 259 | link a "work that uses the Library" with the Library to produce a 260 | work containing portions of the Library, and distribute that work 261 | under terms of your choice, provided that the terms permit 262 | modification of the work for the customer's own use and reverse 263 | engineering for debugging such modifications. 264 | 265 | You must give prominent notice with each copy of the work that the 266 | Library is used in it and that the Library and its use are covered by 267 | this License. You must supply a copy of this License. If the work 268 | during execution displays copyright notices, you must include the 269 | copyright notice for the Library among them, as well as a reference 270 | directing the user to the copy of this License. Also, you must do one 271 | of these things: 272 | 273 | a) Accompany the work with the complete corresponding 274 | machine-readable source code for the Library including whatever 275 | changes were used in the work (which must be distributed under 276 | Sections 1 and 2 above); and, if the work is an executable linked 277 | with the Library, with the complete machine-readable "work that 278 | uses the Library", as object code and/or source code, so that the 279 | user can modify the Library and then relink to produce a modified 280 | executable containing the modified Library. (It is understood 281 | that the user who changes the contents of definitions files in the 282 | Library will not necessarily be able to recompile the application 283 | to use the modified definitions.) 284 | 285 | b) Accompany the work with a written offer, valid for at 286 | least three years, to give the same user the materials 287 | specified in Subsection 6a, above, for a charge no more 288 | than the cost of performing this distribution. 289 | 290 | c) If distribution of the work is made by offering access to copy 291 | from a designated place, offer equivalent access to copy the above 292 | specified materials from the same place. 293 | 294 | d) Verify that the user has already received a copy of these 295 | materials or that you have already sent this user a copy. 296 | 297 | For an executable, the required form of the "work that uses the 298 | Library" must include any data and utility programs needed for 299 | reproducing the executable from it. However, as a special exception, 300 | the source code distributed need not include anything that is normally 301 | distributed (in either source or binary form) with the major 302 | components (compiler, kernel, and so on) of the operating system on 303 | which the executable runs, unless that component itself accompanies 304 | the executable. 305 | 306 | It may happen that this requirement contradicts the license 307 | restrictions of other proprietary libraries that do not normally 308 | accompany the operating system. Such a contradiction means you cannot 309 | use both them and the Library together in an executable that you 310 | distribute. 311 | 312 | 7. You may place library facilities that are a work based on the 313 | Library side-by-side in a single library together with other library 314 | facilities not covered by this License, and distribute such a combined 315 | library, provided that the separate distribution of the work based on 316 | the Library and of the other library facilities is otherwise 317 | permitted, and provided that you do these two things: 318 | 319 | a) Accompany the combined library with a copy of the same work 320 | based on the Library, uncombined with any other library 321 | facilities. This must be distributed under the terms of the 322 | Sections above. 323 | 324 | b) Give prominent notice with the combined library of the fact 325 | that part of it is a work based on the Library, and explaining 326 | where to find the accompanying uncombined form of the same work. 327 | 328 | 8. You may not copy, modify, sublicense, link with, or distribute 329 | the Library except as expressly provided under this License. Any 330 | attempt otherwise to copy, modify, sublicense, link with, or 331 | distribute the Library is void, and will automatically terminate your 332 | rights under this License. However, parties who have received copies, 333 | or rights, from you under this License will not have their licenses 334 | terminated so long as such parties remain in full compliance. 335 | 336 | 9. You are not required to accept this License, since you have not 337 | signed it. However, nothing else grants you permission to modify or 338 | distribute the Library or its derivative works. These actions are 339 | prohibited by law if you do not accept this License. Therefore, by 340 | modifying or distributing the Library (or any work based on the 341 | Library), you indicate your acceptance of this License to do so, and 342 | all its terms and conditions for copying, distributing or modifying 343 | the Library or works based on it. 344 | 345 | 10. Each time you redistribute the Library (or any work based on the 346 | Library), the recipient automatically receives a license from the 347 | original licensor to copy, distribute, link with or modify the Library 348 | subject to these terms and conditions. You may not impose any further 349 | restrictions on the recipients' exercise of the rights granted herein. 350 | You are not responsible for enforcing compliance by third parties to 351 | this License. 352 | 353 | 11. If, as a consequence of a court judgment or allegation of patent 354 | infringement or for any other reason (not limited to patent issues), 355 | conditions are imposed on you (whether by court order, agreement or 356 | otherwise) that contradict the conditions of this License, they do not 357 | excuse you from the conditions of this License. If you cannot 358 | distribute so as to satisfy simultaneously your obligations under this 359 | License and any other pertinent obligations, then as a consequence you 360 | may not distribute the Library at all. For example, if a patent 361 | license would not permit royalty-free redistribution of the Library by 362 | all those who receive copies directly or indirectly through you, then 363 | the only way you could satisfy both it and this License would be to 364 | refrain entirely from distribution of the Library. 365 | 366 | If any portion of this section is held invalid or unenforceable under any 367 | particular circumstance, the balance of the section is intended to apply, 368 | and the section as a whole is intended to apply in other circumstances. 369 | 370 | It is not the purpose of this section to induce you to infringe any 371 | patents or other property right claims or to contest validity of any 372 | such claims; this section has the sole purpose of protecting the 373 | integrity of the free software distribution system which is 374 | implemented by public license practices. Many people have made 375 | generous contributions to the wide range of software distributed 376 | through that system in reliance on consistent application of that 377 | system; it is up to the author/donor to decide if he or she is willing 378 | to distribute software through any other system and a licensee cannot 379 | impose that choice. 380 | 381 | This section is intended to make thoroughly clear what is believed to 382 | be a consequence of the rest of this License. 383 | 384 | 12. If the distribution and/or use of the Library is restricted in 385 | certain countries either by patents or by copyrighted interfaces, the 386 | original copyright holder who places the Library under this License may add 387 | an explicit geographical distribution limitation excluding those countries, 388 | so that distribution is permitted only in or among countries not thus 389 | excluded. In such case, this License incorporates the limitation as if 390 | written in the body of this License. 391 | 392 | 13. The Free Software Foundation may publish revised and/or new 393 | versions of the Library General Public License from time to time. 394 | Such new versions will be similar in spirit to the present version, 395 | but may differ in detail to address new problems or concerns. 396 | 397 | Each version is given a distinguishing version number. If the Library 398 | specifies a version number of this License which applies to it and 399 | "any later version", you have the option of following the terms and 400 | conditions either of that version or of any later version published by 401 | the Free Software Foundation. If the Library does not specify a 402 | license version number, you may choose any version ever published by 403 | the Free Software Foundation. 404 | 405 | 14. If you wish to incorporate parts of the Library into other free 406 | programs whose distribution conditions are incompatible with these, 407 | write to the author to ask for permission. For software which is 408 | copyrighted by the Free Software Foundation, write to the Free 409 | Software Foundation; we sometimes make exceptions for this. Our 410 | decision will be guided by the two goals of preserving the free status 411 | of all derivatives of our free software and of promoting the sharing 412 | and reuse of software generally. 413 | 414 | NO WARRANTY 415 | 416 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 417 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 418 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 419 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 420 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 421 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 422 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 423 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 424 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 425 | 426 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 427 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 428 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 429 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 430 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 431 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 432 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 433 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 434 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 435 | DAMAGES. 436 | 437 | END OF TERMS AND CONDITIONS 438 | 439 | How to Apply These Terms to Your New Libraries 440 | 441 | If you develop a new library, and you want it to be of the greatest 442 | possible use to the public, we recommend making it free software that 443 | everyone can redistribute and change. You can do so by permitting 444 | redistribution under these terms (or, alternatively, under the terms of the 445 | ordinary General Public License). 446 | 447 | To apply these terms, attach the following notices to the library. It is 448 | safest to attach them to the start of each source file to most effectively 449 | convey the exclusion of warranty; and each file should have at least the 450 | "copyright" line and a pointer to where the full notice is found. 451 | 452 | 453 | Copyright (C) 454 | 455 | This library is free software; you can redistribute it and/or 456 | modify it under the terms of the GNU Library General Public 457 | License as published by the Free Software Foundation; either 458 | version 2 of the License, or (at your option) any later version. 459 | 460 | This library is distributed in the hope that it will be useful, 461 | but WITHOUT ANY WARRANTY; without even the implied warranty of 462 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 463 | Library General Public License for more details. 464 | 465 | You should have received a copy of the GNU Library General Public 466 | License along with this library; if not, write to the Free Software 467 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 468 | 469 | Also add information on how to contact you by electronic and paper mail. 470 | 471 | You should also get your employer (if you work as a programmer) or your 472 | school, if any, to sign a "copyright disclaimer" for the library, if 473 | necessary. Here is a sample; alter the names: 474 | 475 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 476 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 477 | 478 | , 1 April 1990 479 | Ty Coon, President of Vice 480 | 481 | That's all there is to it! 482 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/LICENSE: -------------------------------------------------------------------------------- 1 | The C library "libftdi1" is distributed under the 2 | GNU Library General Public License version 2. 3 | 4 | A copy of the GNU Library General Public License (LGPL) is included 5 | in this distribution, in the file COPYING.LIB. 6 | 7 | ---------------------------------------------------------------------- 8 | 9 | The C++ wrapper "ftdipp1" is distributed under the GNU General 10 | Public License version 2 (with a special exception described below). 11 | 12 | A copy of the GNU General Public License (GPL) is included 13 | in this distribution, in the file COPYING.GPL. 14 | 15 | As a special exception, if other files instantiate templates or use macros 16 | or inline functions from this file, or you compile this file and link it 17 | with other works to produce a work based on this file, this file 18 | does not by itself cause the resulting work to be covered 19 | by the GNU General Public License. 20 | 21 | However the source code for this file must still be made available 22 | in accordance with section (3) of the GNU General Public License. 23 | 24 | This exception does not invalidate any other reasons why a work based 25 | on this file might be covered by the GNU General Public License. 26 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------- 2 | libftdi version 1.5 3 | -------------------------------------------------------------------- 4 | 5 | libftdi - A library (using libusb) to talk to FTDI's UART/FIFO chips 6 | including the popular bitbang mode. 7 | 8 | The following chips are supported: 9 | * FT230X 10 | - FT4232H / FT2232H 11 | - FT232R / FT245R 12 | - FT2232L / FT2232D / FT2232C 13 | - FT232BM / FT245BM (and the BL/BQ variants) 14 | - FT8U232AM / FT8U245AM 15 | 16 | libftdi requires libusb 1.x. 17 | 18 | The AUTHORS file contains a list of all the people 19 | that made libftdi possible what it is today. 20 | 21 | Changes 22 | ------- 23 | * Implement tc[io]flush methods & deprecate broken purge_buffers methods 24 | 25 | Please check your code for ftdi_usb_purge_rx_buffer(), 26 | ftdi_usb_purge_tx_buffer() and ftdi_usb_purge_buffers() 27 | and migrate to the new ftdi_tc[io]flush() methods. 28 | 29 | Old code will continue to function, but you'll get 30 | a deprecation warning during compilation. 31 | 32 | * Add program to test buffer flush (purge) functionality 33 | * Add kernel driver auto attach/detach. 34 | See new AUTO_DETACH_REATACH_SIO_MODULE option 35 | * Add ftdi_setflowctrl_xonxoff() 36 | * ftdi_eeprom / eeprom handling: 37 | * Unify handling of all boolean eeprom flags 38 | * Add device release number support 39 | * Add channel_a_driver support for type xxR chips 40 | * Add support for group0 drive levels on x232H chips 41 | * Fix handling of high_current_drive parameter 42 | * Fix inverted handling of VCP driver field for TYPE_R chips 43 | * New --verbose option for eeprom decode operation 44 | * Add example code for async mode 45 | * Add SPDX license identifiers to the core library & ftdi_eeprom 46 | * Various python SWIG wrapper improvements 47 | * Various cmake file improvements 48 | * Fix small bugs in error code paths 49 | 50 | You'll find the newest version of libftdi at: 51 | https://www.intra2net.com/en/developer/libftdi 52 | 53 | 54 | Quick start 55 | ----------- 56 | mkdir build 57 | cd build 58 | 59 | cmake -DCMAKE_INSTALL_PREFIX="/usr" ../ 60 | make 61 | make install 62 | 63 | More verbose build instructions are in "README.build" 64 | 65 | -------------------------------------------------------------------- 66 | www.intra2net.com 2003-2020 Intra2net AG 67 | -------------------------------------------------------------------- 68 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/README.build: -------------------------------------------------------------------------------- 1 | Here is a short tutorial on how to build libftdi git under 2 | Ubuntu 12.10, But it is similar on other Linux distros. 3 | 4 | 1) Install the build tools 5 | sudo apt-get install build-essential (yum install make automake gcc gcc-c++ kernel-devel) 6 | sudo apt-get install git-core (yum install git) 7 | sudo apt-get install cmake (yum install cmake) 8 | sudo apt-get install doxygen (for building documentations) (yum install doxygen) 9 | 10 | 2) Install dependencies 11 | sudo apt-get install libusb-1.0-devel (yum install libusb-devel) 12 | (if the system comes with older version like 1.0.8 or 13 | earlier, it is recommended you build libusbx-1.0.14 or later). 14 | 15 | sudo apt-get install libconfuse-dev (for ftdi-eeprom) (yum install libconfuse-devel) 16 | sudo apt-get install swig python-dev (for python bindings) (yum install swig python-devel) 17 | sudo apt-get install libboost-all-dev (for C++ binding and unit test) (yum install boost-devel) 18 | 19 | 3) Clone the git repository 20 | mkdir libftdi 21 | cd libftdi 22 | git clone git://developer.intra2net.com/libftdi 23 | 24 | If you are building the release tar ball, just extract the source 25 | tar ball. 26 | 27 | 4) Build the git source and install 28 | cd libftdi 29 | mkdir build 30 | cd build 31 | cmake -DCMAKE_INSTALL_PREFIX="/usr" ../ 32 | make 33 | sudo make install 34 | 35 | 5) carry out some tests 36 | cd examples 37 | 38 | mcuee@Ubuntu1210VM:~/Desktop/build/libftdi/libftdi/build/examples$ 39 | ./find_all_pp -v 0x0403 -p 0x6001 40 | Found devices ( VID: 0x403, PID: 0x6001 ) 41 | ------------------------------------------------ 42 | FTDI (0x8730800): ftdi, usb serial converter, ftDEH51S (Open OK) 43 | FTDI (0x8730918): FTDI, FT232R USB UART, A8007Ub5 (Open OK) 44 | 45 | mcuee@Ubuntu1210VM:~/Desktop/build/libftdi/libftdi/build/examples$ ./eeprom 46 | 2 FTDI devices found: Only Readout on EEPROM done. Use 47 | VID/PID/desc/serial to select device 48 | Decoded values of device 1: 49 | Chip type 1 ftdi_eeprom_size: 128 50 | 0x000: 00 00 03 04 01 60 00 04 a0 16 08 00 10 01 94 0a .....`.. ........ 51 | 0x010: 9e 2a c8 12 0a 03 66 00 74 00 64 00 69 00 2a 03 .*....f. t.d.i.*. 52 | 0x020: 75 00 73 00 62 00 20 00 73 00 65 00 72 00 69 00 u.s.b. . s.e.r.i. 53 | 0x030: 61 00 6c 00 20 00 63 00 6f 00 6e 00 76 00 65 00 a.l. .c. o.n.v.e. 54 | 0x040: 72 00 74 00 65 00 72 00 12 03 66 00 74 00 44 00 r.t.e.r. ..f.t.D. 55 | 0x050: 45 00 48 00 35 00 31 00 53 00 02 03 00 00 00 00 E.H.5.1. S....... 56 | 0x060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........ 57 | 0x070: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 16 02 ........ ........ 58 | VID: 0x0403 59 | PID: 0x6001 60 | Release: 0x0400 61 | Bus Powered: 44 mA USB Remote Wake Up 62 | Manufacturer: ftdi 63 | Product: usb serial converter 64 | Serial: ftDEH51S 65 | Checksum : 0216 66 | Enable Remote Wake Up 67 | PNP: 1 68 | Decoded values of device 2: 69 | Chip type 3 ftdi_eeprom_size: 128 70 | 0x000: 00 40 03 04 01 60 00 00 a0 2d 08 00 00 00 98 0a .@...`.. .-...... 71 | 0x010: a2 20 c2 12 23 10 05 00 0a 03 46 00 54 00 44 00 . ..#... ..F.T.D. 72 | 0x020: 49 00 20 03 46 00 54 00 32 00 33 00 32 00 52 00 I. .F.T. 2.3.2.R. 73 | 0x030: 20 00 55 00 53 00 42 00 20 00 55 00 41 00 52 00 .U.S.B. .U.A.R. 74 | 0x040: 54 00 12 03 41 00 38 00 30 00 30 00 37 00 55 00 T...A.8. 0.0.7.U. 75 | 0x050: 62 00 35 00 c9 bf 1c 80 00 00 00 00 00 00 00 00 b.5..... ........ 76 | 0x060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........ 77 | 0x070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f 23 ........ .......# 78 | 0x080: 2c 04 d3 fb 00 00 c9 bf 1c 80 42 00 00 00 00 00 ,....... ..B..... 79 | 0x090: 00 00 00 00 00 00 00 00 38 41 32 52 4a 33 47 4f ........ 8A2RJ3GO 80 | VID: 0x0403 81 | PID: 0x6001 82 | Release: 0x0000 83 | Bus Powered: 90 mA USB Remote Wake Up 84 | Manufacturer: FTDI 85 | Product: FT232R USB UART 86 | Serial: A8007Ub5 87 | Checksum : 230f 88 | Internal EEPROM 89 | Enable Remote Wake Up 90 | PNP: 1 91 | Channel A has Mode UART VCP 92 | C0 Function: TXLED 93 | C1 Function: RXLED 94 | C2 Function: TXDEN 95 | C3 Function: PWREN 96 | C4 Function: SLEEP 97 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libftdi/README.mingw: -------------------------------------------------------------------------------- 1 | * How to cross compile libftdi-1.x for Windows? * 2 | 1 - Prepare a pkg-config wrapper according to 3 | https://autotools.io/pkgconfig/cross-compiling.html , 4 | additionally export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS and 5 | PKG_CONFIG_ALLOW_SYSTEM_LIBS. 6 | 2 - Write a CMake toolchain file according to 7 | http://www.vtk.org/Wiki/CmakeMingw . Change the path to your future sysroot. 8 | 3 - Get libusb sources (either by cloning the git repo or by downloading a 9 | tarball). Unpack, autogen.sh (when building from git), and configure like this: 10 | ./configure --build=`./config.guess` --host=i686-w64-mingw32 \ 11 | --prefix=/usr --with-sysroot=$HOME/i686-w64-mingw32-root/ 12 | 4 - run 13 | make install DESTDIR=$HOME/i686-w64-mingw32-root/ 14 | 5 - go to libftdi-1.x source directory and run 15 | cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw.cmake \ 16 | -DCMAKE_INSTALL_PREFIX="/usr" \ 17 | -DPKG_CONFIG_EXECUTABLE=`which i686-w64-mingw32-pkg-config` 18 | 6 - run 19 | make install DESTDIR=$HOME/i686-w64-mingw32-root/ 20 | 21 | * How to run libftdi 1.x under Windows * 22 | 23 | On 26-Jan-2014, libusbx and libusb project were merged with the release 24 | of libusb-1.0.18 and now the project is called libusb. 25 | 26 | libusb Windows backend will need to rely on a proper driver to run. 27 | Please refer to the following wiki page for proper driver installation. 28 | https://github.com/libusb/libusb/wiki/Windows#wiki-How_to_use_libusb_on_Windows 29 | 30 | As of 26-Jan-2014, libusb Windows backend supports WinUSB, 31 | libusb0.sys and libusbk.sys driver. However, libusb's support of 32 | libusb0.sys and libusbk.sys is considered to be less mature than 33 | WinUSB. Therefore, WinUSB driver installation using Zadig 34 | is recommended. 35 | 36 | Take note once you replace the original FTDI driver with WinUSB driver, 37 | you can no longer use the functionality the original FTDI driver provides 38 | (eg. Virtual Serial Port or D2XX). 39 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libusb/AUTHORS: -------------------------------------------------------------------------------- 1 | Copyright © 2001 Johannes Erdfelt 2 | Copyright © 2007-2009 Daniel Drake 3 | Copyright © 2010-2012 Peter Stuge 4 | Copyright © 2008-2016 Nathan Hjelm 5 | Copyright © 2009-2013 Pete Batard 6 | Copyright © 2009-2013 Ludovic Rousseau 7 | Copyright © 2010-2012 Michael Plante 8 | Copyright © 2011-2013 Hans de Goede 9 | Copyright © 2012-2013 Martin Pieuchot 10 | Copyright © 2012-2013 Toby Gray 11 | Copyright © 2013-2018 Chris Dickens 12 | 13 | Other contributors: 14 | Adrian Bunk 15 | Akshay Jaggi 16 | Alan Ott 17 | Alan Stern 18 | Alex Vatchenko 19 | Andrew Fernandes 20 | Andy Chunyu 21 | Andy McFadden 22 | Angus Gratton 23 | Anil Nair 24 | Anthony Clay 25 | Antonio Ospite 26 | Artem Egorkine 27 | Aurelien Jarno 28 | Bastien Nocera 29 | Bei Zhang 30 | Benjamin Dobell 31 | Brent Rector 32 | Carl Karsten 33 | Christophe Zeitouny 34 | Colin Walters 35 | Dave Camarillo 36 | David Engraf 37 | David Moore 38 | Davidlohr Bueso 39 | Dmitry Fleytman 40 | Doug Johnston 41 | Evan Hunter 42 | Federico Manzan 43 | Felipe Balbi 44 | Florian Albrechtskirchinger 45 | Francesco Montorsi 46 | Francisco Facioni 47 | Gaurav Gupta 48 | Graeme Gill 49 | Gustavo Zacarias 50 | Hans Ulrich Niedermann 51 | Hector Martin 52 | Hoi-Ho Chan 53 | Ilya Konstantinov 54 | Jakub Klama 55 | James Hanko 56 | Jeffrey Nichols 57 | Johann Richard 58 | John Sheu 59 | Jonathon Jongsma 60 | Joost Muller 61 | Josh Gao 62 | Joshua Blake 63 | Justin Bischoff 64 | KIMURA Masaru 65 | Karsten Koenig 66 | Konrad Rzepecki 67 | Kuangye Guo 68 | Lars Kanis 69 | Lars Wirzenius 70 | Lei Chen 71 | Luca Longinotti 72 | Marcus Meissner 73 | Markus Heidelberg 74 | Martin Ettl 75 | Martin Koegler 76 | Matthew Stapleton 77 | Matthias Bolte 78 | Michel Zou 79 | Mike Frysinger 80 | Mikhail Gusarov 81 | Morgan Leborgne 82 | Moritz Fischer 83 | Ларионов Даниил 84 | Nicholas Corgan 85 | Omri Iluz 86 | Orin Eman 87 | Paul Fertser 88 | Pekka Nikander 89 | Rob Walker 90 | Romain Vimont 91 | Roman Kalashnikov 92 | Sameeh Jubran 93 | Sean McBride 94 | Sebastian Pipping 95 | Sergey Serb 96 | Simon Haggett 97 | Simon Newton 98 | Stefan Agner 99 | Stefan Tauner 100 | Steinar H. Gunderson 101 | Thomas Röfer 102 | Tim Hutt 103 | Tim Roberts 104 | Tobias Klauser 105 | Toby Peterson 106 | Tormod Volden 107 | Trygve Laugstøl 108 | Uri Lublin 109 | Vasily Khoruzhick 110 | Vegard Storheil Eriksen 111 | Venkatesh Shukla 112 | Vianney le Clément de Saint-Marcq 113 | Victor Toso 114 | Vitali Lovich 115 | William Skellenger 116 | Xiaofan Chen 117 | Zoltán Kovács 118 | Роман Донченко 119 | parafin 120 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libusb/COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /libftdi1-1.5/Copyright/libusb/README: -------------------------------------------------------------------------------- 1 | # libusb 2 | 3 | [![Build Status](https://travis-ci.org/libusb/libusb.svg?branch=master)](https://travis-ci.org/libusb/libusb) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/xvrfam94jii4a6lw?svg=true)](https://ci.appveyor.com/project/LudovicRousseau/libusb) 5 | [![Coverity Scan Build Status](https://scan.coverity.com/projects/2180/badge.svg)](https://scan.coverity.com/projects/libusb-libusb) 6 | 7 | libusb is a library for USB device access from Linux, macOS, 8 | Windows, OpenBSD/NetBSD and Haiku userspace. 9 | It is written in C (Haiku backend in C++) and licensed under the GNU 10 | Lesser General Public License version 2.1 or, at your option, any later 11 | version (see [COPYING](COPYING)). 12 | 13 | libusb is abstracted internally in such a way that it can hopefully 14 | be ported to other operating systems. Please see the [PORTING](PORTING) 15 | file for more information. 16 | 17 | libusb homepage: 18 | http://libusb.info/ 19 | 20 | Developers will wish to consult the API documentation: 21 | http://api.libusb.info 22 | 23 | Use the mailing list for questions, comments, etc: 24 | http://mailing-list.libusb.info 25 | 26 | - Hans de Goede 27 | - Xiaofan Chen 28 | - Ludovic Rousseau 29 | - Nathan Hjelm 30 | - Chris Dickens 31 | 32 | (Please use the mailing list rather than mailing developers directly) 33 | -------------------------------------------------------------------------------- /libftdi1-1.5/Driver/Driver.txt: -------------------------------------------------------------------------------- 1 | 2 | You need to install libusb Windows backend supported drivers 3 | in order to use libftdi1 under Windows. You can usesing Zadig 4 | from the libwdi project to do that. 5 | Zadig: http://zadig.akeo.ie/ 6 | 7 | In general, you should use WinUSB driver since it is the best 8 | supported by libusb Windows backend. You should avoid 9 | using libusb0.sys as it is not well supported by libusb 10 | Windows backend yet. 11 | 12 | libusbk is usable as well if you want to use libusb-win32 along 13 | with libusb-1.0 Windows. 14 | 15 | You can also try usbdk which is not as mature as WinUSB but 16 | it offers an advantage that you can use it along with the 17 | default FTDI vendor driver (eg: VCP serial port and D2XX function). 18 | 19 | 20 | -------------------------------------------------------------------------------- /libftdi1-1.5/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Date of compilation: 19-July-2020 3 | Xiaofan Chen 22 | #ifndef _WIN32 23 | #include 24 | #endif 25 | 26 | /* Define _FTDI_DISABLE_DEPRECATED to disable deprecated messages. */ 27 | #ifdef _FTDI_DISABLE_DEPRECATED 28 | #define _Ftdi_Pragma(_msg) 29 | #else 30 | #define _Ftdi_Pragma(_msg) _Pragma(_msg) 31 | #endif 32 | 33 | /* 'interface' might be defined as a macro on Windows, so we need to 34 | * undefine it so as not to break the current libftdi API, because 35 | * struct ftdi_context has an 'interface' member 36 | * As this can be problematic if you include windows.h after ftdi.h 37 | * in your sources, we force windows.h to be included first. */ 38 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 39 | #include 40 | #if defined(interface) 41 | #undef interface 42 | #endif 43 | #endif 44 | 45 | /** FTDI chip type */ 46 | enum ftdi_chip_type 47 | { 48 | TYPE_AM=0, 49 | TYPE_BM=1, 50 | TYPE_2232C=2, 51 | TYPE_R=3, 52 | TYPE_2232H=4, 53 | TYPE_4232H=5, 54 | TYPE_232H=6, 55 | TYPE_230X=7, 56 | }; 57 | /** Parity mode for ftdi_set_line_property() */ 58 | enum ftdi_parity_type { NONE=0, ODD=1, EVEN=2, MARK=3, SPACE=4 }; 59 | /** Number of stop bits for ftdi_set_line_property() */ 60 | enum ftdi_stopbits_type { STOP_BIT_1=0, STOP_BIT_15=1, STOP_BIT_2=2 }; 61 | /** Number of bits for ftdi_set_line_property() */ 62 | enum ftdi_bits_type { BITS_7=7, BITS_8=8 }; 63 | /** Break type for ftdi_set_line_property2() */ 64 | enum ftdi_break_type { BREAK_OFF=0, BREAK_ON=1 }; 65 | 66 | /** MPSSE bitbang modes */ 67 | enum ftdi_mpsse_mode 68 | { 69 | BITMODE_RESET = 0x00, /**< switch off bitbang mode, back to regular serial/FIFO */ 70 | BITMODE_BITBANG= 0x01, /**< classical asynchronous bitbang mode, introduced with B-type chips */ 71 | BITMODE_MPSSE = 0x02, /**< MPSSE mode, available on 2232x chips */ 72 | BITMODE_SYNCBB = 0x04, /**< synchronous bitbang mode, available on 2232x and R-type chips */ 73 | BITMODE_MCU = 0x08, /**< MCU Host Bus Emulation mode, available on 2232x chips */ 74 | /* CPU-style fifo mode gets set via EEPROM */ 75 | BITMODE_OPTO = 0x10, /**< Fast Opto-Isolated Serial Interface Mode, available on 2232x chips */ 76 | BITMODE_CBUS = 0x20, /**< Bitbang on CBUS pins of R-type chips, configure in EEPROM before */ 77 | BITMODE_SYNCFF = 0x40, /**< Single Channel Synchronous FIFO mode, available on 2232H chips */ 78 | BITMODE_FT1284 = 0x80, /**< FT1284 mode, available on 232H chips */ 79 | }; 80 | 81 | /** Port interface for chips with multiple interfaces */ 82 | enum ftdi_interface 83 | { 84 | INTERFACE_ANY = 0, 85 | INTERFACE_A = 1, 86 | INTERFACE_B = 2, 87 | INTERFACE_C = 3, 88 | INTERFACE_D = 4 89 | }; 90 | 91 | /** Automatic loading / unloading of kernel modules */ 92 | enum ftdi_module_detach_mode 93 | { 94 | AUTO_DETACH_SIO_MODULE = 0, 95 | DONT_DETACH_SIO_MODULE = 1, 96 | AUTO_DETACH_REATACH_SIO_MODULE = 2 97 | }; 98 | 99 | /* Shifting commands IN MPSSE Mode*/ 100 | #define MPSSE_WRITE_NEG 0x01 /* Write TDI/DO on negative TCK/SK edge*/ 101 | #define MPSSE_BITMODE 0x02 /* Write bits, not bytes */ 102 | #define MPSSE_READ_NEG 0x04 /* Sample TDO/DI on negative TCK/SK edge */ 103 | #define MPSSE_LSB 0x08 /* LSB first */ 104 | #define MPSSE_DO_WRITE 0x10 /* Write TDI/DO */ 105 | #define MPSSE_DO_READ 0x20 /* Read TDO/DI */ 106 | #define MPSSE_WRITE_TMS 0x40 /* Write TMS/CS */ 107 | 108 | /* FTDI MPSSE commands */ 109 | #define SET_BITS_LOW 0x80 110 | /*BYTE DATA*/ 111 | /*BYTE Direction*/ 112 | #define SET_BITS_HIGH 0x82 113 | /*BYTE DATA*/ 114 | /*BYTE Direction*/ 115 | #define GET_BITS_LOW 0x81 116 | #define GET_BITS_HIGH 0x83 117 | #define LOOPBACK_START 0x84 118 | #define LOOPBACK_END 0x85 119 | #define TCK_DIVISOR 0x86 120 | /* H Type specific commands */ 121 | #define DIS_DIV_5 0x8a 122 | #define EN_DIV_5 0x8b 123 | #define EN_3_PHASE 0x8c 124 | #define DIS_3_PHASE 0x8d 125 | #define CLK_BITS 0x8e 126 | #define CLK_BYTES 0x8f 127 | #define CLK_WAIT_HIGH 0x94 128 | #define CLK_WAIT_LOW 0x95 129 | #define EN_ADAPTIVE 0x96 130 | #define DIS_ADAPTIVE 0x97 131 | #define CLK_BYTES_OR_HIGH 0x9c 132 | #define CLK_BYTES_OR_LOW 0x9d 133 | /*FT232H specific commands */ 134 | #define DRIVE_OPEN_COLLECTOR 0x9e 135 | /* Value Low */ 136 | /* Value HIGH */ /*rate is 12000000/((1+value)*2) */ 137 | #define DIV_VALUE(rate) (rate > 6000000)?0:((6000000/rate -1) > 0xffff)? 0xffff: (6000000/rate -1) 138 | 139 | /* Commands in MPSSE and Host Emulation Mode */ 140 | #define SEND_IMMEDIATE 0x87 141 | #define WAIT_ON_HIGH 0x88 142 | #define WAIT_ON_LOW 0x89 143 | 144 | /* Commands in Host Emulation Mode */ 145 | #define READ_SHORT 0x90 146 | /* Address_Low */ 147 | #define READ_EXTENDED 0x91 148 | /* Address High */ 149 | /* Address Low */ 150 | #define WRITE_SHORT 0x92 151 | /* Address_Low */ 152 | #define WRITE_EXTENDED 0x93 153 | /* Address High */ 154 | /* Address Low */ 155 | 156 | /* Definitions for flow control */ 157 | #define SIO_RESET 0 /* Reset the port */ 158 | #define SIO_MODEM_CTRL 1 /* Set the modem control register */ 159 | #define SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 160 | #define SIO_SET_BAUD_RATE 3 /* Set baud rate */ 161 | #define SIO_SET_DATA 4 /* Set the data characteristics of the port */ 162 | 163 | #define FTDI_DEVICE_OUT_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT) 164 | #define FTDI_DEVICE_IN_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN) 165 | 166 | /* Requests */ 167 | #define SIO_RESET_REQUEST SIO_RESET 168 | #define SIO_SET_BAUDRATE_REQUEST SIO_SET_BAUD_RATE 169 | #define SIO_SET_DATA_REQUEST SIO_SET_DATA 170 | #define SIO_SET_FLOW_CTRL_REQUEST SIO_SET_FLOW_CTRL 171 | #define SIO_SET_MODEM_CTRL_REQUEST SIO_MODEM_CTRL 172 | #define SIO_POLL_MODEM_STATUS_REQUEST 0x05 173 | #define SIO_SET_EVENT_CHAR_REQUEST 0x06 174 | #define SIO_SET_ERROR_CHAR_REQUEST 0x07 175 | #define SIO_SET_LATENCY_TIMER_REQUEST 0x09 176 | #define SIO_GET_LATENCY_TIMER_REQUEST 0x0A 177 | #define SIO_SET_BITMODE_REQUEST 0x0B 178 | #define SIO_READ_PINS_REQUEST 0x0C 179 | #define SIO_READ_EEPROM_REQUEST 0x90 180 | #define SIO_WRITE_EEPROM_REQUEST 0x91 181 | #define SIO_ERASE_EEPROM_REQUEST 0x92 182 | 183 | 184 | #define SIO_RESET_SIO 0 185 | 186 | /* ** WARNING ** SIO_RESET_PURGE_RX or SIO_RESET_PURGE_TX are values used 187 | * internally by libftdi to purge the RX and/or TX FIFOs (buffers). 188 | * APPLICATION PROGRAMS SHOULD NOT BE USING THESE VALUES. Application 189 | * programs should use one of the ftdi_tciflush, ftdi_tcoflush, or 190 | * ftdi_tcioflush functions which emulate the Linux serial port tcflush(3) 191 | * function. 192 | * 193 | * History: 194 | * 195 | * The definitions for these values are with respect to the FTDI chip, not the 196 | * CPU. That is, when the FTDI chip receives a USB control transfer request 197 | * with the command SIO_RESET_PURGE_RX, the FTDI chip empties the FIFO 198 | * containing data received from the CPU awaiting transfer out the serial 199 | * port to the connected serial device (e.g., a modem). Likewise, upon 200 | * reception of the SIO_RESET_PURGE_TX command, the FTDI chip empties the 201 | * FIFO of data received from the attached serial device destined to be 202 | * transmitted to the CPU. 203 | * 204 | * Unfortunately the coding of the previous releases of libfti assumed these 205 | * commands had the opposite effect. This resulted in the function 206 | * ftdi_usb_purge_tx_buffer clearing data received from the attached serial 207 | * device. Similarly, the function ftdi_usb_purge_rx_buffer cleared the 208 | * FTDI FIFO containing data to be transmitted to the attached serial 209 | * device. More seriously, this latter function clear the libftid's 210 | * internal buffer of data received from the serial device, destined 211 | * to the application program. 212 | */ 213 | #ifdef __GNUC__ 214 | #define SIO_RESET_PURGE_RX _Ftdi_Pragma("GCC warning \"SIO_RESET_PURGE_RX\" deprecated: - use tciflush() method") 1 215 | #define SIO_RESET_PURGE_TX _Ftdi_Pragma("GCC warning \"SIO_RESET_PURGE_RX\" deprecated: - use tcoflush() method") 2 216 | #else 217 | #pragma message("WARNING: You need to implement deprecated #define for this compiler") 218 | #define SIO_RESET_PURGE_RX 1 219 | #define SIO_RESET_PURGE_TX 2 220 | #endif 221 | /* New names for the values used internally to flush (purge). */ 222 | #define SIO_TCIFLUSH 2 223 | #define SIO_TCOFLUSH 1 224 | 225 | #define SIO_DISABLE_FLOW_CTRL 0x0 226 | #define SIO_RTS_CTS_HS (0x1 << 8) 227 | #define SIO_DTR_DSR_HS (0x2 << 8) 228 | #define SIO_XON_XOFF_HS (0x4 << 8) 229 | 230 | #define SIO_SET_DTR_MASK 0x1 231 | #define SIO_SET_DTR_HIGH ( 1 | ( SIO_SET_DTR_MASK << 8)) 232 | #define SIO_SET_DTR_LOW ( 0 | ( SIO_SET_DTR_MASK << 8)) 233 | #define SIO_SET_RTS_MASK 0x2 234 | #define SIO_SET_RTS_HIGH ( 2 | ( SIO_SET_RTS_MASK << 8 )) 235 | #define SIO_SET_RTS_LOW ( 0 | ( SIO_SET_RTS_MASK << 8 )) 236 | 237 | #define SIO_RTS_CTS_HS (0x1 << 8) 238 | 239 | /* marker for unused usb urb structures 240 | (taken from libusb) */ 241 | #define FTDI_URB_USERCONTEXT_COOKIE ((void *)0x1) 242 | 243 | #ifdef _FTDI_DISABLE_DEPRECATED 244 | #define DEPRECATED(func) func 245 | #else 246 | #ifdef __GNUC__ 247 | #define DEPRECATED(func) __attribute__ ((deprecated)) func 248 | #elif defined(_MSC_VER) 249 | #define DEPRECATED(func) __declspec(deprecated) func 250 | #else 251 | #pragma message("WARNING: You need to implement DEPRECATED for this compiler") 252 | #define DEPRECATED(func) func 253 | #endif 254 | #endif 255 | 256 | struct ftdi_transfer_control 257 | { 258 | int completed; 259 | unsigned char *buf; 260 | int size; 261 | int offset; 262 | struct ftdi_context *ftdi; 263 | struct libusb_transfer *transfer; 264 | }; 265 | 266 | /** 267 | \brief Main context structure for all libftdi functions. 268 | 269 | Do not access directly if possible. 270 | */ 271 | struct ftdi_context 272 | { 273 | /* USB specific */ 274 | /** libusb's context */ 275 | struct libusb_context *usb_ctx; 276 | /** libusb's usb_dev_handle */ 277 | struct libusb_device_handle *usb_dev; 278 | /** usb read timeout */ 279 | int usb_read_timeout; 280 | /** usb write timeout */ 281 | int usb_write_timeout; 282 | 283 | /* FTDI specific */ 284 | /** FTDI chip type */ 285 | enum ftdi_chip_type type; 286 | /** baudrate */ 287 | int baudrate; 288 | /** bitbang mode state */ 289 | unsigned char bitbang_enabled; 290 | /** pointer to read buffer for ftdi_read_data */ 291 | unsigned char *readbuffer; 292 | /** read buffer offset */ 293 | unsigned int readbuffer_offset; 294 | /** number of remaining data in internal read buffer */ 295 | unsigned int readbuffer_remaining; 296 | /** read buffer chunk size */ 297 | unsigned int readbuffer_chunksize; 298 | /** write buffer chunk size */ 299 | unsigned int writebuffer_chunksize; 300 | /** maximum packet size. Needed for filtering modem status bytes every n packets. */ 301 | unsigned int max_packet_size; 302 | 303 | /* FTDI FT2232C requirecments */ 304 | /** FT2232C interface number: 0 or 1 */ 305 | int interface; /* 0 or 1 */ 306 | /** FT2232C index number: 1 or 2 */ 307 | int index; /* 1 or 2 */ 308 | /* Endpoints */ 309 | /** FT2232C end points: 1 or 2 */ 310 | int in_ep; 311 | int out_ep; /* 1 or 2 */ 312 | 313 | /** Bitbang mode. 1: (default) Normal bitbang mode, 2: FT2232C SPI bitbang mode */ 314 | unsigned char bitbang_mode; 315 | 316 | /** Decoded eeprom structure */ 317 | struct ftdi_eeprom *eeprom; 318 | 319 | /** String representation of last error */ 320 | const char *error_str; 321 | 322 | /** Defines behavior in case a kernel module is already attached to the device */ 323 | enum ftdi_module_detach_mode module_detach_mode; 324 | }; 325 | 326 | /** 327 | List all handled EEPROM values. 328 | Append future new values only at the end to provide API/ABI stability*/ 329 | enum ftdi_eeprom_value 330 | { 331 | VENDOR_ID = 0, 332 | PRODUCT_ID = 1, 333 | SELF_POWERED = 2, 334 | REMOTE_WAKEUP = 3, 335 | IS_NOT_PNP = 4, 336 | SUSPEND_DBUS7 = 5, 337 | IN_IS_ISOCHRONOUS = 6, 338 | OUT_IS_ISOCHRONOUS = 7, 339 | SUSPEND_PULL_DOWNS = 8, 340 | USE_SERIAL = 9, 341 | USB_VERSION = 10, 342 | USE_USB_VERSION = 11, 343 | MAX_POWER = 12, 344 | CHANNEL_A_TYPE = 13, 345 | CHANNEL_B_TYPE = 14, 346 | CHANNEL_A_DRIVER = 15, 347 | CHANNEL_B_DRIVER = 16, 348 | CBUS_FUNCTION_0 = 17, 349 | CBUS_FUNCTION_1 = 18, 350 | CBUS_FUNCTION_2 = 19, 351 | CBUS_FUNCTION_3 = 20, 352 | CBUS_FUNCTION_4 = 21, 353 | CBUS_FUNCTION_5 = 22, 354 | CBUS_FUNCTION_6 = 23, 355 | CBUS_FUNCTION_7 = 24, 356 | CBUS_FUNCTION_8 = 25, 357 | CBUS_FUNCTION_9 = 26, 358 | HIGH_CURRENT = 27, 359 | HIGH_CURRENT_A = 28, 360 | HIGH_CURRENT_B = 29, 361 | INVERT = 30, 362 | GROUP0_DRIVE = 31, 363 | GROUP0_SCHMITT = 32, 364 | GROUP0_SLEW = 33, 365 | GROUP1_DRIVE = 34, 366 | GROUP1_SCHMITT = 35, 367 | GROUP1_SLEW = 36, 368 | GROUP2_DRIVE = 37, 369 | GROUP2_SCHMITT = 38, 370 | GROUP2_SLEW = 39, 371 | GROUP3_DRIVE = 40, 372 | GROUP3_SCHMITT = 41, 373 | GROUP3_SLEW = 42, 374 | CHIP_SIZE = 43, 375 | CHIP_TYPE = 44, 376 | POWER_SAVE = 45, 377 | CLOCK_POLARITY = 46, 378 | DATA_ORDER = 47, 379 | FLOW_CONTROL = 48, 380 | CHANNEL_C_DRIVER = 49, 381 | CHANNEL_D_DRIVER = 50, 382 | CHANNEL_A_RS485 = 51, 383 | CHANNEL_B_RS485 = 52, 384 | CHANNEL_C_RS485 = 53, 385 | CHANNEL_D_RS485 = 54, 386 | RELEASE_NUMBER = 55, 387 | EXTERNAL_OSCILLATOR= 56, 388 | USER_DATA_ADDR = 57, 389 | }; 390 | 391 | /** 392 | \brief list of usb devices created by ftdi_usb_find_all() 393 | */ 394 | struct ftdi_device_list 395 | { 396 | /** pointer to next entry */ 397 | struct ftdi_device_list *next; 398 | /** pointer to libusb's usb_device */ 399 | struct libusb_device *dev; 400 | }; 401 | #define FT1284_CLK_IDLE_STATE 0x01 402 | #define FT1284_DATA_LSB 0x02 /* DS_FT232H 1.3 amd ftd2xx.h 1.0.4 disagree here*/ 403 | #define FT1284_FLOW_CONTROL 0x04 404 | #define POWER_SAVE_DISABLE_H 0x80 405 | 406 | #define USE_SERIAL_NUM 0x08 407 | enum ftdi_cbus_func 408 | { 409 | CBUS_TXDEN = 0, CBUS_PWREN = 1, CBUS_RXLED = 2, CBUS_TXLED = 3, CBUS_TXRXLED = 4, 410 | CBUS_SLEEP = 5, CBUS_CLK48 = 6, CBUS_CLK24 = 7, CBUS_CLK12 = 8, CBUS_CLK6 = 9, 411 | CBUS_IOMODE = 0xa, CBUS_BB_WR = 0xb, CBUS_BB_RD = 0xc 412 | }; 413 | 414 | enum ftdi_cbush_func 415 | { 416 | CBUSH_TRISTATE = 0, CBUSH_TXLED = 1, CBUSH_RXLED = 2, CBUSH_TXRXLED = 3, CBUSH_PWREN = 4, 417 | CBUSH_SLEEP = 5, CBUSH_DRIVE_0 = 6, CBUSH_DRIVE1 = 7, CBUSH_IOMODE = 8, CBUSH_TXDEN = 9, 418 | CBUSH_CLK30 = 10, CBUSH_CLK15 = 11, CBUSH_CLK7_5 = 12 419 | }; 420 | 421 | enum ftdi_cbusx_func 422 | { 423 | CBUSX_TRISTATE = 0, CBUSX_TXLED = 1, CBUSX_RXLED = 2, CBUSX_TXRXLED = 3, CBUSX_PWREN = 4, 424 | CBUSX_SLEEP = 5, CBUSX_DRIVE_0 = 6, CBUSX_DRIVE1 = 7, CBUSX_IOMODE = 8, CBUSX_TXDEN = 9, 425 | CBUSX_CLK24 = 10, CBUSX_CLK12 = 11, CBUSX_CLK6 = 12, CBUSX_BAT_DETECT = 13, 426 | CBUSX_BAT_DETECT_NEG = 14, CBUSX_I2C_TXE = 15, CBUSX_I2C_RXF = 16, CBUSX_VBUS_SENSE = 17, 427 | CBUSX_BB_WR = 18, CBUSX_BB_RD = 19, CBUSX_TIME_STAMP = 20, CBUSX_AWAKE = 21 428 | }; 429 | 430 | /** Invert TXD# */ 431 | #define INVERT_TXD 0x01 432 | /** Invert RXD# */ 433 | #define INVERT_RXD 0x02 434 | /** Invert RTS# */ 435 | #define INVERT_RTS 0x04 436 | /** Invert CTS# */ 437 | #define INVERT_CTS 0x08 438 | /** Invert DTR# */ 439 | #define INVERT_DTR 0x10 440 | /** Invert DSR# */ 441 | #define INVERT_DSR 0x20 442 | /** Invert DCD# */ 443 | #define INVERT_DCD 0x40 444 | /** Invert RI# */ 445 | #define INVERT_RI 0x80 446 | 447 | /** Interface Mode. */ 448 | #define CHANNEL_IS_UART 0x0 449 | #define CHANNEL_IS_FIFO 0x1 450 | #define CHANNEL_IS_OPTO 0x2 451 | #define CHANNEL_IS_CPU 0x4 452 | #define CHANNEL_IS_FT1284 0x8 453 | 454 | #define CHANNEL_IS_RS485 0x10 455 | 456 | #define DRIVE_4MA 0 457 | #define DRIVE_8MA 1 458 | #define DRIVE_12MA 2 459 | #define DRIVE_16MA 3 460 | #define SLOW_SLEW 4 461 | #define IS_SCHMITT 8 462 | 463 | /** Driver Type. */ 464 | #define DRIVER_VCP 0x08 465 | #define DRIVER_VCPH 0x10 /* FT232H has moved the VCP bit */ 466 | 467 | #define USE_USB_VERSION_BIT 0x10 468 | 469 | #define SUSPEND_DBUS7_BIT 0x80 470 | 471 | /** High current drive. */ 472 | #define HIGH_CURRENT_DRIVE 0x10 473 | #define HIGH_CURRENT_DRIVE_R 0x04 474 | 475 | /** 476 | \brief Progress Info for streaming read 477 | */ 478 | struct size_and_time 479 | { 480 | uint64_t totalBytes; 481 | struct timeval time; 482 | }; 483 | 484 | typedef struct 485 | { 486 | struct size_and_time first; 487 | struct size_and_time prev; 488 | struct size_and_time current; 489 | double totalTime; 490 | double totalRate; 491 | double currentRate; 492 | } FTDIProgressInfo; 493 | 494 | typedef int (FTDIStreamCallback)(uint8_t *buffer, int length, 495 | FTDIProgressInfo *progress, void *userdata); 496 | 497 | /** 498 | * Provide libftdi version information 499 | * major: Library major version 500 | * minor: Library minor version 501 | * micro: Currently unused, ight get used for hotfixes. 502 | * version_str: Version as (static) string 503 | * snapshot_str: Git snapshot version if known. Otherwise "unknown" or empty string. 504 | */ 505 | struct ftdi_version_info 506 | { 507 | int major; 508 | int minor; 509 | int micro; 510 | const char *version_str; 511 | const char *snapshot_str; 512 | }; 513 | 514 | 515 | #ifdef __cplusplus 516 | extern "C" 517 | { 518 | #endif 519 | 520 | int ftdi_init(struct ftdi_context *ftdi); 521 | struct ftdi_context *ftdi_new(void); 522 | int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface); 523 | 524 | void ftdi_deinit(struct ftdi_context *ftdi); 525 | void ftdi_free(struct ftdi_context *ftdi); 526 | void ftdi_set_usbdev (struct ftdi_context *ftdi, struct libusb_device_handle *usbdev); 527 | 528 | struct ftdi_version_info ftdi_get_library_version(void); 529 | 530 | int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, 531 | int vendor, int product); 532 | void ftdi_list_free(struct ftdi_device_list **devlist); 533 | void ftdi_list_free2(struct ftdi_device_list *devlist); 534 | int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct libusb_device *dev, 535 | char *manufacturer, int mnf_len, 536 | char *description, int desc_len, 537 | char *serial, int serial_len); 538 | int ftdi_usb_get_strings2(struct ftdi_context *ftdi, struct libusb_device *dev, 539 | char *manufacturer, int mnf_len, 540 | char *description, int desc_len, 541 | char *serial, int serial_len); 542 | 543 | int ftdi_eeprom_get_strings(struct ftdi_context *ftdi, 544 | char *manufacturer, int mnf_len, 545 | char *product, int prod_len, 546 | char *serial, int serial_len); 547 | int ftdi_eeprom_set_strings(struct ftdi_context *ftdi, const char * manufacturer, 548 | const char * product, const char * serial); 549 | 550 | int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product); 551 | int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product, 552 | const char* description, const char* serial); 553 | int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product, 554 | const char* description, const char* serial, unsigned int index); 555 | int ftdi_usb_open_bus_addr(struct ftdi_context *ftdi, uint8_t bus, uint8_t addr); 556 | int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct libusb_device *dev); 557 | int ftdi_usb_open_string(struct ftdi_context *ftdi, const char* description); 558 | 559 | int ftdi_usb_close(struct ftdi_context *ftdi); 560 | int ftdi_usb_reset(struct ftdi_context *ftdi); 561 | int ftdi_tciflush(struct ftdi_context *ftdi); 562 | int ftdi_tcoflush(struct ftdi_context *ftdi); 563 | int ftdi_tcioflush(struct ftdi_context *ftdi); 564 | int DEPRECATED(ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)); 565 | int DEPRECATED(ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi)); 566 | int DEPRECATED(ftdi_usb_purge_buffers(struct ftdi_context *ftdi)); 567 | 568 | int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate); 569 | int ftdi_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits, 570 | enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity); 571 | int ftdi_set_line_property2(struct ftdi_context *ftdi, enum ftdi_bits_type bits, 572 | enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, 573 | enum ftdi_break_type break_type); 574 | 575 | int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size); 576 | int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize); 577 | int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); 578 | 579 | int ftdi_write_data(struct ftdi_context *ftdi, const unsigned char *buf, int size); 580 | int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize); 581 | int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); 582 | 583 | int ftdi_readstream(struct ftdi_context *ftdi, FTDIStreamCallback *callback, 584 | void *userdata, int packetsPerTransfer, int numTransfers); 585 | struct ftdi_transfer_control *ftdi_write_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); 586 | 587 | struct ftdi_transfer_control *ftdi_read_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); 588 | int ftdi_transfer_data_done(struct ftdi_transfer_control *tc); 589 | void ftdi_transfer_data_cancel(struct ftdi_transfer_control *tc, struct timeval * to); 590 | 591 | int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode); 592 | int ftdi_disable_bitbang(struct ftdi_context *ftdi); 593 | int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins); 594 | 595 | int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency); 596 | int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency); 597 | 598 | int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status); 599 | 600 | /* flow control */ 601 | int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl); 602 | int ftdi_setflowctrl_xonxoff(struct ftdi_context *ftdi, unsigned char xon, unsigned char xoff); 603 | int ftdi_setdtr_rts(struct ftdi_context *ftdi, int dtr, int rts); 604 | int ftdi_setdtr(struct ftdi_context *ftdi, int state); 605 | int ftdi_setrts(struct ftdi_context *ftdi, int state); 606 | 607 | int ftdi_set_event_char(struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable); 608 | int ftdi_set_error_char(struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable); 609 | 610 | /* init eeprom for the given FTDI type */ 611 | int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, 612 | char * manufacturer, char *product, 613 | char * serial); 614 | int ftdi_eeprom_build(struct ftdi_context *ftdi); 615 | int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose); 616 | 617 | int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int* value); 618 | int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int value); 619 | 620 | int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size); 621 | int ftdi_set_eeprom_buf(struct ftdi_context *ftdi, const unsigned char * buf, int size); 622 | 623 | int ftdi_set_eeprom_user_data(struct ftdi_context *ftdi, const char * buf, int size); 624 | 625 | int ftdi_read_eeprom(struct ftdi_context *ftdi); 626 | int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid); 627 | int ftdi_write_eeprom(struct ftdi_context *ftdi); 628 | int ftdi_erase_eeprom(struct ftdi_context *ftdi); 629 | 630 | int ftdi_read_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val); 631 | int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val); 632 | 633 | const char *ftdi_get_error_string(struct ftdi_context *ftdi); 634 | 635 | #ifdef __cplusplus 636 | } 637 | #endif 638 | 639 | #endif /* __libftdi_h__ */ 640 | -------------------------------------------------------------------------------- /libftdi1-1.5/include/libftdi/ftdi.hpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | ftdi.hpp - C++ wrapper for libftdi 3 | ------------------- 4 | begin : Mon Oct 13 2008 5 | copyright : (C) 2008-2020 by Marek Vavruša and libftdi developers 6 | email : opensource@intra2net.com and marek@vavrusa.com 7 | ***************************************************************************/ 8 | /* 9 | Copyright (C) 2008-2017 by Marek Vavruša and libftdi developers 10 | 11 | The software in this package is distributed under the GNU General 12 | Public License version 2 (with a special exception described below). 13 | 14 | A copy of GNU General Public License (GPL) is included in this distribution, 15 | in the file COPYING.GPL. 16 | 17 | As a special exception, if other files instantiate templates or use macros 18 | or inline functions from this file, or you compile this file and link it 19 | with other works to produce a work based on this file, this file 20 | does not by itself cause the resulting work to be covered 21 | by the GNU General Public License. 22 | 23 | However the source code for this file must still be made available 24 | in accordance with section (3) of the GNU General Public License. 25 | 26 | This exception does not invalidate any other reasons why a work based 27 | on this file might be covered by the GNU General Public License. 28 | */ 29 | #ifndef __libftdi_hpp__ 30 | #define __libftdi_hpp__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace Ftdi 38 | { 39 | 40 | /* Forward declarations*/ 41 | class List; 42 | class Eeprom; 43 | 44 | /*! \brief FTDI device context. 45 | * Represents single FTDI device context. 46 | */ 47 | class Context 48 | { 49 | /* Friends */ 50 | friend class Eeprom; 51 | friend class List; 52 | 53 | public: 54 | /*! \brief Direction flags for flush(). 55 | */ 56 | enum Direction 57 | { 58 | Input = 0x2, 59 | Output = 0x1, 60 | }; 61 | 62 | /*! \brief Modem control flags. 63 | */ 64 | enum ModemCtl 65 | { 66 | Dtr = 0x2, 67 | Rts = 0x1, 68 | }; 69 | 70 | /* Constructor, Destructor */ 71 | Context(); 72 | ~Context(); 73 | 74 | /* Properties */ 75 | Eeprom* eeprom(); 76 | const std::string& vendor(); 77 | const std::string& description(); 78 | const std::string& serial(); 79 | 80 | /* Device manipulators */ 81 | bool is_open(); 82 | int open(struct libusb_device *dev = 0); 83 | int open(int vendor, int product); 84 | int open(int vendor, int product, const std::string& description, const std::string& serial = std::string(), unsigned int index=0); 85 | int open(const std::string& description); 86 | int close(); 87 | int reset(); 88 | int DEPRECATED(flush)(int mask = Input|Output); 89 | int tcflush(int mask = Input|Output); 90 | int set_interface(enum ftdi_interface interface); 91 | void set_usb_device(struct libusb_device_handle *dev); 92 | 93 | /* Line manipulators */ 94 | int set_baud_rate(int baudrate); 95 | int set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity); 96 | int set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type); 97 | int get_usb_read_timeout() const; 98 | void set_usb_read_timeout(int usb_read_timeout); 99 | int get_usb_write_timeout() const; 100 | void set_usb_write_timeout(int usb_write_timeout); 101 | 102 | /* I/O */ 103 | int read(unsigned char *buf, int size); 104 | int write(const unsigned char *buf, int size); 105 | int set_read_chunk_size(unsigned int chunksize); 106 | int set_write_chunk_size(unsigned int chunksize); 107 | int read_chunk_size(); 108 | int write_chunk_size(); 109 | 110 | /* Async IO 111 | TODO: should wrap? 112 | int writeAsync(const unsigned char *buf, int size); 113 | void asyncComplete(int wait_for_more); 114 | */ 115 | 116 | /* Flow control */ 117 | int set_event_char(unsigned char eventch, unsigned char enable); 118 | int set_error_char(unsigned char errorch, unsigned char enable); 119 | int set_flow_control(int flowctrl); 120 | int set_modem_control(int mask = Dtr|Rts); 121 | int set_latency(unsigned char latency); 122 | int set_dtr(bool state); 123 | int set_rts(bool state); 124 | 125 | unsigned short poll_modem_status(); 126 | unsigned latency(); 127 | 128 | /* BitBang mode */ 129 | int set_bitmode(unsigned char bitmask, unsigned char mode); 130 | int set_bitmode(unsigned char bitmask, enum ftdi_mpsse_mode mode); 131 | int bitbang_disable(); 132 | int read_pins(unsigned char *pins); 133 | 134 | /* Misc */ 135 | const char* error_string(); 136 | 137 | protected: 138 | int get_strings(bool vendor=true, bool description=true, bool serial=true); 139 | int get_strings_and_reopen(bool vendor=true, bool description=true, bool serial=true); 140 | 141 | /* Properties */ 142 | struct ftdi_context* context(); 143 | void set_context(struct ftdi_context* context); 144 | void set_usb_device(struct libusb_device *dev); 145 | 146 | private: 147 | class Private; 148 | boost::shared_ptr d; 149 | }; 150 | 151 | /*! \brief Device EEPROM. 152 | */ 153 | class Eeprom 154 | { 155 | public: 156 | Eeprom(Context* parent); 157 | ~Eeprom(); 158 | 159 | int init_defaults(char *manufacturer, char* product, char * serial); 160 | int chip_id(unsigned int *chipid); 161 | int build(unsigned char *output); 162 | 163 | int read(unsigned char *eeprom); 164 | int write(unsigned char *eeprom); 165 | int read_location(int eeprom_addr, unsigned short *eeprom_val); 166 | int write_location(int eeprom_addr, unsigned short eeprom_val); 167 | int erase(); 168 | 169 | private: 170 | class Private; 171 | boost::shared_ptr d; 172 | }; 173 | 174 | /*! \brief Device list. 175 | */ 176 | class List 177 | { 178 | public: 179 | List(struct ftdi_device_list* devlist = 0); 180 | ~List(); 181 | 182 | static List* find_all(Context &context, int vendor, int product); 183 | 184 | /// List type storing "Context" objects 185 | typedef std::list ListType; 186 | /// Iterator type for the container 187 | typedef ListType::iterator iterator; 188 | /// Const iterator type for the container 189 | typedef ListType::const_iterator const_iterator; 190 | /// Reverse iterator type for the container 191 | typedef ListType::reverse_iterator reverse_iterator; 192 | /// Const reverse iterator type for the container 193 | typedef ListType::const_reverse_iterator const_reverse_iterator; 194 | 195 | iterator begin(); 196 | iterator end(); 197 | const_iterator begin() const; 198 | const_iterator end() const; 199 | 200 | reverse_iterator rbegin(); 201 | reverse_iterator rend(); 202 | const_reverse_iterator rbegin() const; 203 | const_reverse_iterator rend() const; 204 | 205 | ListType::size_type size() const; 206 | bool empty() const; 207 | void clear(); 208 | 209 | void push_back(const Context& element); 210 | void push_front(const Context& element); 211 | 212 | iterator erase(iterator pos); 213 | iterator erase(iterator beg, iterator end); 214 | 215 | private: 216 | class Private; 217 | boost::shared_ptr d; 218 | }; 219 | 220 | } 221 | 222 | #endif 223 | -------------------------------------------------------------------------------- /libftdi1-1.5/lib32/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziutek/ftdi/6d7dbc95c86324ac92f46a3602d3ca28c8d54895/libftdi1-1.5/lib32/libftdi1.a -------------------------------------------------------------------------------- /libftdi1-1.5/lib32/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziutek/ftdi/6d7dbc95c86324ac92f46a3602d3ca28c8d54895/libftdi1-1.5/lib32/libusb-1.0.a -------------------------------------------------------------------------------- /libftdi1-1.5/lib64/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziutek/ftdi/6d7dbc95c86324ac92f46a3602d3ca28c8d54895/libftdi1-1.5/lib64/libftdi1.a -------------------------------------------------------------------------------- /libftdi1-1.5/lib64/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziutek/ftdi/6d7dbc95c86324ac92f46a3602d3ca28c8d54895/libftdi1-1.5/lib64/libusb-1.0.a --------------------------------------------------------------------------------