boards/arduino-zero/include/periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freie Universit├Ąt Berlin
3  * 2016 Inria
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
23 #ifndef PERIPH_CONF_H
24 #define PERIPH_CONF_H
25 
26 #include <stdint.h>
27 
28 #include "cpu.h"
29 #include "periph_cpu.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
66 #define CLOCK_USE_PLL (1)
67 
68 #if CLOCK_USE_PLL
69 /* edit these values to adjust the PLL output frequency */
70 #define CLOCK_PLL_MUL (47U) /* must be >= 31 & <= 95 */
71 #define CLOCK_PLL_DIV (1U) /* adjust to your needs */
72 /* generate the actual used core clock frequency */
73 #define CLOCK_CORECLOCK (((CLOCK_PLL_MUL + 1) * 1000000U) / CLOCK_PLL_DIV)
74 #else
75 /* edit this value to your needs */
76 #define CLOCK_DIV (1U)
77 /* generate the actual core clock frequency */
78 #define CLOCK_CORECLOCK (8000000 / CLOCK_DIV)
79 #endif
80 
86 #define TIMER_NUMOF (2U)
87 #define TIMER_0_EN 1
88 #define TIMER_1_EN 1
89 
90 /* Timer 0 configuration */
91 #define TIMER_0_DEV TC3->COUNT16
92 #define TIMER_0_CHANNELS 2
93 #define TIMER_0_MAX_VALUE (0xffff)
94 #define TIMER_0_ISR isr_tc3
95 
96 /* Timer 1 configuration */
97 #define TIMER_1_DEV TC4->COUNT32
98 #define TIMER_1_CHANNELS 2
99 #define TIMER_1_MAX_VALUE (0xffffffff)
100 #define TIMER_1_ISR isr_tc4
101 
108 static const uart_conf_t uart_config[] = {
109  {
110  .dev = &SERCOM5->USART,
111  .rx_pin = GPIO_PIN(PB,23),
112  .tx_pin = GPIO_PIN(PB,22),
113  .mux = GPIO_MUX_D,
114  .rx_pad = UART_PAD_RX_3,
115  .tx_pad = UART_PAD_TX_2,
116  .flags = UART_FLAG_NONE,
117  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
118  },
119  {
120  .dev = &SERCOM0->USART,
121  .rx_pin = GPIO_PIN(PA,11),
122  .tx_pin = GPIO_PIN(PA,10),
123  .mux = GPIO_MUX_C,
124  .rx_pad = UART_PAD_RX_3,
125  .tx_pad = UART_PAD_TX_2,
126  .flags = UART_FLAG_NONE,
127  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
128  }
129 };
130 
131 /* interrupt function name mapping */
132 #define UART_0_ISR isr_sercom5
133 #define UART_1_ISR isr_sercom0
134 
135 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
136 
142 #define PWM_0_EN 1
143 #define PWM_1_EN 1
144 #define PWM_MAX_CHANNELS 2
145 /* for compatibility with test application */
146 #define PWM_0_CHANNELS PWM_MAX_CHANNELS
147 #define PWM_1_CHANNELS PWM_MAX_CHANNELS
148 
149 /* PWM device configuration */
150 static const pwm_conf_t pwm_config[] = {
151 #if PWM_0_EN
152  {TCC0, {
153  /* GPIO pin, MUX value, TCC channel */
154  { GPIO_PIN(PA, 8), GPIO_MUX_E, 0 },
155  { GPIO_PIN(PA, 9), GPIO_MUX_E, 1 },
156  }},
157 #endif
158 #if PWM_1_EN
159  {TCC1, {
160  /* GPIO pin, MUX value, TCC channel */
161  { GPIO_PIN(PA, 6), GPIO_MUX_E, 0 },
162  { GPIO_PIN(PA, 7), GPIO_MUX_E, 1 },
163  }},
164 #endif
165 };
166 
167 /* number of devices that are actually defined */
168 #define PWM_NUMOF (2U)
169 
175 #define ADC_NUMOF (0)
176 
182 static const spi_conf_t spi_config[] = {
183  {
184  .dev = &SERCOM4->SPI,
185  .miso_pin = GPIO_PIN(PA, 12),
186  .mosi_pin = GPIO_PIN(PB, 10),
187  .clk_pin = GPIO_PIN(PB, 11),
188  .miso_mux = GPIO_MUX_D,
189  .mosi_mux = GPIO_MUX_D,
190  .clk_mux = GPIO_MUX_D,
191  .miso_pad = SPI_PAD_MISO_0,
192  .mosi_pad = SPI_PAD_MOSI_2_SCK_3
193  }
194 };
195 
196 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
197 
203 #define I2C_NUMOF (1U)
204 #define I2C_0_EN 1
205 #define I2C_1_EN 0
206 #define I2C_2_EN 0
207 #define I2C_3_EN 0
208 #define I2C_IRQ_PRIO 1
209 
210 #define I2C_0_DEV SERCOM3->I2CM
211 #define I2C_0_IRQ SERCOM3_IRQn
212 #define I2C_0_ISR isr_sercom3
213 /* I2C 0 GCLK */
214 #define I2C_0_GCLK_ID SERCOM3_GCLK_ID_CORE
215 #define I2C_0_GCLK_ID_SLOW SERCOM3_GCLK_ID_SLOW
216 /* I2C 0 pin configuration */
217 #define I2C_0_SDA GPIO_PIN(PA, 22)
218 #define I2C_0_SCL GPIO_PIN(PA, 23)
219 #define I2C_0_MUX GPIO_MUX_C
220 
225 #define RTC_NUMOF (1U)
226 #define RTC_DEV RTC->MODE2
227 
233 #define RTT_NUMOF (1U)
234 #define RTT_DEV RTC->MODE0
235 #define RTT_IRQ RTC_IRQn
236 #define RTT_IRQ_PRIO 10
237 #define RTT_ISR isr_rtc
238 #define RTT_MAX_VALUE (0xffffffff)
239 #define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
240 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
241 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 #endif /* PERIPH_CONF_H */
248 
select peripheral function D
void * dev
UART, USART or LEUART device used.
select peripheral function E
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
PWM device configuration.
select peripheral function C
UART device configuration.
use pad 2 for MOSI, pad 3 for SCK
SPI module configuration options.
cc2538_ssi_t * dev
SSI device.