rf_drv.h File Reference

Go to the source code of this file.

Macros

#define RF_CHN_TABLE   0x8000
 
#define RF_FAST_MODE_1M   1
 
#define RF_FAST_MODE_2M   0
 
#define RF_LONG_PACKET_EN   0
 
#define RF_BLE_PACKET_LENGTH_OK(p)   ( *((unsigned int*)p) == p[5]+13)
 
#define RF_BLE_PACKET_CRC_OK(p)   ((p[*((unsigned int*)p) + 3] & 0x01) == 0x0)
 
#define RF_PACKET_LENGTH_OK(p)   (MAKE_U16(p[1], p[0]) == p[5]+13)
 
#define RF_PACKET_CRC_OK(p)   ((p[MAKE_U16(p[1], p[0])+3] & 0x01) == 0x0)
 
#define RF_PACKET_1M_LENGTH_OK(p)   (p[0] == p[5]+13)
 
#define RF_PACKET_2M_LENGTH_OK(p)   (p[0] == (p[12]&0x3f)+15)
 
#define RF_FAST_MODE   1
 
#define RF_TRX_MODE   0x80
 
#define RF_TRX_OFF   0x45
 
#define RF_ZIGBEE_PACKET_LENGTH_OK(p)   (p[0] == p[4]+9)
 
#define RF_ZIGBEE_PACKET_CRC_OK(p)   ((p[p[0]+3] & 0x51) == 0x10)
 
#define RF_ZIGBEE_PACKET_RSSI_GET(p)   (p[p[0]+2])
 
#define RF_ZIGBEE_PACKET_TIMESTAMP_GET(p)   (p[p[0]-4] | (p[p[0]-3]<<8) | (p[p[0]-2]<<16) | (p[p[0]-1]<<24))
 
#define RF_ZIGBEE_PACKET_PAYLOAD_LENGTH_GET(p)   (p[4])
 
#define RF_NRF_ESB_PACKET_LENGTH_OK(p)   (p[0] == (p[4] & 0x3f) + 11)
 
#define RF_NRF_ESB_PACKET_CRC_OK(p)   ((p[p[0]+3] & 0x01) == 0x00)
 
#define RF_NRF_ESB_PACKET_RSSI_GET(p)   (p[p[0]+2])
 
#define RF_NRF_SB_PACKET_PAYLOAD_LENGTH_GET(p)   (p[0] - 10)
 
#define RF_NRF_SB_PACKET_CRC_OK(p)   ((p[p[0]+3] & 0x01) == 0x00)
 
#define RF_NRF_SB_PACKET_CRC_GET(p)   ((p[p[0]-8]<<8) + p[p[0]-7])
 
#define RF_NRF_SB_PACKET_RSSI_GET(p)   (p[p[0]+2])
 
#define RF_NRF_ESB_PACKET_TIMESTAMP_GET(p)   (p[p[0]-4] | (p[p[0]-3]<<8) | (p[p[0]-2]<<16) | (p[p[0]-1]<<24))
 
#define RF_NRF_SB_PACKET_TIMESTAMP_GET(p)   (p[p[0]-4] | (p[p[0]-3]<<8) | (p[p[0]-2]<<16) | (p[p[0]-1]<<24))
 

Enumerations

enum  RF_ModeTypeDef {
  RF_MODE_BLE_2M = BIT(0), RF_MODE_BLE_1M = BIT(1), RF_MODE_BLE_1M_NO_PN = BIT(2), RF_MODE_ZIGBEE_250K = BIT(3),
  RF_MODE_LR_S2_500K = BIT(4), RF_MODE_LR_S8_125K = BIT(5), RF_MODE_PRIVATE_250K = BIT(6), RF_MODE_PRIVATE_500K = BIT(7),
  RF_MODE_PRIVATE_1M = BIT(8), RF_MODE_PRIVATE_2M = BIT(9), RF_MODE_ANT = BIT(10), RF_MODE_BLE_2M_NO_PN = BIT(11)
}
 Define RF mode. More...
 
enum  RF_StatusTypeDef { RF_MODE_TX = 0, RF_MODE_RX = 1, RF_MODE_AUTO =2 }
 Define RF Tx/Rx/Auto mode. More...
 
enum  RF_LNARxPinDef { RFFE_RX_PB2 = GPIO_PB2, RFFE_RX_PC6 = GPIO_PC6, RFFE_RX_PD0 = GPIO_PD0 }
 Define RX pin of RF for RFFE. More...
 
enum  RF_PATxPinDef { RFFE_TX_PB3 = GPIO_PB3, RFFE_TX_PC7 = GPIO_PC7, RFFE_TX_PD1 = GPIO_PD1 }
 Define TX pin of RF for RFFE. More...
 
