📄 radioclient.h
字号:
/**
* Header for client nRF24L01 code.
*
* @author Stephen Craig, 25/07/2006
*/
#ifndef _RADIO_CLIENT_H_
#define _RADIO_CLIENT_H_
#include "spi.h" /* support for SPI */
/* payload length */
#define PAYLOAD_LEN 32 /* maximum is 32, minimum is 4 */
/* default baud rate */
#define RADIO_DEFAULT_BAUD_RATE SPI_BAUD_6000000
/* Flags set in the clientFlags register which to signify what clients
are active (for a server), and used by clients to determine what
the LSB of their address should be.
defined to match the EN_RXADDR flags */
#define CLIENT_FLAG_0 0x02
#define CLIENT_FLAG_1 0x04
#define CLIENT_FLAG_2 0x08
#define CLIENT_FLAG_3 0x10
#define CLIENT_FLAG_4 0x20
/* define some error codes for init() */
#define INIT_NO_ERROR 0
#define INIT_ERROR_NO_POWER 1
#define INIT_ERROR_NO_CLIENT_SET 2
#define NULL ((void *) 0)
/**
* Initialises the radio transceiver.
* @param baudRate rate at which to comm with module on SPI
* @param rf_channel should be between 0 and 127
* @param serverAddressHeader first four bytes of server address
* @param clientAddressHeader first four bytes of client addresses
* @param client one of CLIENT_FLAG_0, CLIENT_FLAG_1, etc.
* @return one of the INIT_XXX values
*/
unsigned char RadioClient_Init(unsigned char baudRate,
unsigned char rfChannel,
unsigned long serverAddressHeader,
unsigned long clientAddressHeader,
unsigned char client);
/**
* ISR used to poll the radio module regularly.
*/
__interrupt extern void RadioClient_OnTick(void);
/**
* This method will cycle through all the channels and increment an array
* element corresponding to an RF channel if a signal is detected on that channel.
* The lower the number of carrier detects, the better choice that channel is.
* Advisable to let this run for about 10 minutes...
* Use hyperterminal to output this to "CAPTURE.csv" file. Open in Excel. Remove
* all but the last 128 rows. Then sort on the second column (CD count). The
* channels will be sorted by their relative superiority.
*/
extern void RadioClient_CheckCarrier(void);
/**
* Will add val to the end of the transmit FIFO buffer. This function
* will return 1 if the buffer was full and the character was not added
* to the transmit buffer.
*/
extern unsigned char RadioClient_OutChar(unsigned char val);
/**
* Will add val[0], val[1], ... val[len-1] to the end of the transmit
* FIFO buffer. This function will busy-wait if the buffer is full.
*/
extern void RadioClient_OutCharArray(unsigned char *pt,
unsigned char len);
/**
* Will add the \0 terminated string to the end of the transmit FIFO
* buffer. This function will busy-wait if the buffer is full.
*/
extern void RadioClient_OutString(unsigned char *pt);
/**
* Will empty the transmit buffer.
*/
extern void RadioClient_CleanOut(void);
/**
* Will empty the receive buffer.
*/
extern void RadioClient_CleanIn(void);
/**
* Returns true if the transmit buffer is full.
*/
extern unsigned char RadioClient_IsOutFull(void);
/**
* Returns true if the transmit buffer is empty.
*/
extern unsigned char RadioClient_IsOutEmpty(void);
/**
* Returns true if the receive buffer is full.
*/
extern unsigned char RadioClient_IsInFull(void);
/**
* Returns true if the receive buffer is empty.
*/
extern unsigned char RadioClient_IsInEmpty(void);
/**
* Returns the number of elements stored in receive buffer.
*/
extern unsigned char RadioClient_HasElements();
/**
* Clean the input buffer of this client.
*/
extern void RadioClient_CleanIn(void);
/**
* Clean the output buffer of this client.
*/
extern void RadioClient_CleanOut(void);
/**
* Returns the byte at the head of the receive FIFO buffer, and
* removes it from the buffer. If the buffer is empty, this method
* will busy wait until there is data available.
*/
extern unsigned char RadioClient_InChar(void);
/**
* Removes len bytes from the head of the receive FIFO buffer, and
* writes them to charArray. If the buffer is empty, this method
* will busy wait until there is data available.
*/
extern void RadioClient_InCharArray(unsigned char *pt,
unsigned char len);
/**
* Returns the number of times the server has timed out since
* server/client reset.
*/
extern unsigned short RadioClient_GetFailureCount(void);
#endif // _RADIO_CLIENT_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -