esp-hal icon indicating copy to clipboard operation
esp-hal copied to clipboard

Add RtcI2c driver for ESP32-S3

Open Dominaezzz opened this issue 1 year ago • 4 comments
trafficstars

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request. To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • [ ] I have updated existing examples or added new ones (if applicable).
  • [x] I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • [x] My changes were added to the CHANGELOG.md in the proper section.
  • [x] My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Added a RtcI2c driver for the ESP32-S3's main CPU. In a follow up PR I'll more/less copy the code to the lp-hal for the ULP core to use.

ESP32-S2 support could be added but I don't have one to test with.

Description

See #1030 .

My main blocker is I need to write an example someone on the team can run... Anyone have any register based I2C devices? :sweat_smile:

I've got these:

  • https://wiki.seeedstudio.com/Grove-LCD_RGB_Backlight/
  • https://shop.m5stack.com/products/i-o-hub-1-to-6-expansion-unit-stm32f0
  • https://shop.m5stack.com/products/extend-i-o-unit-2-stm32f0
  • https://shop.m5stack.com/products/i2c-hub-1-to-6-expansion-unit-pca9548apw

Testing

I've ran the code (before I refactored it for this PR) with an ESP32-S3 + I2C 16x2 LCD, from both the main core and ulp core.

Dominaezzz avatar Jun 18 '24 22:06 Dominaezzz

Thanks for the PR! I took a quick glance and things look quite nice, however I will do a proper review some time this week.

One small thing, and this is very optional (you've contributed plenty already!), it would be nice to see doc comments on any public types/functions. I'm happy to do this in a subsequent PR if you do not feel like it though, not a big deal at all.

We have used the LIS3DH accelerometer for other I2C examples, which each member of our team should have access to. I can throw together a quick example using this sensor when I get around to reviewing/testing this PR.

jessebraham avatar Jun 24 '24 14:06 jessebraham

One small thing, and this is very optional (you've contributed plenty already!), it would be nice to see doc comments on any public types/functions. I'm happy to do this in a subsequent PR if you do not feel like it though, not a big deal at all.

I was going to come back to add public docs but I've been occupied with the DMA (and other) stuff. For future PRs I'll add documentation but I'll leave this one to you if you don't mind. :sweat_smile:

Dominaezzz avatar Jun 30 '24 18:06 Dominaezzz

We have used the LIS3DH accelerometer for other I2C examples, which each member of our team should have access to.

I think also everyone owns a BMP180 and an SSD1306 based LCD display. For BMP180 we already have a very similar example

bjoernQ avatar Jul 01 '24 07:07 bjoernQ

Sorry took me a bit longer to get to this than expected. I updated your example to reflect our existing example for the BMP180 (forgot I had this chip, should have suggested it initially), however I am currently unable to get it working. It keeps failing with Error::TimeOut, I will spend some time debugging and try to find the source of this error.

jessebraham avatar Jul 02 '24 16:07 jessebraham

I tried to run the example with BMP180 and I have Timeout error as well. With logic analyzer I can see START and STOP bit at least.

JurajSadel avatar Jul 16 '24 08:07 JurajSadel

I'm converting this to a draft just to help me keep track of its status (my brain is too full 😁) until we can confirm its working, please feel free to convert it back to a proper PR whenever you're ready.

jessebraham avatar Jul 23 '24 18:07 jessebraham

I would just like to do a bit of bikeshedding on the name. As with the RtcCntl, do we want to give the driver a somewhat less confusing name?

bugadani avatar Aug 15 '24 14:08 bugadani

I don't care about the name at all but what's confusing about RtcI2c? That's what it's called in the TRM.

Dominaezzz avatar Aug 15 '24 14:08 Dominaezzz

The whole "RTC" naming is confusing for the low power peripherals.

bugadani avatar Aug 15 '24 14:08 bugadani

Fair enough. I'm just going to note that the RTC_I2C peripheral found on the S2/S3 and the LP_I2C peripheral on the C6 (and maybe P4), are very different pieces of hardware and shouldn't be called the same thing. Or maybe call it the same thing but accept that the API will be different depending on the selected chip. 🤷

Dominaezzz avatar Aug 15 '24 14:08 Dominaezzz

I don't see myself getting back to this anytime soon.

Dominaezzz avatar Aug 28 '24 09:08 Dominaezzz