Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
superbitrf.h File Reference
#include "mcu_periph/gpio.h"
#include "peripherals/cyrf6936.h"
#include "pprzlink/pprzlink_device.h"
#include "pprzlink/pprz_transport.h"
#include "modules/datalink/datalink.h"
+ Include dependency graph for superbitrf.h:

Go to the source code of this file.

Data Structures

struct  SuperbitRF
 

Macros

#define SUPERBITRF_BIND_RECV_TIME   10000
 The time to wait for a bind packet on a channel in microseconds. More...
 
#define SUPERBITRF_SYNC_RECV_TIME   7000
 The time to wait for a sync packet on a channel in microseconds. More...
 
#define SUPERBITRF_RECV_TIME   20000
 The time to wait for a transfer packet on a channel in microseconds. More...
 
#define SUPERBITRF_RECV_SHORT_TIME   6000
 The time to wait for a transfer packet short on a channel in microseconds. More...
 
#define SUPERBITRF_DATARECV_TIME   10000
 The time to wait for a data packet on a channel in microseconds. More...
 
#define SUPERBITRF_DATARECVB_TIME   6000
 The time to wait for a data packet on a channel during bind in microseconds. More...
 
#define IS_DSM2(x)   (x == DSM_DSM2P || x == DSM_DSM2_1 || x == DSM_DSM2_2)
 
#define IS_DSMX(x)   (!IS_DSM2(x))
 
#define SUPERBITRF_TX_BUFFER_SIZE   128
 

Enumerations

enum  SuperbitRFStatus {
  SUPERBITRF_UNINIT , SUPERBITRF_INIT_BINDING , SUPERBITRF_INIT_TRANSFER , SUPERBITRF_BINDING ,
  SUPERBITRF_SYNCING_A , SUPERBITRF_SYNCING_B , SUPERBITRF_TRANSFER
}
 
enum  dsm_resolution { SUPERBITRF_10_BIT_RESOLUTION = 0x00 , SUPERBITRF_11_BIT_RESOLUTION = 0x01 }
 
enum  dsm_protocol {
  DSM_DSM2_1 = 0x01 , DSM_DSM2_2 = 0x02 , DSM_DSM2P = 0x10 , DSM_DSMXP = 0x11 ,
  DSM_DSMX_1 = 0xA2 , DSM_DSMX_2 = 0xB2 , DSM_DSM2_1 = 0x01 , DSM_DSM2_2 = 0x02 ,
  DSM_DSM2P = 0x10 , DSM_DSMXP = 0x11 , DSM_DSMX_1 = 0xA2 , DSM_DSMX_2 = 0xB2
}
 

Functions

void superbitrf_init (void)
 Initialize the superbitrf. More...
 
void superbitrf_event (void)
 The superbitrf on event call. 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)
 

Variables

struct SuperbitRF superbitrf
 
struct pprz_transport pprz_srf_tp
 

Data Structure Documentation

◆ SuperbitRF

struct SuperbitRF

Definition at line 43 of file superbitrf.h.

+ Collaboration diagram for SuperbitRF:
Data Fields
uint8_t bind_mfg_id[4] The MFG id where the receiver is bound to.
uint32_t bind_mfg_id32 The MFG id where the receiver is bound to in uint32.
uint8_t channel The current channel number.
uint8_t channel_idx The current channel index.
uint8_t channels[23] The channels used for DSM2/DSMX.
uint16_t crc_seed The CRC seed that is calculated with the bind MFG id.
struct Cyrf6936 cyrf6936 The cyrf chip used.
uint8_t data_col The data code column number calculated with the bind MFG id.
struct link_device device Generic device interface.
uint32_t irq_count How many interrupts are made.
uint8_t num_channels The number of channels the transmitter has.
bool packet_loss When we have packet loss last packet.
uint8_t packet_loss_bit The packet loss indicating bit.
enum dsm_protocol protocol The protocol the transmitter uses.
uint32_t rc_count How many valid RC packages are received.
bool rc_frame_available When a RC frame is available.
int16_t rc_values[14] The rc values from the packet.
enum dsm_resolution resolution The resolution that the transmitter has.
uint32_t resync_count The amount of resyncs needed during transfer.
uint32_t rx_packet_count How many packets are received(also the invalid)
struct pprz_transport rx_transport The receive transport.
uint8_t sop_col The sop code column number calculated with the bind MFG id.
uint8_t state The states each status can be in.
enum SuperbitRFStatus status The status of the superbitRF.
uint8_t timeouts The amount of timeouts.
uint32_t timer The timer in microseconds.
bool timer_overflow When the timer overflows.
uint32_t timing1 Time between last receive in microseconds.
uint32_t timing2 Time between second last receive in microseconds.
uint32_t transfer_timeouts The amount of timeouts during transfer.
uint8_t tx_buffer[SUPERBITRF_TX_BUFFER_SIZE] The transmit buffer.
uint8_t tx_extract_idx The transmit buffer extract index.
uint8_t tx_insert_idx The transmit buffer insert index.
uint32_t tx_packet_count How many packets are send(also the invalid)
uint32_t uplink_count How many valid uplink packages are received.

