I am stuck with a really weird issue while using time of flight sensor VL53L0x - 200 cm
and VL6180x - 60 cm
. I have two st boards, STM32F446 Nucleo
and STM32F767 Nucleo
. I have written the libraries for both the time of flight sensors on STM32F767 Nucleo
. But while i was trying to implement the same library on STM32F446 Nucleo
it doesn't work.
While looking for solution i found there is a problem with I2C. In F7 everything is fine and it returns HAL_OK. But in F4 it returns 'HAL_ERROR'. By it I mean this function.
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
Pastebin link for library files
https://pastebin.com/z15btwTD - vl6180.c
https://pastebin.com/62XYxUVx - vl6180.h
Ofcourse in vl6180.h
i have changed #include "stm32f7xx.h"
to #include "stm32f4xx.h"
while using for STM32F446 Nucleo
. And i am using I2C1 in both the boards. But i have tried other I2C's too but they all end up in same problem. Hal library is generated using CubeMx and Attolic True Studio is the IDE.
The same thing is happening for VL53L0X Sensor
.
Any suggestion would be really appreciated.
EDIT
From this particular part of the HAL_I2C_Master_Transmit()
function returns HAL_ERROR
if(I2C_MasterRequestWrite(hi2c, DevAddress, Timeout, tickstart) != HAL_OK)
{
if(hi2c->ErrorCode == HAL_I2C_ERROR_AF)
{
/* Process Unlocked */
__HAL_UNLOCK(hi2c);
//HAL_GPIO_TogglePin(BLUE_GPIO_Port, BLUE_Pin);
return HAL_ERROR;
}
else
{
/* Process Unlocked */
__HAL_UNLOCK(hi2c);
return HAL_TIMEOUT;
}
}
Regards.