Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
#include "modules/datalink/superbitrf.h"
#include <string.h>
#include "paparazzi.h"
#include "led.h"
#include "mcu_periph/spi.h"
#include "mcu_periph/sys_time.h"
#include "mcu_periph/gpio.h"
#include "modules/core/settings.h"
#include "modules/datalink/telemetry.h"
Go to the source code of this file.
Macros | |
#define | SUPERBITRF_SPI_DEV spi1 |
#define | SUPERBITRF_RST_PORT GPIOC |
#define | SUPERBITRF_RST_PIN GPIO12 |
#define | SUPERBITRF_DRDY_PORT GPIOB |
#define | SUPERBITRF_DRDY_PIN GPIO1 |
#define | SUPERBITRF_FORCE_DSM2 TRUE |
#define | SUPERBITRF_UPDATE_DL TRUE |
Functions | |
static void | superbitrf_radio_to_channels (uint8_t *data, uint8_t nb_channels, bool is_11bit, int16_t *channels) |
Parse a radio channel packet. More... | |
static void | superbitrf_receive_packet_cb (bool error, uint8_t status, uint8_t packet[]) |
When we receive a packet this callback is called. More... | |
static void | superbitrf_send_packet_cb (bool error) |
static void | superbitrf_gen_dsmx_channels (void) |
Generate the channels. More... | |
static void | send_superbit (struct transport_tx *trans, struct link_device *dev) |
static int | superbitrf_check_free_space (struct SuperbitRF *p, long *fd, uint16_t len) |
static void | superbitrf_transmit (struct SuperbitRF *p, long fd, uint8_t byte) |
static void | superbitrf_transmit_buffer (struct SuperbitRF *p, long fd, uint8_t *data, uint16_t len) |
static void | superbitrf_send (struct SuperbitRF *p, long fd) |
static int | null_function (struct SuperbitRF *p) |
static uint8_t | null_byte_function (struct SuperbitRF *p) |
void | superbitrf_init (void) |
Initialize the superbitrf. More... | |
void | superbitrf_dl_init (void) |
Initialize datalink part. More... | |
void | superbitrf_dl_event (void) |
The superbitrf datalink event call. More... | |
void | superbitrf_set_mfg_id (uint32_t id) |
void | superbitrf_set_protocol (uint8_t protocol) |
void | superbitrf_event (void) |
The superbitrf on event call. More... | |
Variables | |
struct SuperbitRF | superbitrf |
struct pprz_transport | pprz_srf_tp |
static const uint8_t | cyrf_stratup_config [][2] |
static const uint8_t | cyrf_bind_config [][2] |
static const uint8_t | cyrf_transfer_config [][2] |
const uint8_t | cyrf_abort_receive [][2] |
const uint8_t | cyrf_start_receive [][2] |
static const uint8_t | pn_codes [5][9][8] |
static const uint8_t | pn_bind [] = { 0x98, 0x88, 0x1B, 0xE4, 0x30, 0x79, 0x03, 0x84 } |
#define SUPERBITRF_DRDY_PIN GPIO1 |
Definition at line 59 of file superbitrf.c.
#define SUPERBITRF_DRDY_PORT GPIOB |
Definition at line 55 of file superbitrf.c.
#define SUPERBITRF_FORCE_DSM2 TRUE |
Definition at line 65 of file superbitrf.c.
#define SUPERBITRF_RST_PIN GPIO12 |
Definition at line 49 of file superbitrf.c.
#define SUPERBITRF_RST_PORT GPIOC |
Definition at line 45 of file superbitrf.c.
#define SUPERBITRF_SPI_DEV spi1 |
Definition at line 39 of file superbitrf.c.
#define SUPERBITRF_UPDATE_DL TRUE |
Definition at line 70 of file superbitrf.c.
|
static |
Definition at line 237 of file superbitrf.c.
Referenced by superbitrf_init().
|
static |
Definition at line 236 of file superbitrf.c.
Referenced by superbitrf_init().
|
static |
Definition at line 188 of file superbitrf.c.
References SuperbitRF::bind_mfg_id32, SuperbitRF::cyrf6936, dev, SuperbitRF::irq_count, Cyrf6936::mfg_id, SuperbitRF::rc_count, SuperbitRF::resync_count, SuperbitRF::rx_packet_count, SuperbitRF::status, Cyrf6936::status, status, superbitrf, SuperbitRF::timing1, SuperbitRF::timing2, SuperbitRF::transfer_timeouts, SuperbitRF::tx_packet_count, and SuperbitRF::uplink_count.
Referenced by superbitrf_init().
|
static |
Definition at line 211 of file superbitrf.c.
References p, and SUPERBITRF_TX_BUFFER_SIZE.
Referenced by superbitrf_init().
void superbitrf_dl_event | ( | void | ) |
The superbitrf datalink event call.
Definition at line 294 of file superbitrf.c.
References dl_buffer, dl_msg_available, DlCheckAndParse(), DOWNLINK_DEVICE, pprz_srf_tp, and SUPERBITRF_UPDATE_DL.
void superbitrf_dl_init | ( | void | ) |
void superbitrf_event | ( | void | ) |
The superbitrf on event call.
Definition at line 322 of file superbitrf.c.
References SuperbitRF::bind_mfg_id, SuperbitRF::bind_mfg_id32, SuperbitRF::channel, SuperbitRF::channel_idx, SuperbitRF::channels, SuperbitRF::crc_seed, SuperbitRF::cyrf6936, CYRF6936_IDLE, cyrf6936_multi_write(), cyrf6936_read_rx_irq_status_packet(), cyrf6936_send(), cyrf6936_write(), cyrf6936_write_chan_sop_data_crc(), cyrf_abort_receive, cyrf_bind_config, CYRF_CHANNEL, CYRF_RXC_IRQ, CYRF_RXE_IRQ, cyrf_start_receive, cyrf_stratup_config, cyrf_transfer_config, CYRF_TXC_IRQ, CYRF_TXE_IRQ, SuperbitRF::data_col, get_sys_time_usec(), gpio_get(), Cyrf6936::has_irq, SuperbitRF::irq_count, IS_DSM2, IS_DSMX, LED_ON, LED_TOGGLE, SuperbitRF::num_channels, SuperbitRF::packet_loss, SuperbitRF::packet_loss_bit, pn_bind, pn_codes, SuperbitRF::protocol, SuperbitRF::resync_count, Cyrf6936::rx_irq_status, Cyrf6936::rx_packet, SuperbitRF::rx_packet_count, Cyrf6936::rx_status, SuperbitRF::sop_col, SPEKTRUM_BIND_PIN, SPEKTRUM_BIND_PIN_PORT, SuperbitRF::state, SuperbitRF::status, Cyrf6936::status, superbitrf, SUPERBITRF_BIND_RECV_TIME, SUPERBITRF_BINDING, SUPERBITRF_DATARECV_TIME, SUPERBITRF_DRDY_PIN, SUPERBITRF_DRDY_PORT, SUPERBITRF_FORCE_DSM2, superbitrf_gen_dsmx_channels(), SUPERBITRF_INIT_BINDING, SUPERBITRF_INIT_TRANSFER, superbitrf_receive_packet_cb(), SUPERBITRF_RECV_SHORT_TIME, SUPERBITRF_RECV_TIME, superbitrf_send_packet_cb(), superbitrf_set_mfg_id(), superbitrf_set_protocol(), SUPERBITRF_SYNC_RECV_TIME, SUPERBITRF_SYNCING_A, SUPERBITRF_SYNCING_B, SUPERBITRF_TRANSFER, SUPERBITRF_TX_BUFFER_SIZE, SUPERBITRF_UNINIT, SuperbitRF::timeouts, SuperbitRF::timer, SuperbitRF::timer_overflow, SuperbitRF::transfer_timeouts, SuperbitRF::tx_buffer, SuperbitRF::tx_extract_idx, SuperbitRF::tx_insert_idx, Cyrf6936::tx_irq_status, and SuperbitRF::tx_packet_count.
Referenced by superbitrf_rc_event().
|
inlinestatic |
Generate the channels.
Definition at line 1118 of file superbitrf.c.
References SuperbitRF::bind_mfg_id, SuperbitRF::channels, idx, and superbitrf.
Referenced by superbitrf_event().
void superbitrf_init | ( | void | ) |
Initialize the superbitrf.
Definition at line 242 of file superbitrf.c.
References SuperbitRF::bind_mfg_id32, SuperbitRF::cyrf6936, cyrf6936_init(), DefaultPeriodic, SuperbitRF::device, gpio_setup_input(), null_byte_function(), null_function(), SuperbitRF::num_channels, SuperbitRF::protocol, register_periodic_telemetry(), SuperbitRF::rx_packet_count, send_superbit(), SPEKTRUM_BIND_PIN, SPEKTRUM_BIND_PIN_PORT, SuperbitRF::state, SuperbitRF::status, superbitrf, superbitrf_check_free_space(), SUPERBITRF_DRDY_PIN, SUPERBITRF_DRDY_PORT, SUPERBITRF_RST_PIN, SUPERBITRF_RST_PORT, superbitrf_send(), SUPERBITRF_SPI_DEV, superbitrf_transmit(), superbitrf_transmit_buffer(), SUPERBITRF_UNINIT, SuperbitRF::timer, SuperbitRF::tx_extract_idx, SuperbitRF::tx_insert_idx, and SuperbitRF::tx_packet_count.
Referenced by superbitrf_rc_init().
|
inlinestatic |
Parse a radio channel packet.
Definition at line 1089 of file superbitrf.c.
Referenced by superbitrf_receive_packet_cb().
|
inlinestatic |
When we receive a packet this callback is called.
Definition at line 787 of file superbitrf.c.
References SuperbitRF::bind_mfg_id, SuperbitRF::channel, SuperbitRF::channel_idx, SuperbitRF::channels, SuperbitRF::crc_seed, SuperbitRF::cyrf6936, cyrf6936_multi_write(), CYRF_BAD_CRC, cyrf_start_receive, DatalinkFillDlBuffer, dl_msg_available, get_sys_time_usec(), IS_DSM2, IS_DSMX, SuperbitRF::num_channels, SuperbitRF::packet_loss, SuperbitRF::packet_loss_bit, SuperbitRF::protocol, SuperbitRF::rc_count, SuperbitRF::rc_frame_available, SuperbitRF::rc_values, SuperbitRF::resolution, Cyrf6936::rx_count, SuperbitRF::rx_transport, settings_StoreSettings, SuperbitRF::state, SuperbitRF::status, status, superbitrf, SUPERBITRF_BINDING, SUPERBITRF_FORCE_DSM2, SUPERBITRF_INIT_TRANSFER, superbitrf_radio_to_channels(), SUPERBITRF_RECV_SHORT_TIME, SUPERBITRF_RECV_TIME, superbitrf_set_mfg_id(), superbitrf_set_protocol(), SUPERBITRF_SYNCING_A, SUPERBITRF_SYNCING_B, SUPERBITRF_TRANSFER, SuperbitRF::timeouts, SuperbitRF::timer, SuperbitRF::timing1, SuperbitRF::timing2, and SuperbitRF::uplink_count.
Referenced by superbitrf_event().
|
static |
Definition at line 234 of file superbitrf.c.
Referenced by superbitrf_init().
|
inlinestatic |
Definition at line 1058 of file superbitrf.c.
References SuperbitRF::state, SuperbitRF::status, superbitrf, SUPERBITRF_SYNCING_A, SUPERBITRF_SYNCING_B, and SUPERBITRF_TRANSFER.
Referenced by superbitrf_event().
void superbitrf_set_mfg_id | ( | uint32_t | id | ) |
Definition at line 299 of file superbitrf.c.
References SuperbitRF::bind_mfg_id, SuperbitRF::bind_mfg_id32, SuperbitRF::crc_seed, SuperbitRF::data_col, SuperbitRF::sop_col, and superbitrf.
void superbitrf_set_protocol | ( | uint8_t | protocol | ) |
Definition at line 313 of file superbitrf.c.
References SuperbitRF::protocol, SuperbitRF::resolution, and superbitrf.
|
static |
Definition at line 220 of file superbitrf.c.
References byte, p, and SUPERBITRF_TX_BUFFER_SIZE.
Referenced by superbitrf_init(), and superbitrf_transmit_buffer().
|
static |
Definition at line 226 of file superbitrf.c.
References fd, p, and superbitrf_transmit().
Referenced by superbitrf_init().
const uint8_t cyrf_abort_receive[][2] |
Definition at line 115 of file superbitrf.c.
Referenced by superbitrf_event().
|
static |
Definition at line 100 of file superbitrf.c.
Referenced by superbitrf_event().
const uint8_t cyrf_start_receive[][2] |
Definition at line 120 of file superbitrf.c.
Referenced by superbitrf_event(), and superbitrf_receive_packet_cb().
|
static |
Definition at line 86 of file superbitrf.c.
Referenced by superbitrf_event().
|
static |
Definition at line 108 of file superbitrf.c.
Referenced by superbitrf_event().
|
static |
Definition at line 183 of file superbitrf.c.
Referenced by superbitrf_event().
|
static |
Definition at line 126 of file superbitrf.c.
Referenced by superbitrf_event().
struct pprz_transport pprz_srf_tp |
Definition at line 1 of file superbitrf.c.
Referenced by superbitrf_dl_event(), and superbitrf_dl_init().
struct SuperbitRF superbitrf |
Definition at line 1 of file superbitrf.c.