Skip to content

Conversation

@jacmet
Copy link
Contributor

@jacmet jacmet commented Oct 2, 2025

For some use cases it can be interesting to know when the eeprom has been written to by the I2C host (E.G. once a stop has been received after a write transaction), so add a "changed" callback.

The existing API for accessing the EEPROM data is not ideal, so add getters for the size and data instead and update the sample the use the new APIs

@JarmouniA JarmouniA changed the title Feature/i2c target eeprom extra api Drivers: i2c: target eeprom extra api Oct 2, 2025
@teburd teburd assigned henrikbrixandersen and unassigned teburd Oct 2, 2025
Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few comments below:

Copy link
Contributor

@kartben kartben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor doxygen mistakes. thanks!

@jacmet jacmet force-pushed the feature/i2c-target-eeprom-extra-api branch from b0061a2 to c0f24a0 Compare October 22, 2025 10:09
@jacmet
Copy link
Contributor Author

jacmet commented Oct 22, 2025

Changes since v1:

  • Added user_data argument to callback as suggested by @henrikbrixandersen
  • Made eeprom_target_get_size return a size_t as suggested by @henrikbrixandersen
  • Minor code style change as suggested by @henrikbrixandersen
  • Changed to a zephyr/driver/eeprom.h compatible API for the read/write and deprecated eeprom_target_program as suggested by @henrikbrixandersen
  • Used @return instead of @retval Doxygen tags as suggested by @kartben

@jacmet jacmet force-pushed the feature/i2c-target-eeprom-extra-api branch from c0f24a0 to 78cb854 Compare October 22, 2025 11:48
@jacmet
Copy link
Contributor Author

jacmet commented Oct 22, 2025

Changes since v2:

  • Moved i variable inside for () to make sonarqube happy

For some use cases it can be interesting to know when the eeprom has been
written to by the I2C host (E.G.  once a stop has been received after a
write transaction), so add a "changed" callback.

Multiple EEPROM instances are supported, so pass the device and user data
as arguments to the callback.

Signed-off-by: Peter Korsgaard <[email protected]>
For some use cases it can be interesting to know how big the EEPROM is, so
add a getter for it.

Signed-off-by: Peter Korsgaard <[email protected]>
The current functions to access the EEPROM data are not ideal, E.G.:

- eeprom_target_program() is hard coded to write to the beginning of the
  EEPROM data

- eeprom_target_read() reads a single byte, so large overhead to read all
  data

So as an alternative, add an interface similar to what is provided by
zephyr/drivers/eeprom.h, E.G.  functions taking an offset and and length.

Signed-off-by: Peter Korsgaard <[email protected]>
@jacmet jacmet force-pushed the feature/i2c-target-eeprom-extra-api branch from 78cb854 to 4006a1a Compare October 22, 2025 12:01
@zephyrbot zephyrbot added the area: Tests Issues related to a particular existing or missing test label Oct 22, 2025
…ta()

eeprom_target_program() is about to become deprecated as it does not take
an offset argument, so switch to eeprom_target_write_data() instead.

Signed-off-by: Peter Korsgaard <[email protected]>
It does not provide an offset argument, so suggest
eeprom_target_write_data() instead.

Signed-off-by: Peter Korsgaard <[email protected]>
It is not very handy that the EEPROM stops responding after 1 second, so
drop that.

Signed-off-by: Peter Korsgaard <[email protected]>
And show the usages of the new _get_size() / _get_data() getters.

Signed-off-by: Peter Korsgaard <[email protected]>
@jacmet jacmet force-pushed the feature/i2c-target-eeprom-extra-api branch from 4006a1a to 33696a3 Compare October 22, 2025 12:31
@jacmet
Copy link
Contributor Author

jacmet commented Oct 22, 2025

Changes since v4:

  • One last commit message with a line 1 char too long. Fix that to make CI happy

@sonarqubecloud
Copy link

@jacmet jacmet requested a review from kartben October 22, 2025 14:02
@kartben kartben dismissed their stale review October 23, 2025 09:23

comment addressed - thank you (sorry that I can't really provide an actual review :|)

@henrikbrixandersen henrikbrixandersen added this to the v4.4.0 milestone Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: EEPROM area: I2C area: Samples Samples area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants