periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 ML!PA Consulting GmbH
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 
20 #ifndef PERIPH_CPU_H
21 #define PERIPH_CPU_H
22 
23 #include <limits.h>
24 
25 #include "macros/units.h"
26 #include "periph_cpu_common.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define SAM0_DFLL_FREQ_HZ MHZ(48)
36 
40 #define SAM0_XOSC_FREQ_HZ (XOSC0_FREQUENCY ? XOSC0_FREQUENCY : XOSC1_FREQUENCY)
41 
45 #define SAM0_DPLL_FREQ_MIN_HZ MHZ(96)
46 
50 #define SAM0_DPLL_FREQ_MAX_HZ MHZ(20)
51 
56 #define PM_NUM_MODES (3)
57 
63 enum {
68 };
75 #define SAM0_GCLK_8MHZ SAM0_GCLK_TIMER
76 #define SAM0_GCLK_48MHZ SAM0_GCLK_PERIPH
77 
84 #define SPI_HWCS(x) (UINT_MAX - 1)
85 
86 #ifndef DOXYGEN
87 #define HAVE_ADC_RES_T
88 typedef enum {
89  ADC_RES_6BIT = 0xff,
90  ADC_RES_8BIT = ADC_CTRLB_RESSEL_8BIT,
91  ADC_RES_10BIT = ADC_CTRLB_RESSEL_10BIT,
92  ADC_RES_12BIT = ADC_CTRLB_RESSEL_12BIT,
93  ADC_RES_14BIT = 0xfe,
94  ADC_RES_16BIT = 0xfd
95 } adc_res_t;
97 #endif /* DOXYGEN */
98 
102 #define DAC_RES_BITS (12)
103 
107 #define DAC_NUMOF (2)
108 
113 #define RTT_MAX_VALUE (0xffffffff)
114 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
115 #define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 1024U) /* in Hz */
116 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
117 
123 static const gpio_t rtc_tamper_pins[RTC_NUM_OF_TAMPERS] = {
124  GPIO_PIN(PB, 0), GPIO_PIN(PB, 2), GPIO_PIN(PA, 2),
125  GPIO_PIN(PC, 0), GPIO_PIN(PC, 1)
126 };
127 
133 struct sam0_aux_cfg_mapping {
134  /* config word 0 */
135  uint32_t bod33_disable : 1;
136  uint32_t bod33_level : 8;
137  uint32_t bod33_action : 2;
138  uint32_t bod33_hysteresis : 4;
139  const uint32_t bod12_calibration : 11;
140  uint32_t nvm_boot_size : 4;
141  uint32_t reserved_0 : 2;
142  /* config word 1 */
143  uint32_t smart_eeprom_blocks : 4;
144  uint32_t smart_eeprom_page_size : 3;
145  uint32_t ram_eccdis : 1;
146  uint32_t reserved_1 : 8;
147  uint32_t wdt_enable : 1;
148  uint32_t wdt_always_on : 1;
149  uint32_t wdt_period : 4;
150  uint32_t wdt_window : 4;
151  uint32_t wdt_ewoffset : 4;
152  uint32_t wdt_window_enable : 1;
153  uint32_t reserved_2 : 1;
154  /* config word 2 */
155  uint32_t nvm_locks;
156  /* config word 3 */
157  uint32_t user_page;
158  /* config word 4 */
159  uint32_t reserved_3;
160  /* config words 5,6,7 */
161  uint32_t user_pages[3];
162 };
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* PERIPH_CPU_H */
170 
sam0_aux_cfg_mapping::smart_eeprom_blocks
uint32_t smart_eeprom_blocks
NVM Blocks per SmartEEPROM sector
Definition: periph_cpu.h:143
rtc_tamper_pins
static const gpio_t rtc_tamper_pins[RTC_NUM_OF_TAMPERS]
RTC input pins that can be used for tamper detection and wake from Deep Sleep.
Definition: periph_cpu.h:123
sam0_aux_cfg_mapping::reserved_3
uint32_t reserved_3
Factory settings - do not change.
Definition: periph_cpu.h:159
ADC_RES_6BIT
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition: adc.h:94
PC
@ PC
port C
Definition: periph_cpu.h:150
SAM0_GCLK_MAIN
@ SAM0_GCLK_MAIN
48 MHz main clock
Definition: periph_cpu.h:59
sam0_aux_cfg_mapping
NVM User Row Mapping - Dedicated Entries Config values will be applied at power-on.
Definition: periph_cpu.h:130
SAM0_GCLK_PERIPH
@ SAM0_GCLK_PERIPH
12-48 MHz (DFLL) clock
Definition: periph_cpu.h:67
ADC_RES_14BIT
@ ADC_RES_14BIT
ADC resolution: 14 bit.
Definition: adc.h:98
adc_res_t
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:93
sam0_aux_cfg_mapping::bod33_level
uint32_t bod33_level
BOD33 threshold level at power-on.
Definition: periph_cpu.h:136
sam0_aux_cfg_mapping::user_page
uint32_t user_page
User page
Definition: periph_cpu.h:157
sam0_aux_cfg_mapping::bod33_action
uint32_t bod33_action
BOD33 Action at power-on.
Definition: periph_cpu.h:137
ADC_RES_16BIT
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition: adc.h:99
SAM0_GCLK_TIMER
@ SAM0_GCLK_TIMER
4-8 MHz clock for xTimer
Definition: periph_cpu.h:66
sam0_aux_cfg_mapping::user_pages
uint32_t user_pages[3]
User pages
Definition: periph_cpu.h:161
ADC_RES_8BIT
@ ADC_RES_8BIT
ADC resolution: 8 bit.
Definition: adc.h:95
SAM0_GCLK_32KHZ
@ SAM0_GCLK_32KHZ
32 kHz clock
Definition: periph_cpu.h:61
PB
@ PB
port B
Definition: periph_cpu.h:149
PA
@ PA
port A
Definition: periph_cpu.h:148
sam0_aux_cfg_mapping::reserved_2
uint32_t reserved_2
Factory settings - do not change.
Definition: periph_cpu.h:153
sam0_aux_cfg_mapping::wdt_period
uint32_t wdt_period
WDT Period at power-on.
Definition: periph_cpu.h:149
sam0_aux_cfg_mapping::reserved_1
uint32_t reserved_1
Factory settings - do not change.
Definition: periph_cpu.h:146
sam0_aux_cfg_mapping::bod12_calibration
const uint32_t bod12_calibration
Factory settings - do not change.
Definition: periph_cpu.h:139
sam0_aux_cfg_mapping::wdt_window_enable
uint32_t wdt_window_enable
WDT Window mode enabled on power-on
Definition: periph_cpu.h:152
sam0_aux_cfg_mapping::wdt_window
uint32_t wdt_window
WDT Window at power-on.
Definition: periph_cpu.h:150
sam0_aux_cfg_mapping::reserved_0
uint32_t reserved_0
Factory settings - do not change.
Definition: periph_cpu.h:141
units.h
Unit helper macros.
sam0_aux_cfg_mapping::wdt_enable
uint32_t wdt_enable
WDT Enable at power-on.
Definition: periph_cpu.h:147
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
sam0_aux_cfg_mapping::ram_eccdis
uint32_t ram_eccdis
RAM ECC Disable
Definition: periph_cpu.h:145
ADC_RES_10BIT
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition: adc.h:96
ADC_RES_12BIT
@ ADC_RES_12BIT
ADC resolution: 12 bit.
Definition: adc.h:97
sam0_aux_cfg_mapping::smart_eeprom_page_size
uint32_t smart_eeprom_page_size
SmartEEPROM Page Size
Definition: periph_cpu.h:144
sam0_aux_cfg_mapping::nvm_boot_size
uint32_t nvm_boot_size
NVM Bootloader Size
Definition: periph_cpu.h:140
sam0_aux_cfg_mapping::wdt_always_on
uint32_t wdt_always_on
WDT Always-On at power-on.
Definition: periph_cpu.h:148
sam0_aux_cfg_mapping::nvm_locks
uint32_t nvm_locks
NVM Region Lock Bits.
Definition: periph_cpu.h:155
sam0_aux_cfg_mapping::bod33_disable
uint32_t bod33_disable
BOD33 Disable at power-on.
Definition: periph_cpu.h:135
sam0_aux_cfg_mapping::bod33_hysteresis
uint32_t bod33_hysteresis
BOD33 Hysteresis configuration
Definition: periph_cpu.h:138
sam0_aux_cfg_mapping::wdt_ewoffset
uint32_t wdt_ewoffset
WDT Early Warning Interrupt Offset
Definition: periph_cpu.h:151