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

Non-volatile memory counter and flag refactor with unit tests #93

Merged
merged 13 commits into from
Jan 25, 2025

Conversation

nateinaction
Copy link
Member

@nateinaction nateinaction commented Jan 11, 2025

Summary

This PR replaces the bitflags module with an nvm module that is designed to help with interactions with non-volatile memory (nvm) on the microcontroller. This change started with making a hardware abstraction layer for NVM interactions so we could write unit tests for the bitflags module. Most of the bitflags.multibitflag package was tested and working in e576ae8

After getting that far, we worked to reduce the features implemented by the multiBitFlag class to only what the current version of the flight software uses. We ended up with a simple Counter class with two methods get() and increment().

Also we built a stub for ByteArray which is the interface definition used to back CircuitPython's NVM implementation. I have attempted to contribute this upstream: adafruit/Adafruit_CircuitPython_Typing#46

Next @TaylorGilg converted the bitFlag class to a class named Flag which offers two methods get() and toggle() and added tests.

Testing

Added unit tests
Tested on board

@nateinaction nateinaction changed the title EXAMPLE: Hardware abstraction for rp2040 registers with unit test EXAMPLE: Hardware abstraction for rp2040 non-volatile memory counter with unit test Jan 12, 2025
Comment on lines -542 to -557
@property
def burnarm(self) -> bitFlag:
return self.f_burnarm

@burnarm.setter
def burnarm(self, value: bitFlag) -> None:
self.f_burnarm: bitFlag = value

@property
def burned(self) -> bitFlag:
return self.f_burned

@burned.setter
def burned(self, value: bitFlag) -> None:
self.f_burned: bitFlag = value

Copy link
Member Author

@nateinaction nateinaction Jan 25, 2025

Choose a reason for hiding this comment

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

Note to reviewers, these fns were unused. Instead of updating the flag implementations, we removed them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note: All but nvm registers _BOOTCNT, _ERRORCNT, and _FLAG were removed due to not being able to find any further usage of them across the repo.

@nateinaction nateinaction marked this pull request as ready for review January 25, 2025 18:53
@nateinaction nateinaction requested a review from a team January 25, 2025 18:54
@nateinaction nateinaction changed the title EXAMPLE: Hardware abstraction for rp2040 non-volatile memory counter with unit test Non-volatile memory counter and flag refactor with unit tests Jan 25, 2025
Copy link
Contributor

@TaylorGilg TaylorGilg left a comment

Choose a reason for hiding this comment

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

Looked over all the changes and everything looks good.

@blakejameson blakejameson merged commit e62c9b7 into main Jan 25, 2025
3 checks passed
@blakejameson blakejameson deleted the hardware-abstraction-registers branch January 25, 2025 22:29
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