enum  RF_PowerTypeDef {
  RF_POWER_P10p46dBm = 63, RF_POWER_P10p29dBm = 61, RF_POWER_P10p01dBm = 58, RF_POWER_P9p81dBm = 56,
  RF_POWER_P9p48dBm = 53, RF_POWER_P9p24dBm = 51, RF_POWER_P8p97dBm = 49, RF_POWER_P8p73dBm = 47,
  RF_POWER_P8p44dBm = 45, RF_POWER_P8p13dBm = 43, RF_POWER_P7p79dBm = 41, RF_POWER_P7p41dBm = 39,
  RF_POWER_P7p02dBm = 37, RF_POWER_P6p60dBm = 35, RF_POWER_P6p14dBm = 33, RF_POWER_P5p65dBm = 31,
  RF_POWER_P5p13dBm = 29, RF_POWER_P4p57dBm = 27, RF_POWER_P3p94dBm = 25, RF_POWER_P3p23dBm = 23,
  RF_POWER_P3p01dBm = BIT(7) | 63, RF_POWER_P2p81dBm = BIT(7) | 61, RF_POWER_P2p61dBm = BIT(7) | 59, RF_POWER_P2p39dBm = BIT(7) | 57,
  RF_POWER_P1p99dBm = BIT(7) | 54, RF_POWER_P1p73dBm = BIT(7) | 52, RF_POWER_P1p45dBm = BIT(7) | 50, RF_POWER_P1p17dBm = BIT(7) | 48,
  RF_POWER_P0p90dBm = BIT(7) | 46, RF_POWER_P0p58dBm = BIT(7) | 44, RF_POWER_P0p04dBm = BIT(7) | 41, RF_POWER_N0p14dBm = BIT(7) | 40,
  RF_POWER_N0p97dBm = BIT(7) | 36, RF_POWER_N1p42dBm = BIT(7) | 34, RF_POWER_N1p89dBm = BIT(7) | 32, RF_POWER_N2p48dBm = BIT(7) | 30,
  RF_POWER_N3p03dBm = BIT(7) | 28, RF_POWER_N3p61dBm = BIT(7) | 26, RF_POWER_N4p26dBm = BIT(7) | 24, RF_POWER_N5p03dBm = BIT(7) | 22,
  RF_POWER_N5p81dBm = BIT(7) | 20, RF_POWER_N6p67dBm = BIT(7) | 18, RF_POWER_N7p65dBm = BIT(7) | 16, RF_POWER_N8p65dBm = BIT(7) | 14,
  RF_POWER_N9p89dBm = BIT(7) | 12, RF_POWER_N11p4dBm = BIT(7) | 10, RF_POWER_N13p29dBm = BIT(7) | 8, RF_POWER_N15p88dBm = BIT(7) | 6,
  RF_POWER_N19p27dBm = BIT(7) | 4, RF_POWER_N25p18dBm = BIT(7) | 2, RF_POWER_N30dBm = 0xff, RF_POWER_N50dBm = BIT(7) | 0
}
 Define power list of RF. More...
 

Functions

static void reset_baseband (void)
 This function serves to reset RF BaseBand. More...
 
void rf_drv_init (RF_ModeTypeDef rf_mode)
 This function serves to initiate the mode of RF. More...
 
void rf_set_power_level_index (RF_PowerTypeDef level)
 This function serves to set RF power level index. More...
 
void rf_set_power_level_index_zgb (int level_idx)
 This function serves to set RF power level index. More...
 
signed char rf_get_tx_power_level (void)
 This function serves to get RF TX power level . More...
 
void rf_acc_len_set (unsigned char len)
 this function is to Set byte length for access_code. More...
 
static unsigned char rf_acc_len_get (unsigned char len)
 this function performs to get access_code length. More...
 
void rf_acc_code_set (unsigned char pipe_id, const unsigned char *addr)
 this function is to set access code. More...
 
void rf_acc_code_get (unsigned char pipe_id, unsigned char *addr)
 this function is to set access code. More...
 
void rf_set_channel (signed char chn, unsigned short set)
 This function serves to set RF's channel. More...
 
static void rf_access_code_comm (unsigned int acc)
 This function serves to set RF access command. More...
 
static void rf_longrange_access_code_comm (unsigned int acc)
 This function serves to set RF access command. More...
 
static void rf_rx_acc_code_enable (unsigned char pipe)
 this function is to enable/disable each access_code channel for RF Rx terminal. More...
 
static void rf_tx_acc_code_select (unsigned char pipe)
 this function is to select access_code channel for RF Rx terminal. More...
 
static void rf_set_tx_rx_off (void)
 This function serves to reset RF Tx/Rx mode. More...
 
static void rf_set_tx_rx_off_auto_mode (void)
 This function serves to turn off RF auto mode. More...
 
int rf_trx_state_set (RF_StatusTypeDef rf_status, signed char rf_channel)
 This function serves to judge RF Tx/Rx state. More...
 
RF_StatusTypeDef rf_trx_state_get (void)
 This function serves to get RF status. More...
 
static void rf_set_txmode (void)
 This function serves to set RF Tx mode. More...
 
static void tx_settle_adjust (unsigned short txstl_us)
 This function serves to settle adjust for RF Tx. More...
 
static void rf_set_tx_pipe (unsigned char pipe)
 This function serves to set pipe for RF Tx. More...
 
void rf_tx_pkt (unsigned char *addr)
 This function serves to set RF Tx packet. More...
 
void rf_tx_pkt_auto (void *addr)
 This function serves to send packet for RF. More...
 
static unsigned char rf_tx_finish (void)
 This function serves to determine whether sending a packet of data is finished. More...
 
static void rf_tx_finish_clear_flag (void)
 This function serves to clear the Tx finish flag bit. After all packet data are sent, corresponding Tx finish flag bit will be set as 1.By reading this flag bit, it can check whether packet transmission is finished. After the check, it¡¯s needed to manually clear this flag bit so as to avoid misjudgment. More...
 
