-
Notifications
You must be signed in to change notification settings - Fork 972
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
Bug 1668 v2 - Provide method to prevent init of SYS_CLK, when left on during 'lightsleep' #1672
base: develop
Are you sure you want to change the base?
Conversation
…ing 'lightsleep' During 'lightsleep' user may want to keep some clocks running (for example PIOs), but at present microPython calls 'clock-init()' causing the SYS_CLK to be reinitialised. This patch allows microPython to provide the previously used 'sleep_en0 & sleep_en1' signifying which clocks stayed on. As most are dependant of SYS_CLK it can be inferred that this does NOT need to (/should NOT) be re-initilised.
Yes, should be a logical "&&". I'll update PR and add some documentation. Thanks. |
I removed the tabs. Do you want the whole series resubmitted (_v3?) as a single patch/pull request? |
That's not my decision to make, so leave it as-is for now unless asked otherwise 🙂 |
fixes #1668 |
/// \tag::configure_clk_sys[] | ||
// CLK SYS = PLL SYS (usually) 125MHz / 1 = 125MHz | ||
clock_configure(clk_sys, | ||
CLOCKS_CLK_SYS_CTRL_SRC_VALUE_CLKSRC_CLK_SYS_AUX, | ||
CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS, | ||
SYS_CLK_KHZ * KHZ, | ||
SYS_CLK_KHZ * KHZ); | ||
if (init_sys_clock) { | ||
clock_configure(clk_sys, | ||
CLOCKS_CLK_SYS_CTRL_SRC_VALUE_CLKSRC_CLK_SYS_AUX, | ||
CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS, | ||
SYS_CLK_KHZ * KHZ, | ||
SYS_CLK_KHZ * KHZ); | ||
} | ||
/// \end::configure_clk_sys[] |
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.
This "tag" is used to auto-include this code snippet into page 191 of https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
So in order not to clutter that example, it might make sense to move your new if
check to outside of the tag? i.e.
if (init_sys_clock) {
/// \tag::configure_clk_sys[]
// CLK SYS = PLL SYS (usually) 125MHz / 1 = 125MHz
clock_configure(clk_sys,
CLOCKS_CLK_SYS_CTRL_SRC_VALUE_CLKSRC_CLK_SYS_AUX,
CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS,
SYS_CLK_KHZ * KHZ,
SYS_CLK_KHZ * KHZ);
/// \end::configure_clk_sys[]
}
If this patch was extended to also check and selectively init PLL_USB then it would also meet the use case in #1746. Looks like a good approach to reuse the sleep bits this way. |
During 'lightsleep' user may want to keep some clocks running (for example PIOs), but at present microPython calls 'clock-init()' causing the SYS_CLK to be reinitialized.
This patch allows microPython to provide the previously used 'sleep_en0 & sleep_en1' signifying which clocks stayed on. As most are dependant of SYS_CLK it can be inferred that this does NOT need to (/should NOT) be re-initialized.