Skip to content

Conversation

m-gorecki
Copy link
Contributor

This adds the same API for appcore and netcore.

NRF_CLOCK_NS->TASKS_LFCLKSTOP = 1;
NRF_CLOCK_NS->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK_NS->LFCLKSRC = clksrc;
NRF_CLOCK_NS->TASKS_LFCLKSTART = 1;
Copy link
Contributor

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

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

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) {
}

m-gorecki added 4 commits May 12, 2023 10:31
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.
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