Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lisa_overo_link.h
Go to the documentation of this file.
1 #ifndef LISA_OVERO_LINK_H
2 #define LISA_OVERO_LINK_H
3 
4 #include <inttypes.h>
5 
6 #include "fms/fms_autopilot_msg.h"
7 
9 
10 #define OVERO_LINK_TIMEOUT 10
11 
12 struct LisaOveroLink {
13  volatile uint8_t status;
16  union {
17  struct OVERO_LINK_MSG_UP msg;
18  uint8_t array[sizeof(union AutopilotMessage)];
19  } up;
20  union {
21  struct OVERO_LINK_MSG_DOWN msg;
22  uint8_t array[sizeof(union AutopilotMessage)];
23  } down;
25  /* flags used to reset hardware */
28 };
29 
30 extern struct LisaOveroLink overo_link;
31 
32 extern void overo_link_init(void);
33 extern void overo_link_periodic(void);
34 
35 /* implemented by underlying architecture code */
36 extern void overo_link_arch_init(void);
38 
39 #ifndef SITL
40 #include "lisa_overo_link_arch.h"
41 #endif
42 
43 #if 0 /* that doesn't work yet */
44 #define OveroLinkPeriodic(_timeout_handler) { \
45  if (overo_link.timeout_cnt < OVERO_LINK_TIMEOUT) \
46  overo_link.timeout_cnt++; \
47  else { \
48  if (overo_link.status != LOST && overo_link.status != DATA_AVAILABLE ) { \
49  SPI_Cmd(SPI1, DISABLE); \
50  overo_link.status = LOST; \
51  LED_OFF(OVERO_LINK_LED_OK); \
52  LED_ON(OVERO_LINK_LED_KO); \
53  overo_link.timeout = TRUE; \
54  _timeout_handler(); \
55  } \
56  } \
57  }
58 #else /* this one does */
59 #define OveroLinkPeriodic(_timeout_handler) { \
60  if (overo_link.timeout_cnt < OVERO_LINK_TIMEOUT) \
61  overo_link.timeout_cnt++; \
62  else { \
63  __disable_irq(); \
64  if (overo_link.status != LOST && overo_link.status != DATA_AVAILABLE ) { \
65  overo_link.status = LOST; \
66  __enable_irq(); \
67  LED_OFF(OVERO_LINK_LED_OK); \
68  LED_ON(OVERO_LINK_LED_KO); \
69  _timeout_handler(); \
70  } \
71  __enable_irq(); \
72  } \
73  }
74 #endif
75 
76 
77 
78 
79 
80 
81 /*
82  *
83  * Passing telemetry through Overo Link
84  *
85  */
86 
87 #ifdef USE_OVERO_LINK_TELEMETRY
88 
89 #define OVERO_LINK_TELEMETRY_BUF_SIZE 16
90 
91 extern uint8_t overo_link_telemetry_insert_idx;
92 extern uint8_t overo_link_telemetry_extract_idx;
93 extern uint8_t overo_link_telemetry_buf[OVERO_LINK_TELEMETRY_BUF_SIZE];
94 
95 #define OveroLinkTelemetryCheckFreeSpace(_x) (TRUE)
96 #define OveroLinkTelemetryTransmit(_x) { \
97  uint16_t temp = (overo_link_telemetry_insert_idx + 1) % OVERO_LINK_TELEMETRY_BUF_SIZE; \
98  if (temp != overo_link_telemetry_extract_idx) { /* we have room */ \
99  overo_link_telemetry_buf[overo_link_telemetry_insert_idx] = _x; \
100  overo_link_telemetry_insert_idx = temp; \
101  } \
102  }
103 #define OveroLinkTelemetrySendMessage() {}
104 
105 extern uint8_t overo_link_telemetry_get(char* buf, int len);
106 
107 #endif /* USE_OVERO_LINK_TELEMETRY */
108 
109 #endif /* LISA_OVERO_LINK_H */
110 
111 
112 
unsigned long uint32_t
Definition: types.h:18
unsigned char uint8_t
Definition: types.h:14