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

Fixup rosc_set_div function #15

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

Conversation

lurch
Copy link
Contributor

@lurch lurch commented Mar 16, 2021

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

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);
Copy link
Contributor

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

Copy link
Contributor Author

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());
Copy link
Contributor

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?

Copy link
Contributor Author

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)

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.

2 participants