[riot-notifications] [RIOT-OS/RIOT] cpu/sam0_common: RTC & RTT cleanup (#11689)

Dylan Laduranty notifications at github.com
Fri Jun 14 19:39:12 CEST 2019


dylad requested changes on this pull request.

I have several issues but this should be better once comments are addressed.
Please also enable MCLK_APBAMASK_OSC32KCTRL in cpu.c for SAML1X and SAML21 because it is missing.

>      /* RTC source clock is external oscillator at 1kHz */
+#if EXTERNAL_OSC32_SOURCE

please add #include "periph_conf." at the beginning of the file

>  #else
 static void _rtt_clock_setup(void)
 {
-    /* Turn on power manager for RTC */
-    MCLK->APBAMASK.reg |= MCLK_APBAMASK_OSC32KCTRL;
-
-    /* set clock source */
+    /* RTC source clock is external oscillator at 32kHz */
+#if EXTERNAL_OSC32_SOURCE
+    OSC32KCTRL->XOSC32K.bit.EN1K = 1; /* needed at least on SAME54 */

Should be EN32K.

>  #else
 static void _rtt_clock_setup(void)
 {
-    /* Turn on power manager for RTC */
-    MCLK->APBAMASK.reg |= MCLK_APBAMASK_OSC32KCTRL;
-
-    /* set clock source */
+    /* RTC source clock is external oscillator at 32kHz */
+#if EXTERNAL_OSC32_SOURCE

please add #include "periph_conf." at the beginning of the file

> @@ -34,6 +34,40 @@ static void _gclk_setup(int gclk, uint32_t reg)
     while (GCLK->SYNCBUSY.reg & GCLK_SYNCBUSY_GENCTRL(gclk)) {}
 }
 
+static void _osc32k_setup(void)
+{
+#if INTERNAL_OSC32_SOURCE

please add #include "periph_conf." at the beginning of the file

>      GCLK->GENCTRL[gclk].reg = reg;
+    while (GCLK->SYNCBUSY.reg & GCLK_SYNCBUSY_GENCTRL(gclk)) {}
+}
+
+static void _osc32k_setup(void)
+{
+#if INTERNAL_OSC32_SOURCE

please add #include "periph_conf." at the beginning of the file

>  #else
 static void _rtt_clock_setup(void)
 {
-    /* Turn on power manager for RTC */
-    MCLK->APBAMASK.reg |= MCLK_APBAMASK_OSC32KCTRL;
-
-    /* set clock source */
+    /* RTC source clock is external oscillator at 32kHz */
+#if EXTERNAL_OSC32_SOURCE
+    OSC32KCTRL->XOSC32K.bit.EN1K = 1; /* needed at least on SAME54 */
+    OSC32KCTRL->RTCCTRL.reg = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K;
+#endif /* EXTERNAL_OSC32_SOURCE */
+
+    /* RTC uses internal 32,768KHz Oscillator */
+#if INTERNAL_OSC32_SOURCE

#elif would be better to prevent bad surprise I think

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11689#pullrequestreview-250029684
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190614/50abdb06/attachment-0001.html>


More information about the notifications mailing list