Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
fbw_datalink.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Christophe De Wagter
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
30 #include "mcu_periph/uart.h"
31 #include "led.h"
32 
33 
34 #define ModemLinkDevice (&(MODEM_LINK).device)
35 #define AutopilotLinkDevice (&(AUTOPILOT_LINK).device)
36 
37 static inline void autopilot_parse(char c)
38 {
39  ModemLinkDevice->put_byte(ModemLinkDevice->periph, 0, c);
40 }
41 
42 static inline void modem_parse(char c)
43 {
44  AutopilotLinkDevice->put_byte(AutopilotLinkDevice->periph, 0, c);
45 }
46 
48 {
49 #ifdef MODEM_LINK_LED
50  LED_OFF(MODEM_LINK_LED);
51 #endif
52 #ifdef AUTOPILOT_LINK_LED
53  LED_OFF(AUTOPILOT_LINK_LED);
54 #endif
55 }
56 
58 {
59 #ifdef MODEM_LINK_LED
60  if (ModemLinkDevice->char_available(ModemLinkDevice->periph)) {
61  LED_ON(MODEM_LINK_LED);
62  }
63 #endif
64 #ifdef AUTOPILOT_LINK_LED
65  if (AutopilotLinkDevice->char_available(AutopilotLinkDevice->periph)) {
66  LED_ON(AUTOPILOT_LINK_LED);
67  }
68 #endif
69 
70  while (ModemLinkDevice->char_available(ModemLinkDevice->periph))
71  modem_parse(ModemLinkDevice->get_byte(ModemLinkDevice->periph));
72 
73  while (AutopilotLinkDevice->char_available(AutopilotLinkDevice->periph))
75 }
#define LED_ON(i)
Definition: led_hw.h:51
#define LED_OFF(i)
Definition: led_hw.h:52
arch independent LED (Light Emitting Diodes) API
arch independent UART (Universal Asynchronous Receiver/Transmitter) API