periph_cpu.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015-2016 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include <limits.h>
20 
21 #include "periph_cpu_common.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
31 #define PM_NUM_MODES (4)
38 #ifndef PM_BLOCKER_INITIAL
39 # define PM_BLOCKER_INITIAL { 1, 0, 0, 0 }
40 #endif
41 
46 #define SAMD21_PM_STANDBY (0U)
47 #define SAMD21_PM_IDLE_2 (1U)
48 #define SAMD21_PM_IDLE_1 (2U)
49 #define SAMD21_PM_IDLE_0 (3U)
56 #define SAM0_SPI_PM_BLOCK SAMD21_PM_IDLE_1
63 #define SAM0_USB_ACTIVE_PM_BLOCK SAMD21_PM_IDLE_1
70 enum {
76 };
84 #define SPI_HWCS(x) (UINT_MAX - 1)
85 
93 static inline int _sercom_id(SercomUsart *sercom)
94 {
95  return ((((uint32_t)sercom) >> 10) & 0x7) - 2;
96 }
97 
101 static const gpio_t sam0_adc_pins[1][20] = {
102  {
103  GPIO_PIN(PA, 2), GPIO_PIN(PA, 3), GPIO_PIN(PB, 8), GPIO_PIN(PB, 9),
104  GPIO_PIN(PA, 4), GPIO_PIN(PA, 5), GPIO_PIN(PA, 6), GPIO_PIN(PA, 7),
105  GPIO_PIN(PB, 0), GPIO_PIN(PB, 1), GPIO_PIN(PB, 2), GPIO_PIN(PB, 3),
106  GPIO_PIN(PB, 4), GPIO_PIN(PB, 5), GPIO_PIN(PB, 6), GPIO_PIN(PB, 7),
107  GPIO_PIN(PA, 8), GPIO_PIN(PA, 9), GPIO_PIN(PA, 10), GPIO_PIN(PA, 11),
108  }
109 };
110 
115 #define ADC_INPUTCTRL_MUXPOS_PA02 ADC_INPUTCTRL_MUXPOS_PIN0
116 #define ADC_INPUTCTRL_MUXPOS_PA03 ADC_INPUTCTRL_MUXPOS_PIN1
117 #define ADC_INPUTCTRL_MUXPOS_PB08 ADC_INPUTCTRL_MUXPOS_PIN2
118 #define ADC_INPUTCTRL_MUXPOS_PB09 ADC_INPUTCTRL_MUXPOS_PIN3
119 #define ADC_INPUTCTRL_MUXPOS_PA04 ADC_INPUTCTRL_MUXPOS_PIN4
120 #define ADC_INPUTCTRL_MUXPOS_PA05 ADC_INPUTCTRL_MUXPOS_PIN5
121 #define ADC_INPUTCTRL_MUXPOS_PA06 ADC_INPUTCTRL_MUXPOS_PIN6
122 #define ADC_INPUTCTRL_MUXPOS_PA07 ADC_INPUTCTRL_MUXPOS_PIN7
123 #define ADC_INPUTCTRL_MUXPOS_PB00 ADC_INPUTCTRL_MUXPOS_PIN8
124 #define ADC_INPUTCTRL_MUXPOS_PB01 ADC_INPUTCTRL_MUXPOS_PIN9
125 #define ADC_INPUTCTRL_MUXPOS_PB02 ADC_INPUTCTRL_MUXPOS_PIN10
126 #define ADC_INPUTCTRL_MUXPOS_PB03 ADC_INPUTCTRL_MUXPOS_PIN11
127 #define ADC_INPUTCTRL_MUXPOS_PB04 ADC_INPUTCTRL_MUXPOS_PIN12
128 #define ADC_INPUTCTRL_MUXPOS_PB05 ADC_INPUTCTRL_MUXPOS_PIN13
129 #define ADC_INPUTCTRL_MUXPOS_PB06 ADC_INPUTCTRL_MUXPOS_PIN14
130 #define ADC_INPUTCTRL_MUXPOS_PB07 ADC_INPUTCTRL_MUXPOS_PIN15
131 #define ADC_INPUTCTRL_MUXPOS_PA08 ADC_INPUTCTRL_MUXPOS_PIN16
132 #define ADC_INPUTCTRL_MUXPOS_PA09 ADC_INPUTCTRL_MUXPOS_PIN17
133 #define ADC_INPUTCTRL_MUXPOS_PA10 ADC_INPUTCTRL_MUXPOS_PIN18
134 #define ADC_INPUTCTRL_MUXPOS_PA11 ADC_INPUTCTRL_MUXPOS_PIN19
136 #define ADC_INPUTCTRL_MUXNEG_PA02 ADC_INPUTCTRL_MUXPOS_PIN0
137 #define ADC_INPUTCTRL_MUXNEG_PA03 ADC_INPUTCTRL_MUXPOS_PIN1
138 #define ADC_INPUTCTRL_MUXNEG_PB08 ADC_INPUTCTRL_MUXPOS_PIN2
139 #define ADC_INPUTCTRL_MUXNEG_PB09 ADC_INPUTCTRL_MUXPOS_PIN3
140 #define ADC_INPUTCTRL_MUXNEG_PA04 ADC_INPUTCTRL_MUXPOS_PIN4
141 #define ADC_INPUTCTRL_MUXNEG_PA05 ADC_INPUTCTRL_MUXPOS_PIN5
142 #define ADC_INPUTCTRL_MUXNEG_PA06 ADC_INPUTCTRL_MUXPOS_PIN6
143 #define ADC_INPUTCTRL_MUXNEG_PA07 ADC_INPUTCTRL_MUXPOS_PIN7
149 #define DAC_RES_BITS (10)
150 
154 #define DAC_NUMOF (1)
155 
160 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
161 
162 #define RTT_MAX_VALUE (0xffffffff)
163 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
164 #define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 1024U) /* in Hz */
165 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
174  uint64_t bootloader_size : 3;
175  uint64_t reserved_0 : 1;
176  uint64_t eeprom_size : 3;
177  uint64_t reserved_1 : 1;
178  uint64_t bod33_level : 6;
179  uint64_t bod33_enable : 1;
180  uint64_t bod33_action : 2;
181  uint64_t reserved_2 : 8;
182  uint64_t wdt_enable : 1;
183  uint64_t wdt_always_on : 1;
184  uint64_t wdt_period : 4;
185  uint64_t wdt_window : 4;
186  uint64_t wdt_ewoffset : 4;
187  uint64_t wdt_window_enable : 1;
188  uint64_t bod33_hysteresis : 1;
189  const uint64_t bod12_calibration : 1;
190  uint64_t reserved_3 : 6;
191  uint64_t nvm_locks : 16;
192 };
195 #ifdef __cplusplus
196 }
197 #endif
198 
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:42
@ PB
port B
@ PA
port A
@ SAM0_GCLK_MAIN
48 MHz main clock
Definition: periph_cpu.h:71
@ SAM0_GCLK_DISABLED
disabled GCLK
Definition: periph_cpu.h:75
@ SAM0_GCLK_1KHZ
1 kHz clock
Definition: periph_cpu.h:74
@ SAM0_GCLK_32KHZ
32 kHz clock
Definition: periph_cpu.h:73
@ SAM0_GCLK_1MHZ
1 MHz clock for xTimer
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:101
static int _sercom_id(SercomUsart *sercom)
Return the numeric id of a SERCOM device derived from its address.
Definition: periph_cpu.h:93
NVM User Row Mapping - Dedicated Entries Config values will be applied at power-on.
Definition: periph_cpu.h:173
uint64_t bod33_level
BOD33 threshold level at power-on.
Definition: periph_cpu.h:178
uint64_t wdt_window
WDT Window at power-on.
Definition: periph_cpu.h:185
uint64_t wdt_window_enable
WDT Window mode enabled on power-on
Definition: periph_cpu.h:187
uint64_t nvm_locks
NVM Region Lock Bits.
Definition: periph_cpu.h:191
uint64_t bod33_hysteresis
BOD33 Hysteresis configuration
Definition: periph_cpu.h:188
uint64_t bod33_action
BOD33 Action at power-on.
Definition: periph_cpu.h:180
uint64_t bod33_enable
BOD33 Enable at power-on.
Definition: periph_cpu.h:179
uint64_t wdt_period
WDT Period at power-on.
Definition: periph_cpu.h:184
uint64_t reserved_2
Factory settings - do not change.
Definition: periph_cpu.h:181
uint64_t bootloader_size
BOOTPROT: Bootloader Size
Definition: periph_cpu.h:174
uint64_t wdt_ewoffset
WDT Early Warning Interrupt Offset
Definition: periph_cpu.h:186
uint64_t eeprom_size
one of eight different EEPROM sizes
Definition: periph_cpu.h:176
uint64_t reserved_0
Factory settings - do not change.
Definition: periph_cpu.h:175
uint64_t reserved_1
Factory settings - do not change.
Definition: periph_cpu.h:177
uint64_t wdt_always_on
WDT Always-On at power-on.
Definition: periph_cpu.h:183
const uint64_t bod12_calibration
Factory settings - do not change.
Definition: periph_cpu.h:189
uint64_t reserved_3
Factory settings - do not change.
Definition: periph_cpu.h:190
uint64_t wdt_enable
WDT Enable at power-on.
Definition: periph_cpu.h:182