Skip to content
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

i2cTarget implementation problem for espressif boards #8520

Open
cumhuronat opened this issue Oct 25, 2023 · 5 comments
Open

i2cTarget implementation problem for espressif boards #8520

cumhuronat opened this issue Oct 25, 2023 · 5 comments
Labels
enhancement espressif applies to multiple Espressif chips
Milestone

Comments

@cumhuronat
Copy link

The espressif implementation sets the is_read flag always as true, which prevents the user from reading data as a target.

@dhalbert
Copy link
Collaborator

@microdev1 Could you comment on this? Thanks.

@dhalbert dhalbert added this to the 9.0.0 milestone Oct 25, 2023
@dhalbert dhalbert added the espressif applies to multiple Espressif chips label Oct 25, 2023
@microdev1
Copy link
Collaborator

I remember that i2ctarget wasn't completely implemented and the PR was merged as is.

@gamblor21
Copy link
Member

I took a look at this issue to see what may be missing. The issue is the current IDF does not support getting the status of the request to the target device. The IDF intends you to fill the "write" buffer if you have something to write and read the "read" buffer if you need to read. As requests come in the hardware either reads/writes from those buffers.

CircuitPython's API is designed to provide an I2CTargetRequest object if a request has come in, but with the IDF we do not know when a request arrives, not if it is a read or write.

According to this issue the ESP32 does not support any information about an I2C target request but newer chipsets can access it via registers.

There was work done to implement this in Arduino but it is not trivial as it involves a lot of lower level hardware calls to achieve the result. I did not look at it close enough to find out how easy it would be to integrate to what CircuitPython would require.

Another (maybe bad?) option would be to create a new I2CTargetESP32 port specific API that works closer to how the IDF works. Probably an object that you can initialize with the address, and poll to read and write data the Target receives or wants to send.

@dhalbert
Copy link
Collaborator

The I2C API has been revamped in ESP-IDF 5.2: see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/release-5.x/5.2/peripherals.html. But I'm not sure it helps solve the above.

@dhalbert dhalbert self-assigned this Dec 1, 2023
@dhalbert
Copy link
Collaborator

dhalbert commented Dec 1, 2023

Let's turn I2CTarget off for now since it doesn't really work if it can't read data. I'll turn it off, and then make it long term.

@tannewt tannewt assigned tannewt and unassigned dhalbert Jan 31, 2024
@tannewt tannewt modified the milestones: 9.0.0, Long term Jan 31, 2024
dhalbert pushed a commit that referenced this issue Feb 6, 2024
According to #8520 it was never fully implemented and the IDF API
has changed in 5.2, which we haven't switched to yet.
@tannewt tannewt removed their assignment Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement espressif applies to multiple Espressif chips
Projects
None yet
Development

No branches or pull requests

5 participants