You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/02/09 13:23:12 UTC

[mynewt-core] branch master updated: hw/nrf53: Add option to use internal load caps for lfxo

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 6fef283  hw/nrf53: Add option to use internal load caps for lfxo
6fef283 is described below

commit 6fef283fb106f0ed22de327cc6eb1efe0ee63138
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Feb 8 09:47:04 2022 +0100

    hw/nrf53: Add option to use internal load caps for lfxo
---
 hw/bsp/nordic_pca10095/syscfg.yml      |  1 +
 hw/mcu/nordic/nrf5340/src/hal_system.c | 11 +++++++++++
 hw/mcu/nordic/nrf5340/syscfg.yml       | 10 ++++++++++
 3 files changed, 22 insertions(+)

diff --git a/hw/bsp/nordic_pca10095/syscfg.yml b/hw/bsp/nordic_pca10095/syscfg.yml
index 834a756..6a7776f 100644
--- a/hw/bsp/nordic_pca10095/syscfg.yml
+++ b/hw/bsp/nordic_pca10095/syscfg.yml
@@ -95,6 +95,7 @@ syscfg.vals:
 
 syscfg.vals.!BOOT_LOADER:
     MCU_LFCLK_SOURCE: LFXO
+    MCU_LFCLK_XO_INTCAP: c9pf
 
 syscfg.vals.BLE_HOST:
     BLE_HCI_TRANSPORT: nrf5340
diff --git a/hw/mcu/nordic/nrf5340/src/hal_system.c b/hw/mcu/nordic/nrf5340/src/hal_system.c
index ea01400..af75d20 100644
--- a/hw/mcu/nordic/nrf5340/src/hal_system.c
+++ b/hw/mcu/nordic/nrf5340/src/hal_system.c
@@ -86,6 +86,17 @@ hal_system_clock_start(void)
     regval = CLOCK_LFCLKSTAT_STATE_Running << CLOCK_LFCLKSTAT_STATE_Pos;
 
 #if MYNEWT_VAL_CHOICE(MCU_LFCLK_SOURCE, LFXO)
+
+#if MYNEWT_VAL_CHOICE(MCU_LFCLK_XO_INTCAP, external)
+    NRF_OSCILLATORS->XOSC32KI.INTCAP = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_External;
+#elif MYNEWT_VAL_CHOICE(MCU_LFCLK_XO_INTCAP, c6pf)
+    NRF_OSCILLATORS->XOSC32KI.INTCAP = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C6PF
+#elif MYNEWT_VAL_CHOICE(MCU_LFCLK_XO_INTCAP, c7pf)
+    NRF_OSCILLATORS->XOSC32KI.INTCAP = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C7PF;
+#elif MYNEWT_VAL_CHOICE(MCU_LFCLK_XO_INTCAP, c9pf)
+    NRF_OSCILLATORS->XOSC32KI.INTCAP = OSCILLATORS_XOSC32KI_INTCAP_INTCAP_C11PF;
+#endif
+
 #if !defined(NRF_TRUSTZONE_NONSECURE)
     NRF_P0->PIN_CNF[0] = GPIO_PIN_CNF_MCUSEL_Peripheral << GPIO_PIN_CNF_MCUSEL_Pos;
     NRF_P0->PIN_CNF[1] = GPIO_PIN_CNF_MCUSEL_Peripheral << GPIO_PIN_CNF_MCUSEL_Pos;
diff --git a/hw/mcu/nordic/nrf5340/syscfg.yml b/hw/mcu/nordic/nrf5340/syscfg.yml
index 806f52d..0a71425 100644
--- a/hw/mcu/nordic/nrf5340/syscfg.yml
+++ b/hw/mcu/nordic/nrf5340/syscfg.yml
@@ -54,6 +54,16 @@ syscfg.defs:
             - LFRC      # 32.768 kHz RC oscillator
             - LFXO      # 32.768 kHz crystal oscillator
             - LFSYNTH   # 32.768 kHz synthesized from HFCLK
+    MCU_LFCLK_XO_INTCAP:
+        description: >
+            Control usage of internal load capacitors for 32.768 kHz crystal
+            oscillator.
+        value: external
+        choices:
+            - external  # use external load capacitors
+            - c6pf      # 6pF internal load capacitance
+            - c7pf      # 7pF internal load capacitance
+            - c9pf      # 9pF internal load capacitance
 
     MCU_GPIO_USE_PORT_EVENT:
         description: >