Skip to content

Commit

Permalink
[uart] fix uart speed config on linux based AP
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Jan 13, 2014
1 parent 505ad70 commit e863bf9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions sw/airborne/arch/lpc21/mcu_periph/uart_arch.h
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions sw/airborne/arch/omap/mcu_periph/uart_arch.h
Expand Up @@ -31,6 +31,20 @@
// for definition of baud rates
#include <termios.h>

// 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
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/arch/sim/mcu_periph/uart_arch.h
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/arch/stm32/mcu_periph/uart_arch.h
Expand Up @@ -40,5 +40,6 @@
#define B115200 115200
#define B230400 230400
#define B921600 921600
#define UART_SPEED(_def) _def

#endif /* STM32_UART_ARCH_H */
4 changes: 2 additions & 2 deletions sw/airborne/modules/gps/gps_ubx_ucenter.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e863bf9

Please sign in to comment.