32 #define RF_CHN_TABLE 0x8000 152 #define RF_FAST_MODE_2M 0 153 #define RF_FAST_MODE_1M 0 156 #ifndef RF_FAST_MODE_1M 157 #define RF_FAST_MODE_1M 1 160 #ifndef RF_FAST_MODE_2M 161 #define RF_FAST_MODE_2M 0 164 #ifndef RF_LONG_PACKET_EN 165 #define RF_LONG_PACKET_EN 0 169 #if RF_LONG_PACKET_EN 170 #define RF_PACKET_LENGTH_OK(p) (p[0] == p[12]+13) 171 #define RF_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x51) == 0x40) 173 #define RF_PACKET_LENGTH_OK(p) (p[0] == (p[12]&0x3f)+15) 174 #define RF_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x51) == 0x40) 176 #elif RF_FAST_MODE_1M 177 #define RF_BLE_PACKET_LENGTH_OK(p) ( *((unsigned int*)p) == p[5]+13) //dma_len must 4 byte aligned 178 #define RF_BLE_PACKET_CRC_OK(p) ((p[*((unsigned int*)p) + 3] & 0x01) == 0x0) 180 #if (1) // support RF RX/TX MAX data Length: 251byte 181 #define RF_PACKET_LENGTH_OK(p) (MAKE_U16(p[1], p[0]) == p[5]+13) 182 #define RF_PACKET_CRC_OK(p) ((p[MAKE_U16(p[1], p[0])+3] & 0x01) == 0x0) 184 #define RF_PACKET_LENGTH_OK(p) (p[0] == p[5]+13) 185 #define RF_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x01) == 0x0) 188 #define RF_PACKET_LENGTH_OK(p) (p[0] == p[12]+13) 189 #define RF_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x51) == 0x10) 192 #define RF_PACKET_1M_LENGTH_OK(p) (p[0] == p[5]+13) 193 #define RF_PACKET_2M_LENGTH_OK(p) (p[0] == (p[12]&0x3f)+15) 196 #if (RF_FAST_MODE_2M) 197 #define RF_FAST_MODE 1 198 #define RF_TRX_MODE 0x80 199 #define RF_TRX_OFF 0x44 //f02 200 #elif (RF_FAST_MODE_1M) 201 #define RF_FAST_MODE 1 202 #define RF_TRX_MODE 0x80 203 #define RF_TRX_OFF 0x45 //f02 205 #define RF_FAST_MODE 0 206 #define RF_TRX_MODE 0xe0 207 #define RF_TRX_OFF 0x45 //f02 212 #define RF_ZIGBEE_PACKET_LENGTH_OK(p) (p[0] == p[4]+9) 213 #define RF_ZIGBEE_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x51) == 0x10) 214 #define RF_ZIGBEE_PACKET_RSSI_GET(p) (p[p[0]+2]) 215 #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)) 216 #define RF_ZIGBEE_PACKET_PAYLOAD_LENGTH_GET(p) (p[4]) 217 #define RF_NRF_ESB_PACKET_LENGTH_OK(p) (p[0] == (p[4] & 0x3f) + 11) 218 #define RF_NRF_ESB_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x01) == 0x00) 219 #define RF_NRF_ESB_PACKET_RSSI_GET(p) (p[p[0]+2]) 220 #define RF_NRF_SB_PACKET_PAYLOAD_LENGTH_GET(p) (p[0] - 10) 221 #define RF_NRF_SB_PACKET_CRC_OK(p) ((p[p[0]+3] & 0x01) == 0x00) 222 #define RF_NRF_SB_PACKET_CRC_GET(p) ((p[p[0]-8]<<8) + p[p[0]-7]) //Note: here assume that the MSByte of CRC is received first 223 #define RF_NRF_SB_PACKET_RSSI_GET(p) (p[p[0]+2]) 224 #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)) 225 #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)) 293 extern void rf_acc_code_set(
unsigned char pipe_id,
const unsigned char *addr);
300 extern void rf_acc_code_get(
unsigned char pipe_id,
unsigned char *addr);
431 extern void rf_tx_pkt(
unsigned char * addr);
473 return (
unsigned char)((
read_reg8(0xf20) &
BIT(0))==0x01);
494 extern void rf_rx_buffer_set(
unsigned char * RF_RxAddr,
int size,
unsigned char PingpongEn);
550 extern void rf_start_btx (
void* addr,
unsigned int tick);
561 extern void rf_start_brx (
void* addr,
unsigned int tick);
570 extern void rf_start_stx (
void* addr,
unsigned int tick);
682 write_reg32 (0x800424, p[0] | (p[1]<<8) | (p[2]<<16));
712 write_reg32 (0x800408, p[3] | (p[2]<<8) | (p[1]<<16) | (p[0]<<24));
743 for (
int i=0; i<16; i++) {
745 r |= code &
BIT(i) ? 1 : 2;
757 unsigned short r = 0;
758 for (
int i=0; i<16; i++) {
761 r |= (code &
BIT(i*2)) ? 1 : 0;
776 return (((
read_reg8(0x448)>>5)& 1) == 1);
803 extern void rf_rx_cfg(
int size,
unsigned char PingpongEn);
812 extern unsigned short crc16_ccitt_cal(
unsigned char *input,
unsigned int len,
unsigned short init_val);
828 unsigned char *acc_code,
unsigned char acc_len,
829 unsigned char *payload,
unsigned char pld_len,
830 unsigned char *tx_buf,
unsigned short crc_init);
static void rf_rx_acc_code_enable(unsigned char pipe)
this function is to enable/disable each access_code channel for RF Rx terminal.
Definition: rf_drv.h:343
Definition: gpio_8258.h:58
void rf_set_channel(signed char chn, unsigned short set)
This function serves to set RF's channel.
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.
Definition: rf_drv.h:527
Definition: gpio_8258.h:70
static unsigned char rf_tx_finish(void)
This function serves to determine whether sending a packet of data is finished.
Definition: rf_drv.h:444
RF_StatusTypeDef rf_trx_state_get(void)
This function serves to get RF status.
static void rf_access_code_comm(unsigned int acc)
This function serves to set RF access command.
Definition: rf_drv.h:315
void rf_rx_cfg(int size, unsigned char PingpongEn)
This function.
Definition: gpio_8258.h:73
static void rf_rx_buffer_reconfig(unsigned short RF_RxAddr)
This function serves to reconfigure the buffer.
Definition: rf_drv.h:503
static unsigned char rf_acc_len_get(unsigned char len)
this function performs to get access_code length.
Definition: rf_drv.h:283
RF_ModeTypeDef
Define RF mode.
Definition: rf_drv.h:39
void rf_set_ble_channel(signed char chn_num)
This function serves to set the ble channel.
#define RF_TRX_MODE
Definition: rf_drv.h:202
static unsigned short rf_access_code_32to16(unsigned int code)
This function serves to set RF access code 6bit to 32bit.
Definition: rf_drv.h:755
#define write_reg32(addr, v)
Definition: bsp.h:108
void rf_acc_len_set(unsigned char len)
this function is to Set byte length for access_code.
static void rf_set_tx_rx_off(void)
This function serves to reset RF Tx/Rx mode.
Definition: rf_drv.h:367
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 wi...
RF_LNARxPinDef
Define RX pin of RF for RFFE.
Definition: rf_drv.h:71
static void rf_set_tx_rx_off_auto_mode(void)
This function serves to turn off RF auto mode.
Definition: rf_drv.h:378
static void rf_set_ble_crc_adv()
This function serves to set CRC advantage.
Definition: rf_drv.h:700
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...
Definition: rf_drv.h:471
RF_StatusTypeDef
Define RF Tx/Rx/Auto mode.
Definition: rf_drv.h:59
static void rf_set_ble_crc(unsigned char *p)
This function serves to set pipe for RF Tx.
Definition: rf_drv.h:680
static void rf_set_ble_access_code(unsigned char *p)
This function serves to set RF access code.
Definition: rf_drv.h:710
#define write_reg8(addr, v)
Definition: bsp.h:106
void rf_acc_code_set(unsigned char pipe_id, const unsigned char *addr)
this function is to set access code.
signed char rf_get_tx_power_level(void)
This function serves to get RF TX power level .
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...
static void rf_set_txmode(void)
This function serves to set RF Tx mode.
Definition: rf_drv.h:402
static unsigned int rf_access_code_16to32(unsigned short code)
This function serves to set RF access code 6bit to 32bit.
Definition: rf_drv.h:740
const RF_PowerTypeDef rf_power_Level_list[60]
static void rf_reset_sn(void)
This function serves to reset the RF sn.
Definition: rf_drv.h:669
void rf_acc_code_get(unsigned char pipe_id, unsigned char *addr)
this function is to set access code.
void rf_tx_pkt_auto(void *addr)
This function serves to send packet for RF.
#define BIT(n)
Definition: bsp.h:33
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 compatibl...
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 unt...
void rf_drv_init(RF_ModeTypeDef rf_mode)
This function serves to initiate the mode of RF.
static void tx_settle_adjust(unsigned short txstl_us)
This function serves to settle adjust for RF Tx.
Definition: rf_drv.h:412
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 ...
static void reset_baseband(void)
This function serves to reset RF BaseBand.
Definition: rf_drv.h:237
Definition: gpio_8258.h:71
#define REG_ADDR8(a)
Definition: bsp.h:102
unsigned short crc16_ccitt_cal(unsigned char *input, unsigned int len, unsigned short init_val)
This function serves to get CRC.
static void rf_set_ble_crc_value(unsigned int crc)
This function serves to set CRC value for RF.
Definition: rf_drv.h:690
static void rf_set_tx_pipe(unsigned char pipe)
This function serves to set pipe for RF Tx.
Definition: rf_drv.h:422
void rf_rx_buffer_set(unsigned char *RF_RxAddr, int size, unsigned char PingpongEn)
This function is to set rx buffer.
void rf_set_channel_500k(signed short chn, unsigned short set)
This function serves to set The channel .
#define reg_dma2_addr
Definition: register_8258.h:1112
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.
void rf_set_power_level_index_zgb(int level_idx)
This function serves to set RF power level index.
static void rf_longrange_access_code_comm(unsigned int acc)
This function serves to set RF access command.
Definition: rf_drv.h:327
void rf_tx_pkt(unsigned char *addr)
This function serves to set RF Tx packet.
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 pac...
static unsigned char rf_is_rx_right(void)
This function serves to determine whether a packet of data received is right.
Definition: rf_drv.h:513
static void rf_ble_tx_done()
This function performs to done RF Tx.
Definition: rf_drv.h:649
Definition: gpio_8258.h:57
#define REG_ADDR16(a)
Definition: bsp.h:103
void rf_set_power_level_index(RF_PowerTypeDef level)
This function serves to set RF power level index.
static void rf_set_rxmode(void)
This function serves to set RF Tx mode.
Definition: rf_drv.h:537
static void rf_set_ble_access_code_value(unsigned int ac)
This function serves to set RF access code value.
Definition: rf_drv.h:720
#define read_reg8(addr)
Definition: bsp.h:110
void rf_start_btx(void *addr, unsigned int tick)
This function serves to start Tx of ble_mode.
RF_PATxPinDef
Define TX pin of RF for RFFE.
Definition: rf_drv.h:81
static void rf_fix_payload_len_set(int len)
this function is to set shock burst for RF.
Definition: rf_drv.h:790
static void rf_ble_tx_on()
This function performs to enable RF Tx.
Definition: rf_drv.h:639
void rf_start_stx(void *addr, unsigned int tick)
This function serves to start Tx.
int rf_trx_state_set(RF_StatusTypeDef rf_status, signed char rf_channel)
This function serves to judge RF Tx/Rx state.
static void rf_tx_acc_code_select(unsigned char pipe)
this function is to select access_code channel for RF Rx terminal.
Definition: rf_drv.h:356
RF_PowerTypeDef
Define power list of RF.
Definition: rf_drv.h:90
#define RF_TRX_OFF
Definition: rf_drv.h:203
void rf_rffe_set_pin(RF_PATxPinDef tx_pin, RF_LNARxPinDef rx_pin)
This function serves to set pin for RFFE of RF.
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.
Definition: rf_drv.h:458
static unsigned char is_rf_receiving_pkt(void)
This function serves to judge the statue of RF receive.
Definition: rf_drv.h:773
void rf_start_srx(unsigned int tick)
This function serves to start Rx.
Definition: gpio_8258.h:74
void rf_ed_detecct_154(void)
This function is to start energy detect of the current channel for zigbee mode Before using it...
static void reset_sn_nesn(void)
This function serves to reset function for RF.
Definition: rf_drv.h:659
static void rf_set_ble_access_code_adv(void)
This function serves to set RF access code advantage.
Definition: rf_drv.h:730