|
gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
|
Functions for configuring the system and putting it in standby mode. More...
Functions | |
| void | sys_init (void) |
| Initializes the system clocks and performs any required system-wide setup. | |
| uint32_t | get_cpu_frequency (void) |
| Gets the CPU frequency. | |
| bool | set_cpu_frequency (uint32_t freq) |
| Sets the CPU frequency. | |
| void | _enable_48mhz_gclk1 (void) |
| Enables the 48 MHz clock on GCLK1 for USB operation. | |
| void | set_light_sleep_enabled (bool enabled) |
| Enables or disables light sleep mode. | |
| bool | get_light_sleep_enabled (void) |
| Gets whether light sleep mode is enabled. | |
| void | _enter_standby_mode (void) |
| Enters the configured sleep mode. Does not return until an interrupt fires. | |
Functions for configuring the system and putting it in standby mode.
| void _enable_48mhz_gclk1 | ( | void | ) |
Enables the 48 MHz clock on GCLK1 for USB operation.
This function is called by the USB stack when it is initialized.
| void _enter_standby_mode | ( | void | ) |
Enters the configured sleep mode. Does not return until an interrupt fires.
You should not generally need to call this function; at the end of every app_loop invocation, the main run loop enters sleep mode if your app indicated that it was appropriate. The sleep mode used depends on whether light sleep is enabled via set_light_sleep_enabled.
| uint32_t get_cpu_frequency | ( | void | ) |
Gets the CPU frequency.
set_cpu_frequency | bool get_light_sleep_enabled | ( | void | ) |
Gets whether light sleep mode is enabled.
| bool set_cpu_frequency | ( | uint32_t | freq | ) |
Sets the CPU frequency.
| freq | one of 1000000, 2000000, 4000000, 8000000, 12000000, 16000000, 48000000, 96000000 or 120000000 (last three are SAM D51 only). |
Supported CPU frequencies vary from chip to chip:
| void set_light_sleep_enabled | ( | bool | enabled | ) |
Enables or disables light sleep mode.
| enabled | true to use a lighter IDLE sleep mode when app_loop returns true; false to use the default deep STANDBY mode. |
By default, returning true from app_loop enters STANDBY mode, the deepest sleep available. Light sleep uses a lighter idle mode instead, which is useful when your application needs DMA to continue running during sleep, or when fast interrupt response time is critical.
On SAM D11 and D21 light sleep uses IDLE0, which keeps the AHB and APB peripheral buses running. This is required to allow DMA transfers to continue.
On SAM L21 and L22, light sleep uses IDLE2 mode, which stops all buses but provides faster wakeup than STANDBY. IDLE0 is not available on L21 and L22; for DMA on those chips, consult the DMAC's per-channel RUNSTDBY bits.
| void sys_init | ( | void | ) |
Initializes the system clocks and performs any required system-wide setup.
Gossamer aims for consistency at system startup, no matter which chip you are working with. On the SAM D11, D21, L21 and L22:
usb_init function will claim GCLK1 for the 48 MHz DFLL clock.On the SAM D51, the clock layout is different. The DFLL is the CPU clock source at reset, so GCLK0 boots at 48 MHz from the DFLL. sys_init sets up the following generators:
dac_init as a 12 MHz clock (DFLL divided by 4), required because the D51 DAC's input clock may not exceed 12 MHz.set_cpu_frequency as a 1 MHz PLL reference (DFLL divided by 48), used when switching GCLK0 to DPLL0. The D51 also enables the CMCC cache controller, which becomes important once the CPU frequency exceeds the flash access speed.