资源描述:
《STC12单片机SPI的nrf24l01接收程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、片include#include〈intrins・h>typedefunsignedcharuchar;#dcfineuintunsignedintffl
2、
3、7r.•I1^■*/•rjw^Jw^Jw^Jw^Jw^Jw^Jw^Jw^JwIII•*l
4、t
5、[]>I«sfrSPCTL二OxCE;//SP1ControlRegisterSS1GSPENDORDMSTRCPOLCP11ASPR1SPRO0000,0100sfrSPSTAT=OxCD;//SPTStatusRegisterSPIFWCOL------OOxx,xxxxsfrSPDAT二O
6、xCF;sbitCE=Pr0;sbitCSN=Pri;sbitTRQ=PP2;sbitled=P「3;^defineTX_ADR_W1DTI15^defineRXADRWTDTH5#defineTX_PLOAD_WIDTH32^defineRX_PLOAD」IDTH32//5uintsTXaddresswidth//5uintsRXaddresswidth//32uintsTXpayload//32uintsTXpayload、▼“■,“、▼“、▼“v*>7"7"、▼“7"7"7"7"、▼“7"、▼“7“、▼“7“7“、▼“7“v*>7“7“、▼“7“7“7“7
7、“7“7“7“7“7“7“7“7“7“7“vzkJ^v^zv^z^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^1、^T、^T、ucharbdatasta;sbitRXDR=sta6;//状态标志sbitTX_DS=sta5;sbitMAXRT=sta"4;•%w%w%w%w%w%w%w%w%w%w%w%w%wL^[IJI-•J>1If11夕。、彳、r、彳、r、彳、r、r、彳、r、彳、r、彳、r、彳、r、彳、r、彳、r、彳、r、彳、r、彳、r、8、、r、彳、r、彳、r、彳、r、彳、r、彳、r、JIwIIill彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、彳、uchtirconstTX_ADDRESS[TX_ADR_WIDTH]二{0x34,0x43,0x10,0x10,0x01};//本地地址ucharconstRX_ADDRESS[RX_ADRJV1DTII]={0x34,0x43,0x10,0x10,0x01};〃接收地址codeucharTx_Buf[TXPLOADWIDTH]={Oxff>Oxee,0x11,0x22
9、,0x33,Oxaa,Oxbb,0x11,0x22,0x33,Oxaa,Oxbb,0x11,0x22,0x33,Oxcia,Oxbb,Oxll,0x22,0x33,Oxtia,Oxbb,Oxll,0x22,0x33,Oxaa,Oxbb,0x11,0x22,0x33,Oxee,Oxff};//发送数据ucharRxBuf[RXPLOADWIDTH];//接收数据//***************************************NRF24L01寄存器扌旨令I»"Wfg"Wfg"Wfg»左fg»左fg»左fg»左fg»左fg»左fg»左fg»左fg»左
10、fg»左fg»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左F»»左^T>^defineREAD_REG0x00//读寄存器指令^defineWR1TE_REG0x20//写寄存器指令廿defincRDRXPLOAD0x61//读取接收数据指令ttdefineWRTXPLOADOxAO//写待发数据指令#defineFLUSHTXOxEl//冲洗发送FIFO指令^defineFLISII_RX0xE2//冲洗接收E1F0指令^defineREISE_TX_PL0xE3//定义重复装载数据指令廿defincNOP
11、OxFF//保留^defineCONFTG0x00〃配置收发状态,CRC校验模式以及收发状态响应方式defineEN_AA0x01//自动应答功能设置^defineEN_RXADDR0x02//可用信道设置^defineSETUP_AW0x03〃收发地址宽度设置#defineSETUPRETR0x04//h动重发功能设置#defineRFCH0x05//工作频率设置defineRF一SETUP0x06//发射速率、功耗功能设置^defineSTATUS0x07//状态寄存器^defineOBSERVE_TX0x08//发送监测功能^defineCD0x09//地
12、址检测^defineRX