periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
22 #include "periph_cpu_common.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
31 #define CPU_BACKUP_RAM_NOT_RETAINED (1)
32 
37 #define PM_NUM_MODES (3)
38 #define SAML21_PM_MODE_BACKUP (0)
39 #define SAML21_PM_MODE_STANDBY (1)
40 #define SAML21_PM_MODE_IDLE (2)
47 #define SAM0_GPIO_PM_BLOCK SAML21_PM_MODE_BACKUP
48 #define SAM0_RTCRTT_PM_BLOCK SAML21_PM_MODE_BACKUP
49 #define SAM0_SPI_PM_BLOCK SAML21_PM_MODE_STANDBY
50 #define SAM0_TIMER_PM_BLOCK SAML21_PM_MODE_STANDBY
51 #define SAM0_UART_PM_BLOCK SAML21_PM_MODE_STANDBY
52 #define SAM0_USB_IDLE_PM_BLOCK SAML21_PM_MODE_BACKUP
53 #define SAM0_USB_ACTIVE_PM_BLOCK SAML21_PM_MODE_STANDBY
60 #ifndef PM_BLOCKER_INITIAL
61 #define PM_BLOCKER_INITIAL { 0, 0, 0 }
62 #endif
63 
68 enum {
73 };
79 static const gpio_t sam0_adc_pins[1][20] = {
80  {
81  GPIO_PIN(PA, 2), GPIO_PIN(PA, 3), GPIO_PIN(PB, 8), GPIO_PIN(PB, 9),
82  GPIO_PIN(PA, 4), GPIO_PIN(PA, 5), GPIO_PIN(PA, 6), GPIO_PIN(PA, 7),
83  GPIO_PIN(PB, 0), GPIO_PIN(PB, 1), GPIO_PIN(PB, 2), GPIO_PIN(PB, 3),
84  GPIO_PIN(PB, 4), GPIO_PIN(PB, 5), GPIO_PIN(PB, 6), GPIO_PIN(PB, 7),
85  GPIO_PIN(PA, 8), GPIO_PIN(PA, 9), GPIO_PIN(PA, 10), GPIO_PIN(PA, 11),
86  }
87 };
88 
93 #define ADC_INPUTCTRL_MUXPOS_PA02 ADC_INPUTCTRL_MUXPOS_AIN0
94 #define ADC_INPUTCTRL_MUXPOS_PA03 ADC_INPUTCTRL_MUXPOS_AIN1
95 #define ADC_INPUTCTRL_MUXPOS_PB08 ADC_INPUTCTRL_MUXPOS_AIN2
96 #define ADC_INPUTCTRL_MUXPOS_PB09 ADC_INPUTCTRL_MUXPOS_AIN3
97 #define ADC_INPUTCTRL_MUXPOS_PA04 ADC_INPUTCTRL_MUXPOS_AIN4
98 #define ADC_INPUTCTRL_MUXPOS_PA05 ADC_INPUTCTRL_MUXPOS_AIN5
99 #define ADC_INPUTCTRL_MUXPOS_PA06 ADC_INPUTCTRL_MUXPOS_AIN6
100 #define ADC_INPUTCTRL_MUXPOS_PA07 ADC_INPUTCTRL_MUXPOS_AIN7
101 #define ADC_INPUTCTRL_MUXPOS_PB00 ADC_INPUTCTRL_MUXPOS_AIN8
102 #define ADC_INPUTCTRL_MUXPOS_PB01 ADC_INPUTCTRL_MUXPOS_AIN9
103 #define ADC_INPUTCTRL_MUXPOS_PB02 ADC_INPUTCTRL_MUXPOS_AIN10
104 #define ADC_INPUTCTRL_MUXPOS_PB03 ADC_INPUTCTRL_MUXPOS_AIN11
105 #define ADC_INPUTCTRL_MUXPOS_PB04 ADC_INPUTCTRL_MUXPOS_AIN12
106 #define ADC_INPUTCTRL_MUXPOS_PB05 ADC_INPUTCTRL_MUXPOS_AIN13
107 #define ADC_INPUTCTRL_MUXPOS_PB06 ADC_INPUTCTRL_MUXPOS_AIN14
108 #define ADC_INPUTCTRL_MUXPOS_PB07 ADC_INPUTCTRL_MUXPOS_AIN15
109 #define ADC_INPUTCTRL_MUXPOS_PA08 ADC_INPUTCTRL_MUXPOS_AIN16
110 #define ADC_INPUTCTRL_MUXPOS_PA09 ADC_INPUTCTRL_MUXPOS_AIN17
111 #define ADC_INPUTCTRL_MUXPOS_PA10 ADC_INPUTCTRL_MUXPOS_AIN18
112 #define ADC_INPUTCTRL_MUXPOS_PA11 ADC_INPUTCTRL_MUXPOS_AIN19
114 #define ADC_INPUTCTRL_MUXNEG_PA02 ADC_INPUTCTRL_MUXPOS_AIN0
115 #define ADC_INPUTCTRL_MUXNEG_PA03 ADC_INPUTCTRL_MUXPOS_AIN1
116 #define ADC_INPUTCTRL_MUXNEG_PB08 ADC_INPUTCTRL_MUXPOS_AIN2
117 #define ADC_INPUTCTRL_MUXNEG_PB09 ADC_INPUTCTRL_MUXPOS_AIN3
118 #define ADC_INPUTCTRL_MUXNEG_PA04 ADC_INPUTCTRL_MUXPOS_AIN4
119 #define ADC_INPUTCTRL_MUXNEG_PA05 ADC_INPUTCTRL_MUXPOS_AIN5
120 #define ADC_INPUTCTRL_MUXNEG_PA06 ADC_INPUTCTRL_MUXPOS_AIN6
121 #define ADC_INPUTCTRL_MUXNEG_PA07 ADC_INPUTCTRL_MUXPOS_AIN7
127 #define DAC_RES_BITS (12)
128 
132 #define DAC_NUMOF (2)
133 
138 #define RTT_MAX_VALUE (0xffffffff)
139 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
140 #define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 512U) /* in Hz */
141 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
142 /* determined by tests/sys/ztimer_underflow */
143 #define RTT_MIN_OFFSET (8U)
151 struct sam0_aux_cfg_mapping {
152  uint64_t bootloader_size : 3;
153  uint64_t reserved_0 : 1;
154  uint64_t eeprom_size : 3;
155  uint64_t reserved_1 : 1;
156  uint64_t bod33_level : 6;
157  uint64_t bod33_enable : 1;
158  uint64_t bod33_action : 2;
159  uint64_t reserved_2 : 9;
160  uint64_t wdt_enable : 1;
161  uint64_t wdt_always_on : 1;
162  uint64_t wdt_period : 4;
163  uint64_t wdt_window : 4;
164  uint64_t wdt_ewoffset : 4;
165  uint64_t wdt_window_enable : 1;
166  uint64_t bod33_hysteresis : 1;
167  uint64_t reserved_3 : 6;
168  uint64_t nvm_locks : 16;
169 };
172 #ifdef __cplusplus
173 }
174 #endif
175 
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
@ PB
port B
@ PA
port A
@ SAM0_GCLK_MAIN
48 MHz main clock
Definition: periph_cpu.h:74
@ SAM0_GCLK_32KHZ
32 kHz clock
Definition: periph_cpu.h:76
@ SAM0_GCLK_TIMER
4/8MHz clock for timers
Definition: periph_cpu.h:70
@ SAM0_GCLK_48MHZ
48MHz clock
Definition: periph_cpu.h:72
static const gpio_t sam0_adc_pins[1][20]
Pins that can be used for ADC input.
Definition: periph_cpu.h:79
NVM User Row Mapping - Dedicated Entries Config values will be applied at power-on.
Definition: periph_cpu.h:176
uint64_t bod33_level
BOD33 threshold level at power-on.
Definition: periph_cpu.h:181
uint64_t wdt_window
WDT Window at power-on.
Definition: periph_cpu.h:188
uint64_t wdt_window_enable
WDT Window mode enabled on power-on
Definition: periph_cpu.h:190
uint64_t nvm_locks
NVM Region Lock Bits.
Definition: periph_cpu.h:194
uint64_t bod33_hysteresis
BOD33 Hysteresis configuration
Definition: periph_cpu.h:191
uint64_t bod33_action
BOD33 Action at power-on.
Definition: periph_cpu.h:183
uint64_t bod33_enable
BOD33 Enable at power-on.
Definition: periph_cpu.h:182
uint64_t wdt_period
WDT Period at power-on.
Definition: periph_cpu.h:187
uint64_t reserved_2
Factory settings - do not change.
Definition: periph_cpu.h:184
uint64_t bootloader_size
BOOTPROT: Bootloader Size
Definition: periph_cpu.h:177
uint64_t wdt_ewoffset
WDT Early Warning Interrupt Offset
Definition: periph_cpu.h:189
uint64_t eeprom_size
one of eight different EEPROM sizes
Definition: periph_cpu.h:179
uint64_t reserved_0
Factory settings - do not change.
Definition: periph_cpu.h:178
uint64_t reserved_1
Factory settings - do not change.
Definition: periph_cpu.h:180
uint64_t wdt_always_on
WDT Always-On at power-on.
Definition: periph_cpu.h:186
uint64_t reserved_3
Factory settings - do not change.
Definition: periph_cpu.h:193
uint64_t wdt_enable
WDT Enable at power-on.
Definition: periph_cpu.h:185