Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
superbitrf.c File Reference
#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"
+ Include dependency graph for superbitrf.c:

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 }
 

Macro Definition Documentation

◆ SUPERBITRF_DRDY_PIN

#define SUPERBITRF_DRDY_PIN   GPIO1

Definition at line 59 of file superbitrf.c.

◆ SUPERBITRF_DRDY_PORT

#define SUPERBITRF_DRDY_PORT   GPIOB

Definition at line 55 of file superbitrf.c.

◆ SUPERBITRF_FORCE_DSM2

#define SUPERBITRF_FORCE_DSM2   TRUE

Definition at line 65 of file superbitrf.c.

◆ SUPERBITRF_RST_PIN

#define SUPERBITRF_RST_PIN   GPIO12

Definition at line 49 of file superbitrf.c.

◆ SUPERBITRF_RST_PORT

#define SUPERBITRF_RST_PORT   GPIOC

Definition at line 45 of file superbitrf.c.

◆ SUPERBITRF_SPI_DEV

#define SUPERBITRF_SPI_DEV   spi1

Definition at line 39 of file superbitrf.c.

◆ SUPERBITRF_UPDATE_DL

#define SUPERBITRF_UPDATE_DL   TRUE

Definition at line 70 of file superbitrf.c.

Function Documentation

◆ null_byte_function()

static uint8_t null_byte_function ( struct SuperbitRF p)
static

Definition at line 237 of file superbitrf.c.

Referenced by superbitrf_init().

+ Here is the caller graph for this function:

◆ null_function()

static int null_function ( struct SuperbitRF p)
static

Definition at line 236 of file superbitrf.c.

Referenced by superbitrf_init().

+ Here is the caller graph for this function:

◆ send_superbit()

◆ superbitrf_check_free_space()

static int superbitrf_check_free_space ( struct SuperbitRF p,
long *  fd,
uint16_t  len 
)
static

Definition at line 211 of file superbitrf.c.

References p, and SUPERBITRF_TX_BUFFER_SIZE.

Referenced by superbitrf_init().

+ Here is the caller graph for this function:

◆ superbitrf_dl_event()

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.

+ Here is the call graph for this function:

◆ superbitrf_dl_init()

void superbitrf_dl_init ( void  )

Initialize datalink part.

Definition at line 285 of file superbitrf.c.

References pprz_srf_tp.

◆ superbitrf_event()

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, 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 superbitrf_rc_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ superbitrf_gen_dsmx_channels()

static void superbitrf_gen_dsmx_channels ( void  )
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().

+ Here is the caller graph for this function:

◆ superbitrf_init()

◆ superbitrf_radio_to_channels()

static void superbitrf_radio_to_channels ( uint8_t data,
uint8_t  nb_channels,
bool  is_11bit,
int16_t channels 
)
inlinestatic

Parse a radio channel packet.

Definition at line 1089 of file superbitrf.c.

References MAX_PPRZ, and val.

Referenced by superbitrf_receive_packet_cb().

+ Here is the caller graph for this function:

◆ superbitrf_receive_packet_cb()

◆ superbitrf_send()

static void superbitrf_send ( struct SuperbitRF p,
long  fd 
)
static

Definition at line 234 of file superbitrf.c.

Referenced by superbitrf_init().

+ Here is the caller graph for this function:

◆ superbitrf_send_packet_cb()

static void superbitrf_send_packet_cb ( bool  error)
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().

+ Here is the caller graph for this function:

◆ superbitrf_set_mfg_id()

void superbitrf_set_mfg_id ( uint32_t  id)

◆ superbitrf_set_protocol()

void superbitrf_set_protocol ( uint8_t  protocol)

Definition at line 313 of file superbitrf.c.

References SuperbitRF::protocol, SuperbitRF::resolution, and superbitrf.

◆ superbitrf_transmit()

static void superbitrf_transmit ( struct SuperbitRF p,
long  fd,
uint8_t  byte 
)
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().

+ Here is the caller graph for this function:

◆ superbitrf_transmit_buffer()

static void superbitrf_transmit_buffer ( struct SuperbitRF p,
long  fd,
uint8_t data,
uint16_t  len 
)
static

Definition at line 226 of file superbitrf.c.

References fd, p, and superbitrf_transmit().

Referenced by superbitrf_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ cyrf_abort_receive

const uint8_t cyrf_abort_receive[][2]
Initial value:

Definition at line 115 of file superbitrf.c.

Referenced by superbitrf_event().

◆ cyrf_bind_config

const uint8_t cyrf_bind_config[][2]
static

◆ cyrf_start_receive

const uint8_t cyrf_start_receive[][2]

◆ cyrf_stratup_config

◆ cyrf_transfer_config

const uint8_t cyrf_transfer_config[][2]
static
Initial value:

Definition at line 108 of file superbitrf.c.

Referenced by superbitrf_event().

◆ pn_bind

const uint8_t pn_bind[] = { 0x98, 0x88, 0x1B, 0xE4, 0x30, 0x79, 0x03, 0x84 }
static

Definition at line 183 of file superbitrf.c.

