-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does I2C support various types of slave devices? #12159
Comments
Hi @xiaotailang you don't need to do nothing special, just call look the examples inside boards/arm/stm32/common/src/
Just initialize the I2C Bus/Port as you saw: i2c = stm32_i2cbus_initialize(I2C_BUS); /* Bus could be 1, 2 or 3 */ And them you just call the blablabladevicename_register() passing this i2c pointer, as you see in these files. Actually this code to register the i2c_register(i2c, DS1307_I2C_BUS); is incorrect, because it is already done at stm32_bringup.c. So I will punish the guy who did it! (myself) Hehehe. |
I submitted a PR #12166 to fix the i2c_register() at wrong place |
Hi! @acassis Thank you very much for your answer. After examining the examples you provided, I noticed that their This leads me to conclude that NuttX provides a generic management interface for RTC devices like the ds1302, such that there is no need to implement the |
I am interested in adding device drivers for I2C-based devices, such as G-sensors (accelerometers), RTCs, and the BH1750 light sensor, within the NuttX operating system. I have noticed existing drivers for devices like ADXL345, DS3231, and DS1307 in the nuttx/drivers directory, but upon examining the implementation of application-layer functions bound to open, write, and read, I find that the i2cdrvr_read and i2cdrvr_write functions lack concrete implementations. I have also seen an implementation for accessing the DS1307 via I2C in the context of STM32F4, where the process involves initializing the I2C bus and binding it to the nSH, although the corresponding i2cdrvr_read and i2cdrvr_write functions remain without specific implementation details. Thus, I am unsure how the DS1307 is being read from and written to within the nSH environment. The implementation supporting the DS1307 on STM32F4 is as follows:
int stm32_ds1307_init(void)
{
struct i2c_master_s *i2c;
static bool initialized = false;
int ret;
/* Have we already initialized? */
if (!initialized)
{
/* No.. Get the I2C bus driver */
#ifdef CONFIG_I2C_DRIVER
/* Register the I2C to get the "nsh> i2c bus" command working */
#endif
return OK;
}
The text was updated successfully, but these errors were encountered: