?? radio.h
字號:
// radio.h/*********************************************************************** * * Author: Greg Hunter * Company: UTS * Filenames: radio.h, radio.c * Date: 2007/9/6 * File Version: 0.01 * Other Files Required: * Tools Used: Micro-IDE -> 2.16m * SDCC C Compiler -> 1.2 * * Devices Supported: * nRF24E1 * *********************************************************************** * * Description: * Routines to configure the radio * **********************************************************************/#ifndef Radio_h#define Radio_h// C API for radio.ctypedef struct { // Radio Configuration Buffer: unsigned char Data2; //length of data payload RX channel 2 unsigned char Data1; //length of data payload RX channel 1 unsigned char Addr2s; //top unused byte of address 2 unsigned char Addr2c3; //address for RX channel 2, byte 3 unsigned char Addr2c2; //address for RX channel 2, byte 2 unsigned char Addr2c1; //address for RX channel 2, byte 1 unsigned char Addr2c0; //address for RX channel 2, byte 0 unsigned char Addr1s; //top unused byte of address 1 unsigned char Addr1c3; //address for RX channel 1, byte 3 unsigned char Addr1c2; //address for RX channel 1, byte 2 unsigned char Addr1c1; //address for RX channel 1, byte 1 unsigned char Addr1c0; //address for RX channel 1, byte 0 unsigned char AddCrc; //address length (6 bits), 8 or 16 bit CRC (1 bit) & CRC enable (1 bit) unsigned char Control; //bits to control radio: //7: RX2_EN Enable 2 channel receive mode //6: CM Direct or Shockburst //5: RFDR_SB RF data rate, 1Mbps or 250kbps //2-4: XO_F Crystal frequency //0-1: RF_POWER RF power output unsigned char ChnRxTx; //channel select and RxTx switch //1-7: RF_CH# Frequency channel //0: RXEN RX or TX operation } tRadioParm;#define RADIO_CFG_BYTES 15 //number of configuration bytes#define RadioCfgBufPt &RadioParm.Data2 //start of configuration blockextern tRadioParm RadioParm;void RadioInit(void); // Initialising routine to initialise data buffersvoid RadioOn(void); // Turn on radio and load configurationvoid RadioCfg(void); // Load configuration only#define RadioOff() PWR_UP = 0 // Turn radio offvoid RadioTXBuf(unsigned char *bufPt, unsigned char bytes); // Transmit data in buffer bufPt of length bytes and switch to RX mode // Note for timing it takes 700us for reciever to be ready after a packet is transmitted // so the receiving unit should wait 700us before trasmitting a replyunsigned char RadioRXBuf(unsigned char *bufPt); // Receive wheelchair data and load into bufPt buffer //returns 1 if packet received, 0 otherwise// Example C API for data transmit and receive buffers. This shows a buffer size of 14 bytes.typedef struct {// Data transmit buffer: unsigned char TXAddress3; //byte 3 of address of head unit unsigned char TXAddress2; //byte 2 unsigned char TXAddress1; //byte 1 unsigned char TXAddress0; //byte 0 unsigned char adcData; unsigned char t1; unsigned char t2; unsigned char t3; unsigned char t4; unsigned char t5; unsigned char t6; unsigned char t7; unsigned char t8; unsigned char t9; unsigned char t10; unsigned char t11; unsigned char t12; unsigned char t13;// Data receive buffer: unsigned char pwmData; unsigned char d1; unsigned char d2; unsigned char d3; unsigned char d4; unsigned char d5; unsigned char d6; unsigned char d7; unsigned char d8; unsigned char d9; unsigned char d10; unsigned char d11; unsigned char d12; unsigned char d13; } tComParm;#define COM_TX_BYTES 18 //number of data transmit buffer bytes#define ComTXBufPt (&ComParm.TXAddress3) //start of data transmit buffer#define COM_RX_BYTES 14 //number of receive buffer bytes#define ComRXBufPt (&ComParm.pwmData) //start of receive bufferextern tComParm ComParm;#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -