[inter_mcu] update inter_mcu to use uart directly

This commit is contained in:
Gautier Hattenberger
2015-03-16 22:17:31 +01:00
parent 7c22708ca7
commit 079e5d8956
2 changed files with 12 additions and 14 deletions
@@ -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)
+8 -12
View File
@@ -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;