diff --git a/sw/airborne/arch/lpc21/mcu_periph/uart_arch.h b/sw/airborne/arch/lpc21/mcu_periph/uart_arch.h index eedd044cd63..3d25b6ac872 100644 --- a/sw/airborne/arch/lpc21/mcu_periph/uart_arch.h +++ b/sw/airborne/arch/lpc21/mcu_periph/uart_arch.h @@ -44,6 +44,7 @@ #define B100000 100000 #define B115200 115200 #define B230400 230400 +#define UART_SPEED(_def) _def #define UART_8N1 (uint8_t)(ULCR_CHAR_8 + ULCR_PAR_NO + ULCR_STOP_1) #define UART_7N1 (uint8_t)(ULCR_CHAR_7 + ULCR_PAR_NO + ULCR_STOP_1) diff --git a/sw/airborne/arch/omap/mcu_periph/uart_arch.h b/sw/airborne/arch/omap/mcu_periph/uart_arch.h index eec0d3ab0cd..3e7629ff0fc 100644 --- a/sw/airborne/arch/omap/mcu_periph/uart_arch.h +++ b/sw/airborne/arch/omap/mcu_periph/uart_arch.h @@ -31,6 +31,20 @@ // for definition of baud rates #include +// for conversion between linux baud rate definition and actual speed +#define B1200_SPEED 1200 +#define B2400_SPEED 2400 +#define B4800_SPEED 4800 +#define B9600_SPEED 9600 +#define B19200_SPEED 19200 +#define B38400_SPEED 38400 +#define B57600_SPEED 57600 +#define B100000_SPEED 100000 +#define B115200_SPEED 115200 +#define B230400_SPEED 230400 +#define B921600_SPEED 921600 +#define UART_SPEED(_def) _def##_SPEED + #define UART1_irq_handler usart1_irq_handler #define UART2_irq_handler usart2_irq_handler #define UART3_irq_handler usart3_irq_handler diff --git a/sw/airborne/arch/sim/mcu_periph/uart_arch.h b/sw/airborne/arch/sim/mcu_periph/uart_arch.h index 453ff0bf88b..098c3583737 100644 --- a/sw/airborne/arch/sim/mcu_periph/uart_arch.h +++ b/sw/airborne/arch/sim/mcu_periph/uart_arch.h @@ -38,6 +38,7 @@ extern char stdinout_buffer[STDINOUT_BUFFER_SIZE]; extern uint8_t stdinout_rx_insert_idx; extern uint8_t stdinout_rx_extract_idx; +#define UART_SPEED(_def) {} static inline bool StdInOutChAvailable(void) { struct timeval tv; diff --git a/sw/airborne/arch/stm32/mcu_periph/uart_arch.h b/sw/airborne/arch/stm32/mcu_periph/uart_arch.h index 0b8346ad872..910523b66cf 100644 --- a/sw/airborne/arch/stm32/mcu_periph/uart_arch.h +++ b/sw/airborne/arch/stm32/mcu_periph/uart_arch.h @@ -40,5 +40,6 @@ #define B115200 115200 #define B230400 230400 #define B921600 921600 +#define UART_SPEED(_def) _def #endif /* STM32_UART_ARCH_H */ diff --git a/sw/airborne/modules/gps/gps_ubx_ucenter.c b/sw/airborne/modules/gps/gps_ubx_ucenter.c index 683c855cbdb..a51c9e94e6f 100644 --- a/sw/airborne/modules/gps/gps_ubx_ucenter.c +++ b/sw/airborne/modules/gps/gps_ubx_ucenter.c @@ -297,7 +297,7 @@ static inline void gps_ubx_ucenter_config_port(void) #endif // UART Interface #if GPS_PORT_ID == GPS_PORT_UART1 || GPS_PORT_ID == GPS_PORT_UART2 - UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, UBX_GPS_BAUD, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); + UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x000008D0, UART_SPEED(UBX_GPS_BAUD), UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); #endif #if GPS_PORT_ID == GPS_PORT_USB UbxSend_CFG_PRT(GPS_PORT_ID, 0x0, 0x0, 0x0, 0, UBX_PROTO_MASK, UBX_PROTO_MASK, 0x0, 0x0); @@ -379,7 +379,7 @@ static bool_t gps_ubx_ucenter_configure(uint8_t nr) case 6: // Now the GPS baudrate should have changed GpsUartSetBaudrate(UBX_GPS_BAUD); - gps_ubx_ucenter.baud_run = UBX_GPS_BAUD; + gps_ubx_ucenter.baud_run = UART_SPEED(UBX_GPS_BAUD); gps_ubx_ucenter_config_nav(); break; case 7: