乱码了,将就着看吧
#ifndef __24L01_H
#define __24L01_H
#include <stm32f10x.h>
#define NRF_CSN_LOW() GPIO_ResetBits(GPIOC, GPIO_Pin_13)
#define NRF_CSN_HIGH() GPIO_SetBits(GPIOC, GPIO_Pin_13)
#define NRF_CE_LOW() GPIO_ResetBits(GPIOC, GPIO_Pin_14)
#define NRF_CE_HIGH() GPIO_SetBits(GPIOC, GPIO_Pin_14)
#define NRF_Read_IRQ() GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_15)
/*******************************************************/
#define TX_ADDR_WITDH 5//·¢Ë͵ØÖ·¿í¶ÈÉèÖÃΪ5¸ö×Ö½Ú
#define RX_ADDR_WITDH 5//½ÓÊÕµØÖ·¿í¶ÈÉèÖÃΪ5¸ö×Ö½Ú
#define TX_DATA_WITDH 4//·¢ËÍÊý¾Ý¿í¶È1¸ö×Ö½Ú
#define RX_DATA_WITDH 4//½ÓÊÕÊý¾Ý¿í¶È1¸ö×Ö½Ú
/*******************ÃüÁî¼Ä´æÆ÷***************************/
#define R_REGISTER 0x00//¶ÁÈ¡ÅäÖüĴæÆ÷
#define W_REGISTER 0x20//дÅäÖüĴæÆ÷
#define R_RX_PAYLOAD 0x61//¶ÁÈ¡RXÓÐЧÊý¾Ý
#define W_TX_PAYLOAD 0xa0//дTXÓÐЧÊý¾Ý
#define FLUSH_TX 0xe1//Çå³ýTXFIFO¼Ä´æÆ÷
#define FLUSH_RX 0xe2//Çå³ýRXFIFO¼Ä´æÆ÷
#define REUSE_TX_PL 0xe3//ÖØÐÂʹÓÃÉÏÒ»°üÓÐЧÊý¾Ý
#define NOP 0xff//¿Õ²Ù×÷
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#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 FIFO_STATUS 0x17 //FIFO״̬¼Ä´æÆ÷;bit0,RX FIFO¼Ä´æÆ÷¿Õ±êÖ¾;bit1,RX FIFOÂú±êÖ¾;bit2,3,±£Áô
//bit4,TX FIFO¿Õ±êÖ¾;bit5,TX FIFOÂú±êÖ¾;bit6,1,Ñ»··¢ËÍÉÏÒ»Êý¾Ý°ü.0,²»Ñ»·;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//24L01²Ù×÷Ïß
#define NRF24L01_CE PAout(4) //24L01ƬѡÐźÅ
#define NRF24L01_CSN PCout(4) //SPIƬѡÐźÅ
#define NRF24L01_IRQ PCin(5) //IRQÖ÷»úÊý¾ÝÊäÈë
//24L01·¢ËͽÓÊÕÊý¾Ý¿í¶È¶¨Òå
#define TX_ADR_WIDTH 5 //5×ֽڵĵØÖ·¿í¶È
#define RX_ADR_WIDTH 5 //5×ֽڵĵØÖ·¿í¶È
#define TX_PLOAD_WIDTH 32 //20×Ö½ÚµÄÓû§Êý¾Ý¿í¶È
#define RX_PLOAD_WIDTH 32 //20×Ö½ÚµÄÓû§Êý¾Ý¿í¶È
void NRF24L01_Init(void);//³õʼ»¯
u8 SPI_RW_Byte(SPI_TypeDef* SPIx,unsigned char Byte);
u8 SPI_NRF_Write_buf(SPI_TypeDef* SPIx,char CMD,unsigned char* WBuff,unsigned char ByteNUM);
u8 SPI_NRF_Read_buf(SPI_TypeDef* SPIx,char CMD,unsigned char* RBuff,unsigned char ByteNUM);
void NRF24L01_RX_Mode(void);//ÅäÖÃΪ½ÓÊÕģʽ
void NRF24L01_TX_Mode(void);//ÅäÖÃΪ·¢ËÍģʽ
ErrorStatus NRF24L01_TxPacket(u8* TBuff,u8 ByteNUM);//·¢ËÍÊý¾Ý
ErrorStatus NRF24L01_RxPacket(u8* RBuff); //½ÓÊÕÒ»¸ö°üµÄÊý¾Ý
uint8_t NRF24L01_Check(void);//¼ì²é24L01ÊÇ·ñ´æÔÚ
u8 SPI_NRF_WE(SPI_TypeDef* SPIx,char CMD,unsigned char WBuff);
void read_allreg(void);
#endif