diff --git a/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile b/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile index 0430a139cb..a904dfd32f 100644 --- a/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile +++ b/conf/firmwares/subsystems/fixedwing/intermcu_uart.makefile @@ -10,13 +10,15 @@ endif ifeq ($(TARGET),fbw) ifeq ($(INTERMCU_PORT),none) INTERMCU_PORT = UART2 + INTERMCU_PORT_LOWER = $(shell echo $(INTERMCU_PORT) | tr A-Z a-z) endif - fbw.CFLAGS += -DINTERMCU_LINK=$(INTERMCU_PORT) -DUSE_$(INTERMCU_PORT) -D$(INTERMCU_PORT)_BAUD=B57600 + fbw.CFLAGS += -DINTERMCU_LINK=$(INTERMCU_PORT_LOWER) -DUSE_$(INTERMCU_PORT) -D$(INTERMCU_PORT)_BAUD=B57600 else ifeq ($(INTERMCU_PORT),none) INTERMCU_PORT = UART5 + INTERMCU_PORT_LOWER = $(shell echo $(INTERMCU_PORT) | tr A-Z a-z) endif - ap.CFLAGS += -DINTERMCU_LINK=$(INTERMCU_PORT) -DUSE_$(INTERMCU_PORT) -D$(INTERMCU_PORT)_BAUD=B57600 + ap.CFLAGS += -DINTERMCU_LINK=$(INTERMCU_PORT_LOWER) -DUSE_$(INTERMCU_PORT) -D$(INTERMCU_PORT)_BAUD=B57600 endif ifneq ($(TARGET),sim) diff --git a/sw/airborne/link_mcu_usart.c b/sw/airborne/link_mcu_usart.c index d4a212be14..c42f03537a 100644 --- a/sw/airborne/link_mcu_usart.c +++ b/sw/airborne/link_mcu_usart.c @@ -29,16 +29,12 @@ ////////////////////////////////////////////////////////////////////////////////////////////// // LINK -#define __InterMcuLink(dev, _x) dev##_x -#define _InterMcuLink(dev, _x) __InterMcuLink(dev, _x) -#define InterMcuLink(_x) _InterMcuLink(INTERMCU_LINK, _x) - -#define InterMcuBuffer() InterMcuLink(ChAvailable()) - -#define InterMcuUartSend1(c) InterMcuLink(Transmit(c)) -#define InterMcuUartSetBaudrate(_a) InterMcuLink(SetBaudrate(_a)) -#define InterMcuUartRunning InterMcuLink(TxRunning) -#define InterMcuUartSendMessage InterMcuLink(SendMessage) +// Use uart interface directly +#define InterMcuBuffer() uart_char_available(&(INTERMCU_LINK)) +#define InterMcuUartSend1(c) uart_transmit(&(INTERMCU_LINK), c) +#define InterMcuUartSetBaudrate(_a) uart_periph_set_baudrate(&(INTERMCU_LINK), _a) +#define InterMcuUartSendMessage() {} +#define InterMcuUartGetch() uart_getch(&(INTERMCU_LINK)) ////////////////////////////////////////////////////////////////////////////////////////////// // PROTOCOL @@ -379,8 +375,8 @@ void link_mcu_event_task(void) { /* A message has been received */ if (InterMcuBuffer()) { - while (InterMcuLink(ChAvailable())) { - intermcu_parse(InterMcuLink(Getch())); + while (InterMcuBuffer()) { + intermcu_parse(InterMcuUartGetch()); if (intermcu_data.msg_available) { parse_mavpilot_msg(); intermcu_data.msg_available = FALSE;