比如讀0x42讀lora芯片的版本好 返回的是下一個(gè)寄存器的值。讀0x41才能返回0x42的值
類似的代碼在stm32上正常不會(huì)錯(cuò)位
***********? main **************
#if 1
? /* SPI 0 */
? GPIOA_SetBits( GPIO_Pin_12 );
? GPIOA_ModeCfg( GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14, GPIO_ModeOut_PP_5mA );
? // lora_reset perform reset
????? GPIOA_ResetBits(LORA_RESET);
????? DelayMs( 10 );
????? GPIOA_SetBits(LORA_RESET);
????? DelayMs( 10 );
????? SPI0_DataMode(Mode0_HighBitINFront);
? SPI0_MasterDefInit();
? while( 1 )
? {
??? uint8_t version = LORA_singleTransfer(0x42,0x00);
??? char info[20];
??? sprintf(info,"0x%02x \n",version);
????? PRINT(info);
????? DelayMs(1000);
? }
**************************************
uint8_t LORA_singleTransfer(uint8_t address, uint8_t value)
{
? uint8_t response;
? GPIOA_ResetBits( GPIO_Pin_12 );
? SPI0_MasterSendByte( address );
? SPI0_MasterSendByte( value );
? response = SPI0_MasterRecvByte();
? GPIOA_SetBits( GPIO_Pin_12 );
? return response;
}