CUBEMX配置
uint16_t drv8301_data_t[1];
uint16_t drv8301_data_t0[1] = {0x9000};
uint16_t drv8301_data_t1[1] = {0x0000};
uint16_t drv8301_data_r[1];
//SPI参数配置函数
void DRV8301_SPI_setting(void)
{
drv8301_data_t[0] = 0x1560;
DRV8301_SPI_M1_CS_L;
HAL_SPI_TransmitReceive(&DRV8301_SPI_Get_HSPI,(uint8_t *)drv8301_data_t,(uint8_t *)drv8301_data_r,1,1000);
DRV8301_SPI_M1_CS_H;
DRV8301_SPI_M1_CS_L;
HAL_SPI_TransmitReceive(&DRV8301_SPI_Get_HSPI,(uint8_t *)drv8301_data_t0,(uint8_t *)drv8301_data_r,1,1000);
DRV8301_SPI_M1_CS_H;//发送寄存器地址后要先拉高再读取--重要,忘记这一步就一直读取是0x0000
DRV8301_SPI_M1_CS_L;
HAL_SPI_TransmitReceive(&DRV8301_SPI_Get_HSPI,(uint8_t *)drv8301_data_t1,(uint8_t *)drv8301_data_r,1,1000);
DRV8301_SPI_M1_CS_H;
}
结果