嗨,我正在尝试使用I2C和DMA读取LIS2DH12。
我通过
STM32CubeMx配置了所有内容。
当我想阅读LIS2DH12(WHO_AM_I @ 0x0F)时,我打电话给:
HAL_I2C_Master_Receive_DMA(& hi2c1,(uint16_t)SLAVE_ADDRESS,(uint8_t *)I2CRxBuf,1);
我已经定义了以下内容:
SLAVE_ADDRESS 0x330F //(从地址0x33和读地址0x0F
char I2CRxBuf [5];
我等待它先完成接收:
while(HAL_I2C_GetState(& hi2c1)!= HAL_I2C_STATE_READY);
然后在屏幕上打印该值。它始终保持为零。
我究竟做错了什么?
以上来自于谷歌翻译
以下为原文
Hi, I am trying to read the LIS2DH12 using the I2C and DMA.
I got everything configured via STM32CubeMx.
When I want to read the LIS2DH12 (WHO_AM_I @0x0F) I call:
HAL_I2C_Master_Receive_DMA(&hi2c1, (uint16_t)SLAVE_ADDRESS, (uint8_t *)I2CRxBuf, 1);
I have defined the below:
SLAVE_ADDRESS 0x330F // (slave address 0x33 and read adress 0x0F
char I2CRxBuf[5];
I wait for it to complete the receive first:
while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY);
Then print the value on the screen. It always stay zero.
What am I doing wrong?