<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>libftdi: ftdi.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>ftdi.cpp</h1><a href="ftdi_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> ftdi.cpp - C++ wraper for libftdi</span> <a name="l00003"></a>00003 <span class="comment"> -------------------</span> <a name="l00004"></a>00004 <span class="comment"> begin : Mon Oct 13 2008</span> <a name="l00005"></a>00005 <span class="comment"> copyright : (C) 2008 by Marek Vavruša</span> <a name="l00006"></a>00006 <span class="comment"> email : opensource@intra2net.com and marek@vavrusa.com</span> <a name="l00007"></a>00007 <span class="comment"> ***************************************************************************/</span> <a name="l00008"></a>00008 <span class="comment">/*</span> <a name="l00009"></a>00009 <span class="comment">Copyright (C) 2008 by Marek Vavruša</span> <a name="l00010"></a>00010 <span class="comment"></span> <a name="l00011"></a>00011 <span class="comment">The software in this package is distributed under the GNU General</span> <a name="l00012"></a>00012 <span class="comment">Public License version 2 (with a special exception described below).</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment">A copy of GNU General Public License (GPL) is included in this distribution,</span> <a name="l00015"></a>00015 <span class="comment">in the file COPYING.GPL.</span> <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment">As a special exception, if other files instantiate templates or use macros</span> <a name="l00018"></a>00018 <span class="comment">or inline functions from this file, or you compile this file and link it</span> <a name="l00019"></a>00019 <span class="comment">with other works to produce a work based on this file, this file</span> <a name="l00020"></a>00020 <span class="comment">does not by itself cause the resulting work to be covered</span> <a name="l00021"></a>00021 <span class="comment">by the GNU General Public License.</span> <a name="l00022"></a>00022 <span class="comment"></span> <a name="l00023"></a>00023 <span class="comment">However the source code for this file must still be made available</span> <a name="l00024"></a>00024 <span class="comment">in accordance with section (3) of the GNU General Public License.</span> <a name="l00025"></a>00025 <span class="comment"></span> <a name="l00026"></a>00026 <span class="comment">This exception does not invalidate any other reasons why a work based</span> <a name="l00027"></a>00027 <span class="comment">on this file might be covered by the GNU General Public License.</span> <a name="l00028"></a>00028 <span class="comment">*/</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="ftdi_8hpp.html">ftdi.hpp</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="ftdi_8h.html">ftdi.h</a>"</span> <a name="l00031"></a>00031 <a name="l00032"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#a04d13cee8be6a93d1990d4519426e05d">00032</a> <span class="keyword">namespace </span>Ftdi <a name="l00033"></a>00033 { <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">class </span><a class="code" href="classFtdi_1_1Context_1_1Private.html">Context::Private</a> <a name="l00036"></a>00036 { <a name="l00037"></a>00037 <span class="keyword">public</span>: <a name="l00038"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#ac6914d23ec3542ea32c8d2b2ec525e96">00038</a> <a class="code" href="classFtdi_1_1Context_1_1Private.html#a04d13cee8be6a93d1990d4519426e05d">Private</a>() <a name="l00039"></a>00039 : <a class="code" href="classFtdi_1_1Context_1_1Private.html#ad7923179c336fca19a5cc3ca19a6a815">ftdi</a>(0), <a class="code" href="classFtdi_1_1Context_1_1Private.html#a55c40af588c5b818b9a73e75272a28e4">dev</a>(0), <a class="code" href="classFtdi_1_1Context_1_1Private.html#aa5fa397d6e6021093a4f4b39e32523aa">open</a>(false) <a name="l00040"></a>00040 { <a name="l00041"></a>00041 <a class="code" href="classFtdi_1_1Context_1_1Private.html#ad7923179c336fca19a5cc3ca19a6a815">ftdi</a> = <a class="code" href="group__libftdi.html#gafd46c6784367fd95c5f852d3b38949a8">ftdi_new</a>(); <a name="l00042"></a>00042 } <a name="l00043"></a>00043 <a name="l00044"></a>00044 <a class="code" href="classFtdi_1_1Context_1_1Private.html#ac6914d23ec3542ea32c8d2b2ec525e96">~Private</a>() <a name="l00045"></a>00045 { <a name="l00046"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#aa5fa397d6e6021093a4f4b39e32523aa">00046</a> <span class="keywordflow">if</span> (<a class="code" href="classFtdi_1_1Context_1_1Private.html#aa5fa397d6e6021093a4f4b39e32523aa">open</a>) <a name="l00047"></a>00047 <a class="code" href="group__libftdi.html#ga9536eff48c7ae9313b2a97320743ee3b">ftdi_usb_close</a>(<a class="code" href="classFtdi_1_1Context_1_1Private.html#ad7923179c336fca19a5cc3ca19a6a815">ftdi</a>); <a name="l00048"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#ad7923179c336fca19a5cc3ca19a6a815">00048</a> <a name="l00049"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#a55c40af588c5b818b9a73e75272a28e4">00049</a> <a class="code" href="group__libftdi.html#ga3cc28e5b7f1f50246861fcb39e7dd291">ftdi_free</a>(<a class="code" href="classFtdi_1_1Context_1_1Private.html#ad7923179c336fca19a5cc3ca19a6a815">ftdi</a>); <a name="l00050"></a>00050 } <a name="l00051"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#a0b0fb0d19d6e4a2f9552211e195f73c9">00051</a> <a name="l00052"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#a6c042b17b2e52d060502ad2dc2d786da">00052</a> <span class="keywordtype">bool</span> <a class="code" href="classFtdi_1_1Context_1_1Private.html#aa5fa397d6e6021093a4f4b39e32523aa">open</a>; <a name="l00053"></a><a class="code" href="classFtdi_1_1Context_1_1Private.html#a6efce3ed52f70fb07f7b789ecc412ebe">00053</a> <a name="l00054"></a>00054 <span class="keyword">struct </span><a class="code" href="structftdi__context.html" title="Main context structure for all libftdi functions.">ftdi_context</a>* <a class="code" href="classFtdi_1_1Context_1_1Private.html#ad7923179c336fca19a5cc3ca19a6a815">ftdi</a>; <a name="l00055"></a>00055 <span class="keyword">struct </span>usb_device* <a class="code" href="classFtdi_1_1Context_1_1Private.html#a55c40af588c5b818b9a73e75272a28e4">dev</a>; <a name="l00056"></a>00056 <a name="l00057"></a>00057 std::string <a class="code" href="classFtdi_1_1Context_1_1Private.html#a0b0fb0d19d6e4a2f9552211e195f73c9">vendor</a>; <a name="l00058"></a>00058 std::string <a class="code" href="classFtdi_1_1Context_1_1Private.html#a6c042b17b2e52d060502ad2dc2d786da">description</a>; <a name="l00059"></a>00059 std::string <a class="code" href="classFtdi_1_1Context_1_1Private.html#a6efce3ed52f70fb07f7b789ecc412ebe">serial</a>; <a name="l00060"></a>00060 }; <a name="l00061"></a><a class="code" href="classFtdi_1_1Context.html#a06bd23d6d2d16489cb5abf792f368b8e">00061</a> <a name="l00064"></a>00064 <a class="code" href="classFtdi_1_1Context.html#a06bd23d6d2d16489cb5abf792f368b8e" title="Constructor.">Context::Context</a>() <a name="l00065"></a>00065 : d( new <a class="code" href="classFtdi_1_1Context_1_1Private.html">Private</a>() ) <a name="l00066"></a>00066 { <a name="l00067"></a>00067 } <a name="l00068"></a><a class="code" href="classFtdi_1_1Context.html#ad12a84ca44914ae7c90404881c99503e">00068</a> <a name="l00071"></a>00071 <a class="code" href="classFtdi_1_1Context.html#ad12a84ca44914ae7c90404881c99503e" title="Destructor.">Context::~Context</a>() <a name="l00072"></a><a class="code" href="classFtdi_1_1Context.html#a3a222cbc0ac54ea699474aa48b8d27cd">00072</a> { <a name="l00073"></a>00073 } <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keywordtype">bool</span> <a class="code" href="classFtdi_1_1Context.html#a3a222cbc0ac54ea699474aa48b8d27cd">Context::is_open</a>() <a name="l00076"></a>00076 { <a name="l00077"></a><a class="code" href="classFtdi_1_1Context.html#a2669ea3eac16289990cd46cd777e295a">00077</a> <span class="keywordflow">return</span> d->open; <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a25b30dde19d821fe16229c76719ff0cd">Context::open</a>(<span class="keywordtype">int</span> vendor, <span class="keywordtype">int</span> product) <a name="l00081"></a>00081 { <a name="l00082"></a>00082 <span class="comment">// Open device</span> <a name="l00083"></a>00083 <span class="keywordtype">int</span> ret = <a class="code" href="group__libftdi.html#ga95d4689db18fc1fd70011f6504ab8c40">ftdi_usb_open</a>(d->ftdi, vendor, product); <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keywordflow">if</span> (ret < 0) <a name="l00086"></a>00086 <span class="keywordflow">return</span> ret; <a name="l00087"></a>00087 <a name="l00088"></a><a class="code" href="classFtdi_1_1Context.html#af6c6f42c9f6c10ff960e5163f0a052c6">00088</a> <span class="keywordflow">return</span> <a class="code" href="classFtdi_1_1Context.html#a6fa719a467db132076e752dd45223dbe">get_strings_and_reopen</a>(); <a name="l00089"></a>00089 } <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a25b30dde19d821fe16229c76719ff0cd">Context::open</a>(<span class="keywordtype">int</span> vendor, <span class="keywordtype">int</span> product, <span class="keyword">const</span> std::string& description, <span class="keyword">const</span> std::string& serial, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index) <a name="l00092"></a>00092 { <a name="l00093"></a>00093 <span class="comment">// translate empty strings to NULL</span> <a name="l00094"></a>00094 <span class="comment">// -> do not use them to find the device (vs. require an empty string to be set in the EEPROM)</span> <a name="l00095"></a>00095 <span class="keyword">const</span> <span class="keywordtype">char</span>* c_description=NULL; <a name="l00096"></a>00096 <span class="keyword">const</span> <span class="keywordtype">char</span>* c_serial=NULL; <a name="l00097"></a>00097 <span class="keywordflow">if</span> (!description.empty()) <a name="l00098"></a>00098 c_description=description.c_str(); <a name="l00099"></a>00099 <span class="keywordflow">if</span> (!serial.empty()) <a name="l00100"></a>00100 c_serial=serial.c_str(); <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="keywordtype">int</span> ret = <a class="code" href="group__libftdi.html#ga3c5ccb0678b0e268b4081ea978e8eb78">ftdi_usb_open_desc_index</a>(d->ftdi, vendor, product, c_description, c_serial, index); <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordflow">if</span> (ret < 0) <a name="l00105"></a>00105 <span class="keywordflow">return</span> ret; <a name="l00106"></a>00106 <a name="l00107"></a><a class="code" href="classFtdi_1_1Context.html#a6dc5ad42a05d03cbf5b43365b79a3b62">00107</a> <span class="keywordflow">return</span> <a class="code" href="classFtdi_1_1Context.html#a6fa719a467db132076e752dd45223dbe">get_strings_and_reopen</a>(); <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a25b30dde19d821fe16229c76719ff0cd">Context::open</a>(<span class="keyword">const</span> std::string& description) <a name="l00111"></a>00111 { <a name="l00112"></a>00112 <span class="keywordtype">int</span> ret = <a class="code" href="group__libftdi.html#gaae805b82251a61dae46b98345cd84d5c">ftdi_usb_open_string</a>(d->ftdi, description.c_str()); <a name="l00113"></a>00113 <a name="l00114"></a>00114 <span class="keywordflow">if</span> (ret < 0) <a name="l00115"></a>00115 <span class="keywordflow">return</span> ret; <a name="l00116"></a>00116 <a name="l00117"></a><a class="code" href="classFtdi_1_1Context.html#a25b30dde19d821fe16229c76719ff0cd">00117</a> <span class="keywordflow">return</span> <a class="code" href="classFtdi_1_1Context.html#a6fa719a467db132076e752dd45223dbe">get_strings_and_reopen</a>(); <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a25b30dde19d821fe16229c76719ff0cd">Context::open</a>(<span class="keyword">struct</span> usb_device *dev) <a name="l00121"></a>00121 { <a name="l00122"></a>00122 <span class="keywordflow">if</span> (dev != 0) <a name="l00123"></a>00123 d->dev = dev; <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="keywordflow">if</span> (d->dev == 0) <a name="l00126"></a>00126 <span class="keywordflow">return</span> -1; <a name="l00127"></a>00127 <a name="l00128"></a><a class="code" href="classFtdi_1_1Context.html#aad96d64cfe28b6085e384acdbcfe43fa">00128</a> <span class="keywordflow">return</span> <a class="code" href="classFtdi_1_1Context.html#a6fa719a467db132076e752dd45223dbe">get_strings_and_reopen</a>(); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#aad96d64cfe28b6085e384acdbcfe43fa">Context::close</a>() <a name="l00132"></a>00132 { <a name="l00133"></a>00133 d->open = <span class="keyword">false</span>; <a name="l00134"></a><a class="code" href="classFtdi_1_1Context.html#a3d318e752b00f0822d6e2c417420afde">00134</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga9536eff48c7ae9313b2a97320743ee3b">ftdi_usb_close</a>(d->ftdi); <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <a name="l00137"></a>00137 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a3d318e752b00f0822d6e2c417420afde">Context::reset</a>() <a name="l00138"></a>00138 { <a name="l00139"></a><a class="code" href="classFtdi_1_1Context.html#a36cf5e632dcc34f4ccd37a02eeedcb8d">00139</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga266ccc351ea31289022063a8ae29edf4">ftdi_usb_reset</a>(d->ftdi); <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a36cf5e632dcc34f4ccd37a02eeedcb8d">Context::flush</a>(<span class="keywordtype">int</span> mask) <a name="l00143"></a>00143 { <a name="l00144"></a>00144 <span class="keywordtype">int</span> ret = 1; <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="keywordflow">if</span> (mask & <a class="code" href="classFtdi_1_1Context.html#a608e9a5f5e023ab5f14ba6d21ce9fed9a087f9b8fee592efb3929c382e0804404">Input</a>) <a name="l00147"></a>00147 ret &= <a class="code" href="group__libftdi.html#ga25a6d4766e30bd47602ed0c0ecf53476">ftdi_usb_purge_rx_buffer</a>(d->ftdi); <a name="l00148"></a>00148 <span class="keywordflow">if</span> (mask & <a class="code" href="classFtdi_1_1Context.html#a608e9a5f5e023ab5f14ba6d21ce9fed9a5c3962c84bf153b1837ca2ca8ac97886">Output</a>) <a name="l00149"></a>00149 ret &= <a class="code" href="group__libftdi.html#ga1eab1dfd17068c46775a86496fee8bec">ftdi_usb_purge_tx_buffer</a>(d->ftdi); <a name="l00150"></a>00150 <a name="l00151"></a><a class="code" href="classFtdi_1_1Context.html#a9baf46935760b09ba2f06cd978d83a41">00151</a> <span class="keywordflow">return</span> ret; <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <a name="l00154"></a>00154 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a9baf46935760b09ba2f06cd978d83a41">Context::set_interface</a>(<span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#a9c55e66c45a0e4ec5548ee7d6e1a9265">ftdi_interface</a> interface) <a name="l00155"></a>00155 { <a name="l00156"></a><a class="code" href="classFtdi_1_1Context.html#a42107660d1baa13a1229ca819859f662">00156</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga6dc886d709eced377a33dc975fa6e771">ftdi_set_interface</a>(d->ftdi, interface); <a name="l00157"></a>00157 } <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1Context.html#a42107660d1baa13a1229ca819859f662">Context::set_usb_device</a>(<span class="keyword">struct</span> <a class="code" href="structusb__dev__handle.html">usb_dev_handle</a> *dev) <a name="l00160"></a>00160 { <a name="l00161"></a>00161 <a class="code" href="group__libftdi.html#ga1b66cfb146ff0732322c49585d2459f6">ftdi_set_usbdev</a>(d->ftdi, dev); <a name="l00162"></a><a class="code" href="classFtdi_1_1Context.html#a12d1736e590aefe7a4a3880d01961a20">00162</a> d->dev = usb_device(dev); <a name="l00163"></a>00163 } <a name="l00164"></a>00164 <a name="l00165"></a>00165 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a12d1736e590aefe7a4a3880d01961a20">Context::set_baud_rate</a>(<span class="keywordtype">int</span> baudrate) <a name="l00166"></a>00166 { <a name="l00167"></a><a class="code" href="classFtdi_1_1Context.html#acaf9f3ab2dde7b231e26cd35db4a962c">00167</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gae80f1dc38f5c80946a56ec34a329e7f5">ftdi_set_baudrate</a>(d->ftdi, baudrate); <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a name="l00170"></a>00170 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#acaf9f3ab2dde7b231e26cd35db4a962c">Context::set_line_property</a>(<span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#a8007a7d5e37b76307c341051769e5c6f">ftdi_bits_type</a> bits, <span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#a3977a883c99069e02f97e99d059dc8b8">ftdi_stopbits_type</a> sbit, <span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#ab0a93b5355c5155dd4fbd5beaf5d5e1d">ftdi_parity_type</a> parity) <a name="l00171"></a>00171 { <a name="l00172"></a><a class="code" href="classFtdi_1_1Context.html#a2ba24f72d62c853538f0844259a98c4f">00172</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga044fdde91eaa3f557b545172622ee460">ftdi_set_line_property</a>(d->ftdi, bits, sbit, parity); <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#acaf9f3ab2dde7b231e26cd35db4a962c">Context::set_line_property</a>(<span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#a8007a7d5e37b76307c341051769e5c6f">ftdi_bits_type</a> bits, <span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#a3977a883c99069e02f97e99d059dc8b8">ftdi_stopbits_type</a> sbit, <span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#ab0a93b5355c5155dd4fbd5beaf5d5e1d">ftdi_parity_type</a> parity, <span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#ae1ca6c6246df33380443c4ba6f192025">ftdi_break_type</a> break_type) <a name="l00176"></a>00176 { <a name="l00177"></a><a class="code" href="classFtdi_1_1Context.html#a1858062c4dacda2ab8271cd51550b7ee">00177</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga481d055a35dd9042c1c23e2214d2655c">ftdi_set_line_property2</a>(d->ftdi, bits, sbit, parity, break_type); <a name="l00178"></a>00178 } <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a1858062c4dacda2ab8271cd51550b7ee">Context::read</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf, <span class="keywordtype">int</span> size) <a name="l00181"></a>00181 { <a name="l00182"></a><a class="code" href="classFtdi_1_1Context.html#a6e4b4df1cd2c0786b94620b4e5b2f80f">00182</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga72d87e30015c98bd0be22e7c8c873345">ftdi_read_data</a>(d->ftdi, buf, size); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a6e4b4df1cd2c0786b94620b4e5b2f80f">Context::set_read_chunk_size</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> chunksize) <a name="l00186"></a>00186 { <a name="l00187"></a><a class="code" href="classFtdi_1_1Context.html#a4c482b031ffe04b12087e573e91e4b79">00187</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga65783703baf0828d519ef597bb2855c1">ftdi_read_data_set_chunksize</a>(d->ftdi, chunksize); <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a>00190 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a4c482b031ffe04b12087e573e91e4b79">Context::read_chunk_size</a>() <a name="l00191"></a>00191 { <a name="l00192"></a>00192 <span class="keywordtype">unsigned</span> chunk = -1; <a name="l00193"></a>00193 <span class="keywordflow">if</span> (<a class="code" href="group__libftdi.html#gab42b05f26b6a6545ae3ae1b4edc28e5c">ftdi_read_data_get_chunksize</a>(d->ftdi, &chunk) < 0) <a name="l00194"></a>00194 <span class="keywordflow">return</span> -1; <a name="l00195"></a>00195 <a name="l00196"></a><a class="code" href="classFtdi_1_1Context.html#a5cb1b4266a68f3bd9133e52178042ddf">00196</a> <span class="keywordflow">return</span> chunk; <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a5cb1b4266a68f3bd9133e52178042ddf">Context::write</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf, <span class="keywordtype">int</span> size) <a name="l00200"></a>00200 { <a name="l00201"></a><a class="code" href="classFtdi_1_1Context.html#a54859d31d5177488aefa95067c8d4666">00201</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gaa79550f209ce3327a5df03f2bd1e80f0">ftdi_write_data</a>(d->ftdi, buf, size); <a name="l00202"></a>00202 } <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a54859d31d5177488aefa95067c8d4666">Context::set_write_chunk_size</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> chunksize) <a name="l00205"></a>00205 { <a name="l00206"></a><a class="code" href="classFtdi_1_1Context.html#ad4500d40d2bd07f383724968ffa945a2">00206</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga85e22717c3315a09219b03a1862c0c46">ftdi_write_data_set_chunksize</a>(d->ftdi, chunksize); <a name="l00207"></a>00207 } <a name="l00208"></a>00208 <a name="l00209"></a>00209 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#ad4500d40d2bd07f383724968ffa945a2">Context::write_chunk_size</a>() <a name="l00210"></a>00210 { <a name="l00211"></a>00211 <span class="keywordtype">unsigned</span> chunk = -1; <a name="l00212"></a>00212 <span class="keywordflow">if</span> (<a class="code" href="group__libftdi.html#ga5944f14ffd11faa113515ff29dc769ed">ftdi_write_data_get_chunksize</a>(d->ftdi, &chunk) < 0) <a name="l00213"></a>00213 <span class="keywordflow">return</span> -1; <a name="l00214"></a>00214 <a name="l00215"></a><a class="code" href="classFtdi_1_1Context.html#a0c29fde1904335a1213ce1e1982adc24">00215</a> <span class="keywordflow">return</span> chunk; <a name="l00216"></a>00216 } <a name="l00217"></a>00217 <a name="l00218"></a>00218 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a0c29fde1904335a1213ce1e1982adc24">Context::set_flow_control</a>(<span class="keywordtype">int</span> flowctrl) <a name="l00219"></a>00219 { <a name="l00220"></a><a class="code" href="classFtdi_1_1Context.html#ad1968faa8b41f6c49c70a55872a6bdbc">00220</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gac3b3d2cc69edf567e653340f434c91e0">ftdi_setflowctrl</a>(d->ftdi, flowctrl); <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#ad1968faa8b41f6c49c70a55872a6bdbc">Context::set_modem_control</a>(<span class="keywordtype">int</span> mask) <a name="l00224"></a>00224 { <a name="l00225"></a>00225 <span class="keywordtype">int</span> dtr = 0, rts = 0; <a name="l00226"></a>00226 <a name="l00227"></a>00227 <span class="keywordflow">if</span> (mask & <a class="code" href="classFtdi_1_1Context.html#ab8cd0b1f5a42a3d2517e804bd3d2c8f1a0ed23ea2a691e4398908cb7442377e37">Dtr</a>) <a name="l00228"></a>00228 dtr = 1; <a name="l00229"></a>00229 <span class="keywordflow">if</span> (mask & <a class="code" href="classFtdi_1_1Context.html#ab8cd0b1f5a42a3d2517e804bd3d2c8f1a7dda31debfdeaf64b64734b881afe109">Rts</a>) <a name="l00230"></a>00230 rts = 1; <a name="l00231"></a>00231 <a name="l00232"></a><a class="code" href="classFtdi_1_1Context.html#a5f05bf405868e37d2efe50afaf377706">00232</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga5a8f23c2e77c8b58c1f44a11e2f52aa9">ftdi_setdtr_rts</a>(d->ftdi, dtr, rts); <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a5f05bf405868e37d2efe50afaf377706">Context::set_dtr</a>(<span class="keywordtype">bool</span> state) <a name="l00236"></a>00236 { <a name="l00237"></a><a class="code" href="classFtdi_1_1Context.html#ae5e60eb0188ba8039ee7b50329779cb0">00237</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga47761f16762363288c55f5fff24620d5">ftdi_setdtr</a>(d->ftdi, state); <a name="l00238"></a>00238 } <a name="l00239"></a>00239 <a name="l00240"></a>00240 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#ae5e60eb0188ba8039ee7b50329779cb0">Context::set_rts</a>(<span class="keywordtype">bool</span> state) <a name="l00241"></a>00241 { <a name="l00242"></a><a class="code" href="classFtdi_1_1Context.html#a60ebdaac48d273b925ff35c510f3c19a">00242</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga5713ba73288b3e1ac1d45096c917c1ab">ftdi_setrts</a>(d->ftdi, state); <a name="l00243"></a>00243 } <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a60ebdaac48d273b925ff35c510f3c19a">Context::set_latency</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> latency) <a name="l00246"></a>00246 { <a name="l00247"></a><a class="code" href="classFtdi_1_1Context.html#a7e87873dc7c2987cd588f4f4d72e7732">00247</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga3e0227b0c7aa859d2d2afb5ffa4c8466">ftdi_set_latency_timer</a>(d->ftdi, latency); <a name="l00248"></a>00248 } <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="keywordtype">unsigned</span> <a class="code" href="classFtdi_1_1Context.html#a7e87873dc7c2987cd588f4f4d72e7732">Context::latency</a>() <a name="l00251"></a>00251 { <a name="l00252"></a>00252 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classFtdi_1_1Context.html#a7e87873dc7c2987cd588f4f4d72e7732">latency</a> = 0; <a name="l00253"></a>00253 <a class="code" href="group__libftdi.html#gacf7b6dcc4de33db2263ce8a421e18bfc">ftdi_get_latency_timer</a>(d->ftdi, &latency); <a name="l00254"></a><a class="code" href="classFtdi_1_1Context.html#a9204d8315dd586286535da2a68917dad">00254</a> <span class="keywordflow">return</span> latency; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00257"></a>00257 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="classFtdi_1_1Context.html#a9204d8315dd586286535da2a68917dad">Context::poll_modem_status</a>() <a name="l00258"></a>00258 { <a name="l00259"></a>00259 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> status = 0; <a name="l00260"></a>00260 <a class="code" href="group__libftdi.html#ga396c3bf1435fb3317755868e28c47414">ftdi_poll_modem_status</a>(d->ftdi, &status); <a name="l00261"></a><a class="code" href="classFtdi_1_1Context.html#a7471fc6635a9ff2f98d30c5830eb7593">00261</a> <span class="keywordflow">return</span> status; <a name="l00262"></a>00262 } <a name="l00263"></a>00263 <a name="l00264"></a>00264 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a7471fc6635a9ff2f98d30c5830eb7593">Context::set_event_char</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> eventch, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> enable) <a name="l00265"></a>00265 { <a name="l00266"></a><a class="code" href="classFtdi_1_1Context.html#a5b846e30bb38c78fd772281be7fc342b">00266</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga71eeabe2ee5474d5c0ceddc2e08766cd">ftdi_set_event_char</a>(d->ftdi, eventch, enable); <a name="l00267"></a>00267 } <a name="l00268"></a>00268 <a name="l00269"></a>00269 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a5b846e30bb38c78fd772281be7fc342b">Context::set_error_char</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> errorch, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> enable) <a name="l00270"></a>00270 { <a name="l00271"></a>00271 <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gaeb9510a61f6648eb1bd57f0f99a390e1">ftdi_set_error_char</a>(d->ftdi, errorch, enable); <a name="l00272"></a>00272 } <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="keywordtype">int</span> Context::bitbang_enable(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> bitmask) <a name="l00275"></a>00275 { <a name="l00276"></a><a class="code" href="classFtdi_1_1Context.html#ace0a0738c511bf041a456b94ca096ec9">00276</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga83b41e900a1faf2ecc0546ce48ec7e70">ftdi_set_bitmode</a>(d->ftdi, bitmask, <a class="code" href="ftdi_8h.html#a2250f7812c87a96ada7fd4f19b82f666aaa4fb0ac6e618b52746cc047b0fd7b19">BITMODE_BITBANG</a>); <a name="l00277"></a>00277 } <a name="l00278"></a>00278 <a name="l00279"></a>00279 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#ace0a0738c511bf041a456b94ca096ec9">Context::bitbang_disable</a>() <a name="l00280"></a>00280 { <a name="l00281"></a><a class="code" href="classFtdi_1_1Context.html#ad8a0a54d23eb0f6b8b3c77155c1b4487">00281</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga42b4776b91c6b14d2d1008b160b78efa">ftdi_disable_bitbang</a>(d->ftdi); <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <a name="l00284"></a>00284 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#ad8a0a54d23eb0f6b8b3c77155c1b4487">Context::set_bitmode</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> bitmask, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> mode) <a name="l00285"></a>00285 { <a name="l00286"></a><a class="code" href="classFtdi_1_1Context.html#ab419f56aee86647a9d4bbc7e348960cf">00286</a> <span class="keywordflow">return</span> <a class="code" href="classFtdi_1_1Context.html#ad8a0a54d23eb0f6b8b3c77155c1b4487">set_bitmode</a>(bitmask, mode); <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <a name="l00289"></a>00289 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#ad8a0a54d23eb0f6b8b3c77155c1b4487">Context::set_bitmode</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> bitmask, <span class="keyword">enum</span> <a class="code" href="ftdi_8h.html#a2250f7812c87a96ada7fd4f19b82f666">ftdi_mpsse_mode</a> mode) <a name="l00290"></a>00290 { <a name="l00291"></a><a class="code" href="classFtdi_1_1Context.html#aa41e612799358ce70b4a5003ebcfe9ec">00291</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga83b41e900a1faf2ecc0546ce48ec7e70">ftdi_set_bitmode</a>(d->ftdi, bitmask, mode); <a name="l00292"></a>00292 } <a name="l00293"></a>00293 <a name="l00294"></a>00294 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#aa41e612799358ce70b4a5003ebcfe9ec">Context::read_pins</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *pins) <a name="l00295"></a>00295 { <a name="l00296"></a><a class="code" href="classFtdi_1_1Context.html#ab4e06e0e4bf156c0c5421ec0bbb4cdd1">00296</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gab823dd90f2359612b1546ef0ceebdc0e">ftdi_read_pins</a>(d->ftdi, pins); <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <a name="l00299"></a>00299 <span class="keywordtype">char</span>* <a class="code" href="classFtdi_1_1Context.html#ab4e06e0e4bf156c0c5421ec0bbb4cdd1">Context::error_string</a>() <a name="l00300"></a>00300 { <a name="l00301"></a><a class="code" href="classFtdi_1_1Context.html#aaaf4d528fe4d70502b14582702103db8">00301</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga28c84d963760d7396e5a2992e63a9354">ftdi_get_error_string</a>(d->ftdi); <a name="l00302"></a>00302 } <a name="l00303"></a>00303 <a name="l00304"></a>00304 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#aaaf4d528fe4d70502b14582702103db8">Context::get_strings</a>() <a name="l00305"></a>00305 { <a name="l00306"></a>00306 <span class="comment">// Prepare buffers</span> <a name="l00307"></a>00307 <span class="keywordtype">char</span> vendor[512], desc[512], serial[512]; <a name="l00308"></a>00308 <a name="l00309"></a>00309 <span class="keywordtype">int</span> ret = <a class="code" href="group__libftdi.html#gabeca5642c95141e11b6936175ce08b3b">ftdi_usb_get_strings</a>(d->ftdi, d->dev, vendor, 512, desc, 512, serial, 512); <a name="l00310"></a>00310 <a name="l00311"></a>00311 <span class="keywordflow">if</span> (ret < 0) <a name="l00312"></a>00312 <span class="keywordflow">return</span> -1; <a name="l00313"></a>00313 <a name="l00314"></a>00314 d->vendor = vendor; <a name="l00315"></a>00315 d->description = desc; <a name="l00316"></a>00316 d->serial = serial; <a name="l00317"></a>00317 <a name="l00318"></a><a class="code" href="classFtdi_1_1Context.html#a6fa719a467db132076e752dd45223dbe">00318</a> <span class="keywordflow">return</span> 1; <a name="l00319"></a>00319 } <a name="l00320"></a>00320 <a name="l00321"></a>00321 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Context.html#a6fa719a467db132076e752dd45223dbe">Context::get_strings_and_reopen</a>() <a name="l00322"></a>00322 { <a name="l00323"></a>00323 <span class="comment">// Get device strings (closes device)</span> <a name="l00324"></a>00324 <span class="keywordtype">int</span> ret=<a class="code" href="classFtdi_1_1Context.html#aaaf4d528fe4d70502b14582702103db8">get_strings</a>(); <a name="l00325"></a>00325 <span class="keywordflow">if</span> (ret < 0) <a name="l00326"></a>00326 { <a name="l00327"></a>00327 d->open = 0; <a name="l00328"></a>00328 <span class="keywordflow">return</span> ret; <a name="l00329"></a>00329 } <a name="l00330"></a>00330 <a name="l00331"></a>00331 <span class="comment">// Reattach device</span> <a name="l00332"></a>00332 ret = <a class="code" href="group__libftdi.html#gaa03eb28a2ec02db4e923e3949854a30d">ftdi_usb_open_dev</a>(d->ftdi, d->dev); <a name="l00333"></a>00333 d->open = (ret >= 0); <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="keywordflow">return</span> ret; <a name="l00336"></a>00336 } <a name="l00337"></a><a class="code" href="classFtdi_1_1Context.html#ab1ef11b1851c8234f5305fdfc7421887">00337</a> <a name="l00340"></a>00340 <span class="keyword">const</span> std::string& <a class="code" href="classFtdi_1_1Context.html#ab1ef11b1851c8234f5305fdfc7421887" title="Device strings properties.">Context::vendor</a>() <a name="l00341"></a>00341 { <a name="l00342"></a>00342 <span class="keywordflow">return</span> d->vendor; <a name="l00343"></a>00343 } <a name="l00344"></a><a class="code" href="classFtdi_1_1Context.html#a1851e8cffbb77e7f7ef7adb8fa833962">00344</a> <a name="l00347"></a>00347 <span class="keyword">const</span> std::string& <a class="code" href="classFtdi_1_1Context.html#a1851e8cffbb77e7f7ef7adb8fa833962" title="Device strings properties.">Context::description</a>() <a name="l00348"></a>00348 { <a name="l00349"></a>00349 <span class="keywordflow">return</span> d->description; <a name="l00350"></a>00350 } <a name="l00351"></a><a class="code" href="classFtdi_1_1Context.html#a3d4035444e2f78ff8d7aa37c26236df8">00351</a> <a name="l00354"></a>00354 <span class="keyword">const</span> std::string& <a class="code" href="classFtdi_1_1Context.html#a3d4035444e2f78ff8d7aa37c26236df8" title="Device strings properties.">Context::serial</a>() <a name="l00355"></a>00355 { <a name="l00356"></a><a class="code" href="classFtdi_1_1Context.html#aaac96a16870d29bb7f59353a36524a39">00356</a> <span class="keywordflow">return</span> d->serial; <a name="l00357"></a>00357 } <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1Context.html#aaac96a16870d29bb7f59353a36524a39">Context::set_context</a>(<span class="keyword">struct</span> <a class="code" href="structftdi__context.html" title="Main context structure for all libftdi functions.">ftdi_context</a>* context) <a name="l00360"></a>00360 { <a name="l00361"></a>00361 <a class="code" href="group__libftdi.html#ga3cc28e5b7f1f50246861fcb39e7dd291">ftdi_free</a>(d->ftdi); <a name="l00362"></a><a class="code" href="classFtdi_1_1Context.html#ae284dd68cb918774dea596b169214240">00362</a> d->ftdi = context; <a name="l00363"></a>00363 } <a name="l00364"></a>00364 <a name="l00365"></a>00365 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1Context.html#a42107660d1baa13a1229ca819859f662">Context::set_usb_device</a>(<span class="keyword">struct</span> usb_device *dev) <a name="l00366"></a>00366 { <a name="l00367"></a><a class="code" href="classFtdi_1_1Context.html#ae7cb8331c5eab1d7aa4ade40a1bd5b9e">00367</a> d->dev = dev; <a name="l00368"></a>00368 } <a name="l00369"></a>00369 <a name="l00370"></a>00370 <span class="keyword">struct </span><a class="code" href="structftdi__context.html" title="Main context structure for all libftdi functions.">ftdi_context</a>* <a class="code" href="classFtdi_1_1Context.html#ae7cb8331c5eab1d7aa4ade40a1bd5b9e">Context::context</a>() <a name="l00371"></a>00371 { <a name="l00372"></a><a class="code" href="classFtdi_1_1Eeprom_1_1Private.html">00372</a> <span class="keywordflow">return</span> d->ftdi; <a name="l00373"></a>00373 } <a name="l00374"></a>00374 <a name="l00375"></a><a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a63564082f5d1703b9c00f261b0e47499">00375</a> <span class="keyword">class </span><a class="code" href="classFtdi_1_1Eeprom_1_1Private.html">Eeprom::Private</a> <a name="l00376"></a>00376 { <a name="l00377"></a>00377 <span class="keyword">public</span>: <a name="l00378"></a>00378 <a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a63564082f5d1703b9c00f261b0e47499">Private</a>() <a name="l00379"></a><a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a9c23d26cb036d09954a824526b65777e">00379</a> : <a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a32698304e80aca69bc1412f1a24812ca">context</a>(0) <a name="l00380"></a><a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a32698304e80aca69bc1412f1a24812ca">00380</a> {} <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="keyword">struct </span><a class="code" href="structftdi__eeprom.html" title="FTDI eeprom structure.">ftdi_eeprom</a> <a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a9c23d26cb036d09954a824526b65777e">eeprom</a>; <a name="l00383"></a><a class="code" href="classFtdi_1_1Eeprom.html#a7ecd3ee3bb235d7d9c32b5287f509edc">00383</a> <span class="keyword">struct </span><a class="code" href="structftdi__context.html" title="Main context structure for all libftdi functions.">ftdi_context</a>* <a class="code" href="classFtdi_1_1Eeprom_1_1Private.html#a32698304e80aca69bc1412f1a24812ca">context</a>; <a name="l00384"></a>00384 }; <a name="l00385"></a>00385 <a name="l00386"></a>00386 <a class="code" href="classFtdi_1_1Eeprom.html#a7ecd3ee3bb235d7d9c32b5287f509edc">Eeprom::Eeprom</a>(<a class="code" href="classFtdi_1_1Context.html" title="FTDI device context. Represents single FTDI device context.">Context</a>* parent) <a name="l00387"></a>00387 : d ( new Private() ) <a name="l00388"></a>00388 { <a name="l00389"></a><a class="code" href="classFtdi_1_1Eeprom.html#ae7945809c4ff06b8bd386472eed26b1e">00389</a> d->context = parent-><a class="code" href="classFtdi_1_1Context.html#ae7cb8331c5eab1d7aa4ade40a1bd5b9e">context</a>(); <a name="l00390"></a>00390 } <a name="l00391"></a>00391 <a name="l00392"></a>00392 <a class="code" href="classFtdi_1_1Eeprom.html#ae7945809c4ff06b8bd386472eed26b1e">Eeprom::~Eeprom</a>() <a name="l00393"></a><a class="code" href="classFtdi_1_1Eeprom.html#ab8eca942c0bdbee8a1b67910857f1ea0">00393</a> { <a name="l00394"></a>00394 } <a name="l00395"></a>00395 <a name="l00396"></a>00396 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1Eeprom.html#ab8eca942c0bdbee8a1b67910857f1ea0">Eeprom::init_defaults</a>() <a name="l00397"></a>00397 { <a name="l00398"></a><a class="code" href="classFtdi_1_1Eeprom.html#a3f6fc32b69a68b190b03bc4e3c4b8810">00398</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga3302c00605356730893c0b11ef0dba03">ftdi_eeprom_initdefaults</a>(&d->eeprom); <a name="l00399"></a>00399 } <a name="l00400"></a>00400 <a name="l00401"></a>00401 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1Eeprom.html#a3f6fc32b69a68b190b03bc4e3c4b8810">Eeprom::set_size</a>(<span class="keywordtype">int</span> size) <a name="l00402"></a>00402 { <a name="l00403"></a><a class="code" href="classFtdi_1_1Eeprom.html#aeeb5331e185e8e6c24ad0baf5c851276">00403</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gaf2ce1365f476463d01d02d5aba5fa818">ftdi_eeprom_setsize</a>(d->context, &d->eeprom, size); <a name="l00404"></a>00404 } <a name="l00405"></a>00405 <a name="l00406"></a>00406 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#aeeb5331e185e8e6c24ad0baf5c851276">Eeprom::size</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *eeprom, <span class="keywordtype">int</span> maxsize) <a name="l00407"></a>00407 { <a name="l00408"></a><a class="code" href="classFtdi_1_1Eeprom.html#af7ab5af427de9c7464f11f1ec784c4da">00408</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gaf9fc6da50167f7160024aca768c8dccc">ftdi_read_eeprom_getsize</a>(d->context, eeprom, maxsize); <a name="l00409"></a>00409 } <a name="l00410"></a>00410 <a name="l00411"></a>00411 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#af7ab5af427de9c7464f11f1ec784c4da">Eeprom::chip_id</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *chipid) <a name="l00412"></a>00412 { <a name="l00413"></a><a class="code" href="classFtdi_1_1Eeprom.html#abddb318d9df2c626fffa09047d5ab549">00413</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gab978a76c2cc0dbfbc1fd6350db848300">ftdi_read_chipid</a>(d->context, chipid); <a name="l00414"></a>00414 } <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#abddb318d9df2c626fffa09047d5ab549">Eeprom::build</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *output) <a name="l00417"></a>00417 { <a name="l00418"></a><a class="code" href="classFtdi_1_1Eeprom.html#a59ef82e22828370274fa7de627eff2e4">00418</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga6e80677242c262c58169ea5565ae9163">ftdi_eeprom_build</a>(&d->eeprom, output); <a name="l00419"></a>00419 } <a name="l00420"></a>00420 <a name="l00421"></a>00421 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#a59ef82e22828370274fa7de627eff2e4">Eeprom::read</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *eeprom) <a name="l00422"></a>00422 { <a name="l00423"></a><a class="code" href="classFtdi_1_1Eeprom.html#ac6fb73bd70749209c46bdd9529344392">00423</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#gac2607b0a26dd8d78431d30a3fd01c052">ftdi_read_eeprom</a>(d->context, eeprom); <a name="l00424"></a>00424 } <a name="l00425"></a>00425 <a name="l00426"></a>00426 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#ac6fb73bd70749209c46bdd9529344392">Eeprom::write</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *eeprom) <a name="l00427"></a>00427 { <a name="l00428"></a><a class="code" href="classFtdi_1_1Eeprom.html#aacdb0d74cceaeae77b754232c8b68f9e">00428</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga28e530f10b046bcc353aa75938bddb31">ftdi_write_eeprom</a>(d->context, eeprom); <a name="l00429"></a>00429 } <a name="l00430"></a>00430 <a name="l00431"></a>00431 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#aacdb0d74cceaeae77b754232c8b68f9e">Eeprom::read_location</a>(<span class="keywordtype">int</span> eeprom_addr, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> *eeprom_val) <a name="l00432"></a>00432 { <a name="l00433"></a><a class="code" href="classFtdi_1_1Eeprom.html#aaa79973c9fa5c44e041ad416860fa1b8">00433</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga650df1dc49ec78f0ee58b1c4f2644fd9">ftdi_read_eeprom_location</a>(d->context, eeprom_addr, eeprom_val); <a name="l00434"></a>00434 } <a name="l00435"></a>00435 <a name="l00436"></a>00436 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#aaa79973c9fa5c44e041ad416860fa1b8">Eeprom::write_location</a>(<span class="keywordtype">int</span> eeprom_addr, <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> eeprom_val) <a name="l00437"></a>00437 { <a name="l00438"></a><a class="code" href="classFtdi_1_1Eeprom.html#a3044b5cd481ebbefd3c64e4653e8d6f3">00438</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga5f2f678fc05cb8f92708fb1e5eb75100">ftdi_write_eeprom_location</a>(d->context, eeprom_addr, eeprom_val); <a name="l00439"></a>00439 } <a name="l00440"></a>00440 <a name="l00441"></a>00441 <span class="keywordtype">int</span> <a class="code" href="classFtdi_1_1Eeprom.html#a3044b5cd481ebbefd3c64e4653e8d6f3">Eeprom::erase</a>() <a name="l00442"></a>00442 { <a name="l00443"></a><a class="code" href="classFtdi_1_1List_1_1Private.html">00443</a> <span class="keywordflow">return</span> <a class="code" href="group__libftdi.html#ga25eb9a83a925065b6c3b61b8f0565951">ftdi_erase_eeprom</a>(d->context); <a name="l00444"></a>00444 } <a name="l00445"></a>00445 <a name="l00446"></a><a class="code" href="classFtdi_1_1List_1_1Private.html#a2442797d80d90894573b45273392278c">00446</a> <span class="keyword">class </span><a class="code" href="classFtdi_1_1List_1_1Private.html">List::Private</a> <a name="l00447"></a>00447 { <a name="l00448"></a>00448 <span class="keyword">public</span>: <a name="l00449"></a>00449 <a class="code" href="classFtdi_1_1List_1_1Private.html#a2442797d80d90894573b45273392278c">Private</a>(<span class="keyword">struct</span> <a class="code" href="structftdi__device__list.html" title="list of usb devices created by ftdi_usb_find_all()">ftdi_device_list</a>* _devlist) <a name="l00450"></a><a class="code" href="classFtdi_1_1List_1_1Private.html#aa5429f4a34d2eb4fc714d45c4fd7bee1">00450</a> : <a class="code" href="classFtdi_1_1List_1_1Private.html#a71b95c38727b514bcf0ebfb331c00b86">devlist</a>(_devlist) <a name="l00451"></a>00451 {} <a name="l00452"></a>00452 <a name="l00453"></a>00453 <a class="code" href="classFtdi_1_1List_1_1Private.html#aa5429f4a34d2eb4fc714d45c4fd7bee1">~Private</a>() <a name="l00454"></a>00454 { <a name="l00455"></a>00455 <span class="keywordflow">if</span>(<a class="code" href="classFtdi_1_1List_1_1Private.html#a71b95c38727b514bcf0ebfb331c00b86">devlist</a>) <a name="l00456"></a><a class="code" href="classFtdi_1_1List_1_1Private.html#ac95ef41346b70deaa321c0fab10f1f3a">00456</a> <a class="code" href="group__libftdi.html#ga35358ea578644aa309300db782415c9f">ftdi_list_free</a>(&<a class="code" href="classFtdi_1_1List_1_1Private.html#a71b95c38727b514bcf0ebfb331c00b86">devlist</a>); <a name="l00457"></a><a class="code" href="classFtdi_1_1List_1_1Private.html#a71b95c38727b514bcf0ebfb331c00b86">00457</a> } <a name="l00458"></a>00458 <a name="l00459"></a>00459 std::list<Context> <a class="code" href="classFtdi_1_1List_1_1Private.html#ac95ef41346b70deaa321c0fab10f1f3a">list</a>; <a name="l00460"></a><a class="code" href="classFtdi_1_1List.html#a9f005b9f8886ab85e43a2ea5b019b72d">00460</a> <span class="keyword">struct </span><a class="code" href="structftdi__device__list.html" title="list of usb devices created by ftdi_usb_find_all()">ftdi_device_list</a>* <a class="code" href="classFtdi_1_1List_1_1Private.html#a71b95c38727b514bcf0ebfb331c00b86">devlist</a>; <a name="l00461"></a>00461 }; <a name="l00462"></a>00462 <a name="l00463"></a>00463 <a class="code" href="classFtdi_1_1List.html#a9f005b9f8886ab85e43a2ea5b019b72d">List::List</a>(<span class="keyword">struct</span> <a class="code" href="structftdi__device__list.html" title="list of usb devices created by ftdi_usb_find_all()">ftdi_device_list</a>* devlist) <a name="l00464"></a>00464 : d( new Private(devlist) ) <a name="l00465"></a>00465 { <a name="l00466"></a>00466 <span class="keywordflow">if</span> (devlist != 0) <a name="l00467"></a>00467 { <a name="l00468"></a>00468 <span class="comment">// Iterate list</span> <a name="l00469"></a>00469 <span class="keywordflow">for</span> (; devlist != 0; devlist = devlist-><a class="code" href="structftdi__device__list.html#aa80d0234b1a36e0e9a91605a7c74df37">next</a>) <a name="l00470"></a>00470 { <a name="l00471"></a>00471 <a class="code" href="classFtdi_1_1Context.html" title="FTDI device context. Represents single FTDI device context.">Context</a> c; <a name="l00472"></a>00472 c.<a class="code" href="classFtdi_1_1Context.html#a42107660d1baa13a1229ca819859f662">set_usb_device</a>(devlist-><a class="code" href="structftdi__device__list.html#a9067b0b6efaa1c0e2be4f4658c3e3e6e">dev</a>); <a name="l00473"></a>00473 c.<a class="code" href="classFtdi_1_1Context.html#aaaf4d528fe4d70502b14582702103db8">get_strings</a>(); <a name="l00474"></a>00474 d->list.push_back(c); <a name="l00475"></a>00475 } <a name="l00476"></a><a class="code" href="classFtdi_1_1List.html#a0d6814256d82692d46483733c71037d7">00476</a> } <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a name="l00479"></a>00479 <a class="code" href="classFtdi_1_1List.html#a0d6814256d82692d46483733c71037d7">List::~List</a>() <a name="l00480"></a>00480 { <a name="l00481"></a>00481 } <a name="l00482"></a>00482 <a name="l00487"></a>00487 <a class="code" href="classFtdi_1_1List.html#a42dc7256a0cacb1534388b272d71a6e1" title="Iterator type for the container.">List::iterator</a> <a class="code" href="classFtdi_1_1List.html#a420ec5202f3c6a12de1b76c4842df42e">List::begin</a>() <a name="l00488"></a>00488 { <a name="l00489"></a>00489 <span class="keywordflow">return</span> d->list.begin(); <a name="l00490"></a>00490 } <a name="l00491"></a>00491 <a name="l00496"></a>00496 <a class="code" href="classFtdi_1_1List.html#a42dc7256a0cacb1534388b272d71a6e1" title="Iterator type for the container.">List::iterator</a> <a class="code" href="classFtdi_1_1List.html#aabc5f6a4b69536ca68b7f364ba58d336">List::end</a>() <a name="l00497"></a>00497 { <a name="l00498"></a>00498 <span class="keywordflow">return</span> d->list.end(); <a name="l00499"></a>00499 } <a name="l00500"></a>00500 <a name="l00505"></a>00505 <a class="code" href="classFtdi_1_1List.html#a89f81377906bec5c14d262a959ac4bb0" title="Const iterator type for the container.">List::const_iterator</a> <a class="code" href="classFtdi_1_1List.html#a420ec5202f3c6a12de1b76c4842df42e">List::begin</a>()<span class="keyword"> const</span> <a name="l00506"></a>00506 <span class="keyword"></span>{ <a name="l00507"></a>00507 <span class="keywordflow">return</span> d->list.begin(); <a name="l00508"></a>00508 } <a name="l00509"></a>00509 <a name="l00514"></a>00514 <a class="code" href="classFtdi_1_1List.html#a89f81377906bec5c14d262a959ac4bb0" title="Const iterator type for the container.">List::const_iterator</a> <a class="code" href="classFtdi_1_1List.html#aabc5f6a4b69536ca68b7f364ba58d336">List::end</a>()<span class="keyword"> const</span> <a name="l00515"></a>00515 <span class="keyword"></span>{ <a name="l00516"></a>00516 <span class="keywordflow">return</span> d->list.end(); <a name="l00517"></a>00517 } <a name="l00518"></a>00518 <a name="l00523"></a>00523 <a class="code" href="classFtdi_1_1List.html#a5031c32928ad47f6a8c9b425a557c998" title="Reverse iterator type for the container.">List::reverse_iterator</a> <a class="code" href="classFtdi_1_1List.html#a691d51ae1d7e04cc7100241fda7226b9">List::rbegin</a>() <a name="l00524"></a>00524 { <a name="l00525"></a>00525 <span class="keywordflow">return</span> d->list.rbegin(); <a name="l00526"></a>00526 } <a name="l00527"></a>00527 <a name="l00532"></a>00532 <a class="code" href="classFtdi_1_1List.html#a5031c32928ad47f6a8c9b425a557c998" title="Reverse iterator type for the container.">List::reverse_iterator</a> <a class="code" href="classFtdi_1_1List.html#aaeae5fdd0a1595cfbca8c558b89d90df">List::rend</a>() <a name="l00533"></a>00533 { <a name="l00534"></a>00534 <span class="keywordflow">return</span> d->list.rend(); <a name="l00535"></a>00535 } <a name="l00536"></a>00536 <a name="l00541"></a>00541 <a class="code" href="classFtdi_1_1List.html#a40ba96ede36bc45a2b22e0a9ceba9cc0" title="Const reverse iterator type for the container.">List::const_reverse_iterator</a> <a class="code" href="classFtdi_1_1List.html#a691d51ae1d7e04cc7100241fda7226b9">List::rbegin</a>()<span class="keyword"> const</span> <a name="l00542"></a>00542 <span class="keyword"></span>{ <a name="l00543"></a>00543 <span class="keywordflow">return</span> d->list.rbegin(); <a name="l00544"></a>00544 } <a name="l00545"></a>00545 <a name="l00550"></a>00550 <a class="code" href="classFtdi_1_1List.html#a40ba96ede36bc45a2b22e0a9ceba9cc0" title="Const reverse iterator type for the container.">List::const_reverse_iterator</a> <a class="code" href="classFtdi_1_1List.html#aaeae5fdd0a1595cfbca8c558b89d90df">List::rend</a>()<span class="keyword"> const</span> <a name="l00551"></a>00551 <span class="keyword"></span>{ <a name="l00552"></a>00552 <span class="keywordflow">return</span> d->list.rend(); <a name="l00553"></a>00553 <a name="l00554"></a>00554 } <a name="l00555"></a>00555 <a name="l00560"></a>00560 List::ListType::size_type <a class="code" href="classFtdi_1_1List.html#a2d76af7ee18d62d11f8048df95f05a69">List::size</a>()<span class="keyword"> const</span> <a name="l00561"></a>00561 <span class="keyword"></span>{ <a name="l00562"></a>00562 <span class="keywordflow">return</span> d->list.size(); <a name="l00563"></a>00563 } <a name="l00564"></a>00564 <a name="l00569"></a>00569 <span class="keywordtype">bool</span> <a class="code" href="classFtdi_1_1List.html#a1d7362506f1d331d5ffafb8d68868d07">List::empty</a>()<span class="keyword"> const</span> <a name="l00570"></a>00570 <span class="keyword"></span>{ <a name="l00571"></a>00571 <span class="keywordflow">return</span> d->list.empty(); <a name="l00572"></a>00572 } <a name="l00573"></a>00573 <a name="l00579"></a>00579 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1List.html#a3e518597e7e1d8cce072fbf0c75a9d32">List::clear</a>() <a name="l00580"></a>00580 { <a name="l00581"></a>00581 <a class="code" href="classFtdi_1_1List.html#a0f7f7fad56e8d14e0b96f9b985a433ad" title="List type storing &quot;Context&quot; objects.">ListType</a>().swap(d->list); <a name="l00582"></a>00582 <a name="l00583"></a>00583 <span class="comment">// Free device list</span> <a name="l00584"></a>00584 <span class="keywordflow">if</span> (d->devlist) <a name="l00585"></a>00585 { <a name="l00586"></a>00586 <a class="code" href="group__libftdi.html#ga35358ea578644aa309300db782415c9f">ftdi_list_free</a>(&d->devlist); <a name="l00587"></a>00587 d->devlist = 0; <a name="l00588"></a>00588 } <a name="l00589"></a>00589 } <a name="l00590"></a>00590 <a name="l00595"></a>00595 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1List.html#a280cb7466bcdc7afbcf27893f6bba4df">List::push_back</a>(<span class="keyword">const</span> Context& element) <a name="l00596"></a>00596 { <a name="l00597"></a>00597 d->list.push_back(element); <a name="l00598"></a>00598 } <a name="l00599"></a>00599 <a name="l00604"></a>00604 <span class="keywordtype">void</span> <a class="code" href="classFtdi_1_1List.html#ae5bbd5d4b9c5c8c159a50a4f25a4c896">List::push_front</a>(<span class="keyword">const</span> Context& element) <a name="l00605"></a>00605 { <a name="l00606"></a>00606 d->list.push_front(element); <a name="l00607"></a>00607 } <a name="l00608"></a>00608 <a name="l00614"></a>00614 <a class="code" href="classFtdi_1_1List.html#a42dc7256a0cacb1534388b272d71a6e1" title="Iterator type for the container.">List::iterator</a> <a class="code" href="classFtdi_1_1List.html#a608e4633a7bac3a39ac51fd67f190a89">List::erase</a>(iterator pos) <a name="l00615"></a>00615 { <a name="l00616"></a>00616 <span class="keywordflow">return</span> d->list.erase(pos); <a name="l00617"></a>00617 } <a name="l00618"></a>00618 <a name="l00625"></a>00625 <a class="code" href="classFtdi_1_1List.html#a42dc7256a0cacb1534388b272d71a6e1" title="Iterator type for the container.">List::iterator</a> <a class="code" href="classFtdi_1_1List.html#a608e4633a7bac3a39ac51fd67f190a89">List::erase</a>(iterator beg, iterator end) <a name="l00626"></a>00626 { <a name="l00627"></a><a class="code" href="classFtdi_1_1List.html#abd0aa0bf990eb06692863274cfdff6cd">00627</a> <span class="keywordflow">return</span> d->list.erase(beg, end); <a name="l00628"></a>00628 } <a name="l00629"></a>00629 <a name="l00630"></a>00630 <a class="code" href="classFtdi_1_1List.html" title="Device list.">List</a>* <a class="code" href="classFtdi_1_1List.html#abd0aa0bf990eb06692863274cfdff6cd">List::find_all</a>(<span class="keywordtype">int</span> vendor, <span class="keywordtype">int</span> product) <a name="l00631"></a>00631 { <a name="l00632"></a>00632 <span class="keyword">struct </span><a class="code" href="structftdi__device__list.html" title="list of usb devices created by ftdi_usb_find_all()">ftdi_device_list</a>* dlist = 0; <a name="l00633"></a>00633 <span class="keyword">struct </span><a class="code" href="structftdi__context.html" title="Main context structure for all libftdi functions.">ftdi_context</a> ftdi; <a name="l00634"></a>00634 <a class="code" href="group__libftdi.html#ga21e2ed53cad4fa8242022afe1e12d2ee">ftdi_init</a>(&ftdi); <a name="l00635"></a>00635 <a class="code" href="group__libftdi.html#ga2845a0c63809747c9c7b1ea404453bc4">ftdi_usb_find_all</a>(&ftdi, &dlist, vendor, product); <a name="l00636"></a>00636 <a class="code" href="group__libftdi.html#ga72838200be98d88737d532f9eee1e7be">ftdi_deinit</a>(&ftdi); <a name="l00637"></a>00637 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classFtdi_1_1List.html#a9f005b9f8886ab85e43a2ea5b019b72d">List</a>(dlist); <a name="l00638"></a>00638 } <a name="l00639"></a>00639 <a name="l00640"></a>00640 } </pre></div></div> <hr size="1"><address style="text-align: right;"><small> Generated for libftdi by <a href="http://www.doxygen.org/ index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.6.2-20100208</small></address> </body> </html>