Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ---=== Winbase.h ===---
- #define CBR_110 0xFF10
- #define CBR_300 0xFF11
- #define CBR_600 0xFF12
- #define CBR_1200 0xFF13
- #define CBR_2400 0xFF14
- #define CBR_4800 0xFF15
- #define CBR_9600 0xFF16
- #define CBR_14400 0xFF17
- #define CBR_19200 0xFF18
- #define CBR_38400 0xFF1B
- #define CBR_56000 0xFF1F
- #define CBR_57600 0xFF20
- #define CBR_115200 0xFF21
- #define CBR_128000 0xFF23
- #define CBR_256000 0xFF27
- // ---=== ===---
- // ---=== http://fenrir.naruoka.org/download/autopilot/common/util/comstream.h ===---
- typedef struct speedmap_e
- {
- uint32_t baudrate;
- uint32_t cbr;
- } speedmap_t;
- // Associate a meaningful # with a meaningless Windows constant.
- static const speedmap_t speed_map[] =
- {
- { 110, CBR_110 },
- { 300, CBR_300 },
- { 600, CBR_600 },
- { 1200, CBR_1200 },
- { 2400, CBR_2400 },
- { 4800, CBR_4800 },
- { 9600, CBR_9600 },
- { 14400, CBR_14400 },
- { 19200, CBR_19200 },
- { 38400, CBR_38400 },
- { 56000, CBR_56000 },
- { 57600, CBR_57600 },
- { 115200, CBR_115200 },
- { 128000, CBR_128000 },
- { 256000, CBR_256000 },
- };
- static uint32_t baud_to_cbr(uint32_t baudrate)
- {
- uint32_t i;
- for(i = 0; i < sizeof(speed_map) / sizeof(speed_map[0]); i++)
- if(speed_map[i].baudrate == baudrate)
- return speed_map[i].cbr;
- return 0; // Error condition -- cound not find baudrate in table
- }
- static uint32_t cbr_to_baud(uint32_t cbr)
- {
- uint32_t i;
- for(i = 0; i < sizeof(speed_map) / sizeof(speed_map[0]); i++)
- if(speed_map[i].cbr == cbr)
- return speed_map[i].baudrate;
- return 0; // Error condition -- cound not find CBR_* value in table
- }
- // ---=== ===---
Advertisement
Add Comment
Please, Sign In to add comment