Referenced by superbitrf_event().

◆ pn_codes

const uint8_t pn_codes[5][9][8]
static

Definition at line 126 of file superbitrf.c.

Referenced by superbitrf_event().

◆ pprz_srf_tp

struct pprz_transport pprz_srf_tp

Definition at line 77 of file superbitrf.c.

Referenced by superbitrf_dl_event(), and superbitrf_dl_init().

◆ superbitrf

struct SuperbitRF superbitrf

Definition at line 74 of file superbitrf.c.

CYRF_RST
#define CYRF_RST
Definition: cyrf6936_regs.h:81
CYRF_TX_OFFSET_MSB
@ CYRF_TX_OFFSET_MSB
Definition: cyrf6936_regs.h:60
CYRF_SOP_LEN
#define CYRF_SOP_LEN
Definition: cyrf6936_regs.h:109
CYRF_RX_IRQ_STATUS
@ CYRF_RX_IRQ_STATUS
Definition: cyrf6936_regs.h:39
CYRF_DATA_MODE_8DR
@ CYRF_DATA_MODE_8DR
Definition: cyrf6936_regs.h:205
CYRF_XACT_CFG
@ CYRF_XACT_CFG
Definition: cyrf6936_regs.h:47
CYRF_RX_ABORT
@ CYRF_RX_ABORT
Definition: cyrf6936_regs.h:73
CYRF_RX_CTRL
@ CYRF_RX_CTRL
Definition: cyrf6936_regs.h:37
CYRF_SOP_EN
#define CYRF_SOP_EN
Definition: cyrf6936_regs.h:110
CYRF_CLK_EN
@ CYRF_CLK_EN
Definition: cyrf6936_regs.h:72
CYRF_FAST_TURN_EN
#define CYRF_FAST_TURN_EN
Definition: cyrf6936_regs.h:186
CYRF_FRAMING_CFG
@ CYRF_FRAMING_CFG
Definition: cyrf6936_regs.h:48
CYRF_RXF
#define CYRF_RXF
Definition: cyrf6936_regs.h:84
CYRF_AUTO_CAL_TIME
@ CYRF_AUTO_CAL_TIME
Definition: cyrf6936_regs.h:74
CYRF_EOP_CTRL
@ CYRF_EOP_CTRL
Definition: cyrf6936_regs.h:52
CYRF_DIS_RXCRC
#define CYRF_DIS_RXCRC
Definition: cyrf6936_regs.h:168
CYRF_RX_OVERRIDE
@ CYRF_RX_OVERRIDE
Definition: cyrf6936_regs.h:62
CYRF_FRC_END
#define CYRF_FRC_END
Definition: cyrf6936_regs.h:94
CYRF_RXE_IRQEN
#define CYRF_RXE_IRQEN
Definition: cyrf6936_regs.h:157
CYRF_PA_4
@ CYRF_PA_4
Definition: cyrf6936_regs.h:201
CYRF_TX_CFG
@ CYRF_TX_CFG
Definition: cyrf6936_regs.h:35
CYRF_DATA_MODE_SDR
@ CYRF_DATA_MODE_SDR
Definition: cyrf6936_regs.h:207
CYRF_DATA_CODE_LENGTH
#define CYRF_DATA_CODE_LENGTH
Definition: cyrf6936_regs.h:209
CYRF_RXC_IRQEN
#define CYRF_RXC_IRQEN
Definition: cyrf6936_regs.h:158
CYRF_LEN_EN
#define CYRF_LEN_EN
Definition: cyrf6936_regs.h:108
CYRF_AUTO_CAL_OFFSET
@ CYRF_AUTO_CAL_OFFSET
Definition: cyrf6936_regs.h:75
CYRF_RX_GO
#define CYRF_RX_GO
Definition: cyrf6936_regs.h:164
CYRF_MODE_SYNTH_RX
@ CYRF_MODE_SYNTH_RX
Definition: cyrf6936_regs.h:91
CYRF_FRC_RXDR
#define CYRF_FRC_RXDR
Definition: cyrf6936_regs.h:170
CYRF_TX_OVERRIDE
@ CYRF_TX_OVERRIDE
Definition: cyrf6936_regs.h:63
CYRF_LNA
#define CYRF_LNA
Definition: cyrf6936_regs.h:189
CYRF_TX_OFFSET_LSB
@ CYRF_TX_OFFSET_LSB
Definition: cyrf6936_regs.h:59
CYRF_RXOW_IRQ
#define CYRF_RXOW_IRQ
Definition: cyrf6936_regs.h:144
CYRF_DIS_TXCRC
#define CYRF_DIS_TXCRC
Definition: cyrf6936_regs.h:177
CYRF_DATA64_THOLD
@ CYRF_DATA64_THOLD
Definition: cyrf6936_regs.h:50
CYRF_RX_CFG
@ CYRF_RX_CFG
Definition: cyrf6936_regs.h:38
CYRF_MODE_OVERRIDE
@ CYRF_MODE_OVERRIDE
Definition: cyrf6936_regs.h:61