-
Notifications
You must be signed in to change notification settings - Fork 369
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
nrf53: Add APIs to change Low Frequency Clock source in the runtime #2993
base: master
Are you sure you want to change the base?
Conversation
NRF_CLOCK_NS->TASKS_LFCLKSTOP = 1; | ||
NRF_CLOCK_NS->EVENTS_LFCLKSTARTED = 0; | ||
NRF_CLOCK_NS->LFCLKSRC = clksrc; | ||
NRF_CLOCK_NS->TASKS_LFCLKSTART = 1; |
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.
lfclk source can be changes without restarting lfclk:
The LFCLK source can be configured at any time (for instance, when the LFCLK has already been started). The content of the LFCLKSRC register only takes effect when the LFCLKSTART task is triggered.
so we can only start lfclk once on system startup, then this API can change source at any time only taking care of hfxo when switching to/from lfsynth
} else { | ||
nrf5340_net_clock_hfxo_request(); | ||
} | ||
} else if ((NRF_CLOCK_NS->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk) == |
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.
LFCLKSRC
can be used instead of masking
(CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos)) { | ||
NRF_CLOCK_NS->EVENTS_HFCLKSTARTED = 0; | ||
nrf5340_net_clock_hfxo_request(); | ||
while (1) { |
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.
while (!NRF_CLOCK_NS->EVENTS_HFCLKSTARTED) {
}
Code from function hal_system_clock_start was moved into new API, so now we can call that API with proper argument to avoid code repetition.
Code from function hal_system_clock_start was moved into new API, so now we can call that API with proper argument to avoid code repetition.
This adds the same API for appcore and netcore.