static unsigned char rf_is_rx_finish (void)
 This function serves to determine whether sending a packet of rf_tx_acc_code_select is finished. More...
 
void rf_rx_buffer_set (unsigned char *RF_RxAddr, int size, unsigned char PingpongEn)
 This function is to set rx buffer. More...
 
static void rf_rx_buffer_reconfig (unsigned short RF_RxAddr)
 This function serves to reconfigure the buffer. More...
 
static unsigned char rf_is_rx_right (void)
 This function serves to determine whether a packet of data received is right. More...
 
static void rf_rx_finish_clear_flag (void)
 This function serves to clear the Rx finish flag bit. After all packet data are resive, corresponding Rx finish flag bit will be set as 1.By reading this flag bit, it can check whether packet transmission is finished. After the check, it¡¯s needed to manually clear this flag bit so as to avoid misjudgment. More...
 
static void rf_set_rxmode (void)
 This function serves to set RF Tx mode. More...
 
void rf_start_btx (void *addr, unsigned int tick)
 This function serves to start Tx of ble_mode. More...
 
void rf_start_brx (void *addr, unsigned int tick)
 This function serves to start Rx of auto mode. In this mode, RF module stays in Rx status until a packet is received or it fails to receive packet when timeout expires. Timeout duration is set by the parameter "tick". The address to store received data is set by the function ¡°addr¡±. More...
 
void rf_start_stx (void *addr, unsigned int tick)
 This function serves to start Tx. More...
 
void rf_start_srx (unsigned int tick)
 This function serves to start Rx. More...
 
void rf_start_stx2rx (void *addr, unsigned int tick)
 This function serves to start stx2rx mode of auto_mode. In this mode, a packet is sent first,RF module waits for 10us, stays in Rx status until data is received or timeout expires, then exits this mode.Timeout duration is set by the parameter ¡°timeout_us¡±.The address to store received data is set by the function ¡°RF_RxBufferSet¡±. More...
 
void rf_start_srx2tx (void *addr, unsigned int tick)
 This function serves to start srx2tx mode of auto_mode. In this mode,RF module stays in Rx status until a packet is received or it fails to receive packetwhen timeout expires. If a packet is received within the timeout duration, RF module will wait for 10us,send a packet, and then exit this mode. If it fails to receive packet when timeout expires, RF module will directly exit this mode.Timeout duration is set by the parameter "timeout_us". The address to store received data is set by the function ¡°RF_RxBufferSet¡±. More...
 
void rf_set_ble_channel (signed char chn_num)
 This function serves to set the ble channel. More...
 
static void rf_ble_tx_on ()
 This function performs to enable RF Tx. More...
 
static void rf_ble_tx_done ()
 This function performs to done RF Tx. More...
 
static void reset_sn_nesn (void)
 This function serves to reset function for RF. More...
 
static void rf_reset_sn (void)
 This function serves to reset the RF sn. More...
 
static void rf_set_ble_crc (unsigned char *p)
 This function serves to set pipe for RF Tx. More...
 
static void rf_set_ble_crc_value (unsigned int crc)
 This function serves to set CRC value for RF. More...
 
static void rf_set_ble_crc_adv ()
 This function serves to set CRC advantage. More...
 
static void rf_set_ble_access_code (unsigned char *p)
 This function serves to set RF access code. More...
 
static void rf_set_ble_access_code_value (unsigned int ac)
 This function serves to set RF access code value. More...
 
static void rf_set_ble_access_code_adv (void)
 This function serves to set RF access code advantage. More...
 
static unsigned int rf_access_code_16to32 (unsigned short code)
 This function serves to set RF access code 6bit to 32bit. More...
 
static unsigned short rf_access_code_32to16 (unsigned int code)
 This function serves to set RF access code 6bit to 32bit. More...
 
static unsigned char is_rf_receiving_pkt (void)
 This function serves to judge the statue of RF receive. More...
 
void rf_set_channel_500k (signed short chn, unsigned short set)
 This function serves to set The channel . More...
 
static void rf_fix_payload_len_set (int len)
 this function is to set shock burst for RF. More...
 
void rf_rx_cfg (int size, unsigned char PingpongEn)
 This function. More...
 
unsigned short crc16_ccitt_cal (unsigned char *input, unsigned int len, unsigned short init_val)
 This function serves to get CRC. More...
 
void rf_tx_500k_simulate_100k (unsigned char *preamble, unsigned char preamble_len, unsigned char *acc_code, unsigned char acc_len, unsigned char *payload, unsigned char pld_len, unsigned char *tx_buf, unsigned short crc_init)
 This function serves to simulate 100k Tx by 500k Tx. More...
 
void rf_ed_detecct_154 (void)
 This function is to start energy detect of the current channel for zigbee mode Before using it. More...
 
unsigned char rf_stop_ed_154 (void)
 This function is to stop energy detect and get energy detect value of the current channel for zigbee mode. More...
 
void rf_rffe_set_pin (RF_PATxPinDef tx_pin, RF_LNARxPinDef rx_pin)
 This function serves to set pin for RFFE of RF. More...
 
