return rtn;
}
-/**
- ftdi_convert_baudrate returns nearest supported baud rate to that requested.
+/* ftdi_to_clkbits_AM For the AM device, convert a requested baudrate
+ to encoded divisor and the achievable baudrate
Function is only used internally
\internal
+
+ See AN120
+ clk/1 -> 0
+ clk/1.5 -> 1
+ clk/2 -> 2
+ From /2, 0.125/ 0.25 and 0.5 steps may be taken
+ The fractional part has frac_code encoding
*/
-static int ftdi_convert_baudrate(int baudrate, struct ftdi_context *ftdi,
- unsigned short *value, unsigned short *index)
+static int ftdi_to_clkbits_AM(int baudrate, unsigned long *encoded_divisor)
+
{
+ static const char frac_code[8] = {0, 3, 2, 4, 1, 5, 6, 7};
static const char am_adjust_up[8] = {0, 0, 0, 1, 0, 3, 2, 1};
static const char am_adjust_dn[8] = {0, 0, 0, 1, 0, 1, 2, 3};
- static const char frac_code[8] = {0, 3, 2, 4, 1, 5, 6, 7};
int divisor, best_divisor, best_baud, best_baud_diff;
- unsigned long encoded_divisor;
- int i;
-
- if (baudrate <= 0)
- {
- // Return error
- return -1;
- }
-
divisor = 24000000 / baudrate;
+ int i;
- if (ftdi->type == TYPE_AM)
- {
- // Round down to supported fraction (AM only)
- divisor -= am_adjust_dn[divisor & 7];
- }
+ // Round down to supported fraction (AM only)
+ divisor -= am_adjust_dn[divisor & 7];
// Try this divisor and the one above it (because division rounds down)
best_divisor = 0;
// Round up to minimum supported divisor
try_divisor = 8;
}
- else if (ftdi->type != TYPE_AM && try_divisor < 12)
- {
- // BM doesn't support divisors 9 through 11 inclusive
- try_divisor = 12;
- }
else if (divisor < 16)
{
// AM doesn't support divisors 9 through 15 inclusive
}
else
{
- if (ftdi->type == TYPE_AM)
- {
- // Round up to supported fraction (AM only)
- try_divisor += am_adjust_up[try_divisor & 7];
- if (try_divisor > 0x1FFF8)
- {
- // Round down to maximum supported divisor value (for AM)
- try_divisor = 0x1FFF8;
- }
- }
- else
+ // Round up to supported fraction (AM only)
+ try_divisor += am_adjust_up[try_divisor & 7];
+ if (try_divisor > 0x1FFF8)
{
- if (try_divisor > 0x1FFFF)
- {
- // Round down to maximum supported divisor value (for BM)
- try_divisor = 0x1FFFF;
- }
+ // Round down to maximum supported divisor value (for AM)
+ try_divisor = 0x1FFF8;
}
}
// Get estimated baud rate (to nearest integer)
}
}
// Encode the best divisor value
- encoded_divisor = (best_divisor >> 3) | (frac_code[best_divisor & 7] << 14);
+ *encoded_divisor = (best_divisor >> 3) | (frac_code[best_divisor & 7] << 14);
// Deal with special cases for encoded value
- if (encoded_divisor == 1)
+ if (*encoded_divisor == 1)
+ {
+ *encoded_divisor = 0; // 3000000 baud
+ }
+ else if (*encoded_divisor == 0x4001)
{
- encoded_divisor = 0; // 3000000 baud
+ *encoded_divisor = 1; // 2000000 baud (BM only)
}
- else if (encoded_divisor == 0x4001)
+ return best_baud;
+}
+
+/* ftdi_to_clkbits Convert a requested baudrate for a given system clock and predivisor
+ to encoded divisor and the achievable baudrate
+ Function is only used internally
+ \internal
+
+ See AN120
+ clk/1 -> 0
+ clk/1.5 -> 1
+ clk/2 -> 2
+ From /2, 0.125 steps may be taken.
+ The fractional part has frac_code encoding
+
+ value[13:0] of value is the divisor
+ index[9] mean 12 MHz Base(120 MHz/10) rate versus 3 MHz (48 MHz/16) else
+
+ H Type have all features above with
+ {index[8],value[15:14]} is the encoded subdivisor
+
+ FT232R, FT2232 and FT232BM have no option for 12 MHz and with
+ {index[0],value[15:14]} is the encoded subdivisor
+
+ AM Type chips have only four fractional subdivisors at value[15:14]
+ for subdivisors 0, 0.5, 0.25, 0.125
+*/
+static int ftdi_to_clkbits(int baudrate, unsigned int clk, int clk_div, unsigned long *encoded_divisor)
+{
+ static const char frac_code[8] = {0, 3, 2, 4, 1, 5, 6, 7};
+ int best_baud = 0;
+ int divisor, best_divisor;
+ if (baudrate >= clk/clk_div)
+ {
+ *encoded_divisor = 0;
+ best_baud = clk/clk_div;
+ }
+ else if (baudrate >= clk/(clk_div + clk_div/2))
+ {
+ *encoded_divisor = 1;
+ best_baud = clk/(clk_div + clk_div/2);
+ }
+ else if (baudrate >= clk/(2*clk_div))
+ {
+ *encoded_divisor = 2;
+ best_baud = clk/(2*clk_div);
+ }
+ else
+ {
+ /* We divide by 16 to have 3 fractional bits and one bit for rounding */
+ divisor = clk*16/clk_div / baudrate;
+ if (divisor & 1) /* Decide if to round up or down*/
+ best_divisor = divisor /2 +1;
+ else
+ best_divisor = divisor/2;
+ if(best_divisor > 0x20000)
+ best_divisor = 0x1ffff;
+ best_baud = clk*16/clk_div/best_divisor;
+ if (best_baud & 1) /* Decide if to round up or down*/
+ best_baud = best_baud /2 +1;
+ else
+ best_baud = best_baud /2;
+ *encoded_divisor = (best_divisor >> 3) | (frac_code[best_divisor & 0x7] << 14);
+ }
+ return best_baud;
+}
+/**
+ ftdi_convert_baudrate returns nearest supported baud rate to that requested.
+ Function is only used internally
+ \internal
+*/
+static int ftdi_convert_baudrate(int baudrate, struct ftdi_context *ftdi,
+ unsigned short *value, unsigned short *index)
+{
+ int best_baud;
+ unsigned long encoded_divisor;
+
+ if (baudrate <= 0)
+ {
+ // Return error
+ return -1;
+ }
+
+#define H_CLK 120000000
+#define C_CLK 48000000
+ if ((ftdi->type == TYPE_2232H) || (ftdi->type == TYPE_4232H) || (ftdi->type == TYPE_232H ))
+ {
+ if(baudrate*10 > H_CLK /0x3fff)
+ {
+ /* On H Devices, use 12 000 000 Baudrate when possible
+ We have a 14 bit divisor, a 1 bit divisor switch (10 or 16)
+ three fractional bits and a 120 MHz clock
+ Assume AN_120 "Sub-integer divisors between 0 and 2 are not allowed" holds for
+ DIV/10 CLK too, so /1, /1.5 and /2 can be handled the same*/
+ best_baud = ftdi_to_clkbits(baudrate, H_CLK, 10, &encoded_divisor);
+ encoded_divisor |= 0x20000; /* switch on CLK/10*/
+ }
+ else
+ best_baud = ftdi_to_clkbits(baudrate, C_CLK, 16, &encoded_divisor);
+ }
+ else if ((ftdi->type == TYPE_BM) || (ftdi->type == TYPE_2232C) || (ftdi->type == TYPE_R ))
+ {
+ best_baud = ftdi_to_clkbits(baudrate, C_CLK, 16, &encoded_divisor);
+ }
+ else
{
- encoded_divisor = 1; // 2000000 baud (BM only)
+ best_baud = ftdi_to_clkbits_AM(baudrate, &encoded_divisor);
}
// Split into "value" and "index" values
*value = (unsigned short)(encoded_divisor & 0xFFFF);
- if (ftdi->type == TYPE_2232C || ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type == TYPE_232H )
+ if (ftdi->type == TYPE_2232H ||
+ ftdi->type == TYPE_4232H || ftdi->type == TYPE_232H )
{
*index = (unsigned short)(encoded_divisor >> 8);
*index &= 0xFF00;
/**@file
@brief Test baudrate calculator code
-@author Thomas Jarosch
+@author Thomas Jarosch and Uwe Bonnes
*/
/***************************************************************************
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp>
+#include <vector>
#include <map>
+#include <math.h>
using namespace std;
ftdi = ftdi_new();
}
- ~BaseFTDIFixture()
+ virtual ~BaseFTDIFixture()
{
delete ftdi;
ftdi = NULL;
struct calc_result
{
int actual_baudrate;
- unsigned short expected_value;
- unsigned short expected_index;
+ unsigned short divisor;
+ unsigned short fractional_bits;
+ unsigned short clock;
- calc_result(int actual, int my_value, int my_index)
+ calc_result(int actual, unsigned short my_divisor, unsigned short my_fractional_bits, unsigned short my_clock)
: actual_baudrate(actual)
- , expected_value(my_value)
- , expected_index(my_index)
+ , divisor(my_divisor)
+ , fractional_bits(my_fractional_bits)
+ , clock(my_clock)
{
}
calc_result()
: actual_baudrate(0)
- , expected_value(0)
- , expected_index(0)
+ , divisor(0)
+ , fractional_bits(0)
+ , clock(0)
{
}
};
const calc_result *res = &baudrate.second;
+ unsigned short divisor = calc_value & 0x3fff;
+ unsigned short fractional_bits = (calc_value >> 14);
+ unsigned short clock = (calc_index & 0x200) ? 120 : 48;
+
+ switch (ftdi->type)
+ {
+ case TYPE_232H:
+ case TYPE_2232H:
+ case TYPE_4232H:
+ fractional_bits |= (calc_index & 0x100) ? 4 : 0;
+ break;
+ case TYPE_R:
+ case TYPE_2232C:
+ case TYPE_BM:
+ fractional_bits |= (calc_index & 0x001) ? 4 : 0;
+ break;
+ default:;
+ }
+
// Aid debugging since this test is a generic function
- BOOST_CHECK_MESSAGE(res->actual_baudrate == calc_baudrate && res->expected_value == calc_value && res->expected_index == calc_index,
+ BOOST_CHECK_MESSAGE(res->actual_baudrate == calc_baudrate && res->divisor == divisor && res->fractional_bits == fractional_bits
+ && res->clock == clock,
"\n\nERROR: baudrate calculation failed for --" << baudrate.first << " baud--. Details below: ");
BOOST_CHECK_EQUAL(res->actual_baudrate, calc_baudrate);
- BOOST_CHECK_EQUAL(res->expected_value, calc_value);
- BOOST_CHECK_EQUAL(res->expected_index, calc_index);
+ BOOST_CHECK_EQUAL(res->divisor, divisor);
+ BOOST_CHECK_EQUAL(res->fractional_bits, fractional_bits);
+ BOOST_CHECK_EQUAL(res->clock, clock);
}
}
ftdi->type = TYPE_AM;
map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 0);
- baudrates[600] = calc_result(600, 5000, 0);
- baudrates[600] = calc_result(600, 5000, 0);
- baudrates[1200] = calc_result(1200, 2500, 0);
- baudrates[2400] = calc_result(2400, 1250, 0);
- baudrates[4800] = calc_result(4800, 625, 0);
- baudrates[9600] = calc_result(9600, 16696, 0);
- baudrates[19200] = calc_result(19200, 32924, 0);
- baudrates[38400] = calc_result(38400, 49230, 0);
- baudrates[57600] = calc_result(57554, 49204, 0);
- baudrates[115200] = calc_result(115385, 26, 0);
- baudrates[230400] = calc_result(230769, 13, 0);
- baudrates[460800] = calc_result(461538, 16390, 0);
- baudrates[921600] = calc_result(923077, 32771, 0);
+ baudrates[183] = calc_result(183, 16383, 0, 48);
+ baudrates[300] = calc_result(300, 10000, 0, 48);
+ baudrates[600] = calc_result(600, 5000, 0, 48);
+ baudrates[1200] = calc_result(1200, 2500, 0, 48);
+ baudrates[2400] = calc_result(2400, 1250, 0, 48);
+ baudrates[4800] = calc_result(4800, 625, 0, 48);
+ baudrates[9600] = calc_result(9600, 312, 1, 48);
+ baudrates[19200] = calc_result(19200, 156, 2, 48);
+ baudrates[38400] = calc_result(38400, 78, 3, 48);
+ baudrates[57600] = calc_result(57554, 52, 3, 48);
+ baudrates[115200] = calc_result(115385, 26, 0, 48);
+ baudrates[230400] = calc_result(230769, 13, 0, 48);
+ baudrates[460800] = calc_result(461538, 6, 1, 48);
+ baudrates[921600] = calc_result(923077, 3, 2, 48);
+ baudrates[1000000] = calc_result(1000000, 3, 0, 48);
+ baudrates[1090512] = calc_result(1000000, 3, 0, 48);
+ baudrates[1090909] = calc_result(1000000, 3, 0, 48);
+ baudrates[1090910] = calc_result(1000000, 3, 0, 48);
+ baudrates[1200000] = calc_result(1200000, 2, 1, 48);
+ baudrates[1333333] = calc_result(1333333, 2, 2, 48);
+ baudrates[1411764] = calc_result(1411765, 2, 3, 48);
+ baudrates[1500000] = calc_result(1500000, 2, 0, 48);
+ baudrates[2000000] = calc_result(1500000, 2, 0, 48);
+ baudrates[3000000] = calc_result(3000000, 0, 0, 48);
test_baudrates(ftdi, baudrates);
}
BOOST_AUTO_TEST_CASE(TypeBMFixedBaudrates)
{
- ftdi->type = TYPE_BM;
-
- map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 0);
- baudrates[600] = calc_result(600, 5000, 0);
- baudrates[600] = calc_result(600, 5000, 0);
- baudrates[1200] = calc_result(1200, 2500, 0);
- baudrates[2400] = calc_result(2400, 1250, 0);
- baudrates[4800] = calc_result(4800, 625, 0);
- baudrates[9600] = calc_result(9600, 16696, 0);
- baudrates[19200] = calc_result(19200, 32924, 0);
- baudrates[38400] = calc_result(38400, 49230, 0);
- baudrates[57600] = calc_result(57554, 49204, 0);
- baudrates[115200] = calc_result(115385, 26, 0);
- baudrates[230400] = calc_result(230769, 13, 0);
- baudrates[460800] = calc_result(461538, 16390, 0);
- baudrates[921600] = calc_result(923077, 32771, 0);
-
- test_baudrates(ftdi, baudrates);
-}
-
-BOOST_AUTO_TEST_CASE(Type2232CFixedBaudrates)
-{
- ftdi->type = TYPE_2232C;
+ // Unify testing of chips behaving the same
+ std::vector<enum ftdi_chip_type> test_types;
+ test_types.push_back(TYPE_BM);
+ test_types.push_back(TYPE_2232C);
+ test_types.push_back(TYPE_R);
map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[1200] = calc_result(1200, 2500, 1);
- baudrates[2400] = calc_result(2400, 1250, 1);
- baudrates[4800] = calc_result(4800, 625, 1);
- baudrates[9600] = calc_result(9600, 16696, 1);
- baudrates[19200] = calc_result(19200, 32924, 1);
- baudrates[38400] = calc_result(38400, 49230, 1);
- baudrates[57600] = calc_result(57554, 49204, 1);
- baudrates[115200] = calc_result(115385, 26, 1);
- baudrates[230400] = calc_result(230769, 13, 1);
- baudrates[460800] = calc_result(461538, 16390, 1);
- baudrates[921600] = calc_result(923077, 32771, 1);
-
- test_baudrates(ftdi, baudrates);
-}
-
-BOOST_AUTO_TEST_CASE(TypeRFixedBaudrates)
-{
- ftdi->type = TYPE_R;
-
- map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 0);
- baudrates[600] = calc_result(600, 5000, 0);
- baudrates[600] = calc_result(600, 5000, 0);
- baudrates[1200] = calc_result(1200, 2500, 0);
- baudrates[2400] = calc_result(2400, 1250, 0);
- baudrates[4800] = calc_result(4800, 625, 0);
- baudrates[9600] = calc_result(9600, 16696, 0);
- baudrates[19200] = calc_result(19200, 32924, 0);
- baudrates[38400] = calc_result(38400, 49230, 0);
- baudrates[57600] = calc_result(57554, 49204, 0);
- baudrates[115200] = calc_result(115385, 26, 0);
- baudrates[230400] = calc_result(230769, 13, 0);
- baudrates[460800] = calc_result(461538, 16390, 0);
- baudrates[921600] = calc_result(923077, 32771, 0);
-
- test_baudrates(ftdi, baudrates);
-}
-
-BOOST_AUTO_TEST_CASE(Type2232HFixedBaudrates)
-{
- ftdi->type = TYPE_2232H;
-
- map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[1200] = calc_result(1200, 2500, 1);
- baudrates[2400] = calc_result(2400, 1250, 1);
- baudrates[4800] = calc_result(4800, 625, 1);
- baudrates[9600] = calc_result(9600, 16696, 1);
- baudrates[19200] = calc_result(19200, 32924, 1);
- baudrates[38400] = calc_result(38400, 49230, 1);
- baudrates[57600] = calc_result(57554, 49204, 1);
- baudrates[115200] = calc_result(115385, 26, 1);
- baudrates[230400] = calc_result(230769, 13, 1);
- baudrates[460800] = calc_result(461538, 16390, 1);
- baudrates[921600] = calc_result(923077, 32771, 1);
-
- test_baudrates(ftdi, baudrates);
-}
-
-BOOST_AUTO_TEST_CASE(Type4232HFixedBaudrates)
-{
- ftdi->type = TYPE_4232H;
-
- map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[1200] = calc_result(1200, 2500, 1);
- baudrates[2400] = calc_result(2400, 1250, 1);
- baudrates[4800] = calc_result(4800, 625, 1);
- baudrates[9600] = calc_result(9600, 16696, 1);
- baudrates[19200] = calc_result(19200, 32924, 1);
- baudrates[38400] = calc_result(38400, 49230, 1);
- baudrates[57600] = calc_result(57554, 49204, 1);
- baudrates[115200] = calc_result(115385, 26, 1);
- baudrates[230400] = calc_result(230769, 13, 1);
- baudrates[460800] = calc_result(461538, 16390, 1);
- baudrates[921600] = calc_result(923077, 32771, 1);
-
- test_baudrates(ftdi, baudrates);
+ baudrates[183] = calc_result(183, 16383, 7, 48);
+ baudrates[184] = calc_result(184, 16304, 4, 48);
+ baudrates[300] = calc_result(300, 10000, 0, 48);
+ baudrates[600] = calc_result(600, 5000, 0, 48);
+ baudrates[1200] = calc_result(1200, 2500, 0, 48);
+ baudrates[2400] = calc_result(2400, 1250, 0, 48);
+ baudrates[4800] = calc_result(4800, 625, 0, 48);
+ baudrates[9600] = calc_result(9600, 312, 1, 48);
+ baudrates[19200] = calc_result(19200, 156, 2, 48);
+ baudrates[38400] = calc_result(38400, 78, 3, 48);
+ baudrates[57600] = calc_result(57554, 52, 3, 48);
+ baudrates[115200] = calc_result(115385, 26, 0, 48);
+ baudrates[230400] = calc_result(230769, 13, 0, 48);
+ baudrates[460800] = calc_result(461538, 6, 1, 48);
+ baudrates[921600] = calc_result(923077, 3, 2, 48);
+ baudrates[1000000] = calc_result(1000000, 3, 0, 48);
+ baudrates[1050000] = calc_result(1043478, 2, 7, 48);
+ baudrates[1400000] = calc_result(1411765, 2, 3, 48);
+ baudrates[1500000] = calc_result(1500000, 2, 0, 48);
+ baudrates[2000000] = calc_result(2000000, 1, 0, 48);
+ baudrates[3000000] = calc_result(3000000, 0, 0, 48);
+
+ baudrates[(3000000*16/(2*16+15))-1] = calc_result(round(3000000/3.000), 3, 0, 48);
+ baudrates[ 3000000*16/(2*16+15) ] = calc_result(round(3000000/3.000), 3, 0, 48);
+ baudrates[(3000000*16/(2*16+15))+1] = calc_result(round(3000000/2.875), 2, 7, 48);
+ baudrates[ 3000000*16/(2*16+13) ] = calc_result(round(3000000/2.875), 2, 7, 48);
+ baudrates[(3000000*16/(2*16+13))+1] = calc_result(round(3000000/2.750), 2, 6, 48);
+ baudrates[ 3000000*16/(2*16+11) ] = calc_result(round(3000000/2.750), 2, 6, 48);
+ baudrates[(3000000*16/(2*16+11))+1] = calc_result(round(3000000/2.625), 2, 5, 48);
+ baudrates[ 3000000*16/(2*16+ 9) ] = calc_result(round(3000000/2.625), 2, 5, 48);
+ baudrates[(3000000*16/(2*16+ 9))+1] = calc_result(round(3000000/2.500), 2, 1, 48);
+ baudrates[ 3000000*16/(2*16+ 7) ] = calc_result(round(3000000/2.500), 2, 1, 48);
+ baudrates[(3000000*16/(2*16+ 7))+1] = calc_result(round(3000000/2.375), 2, 4, 48);
+ baudrates[ 3000000*16/(2*16+ 5) ] = calc_result(round(3000000/2.375), 2, 4, 48);
+ baudrates[(3000000*16/(2*16+ 5))+1] = calc_result(round(3000000/2.250), 2, 2, 48);
+ baudrates[ 3000000*16/(2*16+ 3) ] = calc_result(round(3000000/2.250), 2, 2, 48);
+ baudrates[(3000000*16/(2*16+ 3))+1] = calc_result(round(3000000/2.125), 2, 3, 48);
+ baudrates[ 3000000*16/(2*16+ 1) ] = calc_result(round(3000000/2.125), 2, 3, 48);
+ baudrates[(3000000*16/(2*16+ 1))+1] = calc_result(round(3000000/2.000), 2, 0, 48);
+
+ BOOST_FOREACH(const enum ftdi_chip_type &test_chip_type, test_types)
+ {
+ ftdi->type = test_chip_type;
+ test_baudrates(ftdi, baudrates);
+ }
}
-BOOST_AUTO_TEST_CASE(Type232HFixedBaudrates)
+BOOST_AUTO_TEST_CASE(TypeHFixedBaudrates)
{
- ftdi->type = TYPE_232H;
+ // Unify testing of chips behaving the same
+ std::vector<enum ftdi_chip_type> test_types;
+ test_types.push_back(TYPE_2232H);
+ test_types.push_back(TYPE_4232H);
+ test_types.push_back(TYPE_232H);
map<int, calc_result> baudrates;
- baudrates[300] = calc_result(300, 10000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[600] = calc_result(600, 5000, 1);
- baudrates[1200] = calc_result(1200, 2500, 1);
- baudrates[2400] = calc_result(2400, 1250, 1);
- baudrates[4800] = calc_result(4800, 625, 1);
- baudrates[9600] = calc_result(9600, 16696, 1);
- baudrates[19200] = calc_result(19200, 32924, 1);
- baudrates[38400] = calc_result(38400, 49230, 1);
- baudrates[57600] = calc_result(57554, 49204, 1);
- baudrates[115200] = calc_result(115385, 26, 1);
- baudrates[230400] = calc_result(230769, 13, 1);
- baudrates[460800] = calc_result(461538, 16390, 1);
- baudrates[921600] = calc_result(923077, 32771, 1);
-
- test_baudrates(ftdi, baudrates);
+ baudrates[183] = calc_result(183, 16383, 7, 48);
+ baudrates[184] = calc_result(184, 16304, 4, 48);
+ baudrates[300] = calc_result(300, 10000, 0, 48);
+ baudrates[600] = calc_result(600, 5000, 0, 48);
+ baudrates[1200] = calc_result(1200, 10000, 0, 120);
+ baudrates[2400] = calc_result(2400, 5000, 0, 120);
+ baudrates[4800] = calc_result(4800, 2500, 0, 120);
+ baudrates[9600] = calc_result(9600, 1250, 0, 120);
+ baudrates[19200] = calc_result(19200, 625, 0, 120);
+ baudrates[38400] = calc_result(38400, 312, 1, 120);
+ baudrates[57600] = calc_result(57588, 208, 4, 120);
+ baudrates[115200] = calc_result(115246, 104, 3, 120);
+ baudrates[230400] = calc_result(230216, 52, 3, 120);
+ baudrates[460800] = calc_result(461538, 26, 0, 120);
+ baudrates[921600] = calc_result(923077, 13, 0, 120);
+ baudrates[1000000] = calc_result(1000000, 12, 0, 120);
+ baudrates[1000000] = calc_result(1000000, 12, 0, 120);
+ baudrates[6000000] = calc_result(6000000, 2, 0, 120);
+ baudrates[4173913] = calc_result(4173913, 2, 7, 120);
+ baudrates[8000000] = calc_result(8000000, 1, 0, 120);
+ baudrates[12000000] = calc_result(12000000, 0, 0, 120);
+
+ baudrates[(12000000*16/(2*16+15))-1] = calc_result(round(12000000/3.000), 3, 0, 120);
+ baudrates[ 12000000*16/(2*16+15) ] = calc_result(round(12000000/3.000), 3, 0, 120);
+ baudrates[(12000000*16/(2*16+15))+1] = calc_result(round(12000000/2.875), 2, 7, 120);
+ baudrates[ 12000000*16/(2*16+13) ] = calc_result(round(12000000/2.875), 2, 7, 120);
+ baudrates[(12000000*16/(2*16+13))+1] = calc_result(round(12000000/2.750), 2, 6, 120);
+ baudrates[ 12000000*16/(2*16+11) ] = calc_result(round(12000000/2.750), 2, 6, 120);
+ baudrates[(12000000*16/(2*16+11))+1] = calc_result(round(12000000/2.625), 2, 5, 120);
+ baudrates[ 12000000*16/(2*16+ 9) ] = calc_result(round(12000000/2.625), 2, 5, 120);
+ baudrates[(12000000*16/(2*16+ 9))+1] = calc_result(round(12000000/2.500), 2, 1, 120);
+ baudrates[ 12000000*16/(2*16+ 7) ] = calc_result(round(12000000/2.500), 2, 1, 120);
+ baudrates[(12000000*16/(2*16+ 7))+1] = calc_result(round(12000000/2.375), 2, 4, 120);
+ baudrates[ 12000000*16/(2*16+ 5) ] = calc_result(round(12000000/2.375), 2, 4, 120);
+ baudrates[(12000000*16/(2*16+ 5))+1] = calc_result(round(12000000/2.250), 2, 2, 120);
+ baudrates[ 12000000*16/(2*16+ 3) ] = calc_result(round(12000000/2.250), 2, 2, 120);
+ baudrates[(12000000*16/(2*16+ 3))+1] = calc_result(round(12000000/2.125), 2, 3, 120);
+ baudrates[ 12000000*16/(2*16+ 1) ] = calc_result(round(12000000/2.125), 2, 3, 120);
+ baudrates[(12000000*16/(2*16+ 1))+1] = calc_result(round(12000000/2.000), 2, 0, 120);
+
+ BOOST_FOREACH(const enum ftdi_chip_type &test_chip_type, test_types)
+ {
+ ftdi->type = test_chip_type;
+ test_baudrates(ftdi, baudrates);
+ }
}
BOOST_AUTO_TEST_SUITE_END()