dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
flyingpio_messages.h
Go to the documentation of this file.
1 #define FPPROTO_MAX_SERVOS 16
2 #define FPPROTO_MAX_BANKS 4
3 #define FPPROTO_MAX_RCCHANS 10
4 #define FPPROTO_MAX_ADCCHANS 4
5 
6 /* 34 bytes */
7 
8 #define FLYINGPICMD_ACTUATOR 0xfc
9 #define FLYINGPICMD_CFG 0xfa
10 #define FLYINGPIRESP_IO 0x10
11 
13  /* fractional values; 0 = min, 0xffff = max */
15 
16  uint16_t led_status : 1;
17  uint16_t flags_resv : 15;
18 } __attribute__((__packed__));
19 
21  /* This here is simpler than the controller-side configuration.
22  * min is expected to be a true minimum; max is a true maximum.
23  * The values that come in are scaled linearly between min and max
24  * using fixed point math
25  */
26  struct {
27  uint16_t min; /* microseconds */
28  uint16_t max;
30 
31  /* Rate in Hz; 0 is oneshot */
33  uint16_t receiver_protocol; /* If less than 0x100, this is from
34  * HwShared.PortTypes
35  */
36  uint16_t flags_resv;
37 } __attribute__((__packed__));
38 
39 /* all IO data stuff must be equal/less than length of flyingpi_actuator_fc */
40 /* 20 + 8 + 2 + 2 = 32 bytes */
44 
46  uint16_t flags_resv;
47 } __attribute__((__packed__));
48 
49 /* 3 bytes header */
50 struct flyingpi_msg {
51  uint8_t crc8;
52  uint8_t id;
53 
54  union {
58  } body;
59 } __attribute__((__packed__));
60 
61 static inline bool flyingpi_calc_crc(struct flyingpi_msg *msg, bool fill_in,
62  int *total_len) {
63  uint8_t len;
64 
65  switch (msg->id) {
67  len = sizeof(msg->body.actuator_fc);
68  break;
69  case FLYINGPICMD_CFG:
70  len = sizeof(msg->body.cfg_fa);
71  break;
72  case FLYINGPIRESP_IO:
73  len = sizeof(msg->body.io_10);
74  break;
75  default:
76  return false;
77  }
78 
79  /* Fixup to include ID */
80  uint8_t crc8 = PIOS_CRC_updateCRC(0, ((uint8_t *) &msg->body) - 1,
81  len+1);
82 
83  if (fill_in) {
84  msg->crc8 = crc8;
85  }
86 
87  if (total_len) {
88  *total_len = len + 2;
89  }
90 
91  return msg->crc8 == crc8;
92 }
struct flyingpicmd_actuator_fc __attribute__((__packed__))
Definition: morsel.c:185
uint16_t adc_data[FPPROTO_MAX_ADCCHANS]
uint16_t values[FPPROTO_MAX_SERVOS]
#define FPPROTO_MAX_ADCCHANS
#define FLYINGPICMD_ACTUATOR
struct flyingpiresp_io_10 io_10
struct flyingpicmd_actuator_fc actuator_fc
uint16_t rate[FPPROTO_MAX_BANKS]
#define FLYINGPIRESP_IO
#define FPPROTO_MAX_BANKS
#define FPPROTO_MAX_SERVOS
union flyingpi_msg::@17 body
uint8_t PIOS_CRC_updateCRC(uint8_t crc, const uint8_t *data, int32_t length)
Update a CRC with a data buffer.
Definition: pios_crc.c:153
struct flyingpicmd_cfg_fa cfg_fa
uint8_t crc8
#define FPPROTO_MAX_RCCHANS
uint16_t chan_data[FPPROTO_MAX_RCCHANS]
static bool flyingpi_calc_crc(struct flyingpi_msg *msg, bool fill_in, int *total_len)
struct flyingpicmd_cfg_fa::@15 actuators[FPPROTO_MAX_SERVOS]
#define FLYINGPICMD_CFG