Am 30.04.2021 um 15:06 schrieb Gregory Nutt:


... The main reason is that the AT24XX MTD driver only can handle one type of devices on a single bus. ..
The is a deficiency in the driver and should be pretty easy to fix by passing the I2C address during driver initialization. Other drivers do that.

This has alrady been fixed - there is an option for that. The main problem is that the capacity aka chip type is still a compile-time option, and I'd like not to change this since it may break other people's code.

I was referring to the run time configuration of the I2C address so that you can run multiple copies of the driver.  That would involve adding an address parameter to at24c_initialize().  This is done for many other drivers, for example, include/nuttx/sensors/lm75.h:

int lm75_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
                   uint8_t addr);


Yes, this is already there, if CONFIG_AT24XX_MULTI is defined.

#ifdef CONFIG_AT24XX_MULTI
FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_master_s *dev,
                                       uint8_t address)
#else
FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_master_s *dev)
#endif

The char driver also allows for chip type runtine configuration. This should be added to at24xx.

int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr,
                      FAR char *devname, int devtype, int readonly)

Reply via email to