Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
#include "subsystems/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 "subsystems/settings.h"
#include "subsystems/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 |
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 bool | 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) |
void | superbitrf_init (void) |
Initialize the superbitrf. 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 |
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.
Referenced by superbitrf_event(), and superbitrf_init().
#define SUPERBITRF_DRDY_PORT GPIOB |
Definition at line 55 of file superbitrf.c.
Referenced by superbitrf_event(), and superbitrf_init().
#define SUPERBITRF_FORCE_DSM2 TRUE |
Definition at line 65 of file superbitrf.c.
Referenced by superbitrf_event(), and superbitrf_receive_packet_cb().
#define SUPERBITRF_RST_PIN GPIO12 |
Definition at line 49 of file superbitrf.c.
Referenced by superbitrf_init().
#define SUPERBITRF_RST_PORT GPIOC |
Definition at line 45 of file superbitrf.c.
Referenced by superbitrf_init().
#define SUPERBITRF_SPI_DEV spi1 |
Definition at line 39 of file superbitrf.c.
Referenced by superbitrf_init().
|
static |
Definition at line 229 of file superbitrf.c.
Referenced by superbitrf_init().
|
static |
Definition at line 181 of file superbitrf.c.
References SuperbitRF::bind_mfg_id32, SuperbitRF::cyrf6936, SuperbitRF::irq_count, Cyrf6936::mfg_id, SuperbitRF::rc_count, SuperbitRF::resync_count, SuperbitRF::rx_packet_count, Cyrf6936::status, SuperbitRF::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 204 of file superbitrf.c.
References SUPERBITRF_TX_BUFFER_SIZE, SuperbitRF::tx_extract_idx, and SuperbitRF::tx_insert_idx.
Referenced by superbitrf_init().
void superbitrf_event | ( | void | ) |
The superbitrf on event call.
Definition at line 297 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_CHANNEL, CYRF_RXC_IRQ, CYRF_RXE_IRQ, cyrf_stratup_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, 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, Cyrf6936::status, SuperbitRF::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 radio_control_impl_event().
|
inlinestatic |
Generate the channels.
Definition at line 1093 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 234 of file superbitrf.c.
References SuperbitRF::bind_mfg_id32, SuperbitRF::cyrf6936, cyrf6936_init(), DefaultPeriodic, SuperbitRF::device, gpio_setup_input(), 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 radio_control_impl_init().
|
inlinestatic |
Parse a radio channel packet.
Definition at line 1064 of file superbitrf.c.
Referenced by superbitrf_receive_packet_cb().
|
inlinestatic |
When we receive a packet this callback is called.
Definition at line 762 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, 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, 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 227 of file superbitrf.c.
Referenced by superbitrf_init().
|
inlinestatic |
Definition at line 1033 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 274 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 288 of file superbitrf.c.
References SuperbitRF::protocol, SuperbitRF::resolution, and superbitrf.
|
static |
Definition at line 213 of file superbitrf.c.
References byte, SUPERBITRF_TX_BUFFER_SIZE, SuperbitRF::tx_buffer, and SuperbitRF::tx_insert_idx.
Referenced by superbitrf_init(), and superbitrf_transmit_buffer().
|
static |
Definition at line 219 of file superbitrf.c.
References superbitrf_transmit().
Referenced by superbitrf_init().
const uint8_t cyrf_abort_receive[][2] |
Definition at line 108 of file superbitrf.c.
|
static |
Definition at line 93 of file superbitrf.c.
const uint8_t cyrf_start_receive[][2] |
Definition at line 113 of file superbitrf.c.
|
static |
Definition at line 79 of file superbitrf.c.
Referenced by superbitrf_event().
|
static |
Definition at line 101 of file superbitrf.c.
|
static |
Definition at line 176 of file superbitrf.c.
|
static |
Definition at line 119 of file superbitrf.c.
struct SuperbitRF superbitrf |
Definition at line 70 of file superbitrf.c.