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

I2C Overhaul, Dependency Removal, and Peripheral Manager Redux #625

Merged
merged 9 commits into from
Nov 20, 2023

Conversation

mikepparks
Copy link
Contributor

I2C Overhaul

This moves configuration of I2C controller blocks to a global scope, instead of a per-addon scope.

  • All functionality currently using I2C (Display, ADS1219, and Wii) has been updated to only require a controller block option, and in certain cases, a device address (Wii extension addresses are not selectable so it is exempt).
  • If no I2C block has been enabled and configured, I2C functionality will be disabled and affected functionality will display a message.

Dependency Removal

This also removes a dependency on the BitBangI2C library that existed in name only and wrapped pico-sdk functionality. It has been replaced with a library developed for the project called PicoPeripherals that will handle core peripheral functionality (initialization, reads, writes, etc.).

Peripheral Manager

To round out the changes to I2C, a Peripheral Manager has been introduced. This manager was written to leverage on-chip peripheral devices as needs arise. In addition to I2C, SPI has been added to this manager, but no functionality currently leverages it.

  • Peripheral Manager handles the global configuration scope of I2C and SPI devices, and initializes them if the respective devices have been enabled.
  • Each device is initialized as a singleton, so there can only ever be reference to one interface per controller block. With I2C in mind, this reduces the need to initialize devices or change options, which could disrupt functionality.

…till removes BitBangI2C dependencies in favor of PicoPeripherals. Again, there was much rejoicing.
@dogtopus
Copy link
Contributor

Since I2C and SPI access are now encapsulated, it would also make sense to take this opportunity to allow proper peripheral sharing across cores. Adding a recursive lock and methods to allow exclusive access for multiple read/write transactions (e.g. i2c.grab() and i2c.release()) would probably be enough.

@mikepparks
Copy link
Contributor Author

@dogtopus I do agree, but the first iteration of this is to get the new structure in place, and make sure that it doesn't break things in the process. Optimizations will come in a later PR, as there's some work that I would like to do to the Display functionality to clean things up. Right now, I'm assessing options for that part, which could mean ditching the OneBitDisplay library entirely, but it's a bit too early for me to tell. Display is the culprit for a lot of our I2C collisions, and likely the reason why things do not play nice across cores.

@mikepparks mikepparks marked this pull request as ready for review November 20, 2023 02:28
Copy link
Contributor

@arntsonl arntsonl left a comment

Choose a reason for hiding this comment

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

Looks fantastic, thank you for all the hard work!

@arntsonl arntsonl merged commit a37342f into OpenStickCommunity:main Nov 20, 2023
@mikepparks mikepparks deleted the 20231115-peripherals branch December 26, 2023 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants