ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
ci24r1.c File Reference
#include "ci24r1.h"

Go to the source code of this file.

Functions

void CI24R1_WriteByte (uint8_t value)
 
uint8_t CI24R1_ReadByte (void)
 
void CI24R1_WriteReg (uint8_t reg, uint8_t value)
 
uint8_t CI24R1_ReadReg (uint8_t reg)
 
void CI24R1_WriteCmd (uint8_t cmd)
 
void CI24R1_WriteFromBuf (uint8_t reg, const uint8_t *pBuf, uint8_t len)
 
void CI24R1_ReadToBuf (uint8_t reg, uint8_t *pBuf, uint8_t len)
 
void CI24R1_SetTxMode (void)
 
void CI24R1_SetRxMode (void)
 
uint8_t CI24R1_SPI_Test (void)
 
void CI24R1_SetTxAddress (uint8_t *address)
 
void CI24R1_SetRxAddress (uint8_t *address)
 
void CI24R1_SetChannel (uint8_t channel)
 
void CI24R1_Init (void)
 
uint8_t CI24R1_Tx (uint8_t *ucPayload, uint8_t length)
 
uint8_t CI24R1_Rx (void)
 
uint8_t CI24R1_ReadStatus (void)
 
void CI24R1_Switch1F_AF (uint8_t af)
 
uint8_t CI24R1_PrintStatus (void)
 

Variables

__IDATA uint8_t cbuf [2]
 
__IDATA uint8_t xbuf [CI24R1_PLOAD_MAX_WIDTH+1]
 
uint8_txbuf_data = xbuf + 1
 

Function Documentation

◆ CI24R1_Init()

void CI24R1_Init ( void  )

Definition at line 163 of file ci24r1.c.

164{
166#if (CI24R1_PLOAD_WIDTH == 0)
167 // Enable dynamic payload length on pipe 0 and pipe 1
170#else
171 // Fixed payload length
174 // Length of pipe 0
176 // Length of pipe 1
178#endif
180 // Enable auto ack all pipes
182 // Enable all pipes
184 // Address width, 0x1:3bytes, 0x02:4bytes, 0x3:5bytes
186 // Resend 500us and 3 times. interval: 250us * ([0, 15] + 1), retries: [0, 15]
188 // RF Data Rate 250K 11db
191}
void CI24R1_WriteReg(uint8_t reg, uint8_t value)
Definition: ci24r1.c:66
#define CI24R1_REG_RX_PW_P1
Definition: ci24r1.h:85
#define CI24R1_REG_DYNPD
Definition: ci24r1.h:91
#define CI24R1_PLOAD_WIDTH
Definition: ci24r1.h:21
#define CI24R1_RF_SETUP_11DB
Definition: ci24r1.h:104
#define CI24R1_REG_FEATURE
Definition: ci24r1.h:92
#define CI24R1_CE_HIGH()
Definition: ci24r1.h:40
#define CI24R1_REG_SETUP_AW
Definition: ci24r1.h:66
#define CI24R1_REG_EN_AA
Definition: ci24r1.h:64
#define CI24R1_REG_SETUP_RETR
Definition: ci24r1.h:67
#define CI24R1_RF_SETUP_1M
Definition: ci24r1.h:114
#define CI24R1_REG_RF_SETUP
Definition: ci24r1.h:69
#define CI24R1_REG_RX_PW_P0
Definition: ci24r1.h:84
#define CI24R1_REG_EN_RXADDR
Definition: ci24r1.h:65
#define CI24R1_CE_LOW()
Definition: ci24r1.h:39
#define CI24R1_CMD_W_REGISTER
Definition: ci24r1.h:47
#define CI24R1_REG_CONFIG
Definition: ci24r1.h:63

◆ CI24R1_PrintStatus()

uint8_t CI24R1_PrintStatus ( void  )

Definition at line 269 of file ci24r1.c.

