Skip to content

implement functions for accessing CR8 #547

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Freax13
Copy link
Member

@Freax13 Freax13 commented Apr 27, 2025

CR8 aka the task priority register can be used to mask external interrupts. If a non-zero value is written to the lower 4 bit of CR8, all interrupts with an interrupt lower or equal to that number are masked off. If CR8 contains 0, all external interrupts are enabled.

I've decided to implement this with an enum representing the 15 possible priority classes and used Option to represent the special 0 value. I've decided to make writing to CR8 safe because by itself, I don't think CR8 can be used to cause UB. This is similar to our methods for manipulating the IF flag.

CR8 aka the task priority register can be used to mask external
interrupts. If a non-zero value is written to the lower 4 bit of CR8,
all interrupts with an interrupt lower or equal to that number are
masked off. If CR8 contains 0, all external interrupts are enabled.

I've decided to implement this with an enum representing the 15
possible priority classes and used Option to represent the special 0
value. I've decided to make writing to CR8 safe because by itself, I
don't think CR8 can be used to cause UB. This is similar to our methods
for manipulating the IF flag.
@Freax13 Freax13 requested a review from phil-opp April 27, 2025 14: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.

1 participant