X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=test%2Fbaudrate.cpp;fp=test%2Fbaudrate.cpp;h=7ce2e9a50307fa251dd972ba107b2b4381bbb68f;hp=0d2e0b85b3653127f97f8456928c8035ccb3096b;hb=9956d4289d04f1c67a8738a7b8b32e1345ab0968;hpb=3db4042e16d398b8803a236d2735df99e76bea27 diff --git a/test/baudrate.cpp b/test/baudrate.cpp index 0d2e0b8..7ce2e9a 100644 --- a/test/baudrate.cpp +++ b/test/baudrate.cpp @@ -87,10 +87,24 @@ static void test_baudrates(ftdi_context *ftdi, const map &baud const calc_result *res = &baudrate.second; - unsigned short divisor = calc_value & 0x3ff; - unsigned short fractional_bits = (calc_index & 0x100) ? 4 : (calc_value >> 12); - unsigned short clock = (calc_index & 0x100) ? 120 : 48; - + 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->divisor == divisor && res->fractional_bits == fractional_bits && res->clock == clock,