mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 03:57:45 +08:00
[telemetry] fbw datalink using generic device
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
|
FBW_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z)
|
||||||
|
FBW_AP_PORT_LOWER=$(shell echo $(AUTOPILOT_PORT) | tr A-Z a-z)
|
||||||
|
|
||||||
fbw.srcs += firmwares/fixedwing/fbw_datalink.c
|
fbw.srcs += firmwares/fixedwing/fbw_datalink.c
|
||||||
fbw.CFLAGS += -DFBW_DATALINK
|
fbw.CFLAGS += -DFBW_DATALINK
|
||||||
fbw.CFLAGS += -DMODEM_LINK=$(MODEM_PORT) -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
|
fbw.CFLAGS += -DMODEM_LINK=$(FBW_MODEM_PORT_LOWER) -DUSE_$(MODEM_PORT) -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
|
||||||
fbw.CFLAGS += -DAUTOPILOT_LINK=$(AUTOPILOT_PORT) -DUSE_$(AUTOPILOT_PORT) -D$(AUTOPILOT_PORT)_BAUD=$(MODEM_BAUD)
|
fbw.CFLAGS += -DAUTOPILOT_LINK=$(FBW_AP_PORT_LOWER) -DUSE_$(AUTOPILOT_PORT) -D$(AUTOPILOT_PORT)_BAUD=$(MODEM_BAUD)
|
||||||
|
|||||||
@@ -31,38 +31,19 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
|
|
||||||
#define __ModemLink(dev, _x) dev##_x
|
#define ModemLinkDevice (&(MODEM_LINK).device)
|
||||||
#define _ModemLink(dev, _x) __ModemLink(dev, _x)
|
#define AutopilotLinkDevice (&(AUTOPILOT_LINK).device)
|
||||||
#define ModemLink(_x) _ModemLink(MODEM_LINK, _x)
|
|
||||||
#define ModemBuffer() ModemLink(ChAvailable())
|
|
||||||
|
|
||||||
|
|
||||||
#define __AutopilotLink(dev, _x) dev##_x
|
|
||||||
#define _AutopilotLink(dev, _x) __AutopilotLink(dev, _x)
|
|
||||||
#define AutopilotLink(_x) _AutopilotLink(AUTOPILOT_LINK, _x)
|
|
||||||
|
|
||||||
#define AutopilotBuffer() AutopilotLink(ChAvailable())
|
|
||||||
|
|
||||||
static inline void autopilot_parse(char c)
|
static inline void autopilot_parse(char c)
|
||||||
{
|
{
|
||||||
ModemLink(Transmit(c));
|
ModemLinkDevice->transmit(ModemLinkDevice->periph, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void modem_parse(char c)
|
static inline void modem_parse(char c)
|
||||||
{
|
{
|
||||||
AutopilotLink(Transmit(c));
|
AutopilotLinkDevice->transmit(AutopilotLinkDevice->periph, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ReadAutopilotBuffer() { \
|
|
||||||
while (AutopilotLink(ChAvailable())) \
|
|
||||||
autopilot_parse(AutopilotLink(Getch())); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ReadModemBuffer() { \
|
|
||||||
while (ModemLink(ChAvailable())) \
|
|
||||||
modem_parse(ModemLink(Getch())); \
|
|
||||||
}
|
|
||||||
|
|
||||||
void fbw_datalink_periodic(void)
|
void fbw_datalink_periodic(void)
|
||||||
{
|
{
|
||||||
#ifdef MODEM_LINK_LED
|
#ifdef MODEM_LINK_LED
|
||||||
@@ -76,16 +57,19 @@ void fbw_datalink_periodic(void)
|
|||||||
void fbw_datalink_event(void)
|
void fbw_datalink_event(void)
|
||||||
{
|
{
|
||||||
#ifdef MODEM_LINK_LED
|
#ifdef MODEM_LINK_LED
|
||||||
if (ModemLink(ChAvailable())) {
|
if (ModemLinkDevice->char_available(ModemLinkDevice->periph)) {
|
||||||
LED_ON(MODEM_LINK_LED);
|
LED_ON(MODEM_LINK_LED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef AUTOPILOT_LINK_LED
|
#ifdef AUTOPILOT_LINK_LED
|
||||||
if (AutopilotLink(ChAvailable())) {
|
if (AutopilotLinkDevice->char_available(AutopilotLinkDevice->periph)) {
|
||||||
LED_ON(AUTOPILOT_LINK_LED);
|
LED_ON(AUTOPILOT_LINK_LED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ReadModemBuffer();
|
while (ModemLinkDevice->char_available(ModemLinkDevice->periph))
|
||||||
ReadAutopilotBuffer();
|
modem_parse(ModemLinkDevice->getchar(ModemLinkDevice->periph));
|
||||||
|
|
||||||
|
while (AutopilotLinkDevice->char_available(AutopilotLinkDevice->periph))
|
||||||
|
autopilot_parse(AutopilotLinkDevice->getchar(AutopilotLinkDevice->periph));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user