unsigned char rx_packet_process_1mbps (unsigned char *rx_buf, unsigned int len)
 This function process the received packet in 1mbps shockburst mode only for hanshow for the compatiblity with third-party chips. The process includes data-whitening transformation and crc check. More...
 
void tx_packet_process_1mbps (unsigned char *tx_buf, unsigned char *payload, unsigned int len)
 This function process the tx packet in 1mbps shockburst mode only for hanshow for the compatiblity with third-party chips. The process includes data-whitening transformation and crc padding. More...
 

Variables

const RF_PowerTypeDef rf_power_Level_list [60]
 

Macro Definition Documentation

◆ RF_CHN_TABLE

#define RF_CHN_TABLE   0x8000

◆ RF_FAST_MODE_1M

#define RF_FAST_MODE_1M   1

◆ RF_FAST_MODE_2M

#define RF_FAST_MODE_2M   0

◆ RF_LONG_PACKET_EN

#define RF_LONG_PACKET_EN   0

◆ RF_BLE_PACKET_LENGTH_OK

#define RF_BLE_PACKET_LENGTH_OK (   p)    ( *((unsigned int*)p) == p[5]+13)

◆ RF_BLE_PACKET_CRC_OK

#define RF_BLE_PACKET_CRC_OK (   p)    ((p[*((unsigned int*)p) + 3] & 0x01) == 0x0)

◆ RF_PACKET_LENGTH_OK

#define RF_PACKET_LENGTH_OK (   p)    (MAKE_U16(p[1], p[0]) == p[5]+13)

◆ RF_PACKET_CRC_OK

#define RF_PACKET_CRC_OK (   p)    ((p[MAKE_U16(p[1], p[0])+3] & 0x01) == 0x0)

◆ RF_PACKET_1M_LENGTH_OK

#define RF_PACKET_1M_LENGTH_OK (   p)    (p[0] == p[5]+13)

◆ RF_PACKET_2M_LENGTH_OK

#define RF_PACKET_2M_LENGTH_OK (   p)    (p[0] == (p[12]&0x3f)+15)

◆ RF_FAST_MODE

#define RF_FAST_MODE   1

◆ RF_TRX_MODE

#define RF_TRX_MODE   0x80

◆ RF_TRX_OFF

#define RF_TRX_OFF   0x45

◆ RF_ZIGBEE_PACKET_LENGTH_OK

#define RF_ZIGBEE_PACKET_LENGTH_OK (   p)    (p[0] == p[4]+9)

◆ RF_ZIGBEE_PACKET_CRC_OK

#define RF_ZIGBEE_PACKET_CRC_OK (   p)    ((p[p[0]+3] & 0x51) == 0x10)

◆ RF_ZIGBEE_PACKET_RSSI_GET

#define RF_ZIGBEE_PACKET_RSSI_GET (   p)    (p[p[0]+2])

◆ RF_ZIGBEE_PACKET_TIMESTAMP_GET

#define RF_ZIGBEE_PACKET_TIMESTAMP_GET (   p)    (p[p[0]-4] | (p[p[0]-3]<<8) | (p[p[0]-2]<<16) | (p[p[0]-1]<<24))

◆ RF_ZIGBEE_PACKET_PAYLOAD_LENGTH_GET

#define RF_ZIGBEE_PACKET_PAYLOAD_LENGTH_GET (   p)    (p[4])

◆ RF_NRF_ESB_PACKET_LENGTH_OK

#define RF_NRF_ESB_PACKET_LENGTH_OK (   p)    (p[0] == (p[4] & 0x3f) + 11)

◆ RF_NRF_ESB_PACKET_CRC_OK

#define RF_NRF_ESB_PACKET_CRC_OK (   p)    ((p[p[0]+3] & 0x01) == 0x00)

◆ RF_NRF_ESB_PACKET_RSSI_GET

#define RF_NRF_ESB_PACKET_RSSI_GET (   p)    (p[p[0]+2])

◆ RF_NRF_SB_PACKET_PAYLOAD_LENGTH_GET

#define RF_NRF_SB_PACKET_PAYLOAD_LENGTH_GET (   p)    (p[0] - 10)

◆ RF_NRF_SB_PACKET_CRC_OK

#define RF_NRF_SB_PACKET_CRC_OK (   p)    ((p[p[0]+3] & 0x01) == 0x00)

◆ RF_NRF_SB_PACKET_CRC_GET

#define RF_NRF_SB_PACKET_CRC_GET (   p)    ((p[p[0]-8]<<8) + p[p[0]-7])

◆ RF_NRF_SB_PACKET_RSSI_GET

#define RF_NRF_SB_PACKET_RSSI_GET (   p)    (p[p[0]+2])

◆ RF_NRF_ESB_PACKET_TIMESTAMP_GET

#define RF_NRF_ESB_PACKET_TIMESTAMP_GET (   p)    (p[p[0]-4] | (p[p[0]-3]<<8) | (p[p[0]-2]<<16) | (p[p[0]-1]<<24))

◆ RF_NRF_SB_PACKET_TIMESTAMP_GET

#define RF_NRF_SB_PACKET_TIMESTAMP_GET (   p)    (p[p[0]-4] | (p[p[0]-3]<<8) | (p[p[0]-2]<<16) | (p[p[0]-1]<<24))

Enumeration Type Documentation

◆ RF_ModeTypeDef

