2017-05-14 05:53 AM
silly little nothing that just scans the i2c bus and prints the address of any found devices
output should look similar to this:
Connected to UART Two
Scanning I2C bus: ...............................................................................................0x60.......0x68.......................remember that the HAL wants a left aligned i2c address so 0x60 would be (uint16_t)(0x60<<1) when used in a HAL i2c system call
2017-05-14 05:54 AM
https://github.com/ProjectsByJRP/stm32_hal_i2c_bus_scan
there's no way to edit the initial post
2017-05-14 06:04 AM
Would be probably better to have this as cube example for I2C.
In theory, the scan should be at 100khz to make sure all slaves will respond.
General call is a special case to also take care, some slave answers, some not.
2017-05-14 08:14 AM
my link is stuck in moderation but i simply use HAL_I2C_IsDeviceReady. iterates through the device addresses 1-128
2017-05-14 01:51 PM
Another similar example on github can be found on micropython project. File:
micropython
/stmhal/i2c.c:692