270{
271 uint8_t i, status;
272
273 UART1_TxString("[Config]");
275
276 UART1_TxString(" [EN_AA]");
278
279 UART1_TxString(" [EN_RxAddr]");
281
282 UART1_TxString(" [AddrWidth]");
284
285 UART1_TxString(" [Retry]");
287
288 UART1_TxString("\r\n[RF_Channel]");
290
291 UART1_TxString(" [RF_Setup]");
293
294 UART1_TxString(" [Observe_Tx]");
296
297 UART1_TxString(" [RSSI]");
299
300 UART1_TxString("\r\n[TxAddr] ");
302 for (i = 0; i < 5; i++) {
303 UART1_TxHex(*(xbuf_data + i));
304 }
305
306 UART1_TxString("\r\n[RxAddrP0]");
308 for (i = 0; i < 5; i++) {
309 UART1_TxHex(*(xbuf_data + i));
310 }
311 UART1_TxString(" [RxAddrP1]");
313 for (i = 0; i < 5; i++) {
314 UART1_TxHex(*(xbuf_data + i));
315 }
316 UART1_TxString(" [RxAddrP2]");
318 UART1_TxString(" [RxAddrP3]");
320 UART1_TxString(" [RxAddrP4]");
322 UART1_TxString(" [RxAddrP5]");
324
325 UART1_TxString("\r\n[0F_CRC]");
328
329 UART1_TxString(" [0F_OSC_C]");
332
333 UART1_TxString(" [0F_BT]");
336
337 UART1_TxString(" [0F_BT_CRC_L/M/H]");
344
345 UART1_TxString("\r\n[RX_PW_P0]");
347 UART1_TxString(" [RX_PW_P1]");
349 UART1_TxString(" [RX_PW_P2]");
351 UART1_TxString(" [RX_PW_P3]");
353 UART1_TxString(" [RX_PW_P4]");
355 UART1_TxString(" [RX_PW_P5]");
357
358 UART1_TxString("\r\n[FIFO_Status]");
360
361 UART1_TxString(" [DynPloadWidth]");
363
364 UART1_TxString(" [Feature]");
366
367 status = CI24R1_ReadStatus();
368 UART1_TxString("\r\n[Status]");
369 UART1_TxHex(status);
370 UART1_TxString("\r\n\r\n");
371 return status;
372}
uint8_t * xbuf_data
Definition: ci24r1.c:18
uint8_t CI24R1_ReadStatus(void)
Definition: ci24r1.c:249
uint8_t CI24R1_ReadReg(uint8_t reg)
Definition: ci24r1.c:74
void CI24R1_Switch1F_AF(uint8_t af)
Definition: ci24r1.c:254
void CI24R1_ReadToBuf(uint8_t reg, uint8_t *pBuf, uint8_t len)
Definition: ci24r1.c:103
#define CI24R1_EN_RXADDR_BT
Definition: ci24r1.h:99
#define CI24R1_CMD_R_REGISTER
Definition: ci24r1.h:46
#define CI24R1_REG_RSSI
Definition: ci24r1.h:72
#define CI24R1_REG_RX_PW_P5
Definition: ci24r1.h:89
#define CI24R1_REG_FIFO_STATUS
Definition: ci24r1.h:90
#define CI24R1_REG_TX_ADDR
Definition: ci24r1.h:83
#define CI24R1_EN_RXADDR_BT_CRC_M
Definition: ci24r1.h:101
#define CI24R1_EN_RXADDR_BT_CRC_H
Definition: ci24r1.h:102
#define CI24R1_REG_RX_PW_P4
Definition: ci24r1.h:88
#define CI24R1_REG_RX_ADDR_P2
Definition: ci24r1.h:75
#define CI24R1_REG_RX_ADDR_P1
Definition: ci24r1.h:74
#define CI24R1_REG_RX_ADDR_P3
Definition: ci24r1.h:76
#define CI24R1_REG_RX_PW_P2
Definition: ci24r1.h:86
#define CI24R1_REG_OBSERVE_TX
Definition: ci24r1.h:71
#define CI24R1_EN_RXADDR_OSC_C
Definition: ci24r1.h:98
#define CI24R1_REG_RF_CH
Definition: ci24r1.h:68
#define CI24R1_EN_RXADDR_CRC
Definition: ci24r1.h:97
#define CI24R1_REG_RX_ADDR_P4
Definition: ci24r1.h:77
#define CI24R1_REG_RX_ADDR_P0
Definition: ci24r1.h:73
#define CI24R1_EN_RXADDR_BT_CRC_L
Definition: ci24r1.h:100
#define CI24R1_REG_RX_PW_P3
Definition: ci24r1.h:87
#define CI24R1_REG_RX_ADDR_P5AF
Definition: ci24r1.h:78
unsigned char uint8_t
Definition: fw_types.h:18
void UART1_TxString(uint8_t *str)
Definition: fw_uart.c:85
void UART1_TxHex(uint8_t hex)
Definition: fw_uart.c:79
uint8_t __XDATA i