Define RF mode.

Enumerator
RF_MODE_BLE_2M 
RF_MODE_BLE_1M 
RF_MODE_BLE_1M_NO_PN 
RF_MODE_ZIGBEE_250K 
RF_MODE_LR_S2_500K 
RF_MODE_LR_S8_125K 
RF_MODE_PRIVATE_250K 
RF_MODE_PRIVATE_500K 
RF_MODE_PRIVATE_1M 
RF_MODE_PRIVATE_2M 
RF_MODE_ANT 
RF_MODE_BLE_2M_NO_PN 

◆ RF_StatusTypeDef

Define RF Tx/Rx/Auto mode.

Enumerator
RF_MODE_TX 
RF_MODE_RX 
RF_MODE_AUTO 

◆ RF_LNARxPinDef

Define RX pin of RF for RFFE.

Enumerator
RFFE_RX_PB2 
RFFE_RX_PC6 
RFFE_RX_PD0 

◆ RF_PATxPinDef

Define TX pin of RF for RFFE.

Enumerator
RFFE_TX_PB3 
RFFE_TX_PC7 
RFFE_TX_PD1 

◆ RF_PowerTypeDef

Define power list of RF.

Enumerator
RF_POWER_P10p46dBm 
RF_POWER_P10p29dBm 
RF_POWER_P10p01dBm 
RF_POWER_P9p81dBm 
RF_POWER_P9p48dBm 
RF_POWER_P9p24dBm 
RF_POWER_P8p97dBm 
RF_POWER_P8p73dBm 
RF_POWER_P8p44dBm 
RF_POWER_P8p13dBm 
RF_POWER_P7p79dBm 
RF_POWER_P7p41dBm 
RF_POWER_P7p02dBm 
RF_POWER_P6p60dBm 
RF_POWER_P6p14dBm 
RF_POWER_P5p65dBm 
RF_POWER_P5p13dBm 
RF_POWER_P4p57dBm 
RF_POWER_P3p94dBm 
RF_POWER_P3p23dBm 
RF_POWER_P3p01dBm 
RF_POWER_P2p81dBm 
RF_POWER_P2p61dBm 
RF_POWER_P2p39dBm 
RF_POWER_P1p99dBm 
RF_POWER_P1p73dBm 
RF_POWER_P1p45dBm 
RF_POWER_P1p17dBm 
RF_POWER_P0p90dBm 
RF_POWER_P0p58dBm 
RF_POWER_P0p04dBm 
RF_POWER_N0p14dBm 
RF_POWER_N0p97dBm 
RF_POWER_N1p42dBm 
RF_POWER_N1p89dBm 
RF_POWER_N2p48dBm 
RF_POWER_N3p03dBm 
RF_POWER_N3p61dBm 
RF_POWER_N4p26dBm 
RF_POWER_N5p03dBm 
RF_POWER_N5p81dBm 
RF_POWER_N6p67dBm 
RF_POWER_N7p65dBm 
RF_POWER_N8p65dBm 
RF_POWER_N9p89dBm 
RF_POWER_N11p4dBm 
RF_POWER_N13p29dBm 
RF_POWER_N15p88dBm 
RF_POWER_N19p27dBm 
RF_POWER_N25p18dBm 
RF_POWER_N30dBm 
RF_POWER_N50dBm 

Function Documentation

◆ reset_baseband()

static void reset_baseband ( void  )
inlinestatic

This function serves to reset RF BaseBand.

Parameters
[in]none.
Returns
none.

◆ rf_drv_init()

void rf_drv_init ( RF_ModeTypeDef  rf_mode)

This function serves to initiate the mode of RF.

Parameters
[in]rf_mode- mode of RF
Returns
none.

◆ rf_set_power_level_index()

void rf_set_power_level_index ( RF_PowerTypeDef  level)

This function serves to set RF power level index.

Parameters
[in]RF_PowerTypeDef- the RF power types.
Returns
none.

◆ rf_set_power_level_index_zgb()

void rf_set_power_level_index_zgb ( int  level_idx)

This function serves to set RF power level index.

Parameters
[in]level_idx- the RF power index.
Returns
none.

◆ rf_get_tx_power_level()

signed char rf_get_tx_power_level ( void  )

This function serves to get RF TX power level .

Parameters
[in]RF_PowerTypeDef- the RF power types.
Returns
none.

◆ rf_acc_len_set()

void rf_acc_len_set ( unsigned char  len)

this function is to Set byte length for access_code.

Parameters
[in]lenOptional range: 2~5 , The effect for 3-byte access_code is not good.
Returns
none

◆ rf_acc_len_get()

static unsigned char rf_acc_len_get ( unsigned char  len)
inlinestatic

this function performs to get access_code length.

Parameters
[in]len- Optional range: 3~5 Note: The effect for 3-byte access_code is not good.
Returns
access_byte_num[2:0]

◆ rf_acc_code_set()

void rf_acc_code_set ( unsigned char  pipe_id,
const unsigned char *  addr 
)

this function is to set access code.

Parameters
[in]pipeindex number for access_code channel.
[in]addrthe access code address.
Returns
none

◆ rf_acc_code_get()

void rf_acc_code_get ( unsigned char  pipe_id,
unsigned char *  addr 
)

this function is to set access code.

Parameters
[in]pipe_idindex number for access_code channel.
[in]addrthe access code address.
Returns
none

◆ rf_set_channel()

void rf_set_channel ( signed char  chn,
unsigned short  set 
)

This function serves to set RF's channel.

Parameters
[in]chn- RF channel.
[in]set- the value to set.
Returns
none.

◆ rf_access_code_comm()

static void rf_access_code_comm ( unsigned int  acc)
inlinestatic

This function serves to set RF access command.

Parameters
[in]acc- the command.
Returns
none.

◆ rf_longrange_access_code_comm()

static void rf_longrange_access_code_comm ( unsigned int  acc)
inlinestatic

This function serves to set RF access command.

Parameters
[in]acc- the command.
Returns
none.

◆ rf_rx_acc_code_enable()

static void rf_rx_acc_code_enable ( unsigned char  pipe)
inlinestatic

this function is to enable/disable each access_code channel for RF Rx terminal.

Parameters
[in]pipeBit0~bit5 correspond to channel 0~5, respectively. 0£ºDisable 1£ºEnable If ¡°enable¡± is set as 0x3f (i.e. 00111111), all access_code channels (0~5) are enabled.
Returns
none

◆ rf_tx_acc_code_select()

static void rf_tx_acc_code_select ( unsigned char  pipe)
inlinestatic

this function is to select access_code channel for RF Rx terminal.

Parameters
[in]pipeBit0~bit5 correspond to channel 0~5, respectively. 0£ºDisable 1£ºEnable If ¡°enable¡± is set as 0x3f (i.e. 00111111), all access_code channels (0~5) are enabled.
Returns
none

◆ rf_set_tx_rx_off()

static void rf_set_tx_rx_off ( void  )
inlinestatic

This function serves to reset RF Tx/Rx mode.

Parameters
none.
Returns
none.

◆ rf_set_tx_rx_off_auto_mode()

static void rf_set_tx_rx_off_auto_mode ( void  )
inlinestatic

This function serves to turn off RF auto mode.

Parameters
none.
Returns
none.

◆ rf_trx_state_set()

int rf_trx_state_set ( RF_StatusTypeDef  rf_status,
signed char  rf_channel 
)

This function serves to judge RF Tx/Rx state.

Parameters
[in]rf_status- Tx/Rx status.
[in]rf_channel- RF channel.
Returns
failed -1,else success.

◆ rf_trx_state_get()

RF_StatusTypeDef rf_trx_state_get ( void  )

This function serves to get RF status.

Parameters
[in]none.
Returns
RF Rx/Tx status.

◆ rf_set_txmode()

static void rf_set_txmode ( void  )
inlinestatic

This function serves to set RF Tx mode.

Parameters
none.
Returns
none.

◆ tx_settle_adjust()

static void tx_settle_adjust ( unsigned short  txstl_us)
inlinestatic

This function serves to settle adjust for RF Tx.

Parameters
txstl_us- adjust TX settle time.
Returns
none

◆ rf_set_tx_pipe()

static void rf_set_tx_pipe ( unsigned char  pipe)
inlinestatic

This function serves to set pipe for RF Tx.

Parameters
pipe- RF Optional range .
Returns
none

◆ rf_tx_pkt()

void rf_tx_pkt ( unsigned char *  addr)

This function serves to set RF Tx packet.

Parameters
[in]rf_txaddr- the address RF to send packet.
Returns
none.

◆ rf_tx_pkt_auto()

void rf_tx_pkt_auto ( void *  addr)

This function serves to send packet for RF.

Parameters
addr- the address need to be send.
Returns
none.

◆ rf_tx_finish()

static unsigned char rf_tx_finish ( void  )
inlinestatic

This function serves to determine whether sending a packet of data is finished.

Parameters
[in]none.
Returns
Yes: 1, NO: 0.

◆ rf_tx_finish_clear_flag()

static void rf_tx_finish_clear_flag ( void  )
inlinestatic

This function serves to clear the Tx finish flag bit. After all packet data are sent, corresponding Tx finish flag bit will be set as 1.By reading this flag bit, it can check whether packet transmission is finished. After the check, it¡¯s needed to manually clear this flag bit so as to avoid misjudgment.

Parameters
none
Returns
none

◆ rf_is_rx_finish()

static unsigned char rf_is_rx_finish ( void  )
inlinestatic

This function serves to determine whether sending a packet of rf_tx_acc_code_select is finished.

Parameters
[in]none.
Returns
Yes: 1, NO: 0.

◆ rf_rx_buffer_set()

void rf_rx_buffer_set ( unsigned char *  RF_RxAddr,
int  size,
unsigned char  PingpongEn 
)

This function is to set rx buffer.

Parameters
[out]RF_RxAddrPointer for Rx buffer in RAM(Generally it¡¯s starting address of an array.Should be 4-byte aligned)
[in]sizeRx buffer size (It¡¯s an integral multiple of 16)
[in]PingpongEnEnable/Disable Ping-Pong buffer 1£ºEnable 0£ºDisable Note: When ¡°PingpongEn¡± is set as 0, received RF data will be stored in RAM pointed by ¡° RF_RxAddr¡±. When ¡°PingpongEn¡± is set as 1, received RF data will be stored in buffer0 and buffer1 successively. The RAM size reserved for received RF data should be double of ¡°Size¡±.
Returns
none

