|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #ifndef _NRF24L01_H
- #define _NRF24L01_H
- #include "stm32f10x.h"
- #include "nrf_gpio.h"
- #include "printf.h"
-
- //NRF24L01Ĵ
- #define NRF_READ_REG 0x00 //üĴ,5λΪĴַ
- #define NRF_WRITE_REG 0x20 //дüĴ,5λΪĴַ
- #define RD_RX_PLOAD 0x61 //RXЧ,1~32ֽ
- #define WR_TX_PLOAD 0xA0 //дTXЧ,1~32ֽ
- #define FLUSH_TX 0xE1 //TX FIFOĴ.ģʽ
- #define FLUSH_RX 0xE2 //RX FIFOĴ.ģʽ
- #define REUSE_TX_PL 0xE3 //ʹһ,CEΪ,ݰϷ.
- #define NOP 0xFF //ղ,״̬Ĵ
- //SPI(NRF24L01)Ĵַ
- #define CONFIG 0x00 //üĴַ;bit0:1ģʽ,0ģʽ;bit1:ѡ;bit2:CRCģʽ;bit3:CRCʹ;
- //bit4:жMAX_RT(ﵽطж)ʹ;bit5:жTX_DSʹ;bit6:жRX_DRʹ
- #define EN_AA 0x01 //ʹԶӦ bit0~5,Ӧͨ0~5
- #define EN_RXADDR 0x02 //յַ,bit0~5,Ӧͨ0~5
- #define SETUP_AW 0x03 //õַ(ͨ):bit1,0:00,3ֽ;01,4ֽ;02,5ֽ;
- #define SETUP_RETR 0x04 //Զط;bit3:0,Զط;bit7:4,Զطʱ 250*x+86us
- #define RF_CH 0x05 //RFͨ,bit6:0,ͨƵ;
- #define RF_SETUP 0x06 //RFĴ;bit3:(0:1Mbps,1:2Mbps);bit2:1,书;bit0:Ŵ
- #define STATUS 0x07 //״̬Ĵ;bit0:TX FIFO־;bit3:1,ͨ(:6);bit4,ﵽط
- //bit5:ݷж;bit6:ж;
- #define MAX_TX 0x10 //ﵽʹж
- #define TX_OK 0x20 //TXж
- #define RX_OK 0x40 //յж
-
- #define OBSERVE_TX 0x08 //ͼĴ,bit7:4,ݰʧ;bit3:0,ط
- #define CD 0x09 //زĴ,bit0,ز;
- #define RX_ADDR_P0 0x0A //ͨ0յַ,5ֽ,ֽǰ
- #define RX_ADDR_P1 0x0B //ͨ1յַ,5ֽ,ֽǰ
- #define RX_ADDR_P2 0x0C //ͨ2յַ,ֽڿ,ֽ,ͬRX_ADDR_P1[39:8];
- #define RX_ADDR_P3 0x0D //ͨ3յַ,ֽڿ,ֽ,ͬRX_ADDR_P1[39:8];
- #define RX_ADDR_P4 0x0E //ͨ4յַ,ֽڿ,ֽ,ͬRX_ADDR_P1[39:8];
- #define RX_ADDR_P5 0x0F //ͨ5յַ,ֽڿ,ֽ,ͬRX_ADDR_P1[39:8];
- #define TX_ADDR 0x10 //͵ַ(ֽǰ),ShockBurstTMģʽ,RX_ADDR_P0˵ַ
- #define RX_PW_P0 0x11 //ͨ0Чݿ(1~32ֽ),Ϊ0Ƿ
- #define RX_PW_P1 0x12 //ͨ1Чݿ(1~32ֽ),Ϊ0Ƿ
- #define RX_PW_P2 0x13 //ͨ2Чݿ(1~32ֽ),Ϊ0Ƿ
- #define RX_PW_P3 0x14 //ͨ3Чݿ(1~32ֽ),Ϊ0Ƿ
- #define RX_PW_P4 0x15 //ͨ4Чݿ(1~32ֽ),Ϊ0Ƿ
- #define RX_PW_P5 0x16 //ͨ5Чݿ(1~32ֽ),Ϊ0Ƿ
- #define NRF_FIFO_STATUS 0x17 //FIFO״̬Ĵ;bit0,RX FIFOĴձ־;bit1,RX FIFO־;bit2,3,
- //bit4,TX FIFOձ־;bit5,TX FIFO־;bit6,1,ѭһݰ.0,ѭ;
-
- #define W_ACK_PAYLOAD 0xA8 /// ACK
- #define W_TX_PAYLOAD_NO_ACK 0xA0 /// NO ACK
- #define DYNPD 0x1C
- #define FEATURF 0x1D
- #define R_RX_PL_WID 0x60
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
- //24L01ͽݿȶ
- #define TX_ADR_WIDTH 3 //5ֽڵĵַ
- #define RX_ADR_WIDTH 3 //5ֽڵĵַ
- #define TX_PLOAD_WIDTH 7 //32ֽڵûݿ
- #define RX_PLOAD_WIDTH 10 //32ֽڵûݿ
-
- //-----------------------------------------------------------
- // Functions
- void NRF24L01_Init(void); //ʼ
- void NRF24L01_RX_Mode(SPIType spiNum); //Ϊģʽ
- void NRF24L01_TX_Mode(SPIType spiNum); //Ϊģʽ
- #if APP
- void NRF24L01_RX_Mode_NOACK(SPIType spiNum,u8 num); //
- #else
- void NRF24L01_RX_Mode_NOACK(SPIType spiNum); //
- #endif
- //void NRF24L01_RX_Mode_NOACK(SPIType spiNum); //
- void NRF24L01_RX_Mode_NOACK_VCOM(SPIType spiNum); //VCOM
-
- u8 NRF24L01_Write_Buf(SPIType spiNum,u8 reg, u8 *pBuf, u8 u8s);//д
- u8 NRF24L01_Read_Buf(SPIType spiNum,u8 reg, u8 *pBuf, u8 u8s); //
- u8 NRF24L01_Read_Reg(SPIType spiNum,u8 reg); //Ĵ
- u8 NRF24L01_Write_Reg(SPIType spiNum,u8 reg, u8 value); //дĴ
- u8 NRF24L01_Check(SPIType spiNum); //24L01Ƿ
- u8 NRF24L01_TxPacket(SPIType spiNum,u8 *txbuf); //һ
- u8 NRF24L01_RxPacket(SPIType spiNum,u8 *rxbuf); //һ
- void RF24_CarrierTest(SPIType spiNum,unsigned char rf_channel);
-
- #define SPI_REV SPI_PORT1
- #define SPI_SEND SPI_PORT2
-
- #endif
|