◆ CI24R1_ReadByte()

uint8_t CI24R1_ReadByte ( void  )

Definition at line 42 of file ci24r1.c.

43{
44 uint8_t i = 0, RxData;
45
48 for (i = 0; i < 8; i++)
49 {
50 RxData = RxData << 1;
52 if (CI24R1_DATA_READ())
53 {
54 RxData |= 0x01;
55 }
56 else
57 {
58 RxData &= 0xfe;
59 }
61 }
63 return RxData;
64}
#define CI24R1_DATA_IN()
Definition: ci24r1.h:28
#define CI24R1_DATA_READ()
Definition: ci24r1.h:31
#define CI24R1_CLK_HIGH()
Definition: ci24r1.h:34
#define CI24R1_CLK_LOW()
Definition: ci24r1.h:33

◆ CI24R1_ReadReg()

uint8_t CI24R1_ReadReg ( uint8_t  reg)

Definition at line 74 of file ci24r1.c.

75{
76 uint8_t reg_val;
79 reg_val = CI24R1_ReadByte();
81 return reg_val;
82}
uint8_t CI24R1_ReadByte(void)
Definition: ci24r1.c:42
void CI24R1_WriteByte(uint8_t value)
Definition: ci24r1.c:20
#define CI24R1_NSS_LOW()
Definition: ci24r1.h:36
#define CI24R1_NSS_HIGH()
Definition: ci24r1.h:37

◆ CI24R1_ReadStatus()

uint8_t CI24R1_ReadStatus ( void  )

Definition at line 249 of file ci24r1.c.

250{
252}
#define CI24R1_REG_STATUS
Definition: ci24r1.h:70

◆ CI24R1_ReadToBuf()

void CI24R1_ReadToBuf ( uint8_t  reg,
uint8_t pBuf,
uint8_t  len 
)

Definition at line 103 of file ci24r1.c.

104{
105 uint8_t ctr;
107 CI24R1_WriteByte(reg);
108 for (ctr = 0; ctr < len; ctr++)
109 {
110 pBuf[ctr] = CI24R1_ReadByte();
111 }
113
114}

◆ CI24R1_Rx()

uint8_t CI24R1_Rx ( void  )

Definition at line 217 of file ci24r1.c.

218{
219 uint8_t i, status, rxplWidth;
223 while(CI24R1_DATA_READ());
226 status = CI24R1_ReadStatus();
227 UART1_TxChar('>');
228 UART1_TxHex(status);
229 if (status & CI24R1_FLAG_RX_READY)
230 {
231#if CI24R1_PLOAD_WIDTH == 0
233#else
234 rxplWidth = CI24R1_PLOAD_WIDTH;
235#endif
236 // Read RX to buffer
238 // Clear status flags
240 UART1_TxChar('>');
241 for (i = 0; i < rxplWidth; i++)
242 {
243 UART1_TxHex(*(xbuf_data + i));
244 }
245 }
246 return status;
247}
__IDATA uint8_t xbuf[CI24R1_PLOAD_MAX_WIDTH+1]
Definition: ci24r1.c:17
#define CI24R1_CMD_SELIRQ
Definition: ci24r1.h:60
#define CI24R1_DATA_OUT()
Definition: ci24r1.h:27
#define CI24R1_FLAG_RX_READY
Definition: ci24r1.h:118
#define CI24R1_CMD_NOP
Definition: ci24r1.h:56
#define CI24R1_CMD_FLUSH_RX
Definition: ci24r1.h:51
#define CI24R1_CMD_SELSPI
Definition: ci24r1.h:59
#define CI24R1_CMD_R_RX_PL_WID
Definition: ci24r1.h:53
#define CI24R1_CMD_R_RX_PAYLOAD
Definition: ci24r1.h:48
void UART1_TxChar(char dat)
Definition: fw_uart.c:72

◆ CI24R1_SetChannel()

void CI24R1_SetChannel ( uint8_t  channel)

Definition at line 157 of file ci24r1.c.

158{
159 if (channel > 125) channel = 125;
161}

◆ CI24R1_SetRxAddress()

void CI24R1_SetRxAddress ( uint8_t address)

Definition at line 152 of file ci24r1.c.

153{
155}
void CI24R1_WriteFromBuf(uint8_t reg, const uint8_t *pBuf, uint8_t len)
Definition: ci24r1.c:91

◆ CI24R1_SetRxMode()

void CI24R1_SetRxMode ( void  )

◆ CI24R1_SetTxAddress()

void CI24R1_SetTxAddress ( uint8_t address)

Definition at line 146 of file ci24r1.c.

◆ CI24R1_SetTxMode()

void CI24R1_SetTxMode ( void  )

◆ CI24R1_SPI_Test()

uint8_t CI24R1_SPI_Test ( void  )

Definition at line 132 of file ci24r1.c.

133{
139 for (i = 0; i < 5; i++) {
140 UART1_TxHex(*(xbuf + i));
141 if (*(xbuf + i) != *ptr++) return HAL_ERROR;
142 }
143 return HAL_OK;
144}
#define CI24R1_TEST_ADDR
Definition: ci24r1.h:123
@ HAL_ERROR
Definition: fw_types.h:77
@ HAL_OK
Definition: fw_types.h:76

◆ CI24R1_Switch1F_AF()

void CI24R1_Switch1F_AF ( uint8_t  af)

Definition at line 254 of file ci24r1.c.

255{
256 uint8_t val;
257
259 val &= 0x3F;
260 val |= (af & 0x03) << 6;
262
264 val &= 0x3F;
265 val |= (af & 0x0C) << 4;
267}
uint8_t val[MAX7219_BLOCKS]

◆ CI24R1_Tx()

uint8_t CI24R1_Tx ( uint8_t ucPayload,
uint8_t  length 
)

Definition at line 193 of file ci24r1.c.

194{
195 uint8_t status;
196#if (CI24R1_PLOAD_WIDTH == 0)
198#else
200#endif
204 while (CI24R1_DATA_READ());
207 status = CI24R1_ReadStatus();
208 if (status & CI24R1_FLAG_MAX_RT)
209 {
211 }
212 // Clear status flags
214 return status;
215}
void CI24R1_WriteCmd(uint8_t cmd)
Definition: ci24r1.c:84
#define CI24R1_CMD_W_TX_PAYLOAD
Definition: ci24r1.h:49
#define CI24R1_CMD_FLUSH_TX
Definition: ci24r1.h:50
#define CI24R1_FLAG_MAX_RT
Definition: ci24r1.h:120

◆ CI24R1_WriteByte()

void CI24R1_WriteByte ( uint8_t  value)

Definition at line 20 of file ci24r1.c.

21{
22 uint8_t i = 0;
25 for (i = 0; i < 8; i++)
26 {
28 if (value & 0x80)
29 {
31 }
32 else
33 {
35 }
37 value = value << 1;
38 }
40}
#define CI24R1_DATA_HIGH()
Definition: ci24r1.h:30
#define CI24R1_DATA_LOW()
Definition: ci24r1.h:29

◆ CI24R1_WriteCmd()

void CI24R1_WriteCmd ( uint8_t  cmd)

Definition at line 84 of file ci24r1.c.

85{
89}

◆ CI24R1_WriteFromBuf()

void CI24R1_WriteFromBuf ( uint8_t  reg,
const uint8_t pBuf,
uint8_t  len 
)

Definition at line 91 of file ci24r1.c.

92{
93 uint8_t ctr;
96 for (ctr = 0; ctr < len; ctr++)
97 {
98 CI24R1_WriteByte(*pBuf++);
99 }
101}

◆ CI24R1_WriteReg()

void CI24R1_WriteReg ( uint8_t  reg,
uint8_t  value 
)

Definition at line 66 of file ci24r1.c.

Variable Documentation

◆ cbuf

__IDATA uint8_t cbuf[2]

Definition at line 17 of file ci24r1.c.

◆ xbuf

Definition at line 17 of file ci24r1.c.

◆ xbuf_data

uint8_t* xbuf_data = xbuf + 1

Definition at line 18 of file ci24r1.c.