◆ rf_rx_buffer_reconfig()

static void rf_rx_buffer_reconfig ( unsigned short  RF_RxAddr)
inlinestatic

This function serves to reconfigure the buffer.

Parameters
[out]RF_RxAddrPointer for Rx buffer in RAM(Generally it¡¯s starting address of an array.Should be 4-byte aligned)
Returns
Yes: 1, NO: 0.

◆ rf_is_rx_right()

static unsigned char rf_is_rx_right ( void  )
inlinestatic

This function serves to determine whether a packet of data received is right.

Parameters
[in]none.
Returns
Yes: 1, NO: 0.

◆ rf_rx_finish_clear_flag()

static void rf_rx_finish_clear_flag ( void  )
inlinestatic

This function serves to clear the Rx finish flag bit. After all packet data are resive, corresponding Rx finish flag bit will be set as 1.By reading this flag bit, it can check whether packet transmission is finished. After the check, it¡¯s needed to manually clear this flag bit so as to avoid misjudgment.

Parameters
none
Returns
none

◆ rf_set_rxmode()

static void rf_set_rxmode ( void  )
inlinestatic

This function serves to set RF Tx mode.

Parameters
none.
Returns
none.

◆ rf_start_btx()

void rf_start_btx ( void *  addr,
unsigned int  tick 
)

This function serves to start Tx of ble_mode.

Parameters
[in]addrTx packet address in RAM. Should be 4-byte aligned.
[in]tickTick value of system timer. It determines when to start ble mode and send packet.
Returns
none

◆ rf_start_brx()

void rf_start_brx ( void *  addr,
unsigned int  tick 
)

This function serves to start Rx of auto mode. In this mode, RF module stays in Rx status until a packet is received or it fails to receive packet when timeout expires. Timeout duration is set by the parameter "tick". The address to store received data is set by the function ¡°addr¡±.

Parameters
[in]addr- The address to store received data.
[in]tick- Unit is us. It indicates timeout duration in Rx status.Max value: 0xffffff (16777215)
Returns
none

◆ rf_start_stx()

void rf_start_stx ( void *  addr,
unsigned int  tick 
)

This function serves to start Tx.

Parameters
[in]addrTx packet address in RAM. Should be 4-byte aligned.
[in]tickTick value of system timer.
Returns
none

◆ rf_start_srx()

void rf_start_srx ( unsigned int  tick)

This function serves to start Rx.

Parameters
[in]tickTick value of system timer.
Returns
none

◆ rf_start_stx2rx()

void rf_start_stx2rx ( void *  addr,
unsigned int  tick 
)

This function serves to start stx2rx mode of auto_mode. In this mode, a packet is sent first,RF module waits for 10us, stays in Rx status until data is received or timeout expires, then exits this mode.Timeout duration is set by the parameter ¡°timeout_us¡±.The address to store received data is set by the function ¡°RF_RxBufferSet¡±.

Parameters
[in]addrTx packet address in RAM. Should be 4-byte aligned.
[in]tickTick value of system timer. It determines when to start StxToRx mode and send packet.
[in]timeout_usUnit is us. It indicates timeout duration in Rx status.Max value: 0xfff (4095)
Returns
none

◆ rf_start_srx2tx()

void rf_start_srx2tx ( void *  addr,
unsigned int  tick 
)

This function serves to start srx2tx mode of auto_mode. In this mode,RF module stays in Rx status until a packet is received or it fails to receive packetwhen timeout expires. If a packet is received within the timeout duration, RF module will wait for 10us,send a packet, and then exit this mode. If it fails to receive packet when timeout expires, RF module will directly exit this mode.Timeout duration is set by the parameter "timeout_us". The address to store received data is set by the function ¡°RF_RxBufferSet¡±.

Parameters
[in]addrTx packet address in RAM. Should be 4-byte aligned.
[in]tickTick value of system timer. It determines when to start SrxToTx mode.
[in]timeout_usUnit is us. It indicates timeout duration in Rx status. Max value: 0xffffff (16777215)
Returns
none

◆ rf_set_ble_channel()

void rf_set_ble_channel ( signed char  chn_num)

This function serves to set the ble channel.

Parameters
chn_num- channel numbers.
Returns
none.

◆ rf_ble_tx_on()

static void rf_ble_tx_on ( )
inlinestatic

This function performs to enable RF Tx.

Parameters
[in]none.
Returns
none.

◆ rf_ble_tx_done()

static void rf_ble_tx_done ( )
inlinestatic

This function performs to done RF Tx.

Parameters
[in]none.
Returns
none.

◆ reset_sn_nesn()

static void reset_sn_nesn ( void  )
inlinestatic

This function serves to reset function for RF.

Parameters
none
Returns
none

◆ rf_reset_sn()

static void rf_reset_sn ( void  )
inlinestatic

This function serves to reset the RF sn.

Parameters
none.
Returns
none.

◆ rf_set_ble_crc()

static void rf_set_ble_crc ( unsigned char *  p)
inlinestatic

This function serves to set pipe for RF Tx.

Parameters
p- RF Optional range .
Returns
none

◆ rf_set_ble_crc_value()

static void rf_set_ble_crc_value ( unsigned int  crc)
inlinestatic

This function serves to set CRC value for RF.

