samd21/include/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 
34 static const int8_t exti_config[2][32] = {
35 #ifdef CPU_MODEL_SAMD21J18A
36  { 0, 1, 2, 3, 4, 5, 6, 7, -1, 9, 10, 11, 12, 13, 14, 15,
37  0, 1, 2, 3, 4, 5, 6, 7, 12, 13, -1, 15, 8, -1, 10, 11},
38  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
39  0, 1, -1, -1, -1, -1, 6, 7, -1, -1, -1, -1, -1, -1, 14, 15},
40 #elif CPU_MODEL_SAMD21G18A
41  { 0, 1, 2, 3, 4, 5, 6, 7, -1, 9, 10, 11, 12, 13, 14, 15,
42  0, 1, 2, 3, 4, 5, 6, 7, 12, 13, -1, 15, 8, -1, 10, 11},
43  {-1, -1, 2, 3, -1, -1, -1, -1, 8, 9, 10, 11, -1, -1, -1, -1,
44  -1, -1, -1, -1, -1, -1, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1},
45 #elif CPU_MODEL_SAMR21G18A
46  {-1, 1, -1, -1, 4, 5, 6, 7, -1, 9, 10, 11, 12, 13, 14, 15,
47  -1, 1, 2, 3, -1, -1, 6, 7, 12, 13, -1, 15, 8, -1, 10, 11},
48  { 0, -1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
49  0, 1, -1, -1, -1, -1, 6, 7, -1, -1, -1, -1, 8, -1, -1, -1},
50 #elif CPU_MODEL_SAMR21E18A
51  {-1, -1, -1, -1, -1, -1, 6, 7, -1, 9, 10, 11, -1, -1, 14, 15,
52  -1, 1, 2, 3, -1, -1, -1, -1, 12, 13, -1, 15, 8, -1, 10, 11},
53  { 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
54  0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
55 #else
56  #error Please define a proper CPU_MODEL.
57 #endif
58 };
59 
63 enum {
64  PA = 0,
65  PB = 1,
66  PC = 2,
67 };
68 
77 #define GPIO_MODE(pr, ie, pe) (pr | (ie << 1) | (pe << 2))
78 
84 #define SPI_HWCS(x) (UINT_MAX - 1)
85 
86 #ifndef DOXYGEN
87 
91 #define HAVE_GPIO_MODE_T
92 typedef enum {
93  GPIO_IN = GPIO_MODE(0, 1, 0),
94  GPIO_IN_PD = GPIO_MODE(0, 1, 1),
95  GPIO_IN_PU = GPIO_MODE(1, 1, 1),
96  GPIO_OUT = GPIO_MODE(0, 0, 0),
97  GPIO_OD = 0xfe,
98  GPIO_OD_PU = 0xff
99 } gpio_mode_t;
101 #endif /* ndef DOXYGEN */
102 
106 typedef struct {
107  gpio_t pin;
109  uint8_t chan;
111 
115 typedef struct {
116  Tcc *dev;
117  pwm_conf_chan_t chan[3];
118 } pwm_conf_t;
119 
127 static inline int _sercom_id(SercomUsart *sercom)
128 {
129  return ((((uint32_t)sercom) >> 10) & 0x7) - 2;
130 }
131 
136 #define HAVE_ADC_RES_T
137 typedef enum {
138  ADC_RES_6BIT = 0xff,
139  ADC_RES_8BIT = ADC_CTRLB_RESSEL_8BIT,
140  ADC_RES_10BIT = ADC_CTRLB_RESSEL_10BIT,
141  ADC_RES_12BIT = ADC_CTRLB_RESSEL_12BIT,
142  ADC_RES_14BIT = 0xfe,
144 } adc_res_t;
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* PERIPH_CPU_H */
151 
static const int8_t exti_config[2][32]
Mapping of pins to EXTI lines, -1 means not EXTI possible.
ADC resolution: 12 bit.
gpio_mux_t mux
pin function multiplex value
PWM configuration structure.
ADC resolution: 10 bit.
gpio_mux_t
Available MUX values for configuring a pin&#39;s alternate function.
ADC resolution: 8 bit.
PWM channel configuration data structure.
static int _sercom_id(SercomUsart *sercom)
Return the numeric id of a SERCOM device derived from its address.
Tcc * dev
TCC device to use.
input, no pull
#define GPIO_MODE(pr, ie, pe)
Generate GPIO mode bitfields.
not supported
input, pull-down
uint8_t chan
TCC channel to use.