libftdi 0.20

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

ftdi.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 ftdi.cpp - C++ wraper for libftdi
3 -------------------
4 begin : Mon Oct 13 2008
5 copyright : (C) 2008 by Marek Vavruša
6 email : opensource@intra2net.com and marek@vavrusa.com
7 ***************************************************************************/
8 /*
9 Copyright (C) 2008 by Marek Vavruša
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 #include "ftdi.hpp"
30 #include "ftdi.h"
31
32 namespace Ftdi
33 {
34
35 class Context::Private
36 {
37 public:
38 Private()
39 : ftdi(0), dev(0), open(false)
40 {
41 ftdi = ftdi_new();
42 }
43
44 ~Private()
45 {
46 if (open)
47 ftdi_usb_close(ftdi);
48
49 ftdi_free(ftdi);
50 }
51
52 bool open;
53
54 struct ftdi_context* ftdi;
55 struct usb_device* dev;
56
57 std::string vendor;
58 std::string description;
59 std::string serial;
60 };
61
64 Context::Context()
65 : d( new Private() )
66 {
67 }
68
71 Context::~Context()
72 {
73 }
74
75 bool Context::is_open()
76 {
77 return d->open;
78 }
79
80 int Context::open(int vendor, int product)
81 {
82 // Open device
83 int ret = ftdi_usb_open(d->ftdi, vendor, product);
84
85 if (ret < 0)
86 return ret;
87
88 return get_strings_and_reopen();
89 }
90
91 int Context::open(int vendor, int product, const std::string& description, const std::string& serial, unsigned int index)
92 {
93 // translate empty strings to NULL
94 // -> do not use them to find the device (vs. require an empty string to be set in the EEPROM)
95 const char* c_description=NULL;
96 const char* c_serial=NULL;
97 if (!description.empty())
98 c_description=description.c_str();
99 if (!serial.empty())
100 c_serial=serial.c_str();
101
102 int ret = ftdi_usb_open_desc_index(d->ftdi, vendor, product, c_description, c_serial, index);
103
104 if (ret < 0)
105 return ret;
106
107 return get_strings_and_reopen();
108 }
109
110 int Context::open(const std::string& description)
111 {
112 int ret = ftdi_usb_open_string(d->ftdi, description.c_str());
113
114 if (ret < 0)
115 return ret;
116
117 return get_strings_and_reopen();
118 }
119
120 int Context::open(struct usb_device *dev)
121 {
122 if (dev != 0)
123 d->dev = dev;
124
125 if (d->dev == 0)
126 return -1;
127
128 return get_strings_and_reopen();
129 }
130
131 int Context::close()
132 {
133 d->open = false;
134 return ftdi_usb_close(d->ftdi);
135 }
136
137 int Context::reset()
138 {
139 return ftdi_usb_reset(d->ftdi);
140 }
141
142 int Context::flush(int mask)
143 {
144 int ret = 1;
145
146 if (mask & Input)
147 ret &= ftdi_usb_purge_rx_buffer(d->ftdi);
148 if (mask & Output)
149 ret &= ftdi_usb_purge_tx_buffer(d->ftdi);
150
151 return ret;
152 }
153
154 int Context::set_interface(enum ftdi_interface interface)
155 {
156 return ftdi_set_interface(d->ftdi, interface);
157 }
158
159 void Context::set_usb_device(struct usb_dev_handle *dev)
160 {
161 ftdi_set_usbdev(d->ftdi, dev);
162 d->dev = usb_device(dev);
163 }
164
165 int Context::set_baud_rate(int baudrate)
166 {
167 return ftdi_set_baudrate(d->ftdi, baudrate);
168 }
169
170 int Context::set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
171 {
172 return ftdi_set_line_property(d->ftdi, bits, sbit, parity);
173 }
174
175 int Context::set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type)
176 {
177 return ftdi_set_line_property2(d->ftdi, bits, sbit, parity, break_type);
178 }
179
180 int Context::read(unsigned char *buf, int size)
181 {
182 return ftdi_read_data(d->ftdi, buf, size);
183 }
184
185 int Context::set_read_chunk_size(unsigned int chunksize)
186 {
187 return ftdi_read_data_set_chunksize(d->ftdi, chunksize);
188 }
189
190 int Context::read_chunk_size()
191 {
192 unsigned chunk = -1;
193 if (ftdi_read_data_get_chunksize(d->ftdi, &chunk) < 0)
194 return -1;
195
196 return chunk;
197 }
198
199 int Context::write(unsigned char *buf, int size)
200 {
201 return ftdi_write_data(d->ftdi, buf, size);
202 }
203
204 int Context::set_write_chunk_size(unsigned int chunksize)
205 {
206 return ftdi_write_data_set_chunksize(d->ftdi, chunksize);
207 }
208
209 int Context::write_chunk_size()
210 {
211 unsigned chunk = -1;
212 if (ftdi_write_data_get_chunksize(d->ftdi, &chunk) < 0)
213 return -1;
214
215 return chunk;
216 }
217
218 int Context::set_flow_control(int flowctrl)
219 {
220 return ftdi_setflowctrl(d->ftdi, flowctrl);
221 }
222
223 int Context::set_modem_control(int mask)
224 {
225 int dtr = 0, rts = 0;
226
227 if (mask & Dtr)
228 dtr = 1;
229 if (mask & Rts)
230 rts = 1;
231
232 return ftdi_setdtr_rts(d->ftdi, dtr, rts);
233 }
234
235 int Context::set_dtr(bool state)
236 {
237 return ftdi_setdtr(d->ftdi, state);
238 }
239
240 int Context::set_rts(bool state)
241 {
242 return ftdi_setrts(d->ftdi, state);
243 }
244
245 int Context::set_latency(unsigned char latency)
246 {
247 return ftdi_set_latency_timer(d->ftdi, latency);
248 }
249
250 unsigned Context::latency()
251 {
252 unsigned char latency = 0;
253 ftdi_get_latency_timer(d->ftdi, &latency);
254 return latency;
255 }
256
257 unsigned short Context::poll_modem_status()
258 {
259 unsigned short status = 0;
260 ftdi_poll_modem_status(d->ftdi, &status);
261 return status;
262 }
263
264 int Context::set_event_char(unsigned char eventch, unsigned char enable)
265 {
266 return ftdi_set_event_char(d->ftdi, eventch, enable);
267 }
268
269 int Context::set_error_char(unsigned char errorch, unsigned char enable)
270 {
271 return ftdi_set_error_char(d->ftdi, errorch, enable);
272 }
273
274 int Context::bitbang_enable(unsigned char bitmask)
275 {
276 return ftdi_set_bitmode(d->ftdi, bitmask, BITMODE_BITBANG);
277 }
278
279 int Context::bitbang_disable()
280 {
281 return ftdi_disable_bitbang(d->ftdi);
282 }
283
284 int Context::set_bitmode(unsigned char bitmask, unsigned char mode)
285 {
286 return ftdi_set_bitmode(d->ftdi, bitmask, mode);
287 }
288
289 int Context::set_bitmode(unsigned char bitmask, enum ftdi_mpsse_mode mode)
290 {
291 return ftdi_set_bitmode(d->ftdi, bitmask, mode);
292 }
293
294 int Context::read_pins(unsigned char *pins)
295 {
296 return ftdi_read_pins(d->ftdi, pins);
297 }
298
299 char* Context::error_string()
300 {
301 return ftdi_get_error_string(d->ftdi);
302 }
303
304 int Context::get_strings()
305 {
306 // Prepare buffers
307 char vendor[512], desc[512], serial[512];
308
309 int ret = ftdi_usb_get_strings(d->ftdi, d->dev, vendor, 512, desc, 512, serial, 512);
310
311 if (ret < 0)
312 return -1;
313
314 d->vendor = vendor;
315 d->description = desc;
316 d->serial = serial;
317
318 return 1;
319 }
320
321 int Context::get_strings_and_reopen()
322 {
323 // Get device strings (closes device)
324 int ret=get_strings();
325 if (ret < 0)
326 {
327 d->open = 0;
328 return ret;
329 }
330
331 // Reattach device
332 ret = ftdi_usb_open_dev(d->ftdi, d->dev);
333 d->open = (ret >= 0);
334
335 return ret;
336 }
337
340 const std::string& Context::vendor()
341 {
342 return d->vendor;
343 }
344
347 const std::string& Context::description()
348 {
349 return d->description;
350 }
351
354 const std::string& Context::serial()
355 {
356 return d->serial;
357 }
358
359 void Context::set_context(struct ftdi_context* context)
360 {
361 ftdi_free(d->ftdi);
362 d->ftdi = context;
363 }
364
365 void Context::set_usb_device(struct usb_device *dev)
366 {
367 d->dev = dev;
368 }
369
370 struct ftdi_context* Context::context()
371 {
372 return d->ftdi;
373 }
374
375 class Eeprom::Private
376 {
377 public:
378 Private()
379 : context(0)
380 {}
381
382 struct ftdi_eeprom eeprom;
383 struct ftdi_context* context;
384 };
385
386 Eeprom::Eeprom(Context* parent)
387 : d ( new Private() )
388 {
389 d->context = parent->context();
390 }
391
392 Eeprom::~Eeprom()
393 {
394 }
395
396 void Eeprom::init_defaults()
397 {
398 return ftdi_eeprom_initdefaults(&d->eeprom);
399 }
400
401 void Eeprom::set_size(int size)
402 {
403 return ftdi_eeprom_setsize(d->context, &d->eeprom, size);
404 }
405
406 int Eeprom::size(unsigned char *eeprom, int maxsize)
407 {
408 return ftdi_read_eeprom_getsize(d->context, eeprom, maxsize);
409 }
410
411 int Eeprom::chip_id(unsigned int *chipid)
412 {
413 return ftdi_read_chipid(d->context, chipid);
414 }
415
416 int Eeprom::build(unsigned char *output)
417 {
418 return ftdi_eeprom_build(&d->eeprom, output);
419 }
420
421 int Eeprom::read(unsigned char *eeprom)
422 {
423 return ftdi_read_eeprom(d->context, eeprom);
424 }
425
426 int Eeprom::write(unsigned char *eeprom)
427 {
428 return ftdi_write_eeprom(d->context, eeprom);
429 }
430
431 int Eeprom::read_location(int eeprom_addr, unsigned short *eeprom_val)
432 {
433 return ftdi_read_eeprom_location(d->context, eeprom_addr, eeprom_val);
434 }
435
436 int Eeprom::write_location(int eeprom_addr, unsigned short eeprom_val)
437 {
438 return ftdi_write_eeprom_location(d->context, eeprom_addr, eeprom_val);
439 }
440
441 int Eeprom::erase()
442 {
443 return ftdi_erase_eeprom(d->context);
444 }
445
446 class List::Private
447 {
448 public:
449 Private(struct ftdi_device_list* _devlist)
450 : devlist(_devlist)
451 {}
452
453 ~Private()
454 {
455 if(devlist)
456 ftdi_list_free(&devlist);
457 }
458
459 std::list<Context> list;
460 struct ftdi_device_list* devlist;
461 };
462
463 List::List(struct ftdi_device_list* devlist)
464 : d( new Private(devlist) )
465 {
466 if (devlist != 0)
467 {
468 // Iterate list
469 for (; devlist != 0; devlist = devlist->next)
470 {
471 Context c;
472 c.set_usb_device(devlist->dev);
473 c.get_strings();
474 d->list.push_back(c);
475 }
476 }
477 }
478
479 List::~List()
480 {
481 }
482
487 List::iterator List::begin()
488 {
489 return d->list.begin();
490 }
491
496 List::iterator List::end()
497 {
498 return d->list.end();
499 }
500
505 List::const_iterator List::begin() const
506 {
507 return d->list.begin();
508 }
509
514 List::const_iterator List::end() const
515 {
516 return d->list.end();
517 }
518
523 List::reverse_iterator List::rbegin()
524 {
525 return d->list.rbegin();
526 }
527
532 List::reverse_iterator List::rend()
533 {
534 return d->list.rend();
535 }
536
541 List::const_reverse_iterator List::rbegin() const
542 {
543 return d->list.rbegin();
544 }
545
550 List::const_reverse_iterator List::rend() const
551 {
552 return d->list.rend();
553
554 }
555
560 List::ListType::size_type List::size() const
561 {
562 return d->list.size();
563 }
564
569 bool List::empty() const
570 {
571 return d->list.empty();
572 }
573
579 void List::clear()
580 {
581 ListType().swap(d->list);
582
583 // Free device list
584 if (d->devlist)
585 {
586 ftdi_list_free(&d->devlist);
587 d->devlist = 0;
588 }
589 }
590
595 void List::push_back(const Context& element)
596 {
597 d->list.push_back(element);
598 }
599
604 void List::push_front(const Context& element)
605 {
606 d->list.push_front(element);
607 }
608
614 List::iterator List::erase(iterator pos)
615 {
616 return d->list.erase(pos);
617 }
618
625 List::iterator List::erase(iterator beg, iterator end)
626 {
627 return d->list.erase(beg, end);
628 }
629
630 List* List::find_all(int vendor, int product)
631 {
632 struct ftdi_device_list* dlist = 0;
633 struct ftdi_context ftdi;
634 ftdi_init(&ftdi);
635 ftdi_usb_find_all(&ftdi, &dlist, vendor, product);
636 ftdi_deinit(&ftdi);
637 return new List(dlist);
638 }
639
640 }
Ftdi::List::empty
bool empty() const
Definition: ftdi.cpp:569
ftdi_read_pins
int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins)
Definition: ftdi.c:1795
ftdi_usb_open
int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product)
Definition: ftdi.c:581
Ftdi::Context::set_modem_control
int set_modem_control(int mask=Dtr|Rts)
Definition: ftdi.cpp:223
ftdi_device_list
list of usb devices created by ftdi_usb_find_all()
Definition: ftdi.h:249
usb_dev_handle
Definition: ftdi.c:1270
ftdi_device_list::next
struct ftdi_device_list * next
Definition: ftdi.h:252
Ftdi::List::end
iterator end()
Definition: ftdi.cpp:496
ftdi_read_data_get_chunksize
int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize)
Definition: ftdi.c:1692
Ftdi::Context::error_string
char * error_string()
Definition: ftdi.cpp:299
ftdi_usb_purge_tx_buffer
int ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi)
Definition: ftdi.c:889
ftdi_read_eeprom_location
int ftdi_read_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val)
Definition: ftdi.c:2619
ftdi_deinit
void ftdi_deinit(struct ftdi_context *ftdi)
Definition: ftdi.c:205
Ftdi::Context::Output
Definition: ftdi.hpp:59
Ftdi::Context::write
int write(unsigned char *buf, int size)
Definition: ftdi.cpp:199
Ftdi::Context
FTDI device context. Represents single FTDI device context.
Definition: ftdi.hpp:47
Ftdi::Context::read_chunk_size
int read_chunk_size()
Definition: ftdi.cpp:190
Ftdi::Context::description
const std::string & description()
Device strings properties.
Definition: ftdi.cpp:347
Ftdi::List::rbegin
reverse_iterator rbegin()
Definition: ftdi.cpp:523
ftdi_interface
ftdi_interface
Definition: ftdi.h:50
Ftdi::List::push_front
void push_front(const Context &element)
Definition: ftdi.cpp:604
ftdi_usb_open_desc_index
int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial, unsigned int index)
Definition: ftdi.c:638
Ftdi::Context::read
int read(unsigned char *buf, int size)
Definition: ftdi.cpp:180
Ftdi::Eeprom::Private::context
struct ftdi_context * context
Definition: ftdi.cpp:383
Ftdi::Context::Dtr
Definition: ftdi.hpp:66
ftdi_set_baudrate
int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate)
Definition: ftdi.c:1102
ftdi_write_eeprom
int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom)
Definition: ftdi.c:2778
Ftdi::List::iterator
ListType::iterator iterator
Iterator type for the container.
Definition: ftdi.hpp:185
Ftdi::Context::reset
int reset()
Definition: ftdi.cpp:137
Ftdi::Context::vendor
const std::string & vendor()
Device strings properties.
Definition: ftdi.cpp:340
Ftdi::Eeprom::~Eeprom
~Eeprom()
Definition: ftdi.cpp:392
ftdi_context
Main context structure for all libftdi functions.
Definition: ftdi.h:188
ftdi_usb_get_strings
int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct usb_device *dev, char *manufacturer, int mnf_len, char *description, int desc_len, char *serial, int serial_len)
Definition: ftdi.c:358
Ftdi::Eeprom::read_location
int read_location(int eeprom_addr, unsigned short *eeprom_val)
Definition: ftdi.cpp:431
Ftdi::Context::Private
Definition: ftdi.cpp:35
Ftdi::List::ListType
std::list< Context > ListType
List type storing &quot;Context&quot; objects.
Definition: ftdi.hpp:183
ftdi_set_event_char
int ftdi_set_event_char(struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable)
Definition: ftdi.c:2048
Ftdi::List::Private::list
std::list< Context > list
Definition: ftdi.cpp:459
Ftdi::Context::~Context
~Context()
Destructor.
Definition: ftdi.cpp:71
ftdi_set_bitmode
int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode)
Definition: ftdi.c:1768
Ftdi::Context::bitbang_disable
int bitbang_disable()
Definition: ftdi.cpp:279
ftdi_list_free
void ftdi_list_free(struct ftdi_device_list **devlist)
Definition: ftdi.c:308
Ftdi::Context::flush
int flush(int mask=Input|Output)
Definition: ftdi.cpp:142
Ftdi::Context::open
int open(struct usb_device *dev=0)
Definition: ftdi.cpp:120
Ftdi::List::Private::~Private
~Private()
Definition: ftdi.cpp:453
ftdi_set_line_property
int ftdi_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
Definition: ftdi.c:1148
Ftdi::List::begin
iterator begin()
Definition: ftdi.cpp:487
Ftdi::Context::write_chunk_size
int write_chunk_size()
Definition: ftdi.cpp:209
ftdi_usb_purge_rx_buffer
int ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)
Definition: ftdi.c:863
Ftdi::Context::Private::open
bool open
Definition: ftdi.cpp:52
Ftdi::Context::set_latency
int set_latency(unsigned char latency)
Definition: ftdi.cpp:245
Ftdi::Context::serial
const std::string & serial()
Device strings properties.
Definition: ftdi.cpp:354
ftdi_new
struct ftdi_context * ftdi_new(void)
Definition: ftdi.c:137
ftdi_write_data
int ftdi_write_data(struct ftdi_context *ftdi, unsigned char *buf, int size)
Definition: ftdi.c:1237
ftdi_eeprom_setsize
void ftdi_eeprom_setsize(struct ftdi_context *ftdi, struct ftdi_eeprom *eeprom, int size)
Definition: ftdi.c:2103
ftdi_erase_eeprom
int ftdi_erase_eeprom(struct ftdi_context *ftdi)
Definition: ftdi.c:2818
Ftdi::List::find_all
static List * find_all(int vendor, int product)
Definition: ftdi.cpp:630
ftdi_set_interface
int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface)
Definition: ftdi.c:165
ftdi_read_eeprom
int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom)
Definition: ftdi.c:2640
ftdi_set_usbdev
void ftdi_set_usbdev(struct ftdi_context *ftdi, usb_dev_handle *usb)
Definition: ftdi.c:242
ftdi_usb_open_dev
int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev)
Definition: ftdi.c:457
ftdi_set_error_char
int ftdi_set_error_char(struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable)
Definition: ftdi.c:2077
Ftdi::Context::Private::serial
std::string serial
Definition: ftdi.cpp:59
Ftdi::Context::Input
Definition: ftdi.hpp:58
Ftdi::Eeprom::erase
int erase()
Definition: ftdi.cpp:441
Ftdi::List::Private
Definition: ftdi.cpp:446
ftdi_bits_type
ftdi_bits_type
Definition: ftdi.h:31
Ftdi::Context::set_interface
int set_interface(enum ftdi_interface interface)
Definition: ftdi.cpp:154
ftdi_init
int ftdi_init(struct ftdi_context *ftdi)
Definition: ftdi.c:85
Ftdi::Context::set_read_chunk_size
int set_read_chunk_size(unsigned int chunksize)
Definition: ftdi.cpp:185
Ftdi::Context::Private::vendor
std::string vendor
Definition: ftdi.cpp:57
Ftdi::Context::Private::dev
struct usb_device * dev
Definition: ftdi.cpp:55
Ftdi::List::Private::Private
Private(struct ftdi_device_list *_devlist)
Definition: ftdi.cpp:449
Ftdi::Context::set_rts
int set_rts(bool state)
Definition: ftdi.cpp:240
Ftdi::Context::latency
unsigned latency()
Definition: ftdi.cpp:250
Ftdi::Context::close
int close()
Definition: ftdi.cpp:131
ftdi_eeprom_initdefaults
void ftdi_eeprom_initdefaults(struct ftdi_eeprom *eeprom)
Definition: ftdi.c:2117
Ftdi::Context::poll_modem_status
unsigned short poll_modem_status()
Definition: ftdi.cpp:257
Ftdi::Context::set_write_chunk_size
int set_write_chunk_size(unsigned int chunksize)
Definition: ftdi.cpp:204
ftdi_poll_modem_status
int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status)
Definition: ftdi.c:1902
ftdi_setdtr_rts
int ftdi_setdtr_rts(struct ftdi_context *ftdi, int dtr, int rts)
Definition: ftdi.c:2012
ftdi.hpp
BITMODE_BITBANG
Definition: ftdi.h:39
Ftdi::Eeprom::Private::Private
Private()
Definition: ftdi.cpp:378
ftdi_write_data_set_chunksize
int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)
Definition: ftdi.c:1495
Ftdi::List::reverse_iterator
ListType::reverse_iterator reverse_iterator
Reverse iterator type for the container.
Definition: ftdi.hpp:189
ftdi.h
Ftdi::Context::Private::~Private
~Private()
Definition: ftdi.cpp:44
Ftdi::List::rend
reverse_iterator rend()
Definition: ftdi.cpp:532
Ftdi::List::push_back
void push_back(const Context &element)
Definition: ftdi.cpp:595
ftdi_eeprom_build
int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output)
Definition: ftdi.c:2192
Ftdi::Eeprom::Private::eeprom
struct ftdi_eeprom eeprom
Definition: ftdi.cpp:382
ftdi_setflowctrl
int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl)
Definition: ftdi.c:1928
Ftdi::Context::Private::Private
Private()
Definition: ftdi.cpp:38
Ftdi::List::List
List(struct ftdi_device_list *devlist=0)
Definition: ftdi.cpp:463
Ftdi::Context::set_flow_control
int set_flow_control(int flowctrl)
Definition: ftdi.cpp:218
Ftdi::Context::set_usb_device
void set_usb_device(struct usb_dev_handle *dev)
Definition: ftdi.cpp:159
Ftdi::List::erase
iterator erase(iterator pos)
Definition: ftdi.cpp:614
Ftdi::Eeprom::size
int size(unsigned char *eeprom, int maxsize)
Definition: ftdi.cpp:406
Ftdi::Eeprom::build
int build(unsigned char *output)
Definition: ftdi.cpp:416
Ftdi::Eeprom::init_defaults
void init_defaults()
Definition: ftdi.cpp:396
ftdi_break_type
ftdi_break_type
Definition: ftdi.h:33
Ftdi::Eeprom::chip_id
int chip_id(unsigned int *chipid)
Definition: ftdi.cpp:411
ftdi_usb_close
int ftdi_usb_close(struct ftdi_context *ftdi)
Definition: ftdi.c:942
ftdi_setrts
int ftdi_setrts(struct ftdi_context *ftdi, int state)
Definition: ftdi.c:1981
Ftdi::Context::set_bitmode
int set_bitmode(unsigned char bitmask, unsigned char mode)
Definition: ftdi.cpp:284
Ftdi::List::~List
~List()
Definition: ftdi.cpp:479
ftdi_usb_reset
int ftdi_usb_reset(struct ftdi_context *ftdi)
Definition: ftdi.c:837
ftdi_get_latency_timer
int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency)
Definition: ftdi.c:1848
Ftdi::Context::set_error_char
int set_error_char(unsigned char errorch, unsigned char enable)
Definition: ftdi.cpp:269
ftdi_parity_type
ftdi_parity_type
Definition: ftdi.h:27
Ftdi::Context::get_strings
int get_strings()
Definition: ftdi.cpp:304
ftdi_read_data_set_chunksize
int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)
Definition: ftdi.c:1663
Ftdi::Eeprom::Private
Definition: ftdi.cpp:375
Ftdi::Context::Context
Context()
Constructor.
Definition: ftdi.cpp:64
ftdi_write_data_get_chunksize
int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize)
Definition: ftdi.c:1513
ftdi_usb_open_string
int ftdi_usb_open_string(struct ftdi_context *ftdi, const char *description)
Definition: ftdi.c:739
ftdi_disable_bitbang
int ftdi_disable_bitbang(struct ftdi_context *ftdi)
Definition: ftdi.c:1744
ftdi_setdtr
int ftdi_setdtr(struct ftdi_context *ftdi, int state)
Definition: ftdi.c:1951
Ftdi::List::clear
void clear()
Definition: ftdi.cpp:579
Ftdi::Context::Private::ftdi
struct ftdi_context * ftdi
Definition: ftdi.cpp:54
ftdi_set_latency_timer
int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency)
Definition: ftdi.c:1821
ftdi_eeprom
FTDI eeprom structure.
Definition: ftdi.h:309
ftdi_stopbits_type
ftdi_stopbits_type
Definition: ftdi.h:29
ftdi_device_list::dev
struct usb_device * dev
Definition: ftdi.h:254
Ftdi::Context::set_dtr
int set_dtr(bool state)
Definition: ftdi.cpp:235
ftdi_get_error_string
char * ftdi_get_error_string(struct ftdi_context *ftdi)
Definition: ftdi.c:2836
Ftdi::List
Device list.
Definition: ftdi.hpp:174
Ftdi::Context::set_line_property
int set_line_property(enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
Definition: ftdi.cpp:170
Ftdi::Context::get_strings_and_reopen
int get_strings_and_reopen()
Definition: ftdi.cpp:321
Ftdi::List::const_iterator
ListType::const_iterator const_iterator
Const iterator type for the container.
Definition: ftdi.hpp:187
ftdi_read_eeprom_getsize
int ftdi_read_eeprom_getsize(struct ftdi_context *ftdi, unsigned char *eeprom, int maxsize)
Definition: ftdi.c:2719
Ftdi::Context::context
struct ftdi_context * context()
Definition: ftdi.cpp:370
Ftdi::Context::Rts
Definition: ftdi.hpp:67
ftdi_read_data
int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size)
Definition: ftdi.c:1538
Ftdi::List::Private::devlist
struct ftdi_device_list * devlist
Definition: ftdi.cpp:460
ftdi_write_eeprom_location
int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val)
Definition: ftdi.c:2755
Ftdi::Eeprom::Eeprom
Eeprom(Context *parent)
Definition: ftdi.cpp:386
Ftdi::Eeprom::read
int read(unsigned char *eeprom)
Definition: ftdi.cpp:421
Ftdi::Context::set_baud_rate
int set_baud_rate(int baudrate)
Definition: ftdi.cpp:165
Ftdi::List::size
ListType::size_type size() const
Definition: ftdi.cpp:560
Ftdi::Context::Private::description
std::string description
Definition: ftdi.cpp:58
Ftdi::Eeprom::write
int write(unsigned char *eeprom)
Definition: ftdi.cpp:426
ftdi_free
void ftdi_free(struct ftdi_context *ftdi)
Definition: ftdi.c:230
ftdi_read_chipid
int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid)
Definition: ftdi.c:2683
ftdi_mpsse_mode
ftdi_mpsse_mode
Definition: ftdi.h:36
Ftdi::List::const_reverse_iterator
ListType::const_reverse_iterator const_reverse_iterator
Const reverse iterator type for the container.
Definition: ftdi.hpp:191
Ftdi::Context::set_event_char
int set_event_char(unsigned char eventch, unsigned char enable)
Definition: ftdi.cpp:264
Ftdi::Eeprom::set_size
void set_size(int size)
Definition: ftdi.cpp:401
Ftdi::Context::is_open
bool is_open()
Definition: ftdi.cpp:75
ftdi_usb_find_all
int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, int vendor, int product)
Definition: ftdi.c:265
Ftdi::Context::read_pins
int read_pins(unsigned char *pins)
Definition: ftdi.cpp:294
ftdi_set_line_property2
int ftdi_set_line_property2(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type)
Definition: ftdi.c:1167
Ftdi::Context::set_context
void set_context(struct ftdi_context *context)
Definition: ftdi.cpp:359
Ftdi::Eeprom::write_location
int write_location(int eeprom_addr, unsigned short eeprom_val)
Definition: ftdi.cpp:436