Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
superbitrf.c File Reference
#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"
+ 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)
 
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

#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().

#define SUPERBITRF_UPDATE_DL   TRUE

Definition at line 70 of file superbitrf.c.

Referenced by superbitrf_dl_event().

Function Documentation

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:

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

Definition at line 211 of file superbitrf.c.

References SUPERBITRF_TX_BUFFER_SIZE, SuperbitRF::tx_extract_idx, and SuperbitRF::tx_insert_idx.

Referenced by superbitrf_init().

+ Here is the caller graph for this function:

void superbitrf_dl_event ( void  )

The superbitrf datalink event call.

Definition at line 293 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:

void superbitrf_dl_init ( void  )

Initialize datalink part.

Definition at line 284 of file superbitrf.c.

References pprz_srf_tp.

void superbitrf_event ( void  )

The superbitrf on event call.

Definition at line 321 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_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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void superbitrf_gen_dsmx_channels ( void  )
inlinestatic

Generate the channels.

Definition at line 1117 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:

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 1088 of file superbitrf.c.

References MAX_PPRZ, and val.

Referenced by superbitrf_receive_packet_cb().

+ Here is the caller graph for this function:

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:

static void superbitrf_send_packet_cb ( bool  error)
inlinestatic

Definition at line 1057 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:

void superbitrf_set_mfg_id ( uint32_t  id)
void superbitrf_set_protocol ( uint8_t  protocol)

Definition at line 312 of file superbitrf.c.

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

static void superbitrf_transmit ( struct SuperbitRF p,
long  fd,
uint8_t  byte 
)
static

Definition at line 220 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().

+ Here is the caller graph for this function:

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 superbitrf_transmit().

Referenced by superbitrf_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const uint8_t cyrf_abort_receive[][2]
Initial value:

Definition at line 115 of file superbitrf.c.

const uint8_t cyrf_bind_config[][2]
static
const uint8_t cyrf_start_receive[][2]
Initial value:
= {
}
#define CYRF_RXC_IRQEN
#define CYRF_RX_GO
#define CYRF_RXE_IRQEN
#define CYRF_RXOW_IRQ

Definition at line 120 of file superbitrf.c.

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

Definition at line 183 of file superbitrf.c.

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

Definition at line 126 of file superbitrf.c.

struct pprz_transport pprz_srf_tp

Definition at line 77 of file superbitrf.c.

Referenced by superbitrf_dl_event(), and superbitrf_dl_init().

struct SuperbitRF superbitrf

Definition at line 74 of file superbitrf.c.