periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Mesotic SAS
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 "periph_cpu_common.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 #define PM_NUM_MODES (1)
34 
40 #define PM_BLOCKER_INITIAL 0x00000001
41 
46 enum {
49 };
52 #ifndef DOXYGEN
53 #define HAVE_ADC_RES_T
54 typedef enum {
55  ADC_RES_6BIT = 0xff,
56  ADC_RES_8BIT = ADC_CTRLC_RESSEL_8BIT,
57  ADC_RES_10BIT = ADC_CTRLC_RESSEL_10BIT,
58  ADC_RES_12BIT = ADC_CTRLC_RESSEL_12BIT,
59  ADC_RES_14BIT = 0xfe,
60  ADC_RES_16BIT = 0xfd
61 } adc_res_t;
62 #endif /* ndef DOXYGEN */
63 
68 #define DAC_RES_BITS (10)
69 
73 #define DAC_NUMOF (1)
74 
79 #define RTT_MAX_VALUE (0xffffffff)
80 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
81 #define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 1024U) /* in Hz */
82 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
83 
89 static const gpio_t rtc_tamper_pins[RTC_NUM_OF_TAMPERS] = {
90  GPIO_PIN(PA, 8), GPIO_PIN(PA, 9), GPIO_PIN(PA, 16),
91  GPIO_PIN(PA, 17)
92 };
93 
99 struct sam0_aux_cfg_mapping {
100  /* config word 0 */
101  uint32_t secure_region_unlock : 3;
103  uint32_t reserved_0 : 1;
104  uint32_t bod33_level : 6;
105  uint32_t bod33_disable : 1;
106  uint32_t bod33_action : 2;
107  const uint32_t bod12_calibration : 9;
108  uint32_t wdt_run_standby : 1;
109  uint32_t wdt_enable : 1;
110  uint32_t wdt_always_on : 1;
111  uint32_t wdt_period : 4;
112  /* config word 1 */
113  uint32_t wdt_window : 4;
114  uint32_t wdt_ewoffset : 4;
115  uint32_t wdt_window_enable : 1;
116  uint32_t bod33_hysteresis : 1;
117  uint32_t reserved_1 : 1;
118  uint32_t ram_execute_never : 1;
119  uint32_t data_execute_never : 1;
120  uint32_t reserved_2 : 19;
121  /* config word 2 */
122  uint32_t secure_flash_as_size : 8;
123  uint32_t nsc_size : 6;
124  uint32_t reserved_3 : 2;
125  uint32_t secure_flash_data_size : 4;
126  uint32_t reserved_4 : 4;
127  uint32_t secure_ram_size : 7;
128  uint32_t reserved_5 : 1;
129  /* config word 3 */
130  uint32_t user_row_write_enable : 1;
131  uint32_t reserved_6 : 31;
132  /* config word 4 */
133  uint32_t nonsec_a;
134  /* config word 5 */
135  uint32_t nonsec_b;
136  /* config word 6 */
137  uint32_t nonsec_c;
138  /* config word 7 */
139  uint32_t user_crc;
140 };
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* PERIPH_CPU_H */
148 
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:89
sam0_aux_cfg_mapping::nonsec_a
uint32_t nonsec_a
Peripherals Non-Secure Status Fuses for Bridge A.
Definition: periph_cpu.h:133
ADC_RES_6BIT
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition: adc.h:94
sam0_aux_cfg_mapping::nsc_size
uint32_t nsc_size
Non-Secure Callable Flash (APPLICATION region) Size = ANSC*0x20.
Definition: periph_cpu.h:123
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_aux_cfg_mapping::bod33_action
uint64_t bod33_action
BOD33 Action at power-on.
Definition: periph_cpu.h:137
sam0_aux_cfg_mapping::reserved_5
uint32_t reserved_5
Reserved
Definition: periph_cpu.h:128
sam0_aux_cfg_mapping::nonsec_c
uint32_t nonsec_c
Peripherals Non-Secure Status Fuses for Bridge C.
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::reserved_4
uint32_t reserved_4
Reserved
Definition: periph_cpu.h:126
sam0_aux_cfg_mapping::wdt_enable
uint64_t wdt_enable
WDT Enable at power-on.
Definition: periph_cpu.h:139
sam0_aux_cfg_mapping::secure_flash_as_size
uint32_t secure_flash_as_size
Secure Flash (AS region) Size = AS*0x100.
Definition: periph_cpu.h:122
ADC_RES_8BIT
@ ADC_RES_8BIT
ADC resolution: 8 bit.
Definition: adc.h:95
sam0_aux_cfg_mapping::reserved_6
uint32_t reserved_6
Reserved
Definition: periph_cpu.h:131
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::user_row_write_enable
uint32_t user_row_write_enable
User Row Write Enable
Definition: periph_cpu.h:130
PA
@ PA
port A
Definition: periph_cpu.h:148
sam0_aux_cfg_mapping::reserved_1
uint64_t reserved_1
Factory settings - do not change.
Definition: periph_cpu.h:134
sam0_aux_cfg_mapping::nonsec_b
uint32_t nonsec_b
Peripherals Non-Secure Status Fuses for Bridge B.
Definition: periph_cpu.h:135
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::wdt_run_standby
uint32_t wdt_run_standby
WDT Runstdby at power-on
Definition: periph_cpu.h:108
sam0_aux_cfg_mapping::wdt_ewoffset
uint64_t wdt_ewoffset
WDT Early Warning Interrupt Offset
Definition: periph_cpu.h:143
sam0_aux_cfg_mapping::secure_flash_data_size
uint32_t secure_flash_data_size
Secure Data Flash Size = DS*0x100
Definition: periph_cpu.h:125
sam0_aux_cfg_mapping::ram_execute_never
uint32_t ram_execute_never
RAM is eXecute Never
Definition: periph_cpu.h:118
sam0_aux_cfg_mapping::wdt_window_enable
uint64_t wdt_window_enable
WDT Window mode enabled on power-on
Definition: periph_cpu.h:144
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
ADC_RES_10BIT
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition: adc.h:96
sam0_aux_cfg_mapping::user_crc
uint32_t user_crc
CRC of NVM User Row bits 223:64 (words 2…6)
Definition: periph_cpu.h:139
ADC_RES_12BIT
@ ADC_RES_12BIT
ADC resolution: 12 bit.
Definition: adc.h:97
sam0_aux_cfg_mapping::data_execute_never
uint32_t data_execute_never
Data Flash is eXecute Never
Definition: periph_cpu.h:119
sam0_aux_cfg_mapping::non_secure_region_unlock
uint32_t non_secure_region_unlock
NVM Non-Secure Region UnLock Bits
Definition: periph_cpu.h:102
sam0_aux_cfg_mapping::reserved_3
uint64_t reserved_3
Factory settings - do not change.
Definition: periph_cpu.h:147
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::secure_ram_size
uint32_t secure_ram_size
Secure SRAM Size = RS*0x80
Definition: periph_cpu.h:127
sam0_aux_cfg_mapping::wdt_period
uint64_t wdt_period
WDT Period at power-on.
Definition: periph_cpu.h:141
sam0_aux_cfg_mapping::bod33_disable
uint32_t bod33_disable
BOD33 Disable at power-on.
Definition: periph_cpu.h:135
sam0_aux_cfg_mapping::secure_region_unlock
uint32_t secure_region_unlock
NVM Secure Region UnLock Bits
Definition: periph_cpu.h:101
sam0_aux_cfg_mapping::reserved_0
uint64_t reserved_0
Factory settings - do not change.
Definition: periph_cpu.h:132