freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于單片機(jī)的無線溫度檢測(cè)器的畢業(yè)設(shè)計(jì)-資料下載頁(yè)

2025-06-27 19:38本頁(yè)面
  

【正文】 reg)。void SetRX_Mode(void)。uint SPI_RW_Reg(uchar reg, uchar value)。uint SPI_Read_Buf(uchar reg, uchar *pBuf, uchar uchars)。uint SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars)。unsigned char nRF24L01_RxPacket(unsigned char* rx_buf)。void nRF24L01_TxPacket(unsigned char * tx_buf)。//*******************************長(zhǎng)延時(shí)*****************************************void Delay(unsigned int s){ unsigned int i。 for(i=0。 is。 i++)。 for(i=0。 is。 i++)。}//********************************************************************************uint bdata sta。 //狀態(tài)標(biāo)志sbit RX_DR =sta^6。sbit TX_DS =sta^5。sbit MAX_RT =sta^4。/*********************************************************************************/*延時(shí)函數(shù)/*********************************************************************************/void inerDelay_us(unsigned char n){ for(。n0。n) _nop_()。}//*******************************************************************************/*NRF24L01初始化//*******************************************************************************/void init_NRF24L01(void){ inerDelay_us(100)。 CE=0。 // chip enable CSN=1。 // Spi disable SCK=0。 // SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH)。 // 寫本地地址 SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, RX_ADDRESS, RX_ADR_WIDTH)。 // 寫接收端地址 SPI_RW_Reg(WRITE_REG + EN_AA, 0x01)。 // 頻道0自動(dòng) ACK應(yīng)答允許 SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01)。 // 允許接收地址只有頻道0,如果需要多頻道可以參考Page21 SPI_RW_Reg(WRITE_REG + RF_CH, 0)。 // ,收發(fā)必須一致 SPI_RW_Reg(WRITE_REG + RX_PW_P0, RX_PLOAD_WIDTH)。 //設(shè)置接收數(shù)據(jù)長(zhǎng)度,本次設(shè)置為32字節(jié) SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07)。 //設(shè)置發(fā)射速率為1MHZ,發(fā)射功率為最大值0dB}/*********************************************************************************/*函數(shù):uint SPI_RW(uint uchar)/*功能:NRF24L01的SPI寫時(shí)序/*********************************************************************************/uint SPI_RW(uint uchar){ uint bit_ctr。 for(bit_ctr=0。bit_ctr8。bit_ctr++) // output 8bit { MOSI = (uchar amp。 0x80)。 // output 39。uchar39。, MSB to MOSI uchar = (uchar 1)。 // shift next bit into MSB.. SCK = 1。 // Set SCK high.. uchar |= MISO。 // capture current MISO bit SCK = 0。 // then set SCK low again } return(uchar)。 // return read uchar}/**********************************************************************************/*函數(shù):uchar SPI_Read(uchar reg)/*功能:NRF24L01的SPI時(shí)序/*********************************************************************************/uchar SPI_Read(uchar reg){ uchar reg_val。 CSN = 0。 // CSN low, initialize SPI munication... SPI_RW(reg)。 // Select register to read from.. reg_val = SPI_RW(0)。 // then read registervalue CSN = 1。 // CSN high, terminate SPI munication return(reg_val)。 // return register value}/*******************************************************************************//*功能:NRF24L01讀寫寄存器函數(shù)/*******************************************************************************/uint SPI_RW_Reg(uchar reg, uchar value){ uint status。 CSN = 0。 // CSN low, init SPI transaction status = SPI_RW(reg)。 // select register SPI_RW(value)。 // ..and write value to it.. CSN = 1。 // CSN high again return(status)。 // return nRF24L01 status uchar}/******************************************************************************//*函數(shù):uint SPI_Read_Buf(uchar reg, uchar *pBuf, uchar uchars)/*功能: 用于讀數(shù)據(jù),reg:為寄存器地址,pBuf:為待讀出數(shù)據(jù)地址,uchars:讀出數(shù)據(jù)的個(gè)數(shù)/*****************************************************************************/uint SPI_Read_Buf(uchar reg, uchar *pBuf, uchar uchars){ uint status,uchar_ctr。 CSN = 0。 // Set CSN low, init SPI tranaction status = SPI_RW(reg)。 // Select register to write to and read status uchar for(uchar_ctr=0。uchar_ctruchars。uchar_ctr++) pBuf[uchar_ctr] = SPI_RW(0)。 CSN = 1。 return(status)。 // return nRF24L01 status uchar}/*********************************************************************************/*函數(shù):uint SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars)/*功能: 用于寫數(shù)據(jù):為寄存器地址,pBuf:為待寫入數(shù)據(jù)地址,uchars:寫入數(shù)據(jù)的個(gè)數(shù)/*********************************************************************************uint SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars){ uint status,uchar_ctr。 CSN = 0。 //SPI使能 status = SPI_RW(reg)。 for(uchar_ctr=0。 uchar_ctruchars。 uchar_ctr++) SPI_RW(*pBuf++)。 CSN = 1。 //關(guān)閉SPI return(status)。 }/********************************************************************************//*函數(shù):void SetRX_Mode(void)/*功能:數(shù)據(jù)接收配置 /********************************************************************************/void SetRX_Mode(void){ CE=0。 SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f)。 // IRQ收發(fā)完成中斷響應(yīng),16位CRC ,主接收 CE = 1。 inerDelay_us(130)。}/********************************************************************************//*函數(shù):unsigned char nRF24L01_RxPacket(unsigned char* rx_buf)/*功能:數(shù)據(jù)讀取后放如rx_buf接收緩沖區(qū)中/********************************************************************************/unsigned char nRF24L01_RxPacket(unsigned char* rx_buf){ unsigned char revale=0。 sta=SPI_Read(STATUS)。 // 讀取狀態(tài)寄存其來判斷數(shù)據(jù)接收狀況 if(RX_DR) // 判斷是否接收到數(shù)據(jù) { CE = 0。 //SPI使能 SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH)。// read receive payload from RX_FIFO buffer revale =1。 //讀取數(shù)據(jù)完成標(biāo)志 } SPI_RW_Reg(WRITE_REG+STATUS,sta)。 //接收到數(shù)據(jù)后RX_DR,TX_DS,MAX_PT都置高為1,通過寫1來清楚中斷標(biāo)志 return revale。}/********************************************************************************/*函數(shù):void nRF24L01_TxPacket(unsigned char * tx_buf)/*功能:發(fā)送 tx_buf中數(shù)據(jù)/*********************************
點(diǎn)擊復(fù)制文檔內(nèi)容
化學(xué)相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1