27 #include "subsystems/datalink/superbitrf.h"
38 #ifndef SUPERBITRF_SPI_DEV
39 #define SUPERBITRF_SPI_DEV spi1
44 #ifndef SUPERBITRF_RST_PORT
45 #define SUPERBITRF_RST_PORT GPIOC
48 #ifndef SUPERBITRF_RST_PIN
49 #define SUPERBITRF_RST_PIN GPIO12
54 #ifndef SUPERBITRF_DRDY_PORT
55 #define SUPERBITRF_DRDY_PORT GPIOB
58 #ifndef SUPERBITRF_DRDY_PIN
59 #define SUPERBITRF_DRDY_PIN GPIO1
64 #ifndef SUPERBITRF_FORCE_DSM2
65 #define SUPERBITRF_FORCE_DSM2 TRUE
69 #ifndef SUPERBITRF_UPDATE_DL
70 #define SUPERBITRF_UPDATE_DL TRUE
128 {0x03, 0xBC, 0x6E, 0x8A, 0xEF, 0xBD, 0xFE, 0xF8},
129 {0x88, 0x17, 0x13, 0x3B, 0x2D, 0xBF, 0x06, 0xD6},
130 {0xF1, 0x94, 0x30, 0x21, 0xA1, 0x1C, 0x88, 0xA9},
131 {0xD0, 0xD2, 0x8E, 0xBC, 0x82, 0x2F, 0xE3, 0xB4},
132 {0x8C, 0xFA, 0x47, 0x9B, 0x83, 0xA5, 0x66, 0xD0},
133 {0x07, 0xBD, 0x9F, 0x26, 0xC8, 0x31, 0x0F, 0xB8},
134 {0xEF, 0x03, 0x95, 0x89, 0xB4, 0x71, 0x61, 0x9D},
135 {0x40, 0xBA, 0x97, 0xD5, 0x86, 0x4F, 0xCC, 0xD1},
136 {0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86}
139 {0x83, 0xF7, 0xA8, 0x2D, 0x7A, 0x44, 0x64, 0xD3},
140 {0x3F, 0x2C, 0x4E, 0xAA, 0x71, 0x48, 0x7A, 0xC9},
141 {0x17, 0xFF, 0x9E, 0x21, 0x36, 0x90, 0xC7, 0x82},
142 {0xBC, 0x5D, 0x9A, 0x5B, 0xEE, 0x7F, 0x42, 0xEB},
143 {0x24, 0xF5, 0xDD, 0xF8, 0x7A, 0x77, 0x74, 0xE7},
144 {0x3D, 0x70, 0x7C, 0x94, 0xDC, 0x84, 0xAD, 0x95},
145 {0x1E, 0x6A, 0xF0, 0x37, 0x52, 0x7B, 0x11, 0xD4},
146 {0x62, 0xF5, 0x2B, 0xAA, 0xFC, 0x33, 0xBF, 0xAF},
147 {0x40, 0x56, 0x32, 0xD9, 0x0F, 0xD9, 0x5D, 0x97}
150 {0x40, 0x56, 0x32, 0xD9, 0x0F, 0xD9, 0x5D, 0x97},
151 {0x8E, 0x4A, 0xD0, 0xA9, 0xA7, 0xFF, 0x20, 0xCA},
152 {0x4C, 0x97, 0x9D, 0xBF, 0xB8, 0x3D, 0xB5, 0xBE},
153 {0x0C, 0x5D, 0x24, 0x30, 0x9F, 0xCA, 0x6D, 0xBD},
154 {0x50, 0x14, 0x33, 0xDE, 0xF1, 0x78, 0x95, 0xAD},
155 {0x0C, 0x3C, 0xFA, 0xF9, 0xF0, 0xF2, 0x10, 0xC9},
156 {0xF4, 0xDA, 0x06, 0xDB, 0xBF, 0x4E, 0x6F, 0xB3},
157 {0x9E, 0x08, 0xD1, 0xAE, 0x59, 0x5E, 0xE8, 0xF0},
158 {0xC0, 0x90, 0x8F, 0xBB, 0x7C, 0x8E, 0x2B, 0x8E}
161 {0xC0, 0x90, 0x8F, 0xBB, 0x7C, 0x8E, 0x2B, 0x8E},
162 {0x80, 0x69, 0x26, 0x80, 0x08, 0xF8, 0x49, 0xE7},
163 {0x7D, 0x2D, 0x49, 0x54, 0xD0, 0x80, 0x40, 0xC1},
164 {0xB6, 0xF2, 0xE6, 0x1B, 0x80, 0x5A, 0x36, 0xB4},
165 {0x42, 0xAE, 0x9C, 0x1C, 0xDA, 0x67, 0x05, 0xF6},
166 {0x9B, 0x75, 0xF7, 0xE0, 0x14, 0x8D, 0xB5, 0x80},
167 {0xBF, 0x54, 0x98, 0xB9, 0xB7, 0x30, 0x5A, 0x88},
168 {0x35, 0xD1, 0xFC, 0x97, 0x23, 0xD4, 0xC9, 0x88},
169 {0x88, 0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40}
172 {0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40, 0x93},
173 {0xDC, 0x68, 0x08, 0x99, 0x97, 0xAE, 0xAF, 0x8C},
174 {0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA},
175 {0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC},
176 {0x5C, 0xD5, 0x9C, 0xB8, 0x46, 0x9C, 0x7D, 0x84},
177 {0xF1, 0xC6, 0xFE, 0x5C, 0x9D, 0xA5, 0x4F, 0xB7},
178 {0x58, 0xB5, 0xB3, 0xDD, 0x0E, 0x28, 0xF1, 0xB0},
179 {0x5F, 0x30, 0x3B, 0x56, 0x96, 0x45, 0xF4, 0xA1},
180 {0x03, 0xBC, 0x6E, 0x8A, 0xEF, 0xBD, 0xFE, 0xF8}
183 static const uint8_t pn_bind[] = { 0x98, 0x88, 0x1B, 0xE4, 0x30, 0x79, 0x03, 0x84 };
185 #if PERIODIC_TELEMETRY
192 pprz_msg_send_SUPERBITRF(trans,
dev, AC_ID,
213 int space =
p->tx_extract_idx -
p->tx_insert_idx - 1;
217 return space >= len ? space : 0;
222 p->tx_buffer[
p->tx_insert_idx] =
byte;
229 for (i = 0; i < len; i++) {
276 #if PERIODIC_TELEMETRY
323 uint8_t i, pn_row, data_code[16];
324 static uint8_t packet_size, tx_packet[16];
325 static bool start_transfer =
true;
327 #ifdef RADIO_CONTROL_LED
376 start_transfer =
false;
394 memcpy(data_code,
pn_codes[0][8], 8);
395 memcpy(data_code + 8,
pn_bind, 8);
425 #ifdef RADIO_CONTROL_LED
427 if (slowLedCpt > 100000) {
468 if (start_transfer) {
475 #ifdef RADIO_TRANSMITTER_ID
478 PRINT_CONFIG_VAR(RADIO_TRANSMITTER_ID)
482 #ifdef RADIO_TRANSMITTER_CHAN
483 PRINT_CONFIG_VAR(RADIO_TRANSMITTER_CHAN)
491 #ifdef RADIO_TRANSMITTER_PROTOCOL
493 PRINT_CONFIG_VAR(RADIO_TRANSMITTER_PROTOCOL)
515 #ifdef RADIO_CONTROL_LED
517 if (slowLedCpt > 5000) {
565 if (packet_size > 14) {
569 for (i = 0; i < packet_size; i++) {
633 #ifdef RADIO_CONTROL_LED
634 LED_ON(RADIO_CONTROL_LED);
695 if (packet_size > 14) {
699 for (i = 0; i < packet_size; i++) {
797 if (packet[0] != packet[4] || packet[1] != packet[5] || packet[2] != packet[6] || packet[3] != packet[7]) {
805 for (i = 0; i < 8; i++) {
810 if (packet[8] != sum >> 8 || packet[9] != (sum & 0xFF)) {
817 for (i = 8; i < 14; i++) {
822 if (packet[14] != sum >> 8 || packet[15] != (sum & 0xFF)) {
829 uint32_t mfg_id = ((~packet[3] & 0xFF) << 24 | (~packet[2] & 0xFF) << 16 |
830 (~packet[1] & 0xFF) << 8 | (~packet[0] & 0xFF));
1091 uint8_t bit_shift = (is_11bit) ? 11 : 10;
1092 int16_t value_max = (is_11bit) ? 0x07FF : 0x03FF;
1094 for (i = 0; i < 7; i++) {
1095 const int16_t tmp = ((data[2 * i] << 8) + data[2 * i + 1]) & 0x7FFF;
1096 const uint8_t chan = (tmp >> bit_shift) & 0x0F;
1099 if (chan < nb_channels) {
1100 channels[chan] =
val;
1104 channels[chan] -= 0x400;
1105 channels[chan] *=
MAX_PPRZ / 0x2AC;
1107 channels[chan] -= 0x200;
1108 channels[chan] *=
MAX_PPRZ / 0x156;
1128 int count_3_27 = 0, count_28_51 = 0, count_52_76 = 0;
1130 id_tmp = id_tmp * 0x0019660D + 0x3C6EF35F;
1131 uint8_t next_ch = ((id_tmp >> 8) % 0x49) + 3;
1132 if (((next_ch ^
id) & 0x01) == 0) {
1137 for (i = 0; i <
idx; i++) {
1159 if ((next_ch < 28 && count_3_27 < 8)
1160 || (next_ch >= 28 && next_ch < 52 && count_28_51 < 7)
1161 || (next_ch >= 52 && count_52_76 < 8)) {