[riot-notifications] [RIOT-OS/RIOT] cc26x2_cc13x2: add oscillator switching functions (#13991)

benpicco notifications at github.com
Fri May 1 14:39:32 CEST 2020


@benpicco commented on this pull request.



> + * @{
+ */
+#define OPMODE_PDA_ORDER  (0)
+#define OPMODE_A_ORDER    (1)
+#define OPMODE_LP_ORDER   (2)
+#define OPMODE_PDLP_ORDER (3)
+/** @} */
+
+/** Array to map an operation mode to it's order when changing it */
+static const uint8_t _opmode_to_order[4] = {
+    OPMODE_A_ORDER,
+    OPMODE_LP_ORDER,
+    OPMODE_PDA_ORDER,
+    OPMODE_PDLP_ORDER
+};
+/** Array to map an order to an operation mode, used to get the next operation

```suggestion

/** Array to map an order to an operation mode, used to get the next operation
```

> +#define OSC_SRC_CLK_HF       0x00000001
+#define OSC_SRC_CLK_LF       0x00000004

A comment about what these are doesn't hurt :wink: 

> + * If a request to switch the HF clock source has been made, this function can
+ * be used to check if the clock source is ready to be switched.

How would such a request look like?

> +    if (DDI_0_OSC->STAT0 & DDI_0_OSC_STAT0_PENDINGSCLKHFSWITCHING) {
+        return true;
+    }
+    return false;
+}
+
+void osc_hf_source_switch(void)
+{
+    /* Read SCLK_HF target clock */
+    uint32_t hf_src = DDI_0_OSC->CTL0 & DDI_0_OSC_CTL0_SCLK_HF_SRC_SEL_m;
+
+    /* If target clock source is RCOSC, change clock source for DCDC to RCOSC */
+    if (hf_src == DDI_0_OSC_CTL0_SCLK_HF_SRC_SEL_RCOSC) {
+        /* Force DCDC to use RCOSC before switching SCLK_HF to RCOSC */
+        uint32_t mask = DDI_0_OSC_CTL0_CLK_DCDC_SRC_SEL_m;
+        uint32_t data = (DDI_0_OSC_CTL0_CLK_DCDC_SRC_SEL_m >> 16);

```suggestion
        uint32_t data = DDI_0_OSC_CTL0_CLK_DCDC_SRC_SEL_m >> 16;
```

Makes it easier to compare with the line above.

-- 
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/13991#pullrequestreview-404137328
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200501/ab95e46d/attachment-0001.htm>


More information about the notifications mailing list