-
Notifications
You must be signed in to change notification settings - Fork 121
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
Fixup rosc_set_div function #15
base: master
Are you sure you want to change the base?
Conversation
Writing ROSC DIV incorrectly sets BADWRITE, so avoid rosc_write and manually clear the BADWRITE bit
@@ -30,8 +30,13 @@ uint rosc_find_freq(uint32_t low_mhz, uint32_t high_mhz) { | |||
} | |||
|
|||
void rosc_set_div(uint32_t div) { | |||
assert(div <= 31 && div >= 1); | |||
rosc_write(&rosc_hw->div, ROSC_DIV_VALUE_PASS + div); | |||
assert(div <= 31); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this should actually be a valid_params_if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll update it this evening.
rosc_write(&rosc_hw->div, ROSC_DIV_VALUE_PASS + div); | ||
assert(div <= 31); | ||
rosc_clear_bad_write(); | ||
assert(rosc_write_okay()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
under what circumstances can this fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's a good question - it's so long since I wrote this PR that I can't remember now! I'll have to dig through my emails this evening....... (and hope that the answer exists in an email and isn't lost somewhere in the google chat history)
A ROSC DIV of 0 is okay (and sets DIV = 32)
Writing ROSC DIV incorrectly sets BADWRITE, so avoid rosc_write and manually clear the BADWRITE bit