Code Example
for(uint8_t addr=1; addr<128; addr++)
{
if(HAL_I2C_IsDeviceReady(&hi2c1, addr<<1, 1, 10)==HAL_OK)
{
// device found
}
}
How it works
This STM32 example demonstrates basic peripheral configuration and HAL usage.
Scan I2C bus for connected devices.
for(uint8_t addr=1; addr<128; addr++)
{
if(HAL_I2C_IsDeviceReady(&hi2c1, addr<<1, 1, 10)==HAL_OK)
{
// device found
}
}
This STM32 example demonstrates basic peripheral configuration and HAL usage.
Yes. These examples are intended for STM32CubeIDE and STM32 HAL drivers.
Yes. Update GPIO pin definitions according to your board schematic.