Hello ,
I used other software version. But it doesn't matter all version have same initialization procudure.
Macro definition SPI_BUFF_SZ was 9 in your code. Because of the following code, it is recommended to set it to be greater than 1 and a multiple of 2
/* Bytes written are multiples of 2 */ if ((dev->read_write_len % 2) != 0) { dev->read_write_len = dev->read_write_len - 1; }
if (dev->read_write_len < 2) { dev->read_write_len = 2; }
From the return value of your initialization code, the configuration file failed to be loaded. From BMI270 data sheet, it had dummy byte for SPI read communication. It means it needs to ignore the first dummy byte, and the actual return value is after the dummy byte.
uint8_t GTXBuffer[512], GRXBuffer[2048];
int8_t SensorAPI_SPIx_Read(uint8_t slave_address7, uint8_t subaddress, uint8_t *pBuffer, uint16_t ReadNumbr) { slave_address7 = slave_address7; GTXBuffer[0] = subaddress | 0x80;
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET); // NSS low
//HAL_SPI_TransmitReceive(&hspi2, pTxData, pRxData, ReadNumbr+1, BUS_TIMEOUT); // timeout 1000msec; HAL_SPI_TransmitReceive(&SPI_HANDLE, GTXBuffer, GRXBuffer, ReadNumbr+1, BUS_TIMEOUT); // timeout 1000msec; while(SPI_HANDLE.State == HAL_SPI_STATE_BUSY); // wait for xmission complete
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET); // NSS high memcpy(pBuffer, GRXBuffer+1, ReadNumbr);
return 0; }
By the way, BMI270 SPI interface is incompatible with two mode: '00'[CPOL=0, CPHA=0], '11'[CPOL=1, CPHA=1]. When you initialized your PIC32 SPI interface, you need to choose one mode of 00 or 11.
... View more