比如读0x42读lora芯片的版本好 返回的是下一个寄存器的值。读0x41才能返回0x42的值
类似的代码在stm32上正常不会错位
*********** 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;
}