Macro Definition Documentation

◆ IS_DSM2

#define IS_DSM2 (   x)    (x == DSM_DSM2P || x == DSM_DSM2_1 || x == DSM_DSM2_2)

Definition at line 70 of file superbitrf.h.

◆ IS_DSMX

#define IS_DSMX (   x)    (!IS_DSM2(x))

Definition at line 71 of file superbitrf.h.

◆ SUPERBITRF_BIND_RECV_TIME

#define SUPERBITRF_BIND_RECV_TIME   10000

The time to wait for a bind packet on a channel in microseconds.

Definition at line 37 of file superbitrf.h.

◆ SUPERBITRF_DATARECV_TIME

#define SUPERBITRF_DATARECV_TIME   10000

The time to wait for a data packet on a channel in microseconds.

Definition at line 41 of file superbitrf.h.

◆ SUPERBITRF_DATARECVB_TIME

#define SUPERBITRF_DATARECVB_TIME   6000

The time to wait for a data packet on a channel during bind in microseconds.

Definition at line 42 of file superbitrf.h.

◆ SUPERBITRF_RECV_SHORT_TIME

#define SUPERBITRF_RECV_SHORT_TIME   6000

The time to wait for a transfer packet short on a channel in microseconds.

Definition at line 40 of file superbitrf.h.

◆ SUPERBITRF_RECV_TIME

#define SUPERBITRF_RECV_TIME   20000

The time to wait for a transfer packet on a channel in microseconds.

Definition at line 39 of file superbitrf.h.

◆ SUPERBITRF_SYNC_RECV_TIME

#define SUPERBITRF_SYNC_RECV_TIME   7000

The time to wait for a sync packet on a channel in microseconds.

Definition at line 38 of file superbitrf.h.

◆ SUPERBITRF_TX_BUFFER_SIZE

#define SUPERBITRF_TX_BUFFER_SIZE   128

Definition at line 73 of file superbitrf.h.

Enumeration Type Documentation

◆ dsm_protocol

Enumerator
DSM_DSM2_1 

The original DSM2 protocol with 1 packet of data.

DSM_DSM2_2 

The original DSM2 protocol with 2 packets of data.

DSM_DSM2P 

Our own DSM2 Paparazzi protocol.

DSM_DSMXP 

Our own DSMX Paparazzi protocol.

DSM_DSMX_1 

The original DSMX protocol with 1 packet of data.

DSM_DSMX_2 

The original DSMX protocol with 2 packets of data.

DSM_DSM2_1 

The original DSM2 protocol with 1 packet of data.

DSM_DSM2_2 

The original DSM2 protocol with 2 packets of data.

DSM_DSM2P 

Our own DSM2 Paparazzi protocol.

DSM_DSMXP 

Our own DSMX Paparazzi protocol.

DSM_DSMX_1 

The original DSMX protocol with 1 packet of data.

DSM_DSMX_2 

The original DSMX protocol with 2 packets of data.

Definition at line 62 of file superbitrf.h.

◆ dsm_resolution

Enumerator
SUPERBITRF_10_BIT_RESOLUTION 

The transmitter has a 10 bit resolution.

SUPERBITRF_11_BIT_RESOLUTION 

The transmitter has a 11 bit resolution.

Definition at line 56 of file superbitrf.h.

◆ SuperbitRFStatus

Enumerator
SUPERBITRF_UNINIT 

The chip isn't initialized.

SUPERBITRF_INIT_BINDING 

The chip is initializing binding mode.

SUPERBITRF_INIT_TRANSFER 

The chip is initializing transfer mode.

SUPERBITRF_BINDING 

The chip is in binding mode.

SUPERBITRF_SYNCING_A 

The chip is in synchronizing mode for channel A.

SUPERBITRF_SYNCING_B 

The chip is in synchronizing mode for channel B.

SUPERBITRF_TRANSFER 

The chip is in transfer mode.

Definition at line 45 of file superbitrf.h.

Function Documentation

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

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

◆ superbitrf_init()

◆ superbitrf_set_mfg_id()

void superbitrf_set_mfg_id ( uint32_t  id)

Definition at line 34 of file superbitrf.c.

References SuperbitRF::bind_mfg_id, SuperbitRF::bind_mfg_id32, SuperbitRF::crc_seed, SuperbitRF::data_col, SuperbitRF::sop_col, and superbitrf.

Referenced by superbitrf_event(), and superbitrf_receive_packet_cb().

+ Here is the caller graph for this function:

◆ superbitrf_set_protocol()

void superbitrf_set_protocol ( uint8_t  protocol)

Definition at line 39 of file superbitrf.c.

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

Referenced by superbitrf_event(), and superbitrf_receive_packet_cb().

+ Here is the caller graph for this function:

Variable Documentation

◆ pprz_srf_tp

struct pprz_transport pprz_srf_tp
extern

Definition at line 1 of file superbitrf.c.

Referenced by superbitrf_dl_event(), and superbitrf_dl_init().

◆ superbitrf