samd21: Use TM v4.0 LEDs to debug samd21 clock bits
authorKeith Packard <keithp@keithp.com>
Sat, 18 Feb 2023 23:28:08 +0000 (15:28 -0800)
committerKeith Packard <keithp@keithp.com>
Sat, 18 Feb 2023 23:28:50 +0000 (15:28 -0800)
red on at top of clock routine. green on after XOSC is running.
red off at bottom of clock routine.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/samd21/ao_timer.c

index 2b431d38ada440fa3581d8e46b3237158b69a2b7..91d74b12142d49fe9896ab7163d8340567478d8c 100644 (file)
@@ -122,6 +122,7 @@ ao_clock_init(void)
                ;
 
 #ifdef AO_XOSC
+       ao_enable_output(&samd21_port_b, 10, 1);
        /* Enable xosc (external xtal oscillator) */
        samd21_sysctrl.xosc = ((SAMD21_SYSCTRL_XOSC_STARTUP_8192 << SAMD21_SYSCTRL_XOSC_STARTUP) |
                               (0 << SAMD21_SYSCTRL_XOSC_AMPGC) |
@@ -135,6 +136,8 @@ ao_clock_init(void)
        while ((samd21_sysctrl.pclksr & (1 << SAMD21_SYSCTRL_PCLKSR_XOSCRDY)) == 0)
                ;
 
+       ao_enable_output(&samd21_port_b, 11, 1);
+
        /* program DPLL */
 
        /* Divide down */
@@ -289,4 +292,6 @@ ao_clock_init(void)
 
        /* Disable automatic NVM write operations */
        samd21_nvmctrl.ctrlb |= (1UL << SAMD21_NVMCTRL_CTRLB_MANW);
+
+       ao_gpio_set(&samd21_port_b, 10, 0);
 }