patacongo commented on a change in pull request #1613:
URL: https://github.com/apache/incubator-nuttx/pull/1613#discussion_r474233904



##########
File path: arch/xtensa/src/esp32/esp32_clockconfig.c
##########
@@ -52,13 +46,278 @@ enum xtal_freq_e
   XTAL_AUTO = 0
 };
 
-enum xtal_freq_e
+enum cpu_freq_e
 {
-  CPU_80M = 1,
-  CPU_160M = 2,
-  CPU_240M = 3,
+  CPU_80M = 0,
+  CPU_160M = 1,
+  CPU_240M = 2,
 };
-#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+extern void ets_delay_us(int delay_us);
+
+/****************************************************************************
+ * Name: esp32_set_cpu_freq
+ *
+ * Description:
+ *   Switch to one of PLL-based frequencies.
+ *   Current frequency can be XTAL or PLL.
+ *
+ * Input Parameters:
+ *   cpu_freq_mhz      - new CPU frequency
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void esp32_set_cpu_freq(int cpu_freq_mhz)
+{
+  int dbias = DIG_DBIAS_80M_160M;
+  int per_conf;
+  uint32_t  value;
+
+  switch (cpu_freq_mhz)
+    {
+      case 160:
+        per_conf = CPU_160M;
+        break;
+      case 240:
+        dbias = DIG_DBIAS_240M;
+        per_conf = CPU_240M;
+        break;
+      case 80:
+        per_conf = CPU_80M;
+      default:
+        break;
+    }
+
+  value = (((80 * MHZ) >> 12) & UINT16_MAX)
+          | ((((80 * MHZ) >> 12) & UINT16_MAX) << 16);

Review comment:
       ```suggestion
             ((((80 * MHZ) >> 12) & UINT16_MAX) << 16);
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to