Description
hello,
there are 2 interfaces to the i2c-bus in avm_builtins:
- portbased: components/avm_builtins/i2c_driver.c
- nifbased: components/avm_builtins/i2c_resource.c (why both?)
but why do atomvm_ssd1306.c, ssd1306_display_driver.c and ds3231.c implement their own interfaces?
moreover i feel that the sda and the scl pin definitions are properties of the hardware design and not properties of any peripheral device such as ssd1306 or ds3231.c and possibly others. for this reason i think the definitions of the sda and the scl pin should be done in i2c_driver.c : i2c_driver_init(..) / i2c_resource.c : i2c_resource_init respectively and not in any device implementations.
the configuration of the 2 pins (and possibly for the pins of the second i2c controller) could be done by means of idf.py menuconfig.
one advantage would be that multiple i2c devices can be accessed without any error prone multiple initialization .
addendum: another advantage would be that it will not be necessary to adopt multiple files when moving to the new i2c driver.
what do you think?