periph_cpu.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2018 Mesotic SAS
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include "periph_cpu_common.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
29 #define PM_NUM_MODES (2)
36 enum {
39 };
45 static const gpio_t sam0_adc_pins[1][10] = {
46  {
47  GPIO_PIN(PA, 2), GPIO_PIN(PA, 3), GPIO_PIN(PA, 4), GPIO_PIN(PA, 5),
48  GPIO_PIN(PA, 6), GPIO_PIN(PA, 7), GPIO_PIN(PA, 8), GPIO_PIN(PA, 9),
49  GPIO_PIN(PA, 10), GPIO_PIN(PA, 11)
50  }
51 };
52 
57 #define ADC_INPUTCTRL_MUXPOS_PA02 ADC_INPUTCTRL_MUXPOS_AIN0
58 #define ADC_INPUTCTRL_MUXPOS_PA03 ADC_INPUTCTRL_MUXPOS_AIN1
59 #define ADC_INPUTCTRL_MUXPOS_PA04 ADC_INPUTCTRL_MUXPOS_AIN2
60 #define ADC_INPUTCTRL_MUXPOS_PA05 ADC_INPUTCTRL_MUXPOS_AIN3
61 #define ADC_INPUTCTRL_MUXPOS_PA06 ADC_INPUTCTRL_MUXPOS_AIN4
62 #define ADC_INPUTCTRL_MUXPOS_PA07 ADC_INPUTCTRL_MUXPOS_AIN5
63 #define ADC_INPUTCTRL_MUXPOS_PA08 ADC_INPUTCTRL_MUXPOS_AIN6
64 #define ADC_INPUTCTRL_MUXPOS_PA09 ADC_INPUTCTRL_MUXPOS_AIN7
65 #define ADC_INPUTCTRL_MUXPOS_PA10 ADC_INPUTCTRL_MUXPOS_AIN8
66 #define ADC_INPUTCTRL_MUXPOS_PA11 ADC_INPUTCTRL_MUXPOS_AIN9
68 #define ADC_INPUTCTRL_MUXNEG_PA02 ADC_INPUTCTRL_MUXPOS_AIN0
69 #define ADC_INPUTCTRL_MUXNEG_PA03 ADC_INPUTCTRL_MUXPOS_AIN1
70 #define ADC_INPUTCTRL_MUXNEG_PA04 ADC_INPUTCTRL_MUXPOS_AIN2
71 #define ADC_INPUTCTRL_MUXNEG_PA05 ADC_INPUTCTRL_MUXPOS_AIN3
72 #define ADC_INPUTCTRL_MUXNEG_PA06 ADC_INPUTCTRL_MUXPOS_AIN4
73 #define ADC_INPUTCTRL_MUXNEG_PA07 ADC_INPUTCTRL_MUXPOS_AIN5
74 #define ADC_INPUTCTRL_MUXNEG_PA08 ADC_INPUTCTRL_MUXPOS_AIN6
75 #define ADC_INPUTCTRL_MUXNEG_PA09 ADC_INPUTCTRL_MUXPOS_AIN7
81 #define DAC_RES_BITS (10)
82 
86 #define DAC_NUMOF (1)
87 
92 #define RTT_MAX_VALUE (0xffffffff)
93 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
94 #define RTT_MIN_FREQUENCY (RTT_CLOCK_FREQUENCY / 1024U) /* in Hz */
95 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
102 static const gpio_t rtc_tamper_pins[RTC_NUM_OF_TAMPERS] = {
103  GPIO_PIN(PA, 8), GPIO_PIN(PA, 9), GPIO_PIN(PA, 16),
104  GPIO_PIN(PA, 17)
105 };
106 
111 struct sam0_aux_cfg_mapping {
112  /* config word 0 */
113  uint32_t secure_region_unlock : 3;
115  uint32_t reserved_0 : 1;
116  uint32_t bod33_level : 6;
117  uint32_t bod33_disable : 1;
118  uint32_t bod33_action : 2;
119  const uint32_t bod12_calibration : 9;
120  uint32_t wdt_run_standby : 1;
121  uint32_t wdt_enable : 1;
122  uint32_t wdt_always_on : 1;
123  uint32_t wdt_period : 4;
124  /* config word 1 */
125  uint32_t wdt_window : 4;
126  uint32_t wdt_ewoffset : 4;
127  uint32_t wdt_window_enable : 1;
128  uint32_t bod33_hysteresis : 1;
129  uint32_t reserved_1 : 1;
130  uint32_t ram_execute_never : 1;
131  uint32_t data_execute_never : 1;
132  uint32_t reserved_2 : 19;
133  /* config word 2 */
134  uint32_t secure_flash_as_size : 8;
135  uint32_t nsc_size : 6;
136  uint32_t reserved_3 : 2;
137  uint32_t secure_flash_data_size : 4;
138  uint32_t reserved_4 : 4;
139  uint32_t secure_ram_size : 7;
140  uint32_t reserved_5 : 1;
141  /* config word 3 */
142  uint32_t user_row_write_enable : 1;
143  uint32_t reserved_6 : 31;
144  /* config word 4 */
145  uint32_t nonsec_a;
146  /* config word 5 */
147  uint32_t nonsec_b;
148  /* config word 6 */
149  uint32_t nonsec_c;
150  /* config word 7 */
151  uint32_t user_crc;
152 };
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:42
@ PA
port A
@ SAM0_GCLK_MAIN
48 MHz main clock
Definition: periph_cpu.h:71
@ SAM0_GCLK_32KHZ
32 kHz clock
Definition: periph_cpu.h:73
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:102
static const gpio_t sam0_adc_pins[1][10]
Pins that can be used for ADC input.
Definition: periph_cpu.h:45
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
uint32_t secure_flash_as_size
Secure Flash (AS region) Size = AS*0x100.
Definition: periph_cpu.h:134
uint64_t wdt_window
WDT Window at power-on.
Definition: periph_cpu.h:185
uint32_t nonsec_b
Peripherals Non-Secure Status Fuses for Bridge B.
Definition: periph_cpu.h:147
uint32_t data_execute_never
Data Flash is eXecute Never
Definition: periph_cpu.h:131
uint64_t wdt_window_enable
WDT Window mode enabled on power-on
Definition: periph_cpu.h:187
uint64_t bod33_hysteresis
BOD33 Hysteresis configuration
Definition: periph_cpu.h:188
uint32_t reserved_6
Reserved
Definition: periph_cpu.h:143
uint64_t bod33_action
BOD33 Action at power-on.
Definition: periph_cpu.h:180
uint32_t reserved_4
Reserved
Definition: periph_cpu.h:138
uint64_t wdt_period
WDT Period at power-on.
Definition: periph_cpu.h:184
uint32_t non_secure_region_unlock
NVM Non-Secure Region UnLock Bits
Definition: periph_cpu.h:114
uint32_t wdt_run_standby
WDT Runstdby at power-on
Definition: periph_cpu.h:120
uint64_t reserved_2
Factory settings - do not change.
Definition: periph_cpu.h:181
uint32_t secure_flash_data_size
Secure Data Flash Size = DS*0x100
Definition: periph_cpu.h:137
uint64_t wdt_ewoffset
WDT Early Warning Interrupt Offset
Definition: periph_cpu.h:186
uint32_t user_crc
CRC of NVM User Row bits 223:64 (words 2…6)
Definition: periph_cpu.h:151
uint32_t user_row_write_enable
User Row Write Enable
Definition: periph_cpu.h:142
uint64_t reserved_0
Factory settings - do not change.
Definition: periph_cpu.h:175
uint32_t bod33_disable
BOD33 Disable at power-on.
Definition: periph_cpu.h:232
uint64_t reserved_1
Factory settings - do not change.
Definition: periph_cpu.h:177
uint32_t ram_execute_never
RAM is eXecute Never
Definition: periph_cpu.h:130
uint32_t secure_ram_size
Secure SRAM Size = RS*0x80
Definition: periph_cpu.h:139
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
uint32_t nsc_size
Non-Secure Callable Flash (APPLICATION region) Size = ANSC*0x20.
Definition: periph_cpu.h:135
uint64_t reserved_3
Factory settings - do not change.
Definition: periph_cpu.h:190
uint32_t nonsec_a
Peripherals Non-Secure Status Fuses for Bridge A.
Definition: periph_cpu.h:145
uint32_t nonsec_c
Peripherals Non-Secure Status Fuses for Bridge C.
Definition: periph_cpu.h:149
uint64_t wdt_enable
WDT Enable at power-on.
Definition: periph_cpu.h:182
uint32_t secure_region_unlock
NVM Secure Region UnLock Bits
Definition: periph_cpu.h:113
uint32_t reserved_5
Reserved
Definition: periph_cpu.h:140