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 
20 #ifndef PERIPH_CPU_H
21 #define PERIPH_CPU_H
22 
23 #include <limits.h>
24 
25 #include "periph_cpu_common.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define PM_NUM_MODES (3)
36 
42 #define PM_BLOCKER_INITIAL 0x00000001
43 
48 #define SAMD21_PM_STANDBY (0U)
49 #define SAMD21_PM_IDLE_2 (1U)
50 #define SAMD21_PM_IDLE_1 (2U)
51 #define SAMD21_PM_IDLE_0 (3U)
58 enum {
64 };
72 #define SPI_HWCS(x) (UINT_MAX - 1)
73 
81 static inline int _sercom_id(SercomUsart *sercom)
82 {
83  return ((((uint32_t)sercom) >> 10) & 0x7) - 2;
84 }
85 
86 #ifndef DOXYGEN
87 
91 #define HAVE_ADC_RES_T
92 typedef enum {
93  ADC_RES_6BIT = 0xff,
94  ADC_RES_8BIT = ADC_CTRLB_RESSEL_8BIT,
95  ADC_RES_10BIT = ADC_CTRLB_RESSEL_10BIT,
96  ADC_RES_12BIT = ADC_CTRLB_RESSEL_12BIT,
97  ADC_RES_14BIT = 0xfe,
98  ADC_RES_16BIT = 0xfd
99 } adc_res_t;
101 #endif /* ndef DOXYGEN */
102 
106 #define DAC_RES_BITS (10)
107 
111 #define DAC_NUMOF (1)
112 
117 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
118 
119 #define RTT_MAX_VALUE (0xffffffff)
120 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
121 #define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 1024U) /* in Hz */
122 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
123 
131  uint64_t bootloader_size : 3;
132  uint64_t reserved_0 : 1;
133  uint64_t eeprom_size : 3;
134  uint64_t reserved_1 : 1;
135  uint64_t bod33_level : 6;
136  uint64_t bod33_enable : 1;
137  uint64_t bod33_action : 2;
138  uint64_t reserved_2 : 8;
139  uint64_t wdt_enable : 1;
140  uint64_t wdt_always_on : 1;
141  uint64_t wdt_period : 4;
142  uint64_t wdt_window : 4;
143  uint64_t wdt_ewoffset : 4;
144  uint64_t wdt_window_enable : 1;
145  uint64_t bod33_hysteresis : 1;
146  const uint64_t bod12_calibration : 1;
147  uint64_t reserved_3 : 6;
148  uint64_t nvm_locks : 16;
149 };
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif /* PERIPH_CPU_H */
157 
sam0_aux_cfg_mapping::eeprom_size
uint64_t eeprom_size
one of eight different EEPROM sizes
Definition: periph_cpu.h:133
ADC_RES_6BIT
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition: adc.h:94
SAM0_GCLK_DISABLED
@ SAM0_GCLK_DISABLED
disabled GCLK
Definition: periph_cpu.h:63
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_aux_cfg_mapping::bod33_level
uint64_t bod33_level
BOD33 threshold level at power-on.
Definition: periph_cpu.h:135
SAM0_GCLK_1KHZ
@ SAM0_GCLK_1KHZ
1 kHz clock
Definition: periph_cpu.h:62
sam0_aux_cfg_mapping::bod33_action
uint64_t bod33_action
BOD33 Action at power-on.
Definition: periph_cpu.h:137
sam0_aux_cfg_mapping::reserved_2
uint64_t reserved_2
Factory settings - do not change.
Definition: periph_cpu.h:138
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_hysteresis
uint64_t bod33_hysteresis
BOD33 Hysteresis configuration
Definition: periph_cpu.h:145
ADC_RES_16BIT
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition: adc.h:99
sam0_aux_cfg_mapping::wdt_enable
uint64_t wdt_enable
WDT Enable at power-on.
Definition: periph_cpu.h:139
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
sam0_aux_cfg_mapping::wdt_window
uint64_t wdt_window
WDT Window at power-on.
Definition: periph_cpu.h:142
sam0_aux_cfg_mapping::reserved_1
uint64_t reserved_1
Factory settings - do not change.
Definition: periph_cpu.h:134
sam0_aux_cfg_mapping::bod12_calibration
const uint64_t bod12_calibration
Factory settings - do not change.
Definition: periph_cpu.h:146
sam0_aux_cfg_mapping::bod33_enable
uint64_t bod33_enable
BOD33 Enable at power-on.
Definition: periph_cpu.h:136
sam0_aux_cfg_mapping::bootloader_size
uint64_t bootloader_size
BOOTPROT: Bootloader Size
Definition: periph_cpu.h:131
sam0_aux_cfg_mapping::wdt_ewoffset
uint64_t wdt_ewoffset
WDT Early Warning Interrupt Offset
Definition: periph_cpu.h:143
sam0_aux_cfg_mapping::wdt_window_enable
uint64_t wdt_window_enable
WDT Window mode enabled on power-on
Definition: periph_cpu.h:144
sam0_aux_cfg_mapping::nvm_locks
uint64_t nvm_locks
NVM Region Lock Bits.
Definition: periph_cpu.h:148
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::reserved_3
uint64_t reserved_3
Factory settings - do not change.
Definition: periph_cpu.h:147
SAM0_GCLK_1MHZ
@ SAM0_GCLK_1MHZ
1 MHz clock for xTimer
Definition: periph_cpu.h:60
sam0_aux_cfg_mapping::wdt_always_on
uint64_t wdt_always_on
WDT Always-On at power-on.
Definition: periph_cpu.h:140
sam0_aux_cfg_mapping::wdt_period
uint64_t wdt_period
WDT Period at power-on.
Definition: periph_cpu.h:141
sam0_aux_cfg_mapping::reserved_0
uint64_t reserved_0
Factory settings - do not change.
Definition: periph_cpu.h:132
_sercom_id
static int _sercom_id(SercomUsart *sercom)
Return the numeric id of a SERCOM device derived from its address.
Definition: periph_cpu.h:81