#include "fw_hal.h"
#include "string.h"
Go to the source code of this file.
◆ MAX_RT_FLAG
◆ RX_DR_FLAG
◆ RX_TX_CMP_FLAG
| #define RX_TX_CMP_FLAG 0X60 |
◆ TX_DS_FLAG
◆ XL2400_CMD_ACTIVATE
| #define XL2400_CMD_ACTIVATE 0x50 |
◆ XL2400_CMD_DEACTIVATE
| #define XL2400_CMD_DEACTIVATE 0x50 |
◆ XL2400_CMD_FLUSH_RX
| #define XL2400_CMD_FLUSH_RX 0xE2 |
◆ XL2400_CMD_FLUSH_TX
| #define XL2400_CMD_FLUSH_TX 0xE1 |
◆ XL2400_CMD_NOP
| #define XL2400_CMD_NOP 0xFF |
◆ XL2400_CMD_R_REGISTER
| #define XL2400_CMD_R_REGISTER 0x00 |
REGISTER TABLE
Definition at line 30 of file xl2400.h.
◆ XL2400_CMD_R_RX_PAYLOAD
| #define XL2400_CMD_R_RX_PAYLOAD 0x61 |
◆ XL2400_CMD_R_RX_PL_WID
| #define XL2400_CMD_R_RX_PL_WID 0x60 |
◆ XL2400_CMD_REUSE_TX_PL
| #define XL2400_CMD_REUSE_TX_PL 0xE3 |
◆ XL2400_CMD_RST_FSPI
| #define XL2400_CMD_RST_FSPI 0x53 |
◆ XL2400_CMD_W_ACK_PAYLOAD
| #define XL2400_CMD_W_ACK_PAYLOAD 0xA8 |
◆ XL2400_CMD_W_REGISTER
| #define XL2400_CMD_W_REGISTER 0x20 |
◆ XL2400_CMD_W_TX_PAYLOAD
| #define XL2400_CMD_W_TX_PAYLOAD 0xA0 |
◆ XL2400_CMD_W_TX_PAYLOAD_NOACK
| #define XL2400_CMD_W_TX_PAYLOAD_NOACK 0xB0 |
◆ XL2400_CSN
◆ XL2400_MOSI
◆ XL2400_PL_WIDTH_MAX
| #define XL2400_PL_WIDTH_MAX 64 |
◆ XL2400_PLOAD_WIDTH
| #define XL2400_PLOAD_WIDTH 32 |
◆ XL2400_REG_AGC_SETTING
| #define XL2400_REG_AGC_SETTING 0x0E |
◆ XL2400_REG_ANALOG_CFG0
| #define XL2400_REG_ANALOG_CFG0 0x12 |
◆ XL2400_REG_ANALOG_CFG1
| #define XL2400_REG_ANALOG_CFG1 0x13 |
◆ XL2400_REG_ANALOG_CFG2
| #define XL2400_REG_ANALOG_CFG2 0x14 |
◆ XL2400_REG_ANALOG_CFG3
| #define XL2400_REG_ANALOG_CFG3 0x15 |
◆ XL2400_REG_BER_RESULT
| #define XL2400_REG_BER_RESULT 0x0D |
◆ XL2400_REG_CFG_TOP
| #define XL2400_REG_CFG_TOP 0x00 |
◆ XL2400_REG_DYNPD
| #define XL2400_REG_DYNPD 0x1C |
◆ XL2400_REG_EN_AA
| #define XL2400_REG_EN_AA 0x01 |
◆ XL2400_REG_EN_RXADDR
| #define XL2400_REG_EN_RXADDR 0x02 |
◆ XL2400_REG_FEATURE
| #define XL2400_REG_FEATURE 0x1D |
◆ XL2400_REG_FIFO_STATUS
| #define XL2400_REG_FIFO_STATUS 0x17 |
◆ XL2400_REG_OBSERVE_TX
| #define XL2400_REG_OBSERVE_TX 0x08 |
◆ XL2400_REG_PGA_SETTING
| #define XL2400_REG_PGA_SETTING 0x0F |
◆ XL2400_REG_RAMP_CFG
| #define XL2400_REG_RAMP_CFG 0x1E |
◆ XL2400_REG_RF_CH
| #define XL2400_REG_RF_CH 0x05 |
◆ XL2400_REG_RF_SETUP
| #define XL2400_REG_RF_SETUP 0x06 |
◆ XL2400_REG_RSSI
| #define XL2400_REG_RSSI 0x09 |
◆ XL2400_REG_RSSIREC
| #define XL2400_REG_RSSIREC 0x18 |
◆ XL2400_REG_RX_ADDR_P0
| #define XL2400_REG_RX_ADDR_P0 0x0A |
◆ XL2400_REG_RX_ADDR_P1
| #define XL2400_REG_RX_ADDR_P1 0x0B |
◆ XL2400_REG_RX_ADDR_P2_P5
| #define XL2400_REG_RX_ADDR_P2_P5 0x0C |
◆ XL2400_REG_RX_PW_PX
| #define XL2400_REG_RX_PW_PX 0x11 |
◆ XL2400_REG_RXPROC_CFG
| #define XL2400_REG_RXPROC_CFG 0x1A |
◆ XL2400_REG_SETUP_AW
| #define XL2400_REG_SETUP_AW 0x03 |
◆ XL2400_REG_SETUP_RETR
| #define XL2400_REG_SETUP_RETR 0x04 |
◆ XL2400_REG_STATUS
| #define XL2400_REG_STATUS 0x07 |
◆ XL2400_REG_TX_ADDR
| #define XL2400_REG_TX_ADDR 0x10 |
◆ XL2400_REG_TXPROC_CFG
| #define XL2400_REG_TXPROC_CFG 0x19 |
◆ XL2400_RF_0DB
| #define XL2400_RF_0DB 0x10 |
◆ XL2400_RF_10DB
| #define XL2400_RF_10DB 0x3F |
◆ XL2400_RF_2DB
| #define XL2400_RF_2DB 0x14 |
◆ XL2400_RF_3DB
| #define XL2400_RF_3DB 0x20 |
◆ XL2400_RF_4DB
| #define XL2400_RF_4DB 0x24 |
◆ XL2400_RF_5DB
| #define XL2400_RF_5DB 0x28 |
◆ XL2400_RF_6DB
| #define XL2400_RF_6DB 0x2C |
◆ XL2400_RF_7DB
| #define XL2400_RF_7DB 0x30 |
◆ XL2400_RF_8DB
| #define XL2400_RF_8DB 0x34 |
◆ XL2400_RF_9DB
| #define XL2400_RF_9DB 0x38 |
◆ XL2400_RF__12DB
| #define XL2400_RF__12DB 0x04 |
◆ XL2400_RF__18DB
| #define XL2400_RF__18DB 0x02 |
◆ XL2400_RF__24DB
| #define XL2400_RF__24DB 0x01 |
◆ XL2400_RF__2DB
| #define XL2400_RF__2DB 0x0C |
◆ XL2400_RF__6DB
| #define XL2400_RF__6DB 0x08 |
◆ XL2400_RF_DR_1M
| #define XL2400_RF_DR_1M 0x02 |
◆ XL2400_RF_DR_250K
| #define XL2400_RF_DR_250K 0x22 |
◆ XL2400_SCK
◆ XL2400_TEST_ADDR
| #define XL2400_TEST_ADDR "XL240" |
◆ XL2400_CarrierTest()
| void XL2400_CarrierTest |
( |
void |
| ) |
|
Definition at line 343 of file xl2400.c.
344{
347 *(
xbuf + 12) |= 0x40;
348 *(
xbuf + 4) &= ~0x04;
355}
void XL2400_WriteReg(uint8_t reg, uint8_t value)
void XL2400_WriteFromBuf(uint8_t reg, const uint8_t *pBuf, uint8_t len)
void XL2400_ReadToBuf(uint8_t reg, uint8_t *pBuf, uint8_t len)
__IDATA uint8_t xbuf[XL2400_PL_WIDTH_MAX+1]
void XL2400_ClearStatus(void)
#define XL2400_REG_TXPROC_CFG
#define XL2400_REG_ANALOG_CFG0
#define XL2400_CMD_R_REGISTER
#define XL2400_CMD_W_REGISTER
#define XL2400_REG_RF_SETUP
◆ XL2400_CE_High()
| void XL2400_CE_High |
( |
void |
| ) |
|
Definition at line 121 of file xl2400.c.
122{
126}
#define XL2400_REG_CFG_TOP
◆ XL2400_CE_Low()
| void XL2400_CE_Low |
( |
void |
| ) |
|
◆ XL2400_ClearStatus()
| void XL2400_ClearStatus |
( |
void |
| ) |
|
Definition at line 330 of file xl2400.c.
331{
335}
#define XL2400_CMD_FLUSH_TX
#define XL2400_CMD_FLUSH_RX
#define XL2400_REG_STATUS
◆ XL2400_FlushRxTX()
| void XL2400_FlushRxTX |
( |
void |
| ) |
|
◆ XL2400_Init()
| void XL2400_Init |
( |
void |
| ) |
|
Definition at line 141 of file xl2400.c.
142{
143
145 *(
xbuf + 4) &= ~0x04;
146 *(
xbuf + 12) |= 0x40;
148
150
152
154
156
158
160
164
166
167
168
169
170
171
172
173
175
179}
#define XL2400_REG_EN_RXADDR
#define XL2400_REG_FEATURE
#define XL2400_PLOAD_WIDTH
#define XL2400_REG_SETUP_RETR
#define XL2400_REG_SETUP_AW
#define XL2400_REG_RX_PW_PX
◆ XL2400_PrintStatus()
| uint8_t XL2400_PrintStatus |
( |
void |
| ) |
|
Definition at line 357 of file xl2400.c.
358{
360
361 UART1_TxString(
"Bytes from low to high: 0,1,2,3,...\r\n[Config]");
363 for (
i = 0;
i < 3;
i++) {
365 }
366
369
372
375
378 for (
i = 0;
i < 4;
i++) {
380 }
381
384 for (
i = 0;
i < 3;
i++) {
386 }
387
390 for (
i = 0;
i < 2;
i++) {
392 }
393
396 for (
i = 0;
i < 4;
i++) {
398 }
399
402 for (
i = 0;
i < 2;
i++) {
404 }
405
408 for (
i = 0;
i < 5;
i++) {
410 }
411
414 for (
i = 0;
i < 5;
i++) {
416 }
419 for (
i = 0;
i < 5;
i++) {
421 }
424 for (
i = 0;
i < 4;
i++) {
426 }
427
430 for (
i = 0;
i < 6;
i++) {
432 }
433
436 for (
i = 0;
i < 3;
i++) {
438 }
443
448 return status;
449}
void UART1_TxString(uint8_t *str)
void UART1_TxHex(uint8_t hex)
uint8_t XL2400_ReadStatus(void)
uint8_t XL2400_ReadReg(uint8_t reg)
#define XL2400_REG_RX_ADDR_P0
#define XL2400_REG_OBSERVE_TX
#define XL2400_REG_FIFO_STATUS
#define XL2400_REG_RX_ADDR_P1
#define XL2400_REG_RX_ADDR_P2_P5
#define XL2400_REG_TX_ADDR
◆ XL2400_ReadReg()
Definition at line 80 of file xl2400.c.
81{
87 return reg_val;
88}
void XL2400_WriteByte(uint8_t value)
uint8_t XL2400_ReadByte(void)
#define XL2400_NSS_HIGH()
◆ XL2400_ReadStatus()
◆ XL2400_ReadToBuf()
Definition at line 48 of file xl2400.c.
49{
55}
void SPI_TxRxBytes(uint8_t *pBuf, uint8_t len)
#define XL2400_PL_WIDTH_MAX
◆ XL2400_Rx()
Definition at line 306 of file xl2400.c.
307{
311 {
316
317
318
319
320
321 }
322 return status;
323}
#define XL2400_CMD_R_RX_PAYLOAD
#define XL2400_CMD_R_RX_PL_WID
◆ XL2400_RxCalibrate()
| uint8_t XL2400_RxCalibrate |
( |
void |
| ) |
|
Definition at line 236 of file xl2400.c.
237{
239 for (
i = 0;
i < 10;
i++)
240 {
244 *(
cbuf + 1) &= ~0x20;
250
251 if (*(
cbuf + 1) & 0x20)
252 {
253 j = *(
cbuf + 1) << 3;
261 }
262 }
264}
void SYS_Delay(uint16_t t)
#define XL2400_REG_ANALOG_CFG3
◆ XL2400_SetChannel()
| void XL2400_SetChannel |
( |
uint8_t |
channel | ) |
|
Definition at line 181 of file xl2400.c.
182{
183 if (channel > 80) channel = 80;
184
186
188
189 *(
cbuf + 0) = 0x60 + channel;
192
195}
◆ XL2400_SetPower()
| void XL2400_SetPower |
( |
uint8_t |
power | ) |
|
◆ XL2400_SetRxAddress()
| void XL2400_SetRxAddress |
( |
uint8_t * |
address | ) |
|
◆ XL2400_SetRxMode()
| void XL2400_SetRxMode |
( |
void |
| ) |
|
Definition at line 275 of file xl2400.c.
276{
280
283}
void XL2400_CE_High(void)
◆ XL2400_SetTxAddress()
| void XL2400_SetTxAddress |
( |
uint8_t * |
address | ) |
|
◆ XL2400_SetTxMode()
| void XL2400_SetTxMode |
( |
void |
| ) |
|
Definition at line 266 of file xl2400.c.
267{
273}
uint8_t XL2400_RxCalibrate(void)
◆ XL2400_Sleep()
| void XL2400_Sleep |
( |
void |
| ) |
|
◆ XL2400_SPI_Test()
Definition at line 128 of file xl2400.c.
129{
134 for (
i = 0;
i < 5;
i++) {
137 }
139}
◆ XL2400_Tx()
Definition at line 285 of file xl2400.c.
286{
291
293 {
296
298 {
299 break;
300 }
301 }
303 return status;
304}
void SYS_DelayUs(uint16_t t)
#define XL2400_CMD_W_TX_PAYLOAD
◆ XL2400_WakeUp()
| void XL2400_WakeUp |
( |
void |
| ) |
|
◆ XL2400_WriteBack()
◆ XL2400_WriteFromBuf()
Definition at line 90 of file xl2400.c.
91{
95 for (ctr = 0; ctr < len; ctr++)
96 {
98 }
100}
◆ XL2400_WriteReg()