Parameters
[in]crc- CRC value.
Returns
none.

◆ rf_set_ble_crc_adv()

static void rf_set_ble_crc_adv ( )
inlinestatic

This function serves to set CRC advantage.

Parameters
none.
Returns
none.

◆ rf_set_ble_access_code()

static void rf_set_ble_access_code ( unsigned char *  p)
inlinestatic

This function serves to set RF access code.

Parameters
[in]p- the address to access.
Returns
none

◆ rf_set_ble_access_code_value()

static void rf_set_ble_access_code_value ( unsigned int  ac)
inlinestatic

This function serves to set RF access code value.

Parameters
[in]ac- the address value.
Returns
none

◆ rf_set_ble_access_code_adv()

static void rf_set_ble_access_code_adv ( void  )
inlinestatic

This function serves to set RF access code advantage.

Parameters
none.
Returns
none.

◆ rf_access_code_16to32()

static unsigned int rf_access_code_16to32 ( unsigned short  code)
inlinestatic

This function serves to set RF access code 6bit to 32bit.

Parameters
[in]code- the access code.
Returns
the value of the access code.

◆ rf_access_code_32to16()

static unsigned short rf_access_code_32to16 ( unsigned int  code)
inlinestatic

This function serves to set RF access code 6bit to 32bit.

Parameters
[in]code- the access code.
Returns
the value of access code.

◆ is_rf_receiving_pkt()

static unsigned char is_rf_receiving_pkt ( void  )
inlinestatic

This function serves to judge the statue of RF receive.

Parameters
none.
Returns
none.

◆ rf_set_channel_500k()

void rf_set_channel_500k ( signed short  chn,
unsigned short  set 
)

This function serves to set The channel .

Parameters
[in]RF_PowerTypeDef- the RF power types.
Returns
none.

◆ rf_fix_payload_len_set()

static void rf_fix_payload_len_set ( int  len)
inlinestatic

this function is to set shock burst for RF.

Parameters
[in]len- length of shockburst.
Returns
none.

◆ rf_rx_cfg()

void rf_rx_cfg ( int  size,
unsigned char  PingpongEn 
)

This function.

Parameters
[in]size- the expected size of dma2
[in]PingpongEn- the flag of g_RFRxPingpongEn
Returns
none

◆ crc16_ccitt_cal()

unsigned short crc16_ccitt_cal ( unsigned char *  input,
unsigned int  len,
unsigned short  init_val 
)

This function serves to get CRC.

Parameters
[in]*input- the content of payload
[in]len- the length of payload
[in]init_val- the initial value of CRC
Returns
init_val - CRC

◆ rf_tx_500k_simulate_100k()

void rf_tx_500k_simulate_100k ( unsigned char *  preamble,
unsigned char  preamble_len,
unsigned char *  acc_code,
unsigned char  acc_len,
unsigned char *  payload,
unsigned char  pld_len,
unsigned char *  tx_buf,
unsigned short  crc_init 
)

This function serves to simulate 100k Tx by 500k Tx.

Parameters
[in]*preamble- the content of preamble
[in]preamble_len- the length of preamble
[in]*acc_code- the content of access code
[in]acc_len- the length of access code
[in]*payload- the content of payload
[in]pld_len- the length of payload
[in]*tx_buf- the data need to be sent
[in]crc_init- the initial value of CRC
Returns
none

◆ rf_ed_detecct_154()

void rf_ed_detecct_154 ( void  )

This function is to start energy detect of the current channel for zigbee mode Before using it.

Parameters
[in]none
Returns
none

◆ rf_stop_ed_154()

unsigned char rf_stop_ed_154 ( void  )

This function is to stop energy detect and get energy detect value of the current channel for zigbee mode.

Parameters
none
Returns
rf_ed:0x00~0xff

◆ rf_rffe_set_pin()

void rf_rffe_set_pin ( RF_PATxPinDef  tx_pin,
RF_LNARxPinDef  rx_pin 
)

This function serves to set pin for RFFE of RF.

Parameters
[in]tx_pin- select pin to send
[in]rx_pin- select pin to receive
Returns
none

◆ rx_packet_process_1mbps()

unsigned char rx_packet_process_1mbps ( unsigned char *  rx_buf,
unsigned int  len 
)

This function process the received packet in 1mbps shockburst mode only for hanshow for the compatiblity with third-party chips. The process includes data-whitening transformation and crc check.

Parameters
[in]rx_buf- the rf rx buffer containing the received packet(dma length+payload+3 byte crc)
[in]len- the expected rx length of shockburst mode, containing payload and 3byte crc
Returns
the status of the processing procesure. 1: the received packet is correct, 0: the received packet is incorrect

◆ tx_packet_process_1mbps()

void tx_packet_process_1mbps ( unsigned char *  tx_buf,
unsigned char *  payload,
unsigned int  len 
)

This function process the tx packet in 1mbps shockburst mode only for hanshow for the compatiblity with third-party chips. The process includes data-whitening transformation and crc padding.

Parameters
[in]tx_buf- the rf tx buffer containing the tx packet(dma length+payload+3 byte crc)
[in]len- the expected tx length of shockburst mode, containing payload and 3byte crc
Returns
none

Variable Documentation

◆ rf_power_Level_list

const RF_PowerTypeDef rf_power_Level_list[60]