cancel
Showing results for 
Search instead for 
Did you mean: 

HAL I2C bus scan tool

john doe
Lead
Posted on May 14, 2017 at 14:53

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

4 REPLIES 4
john doe
Lead
Posted on May 14, 2017 at 14:54

https://github.com/ProjectsByJRP/stm32_hal_i2c_bus_scan

 

there's no way to edit the initial post

S.Ma
Principal
Posted on May 14, 2017 at 15:04

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.

Posted on May 14, 2017 at 15:14

my link is stuck in moderation but i simply use HAL_I2C_IsDeviceReady. iterates through the device addresses 1-128

Posted on May 14, 2017 at 20:51

Another similar example on github can be found on micropython project. File:

micropython

/stmhal/i2c.c:692