//此處注釋的方法與正在使用的方法除了一個(gè)是自減,一個(gè)是自增外完全一致,但是注釋的方法卻是錯(cuò)誤的 static?uint8_t?FLASH_SPI_SendAReceiveByte(uint8_t?data) { //????SPITimeout?=?200; ????SPITimeout?=?0; ????while(SPI_I2S_GetFlagStatus(FLASH_SPIx,?SPI_I2S_FLAG_TXE)?==?RESET)//檢測(cè)上一個(gè)字節(jié)是否發(fā)送完成 ????{ //????????SPITimeout--; //????????if(SPITimeout) //????????????return?SPI_TIMEOUT_UserCallback(0); ????????SPITimeout++; ????????if(SPITimeout?>?200) ????????????return?SPI_TIMEOUT_UserCallback(0); ????} ????SPI_I2S_SendData(FLASH_SPIx,?data); //????SPITimeout?=?200; ????SPITimeout?=?0; ????while(SPI_I2S_GetFlagStatus(FLASH_SPIx,?SPI_I2S_FLAG_RXNE)?==?RESET)//檢測(cè)是否接受到一個(gè)字節(jié) ????{ //????????SPITimeout--; //????????if(SPITimeout) //????????????return?SPI_TIMEOUT_UserCallback(1); ????????SPITimeout++; ????????if(SPITimeout?>?200) ????????????return?SPI_TIMEOUT_UserCallback(1); ????} ????return?SPI_I2S_ReceiveData(FLASH_SPIx); }
上面的代碼,只要把while里面注釋的代碼換成非注釋的,檢測(cè)接受的while就會(huì)出問題,請(qǐng)大神解答
附上實(shí)驗(yàn)文件,上面的代碼片段在code文件的flash_spi.c文件中,大佬可以看看解答我的疑問
熱門產(chǎn)品 :
CH397: 高集成度、低功耗USB網(wǎng)卡芯片