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  },
117  {
118  .dev = &SERCOM0->USART,
119  .rx_pin = GPIO_PIN(PA,11),
120  .tx_pin = GPIO_PIN(PA,10),
121  .mux = GPIO_MUX_C,
122  .rx_pad = UART_PAD_RX_3,
123  .tx_pad = UART_PAD_TX_2
124  }
125 };
126 
127 /* interrupt function name mapping */
128 #define UART_0_ISR isr_sercom5
129 #define UART_1_ISR isr_sercom0
130 
131 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
132 
138 #define PWM_0_EN 1
139 #define PWM_1_EN 1
140 #define PWM_MAX_CHANNELS 2
141 /* for compatibility with test application */
142 #define PWM_0_CHANNELS PWM_MAX_CHANNELS
143 #define PWM_1_CHANNELS PWM_MAX_CHANNELS
144 
145 /* PWM device configuration */
146 static const pwm_conf_t pwm_config[] = {
147 #if PWM_0_EN
148  {TCC0, {
149  /* GPIO pin, MUX value, TCC channel */
150  { GPIO_PIN(PA, 8), GPIO_MUX_E, 0 },
151  { GPIO_PIN(PA, 9), GPIO_MUX_E, 1 },
152  }},
153 #endif
154 #if PWM_1_EN
155  {TCC1, {
156  /* GPIO pin, MUX value, TCC channel */
157  { GPIO_PIN(PA, 6), GPIO_MUX_E, 0 },
158  { GPIO_PIN(PA, 7), GPIO_MUX_E, 1 },
159  }},
160 #endif
161 };
162 
163 /* number of devices that are actually defined */
164 #define PWM_NUMOF (2U)
165 
171 #define ADC_NUMOF (0)
172 
178 static const spi_conf_t spi_config[] = {
179  {
180  .dev = &SERCOM4->SPI,
181  .miso_pin = GPIO_PIN(PA, 12),
182  .mosi_pin = GPIO_PIN(PB, 10),
183  .clk_pin = GPIO_PIN(PB, 11),
184  .miso_mux = GPIO_MUX_D,
185  .mosi_mux = GPIO_MUX_D,
186  .clk_mux = GPIO_MUX_D,
187  .miso_pad = SPI_PAD_MISO_0,
188  .mosi_pad = SPI_PAD_MOSI_2_SCK_3
189  }
190 };
191 
192 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
193 
199 #define I2C_NUMOF (1U)
200 #define I2C_0_EN 1
201 #define I2C_1_EN 0
202 #define I2C_2_EN 0
203 #define I2C_3_EN 0
204 #define I2C_IRQ_PRIO 1
205 
206 #define I2C_0_DEV SERCOM3->I2CM
207 #define I2C_0_IRQ SERCOM3_IRQn
208 #define I2C_0_ISR isr_sercom3
209 /* I2C 0 GCLK */
210 #define I2C_0_GCLK_ID SERCOM3_GCLK_ID_CORE
211 #define I2C_0_GCLK_ID_SLOW SERCOM3_GCLK_ID_SLOW
212 /* I2C 0 pin configuration */
213 #define I2C_0_SDA GPIO_PIN(PA, 22)
214 #define I2C_0_SCL GPIO_PIN(PA, 23)
215 #define I2C_0_MUX GPIO_MUX_C
216 
221 #define RTC_NUMOF (1U)
222 #define RTC_DEV RTC->MODE2
223 
229 #define RTT_NUMOF (1U)
230 #define RTT_DEV RTC->MODE0
231 #define RTT_IRQ RTC_IRQn
232 #define RTT_IRQ_PRIO 10
233 #define RTT_ISR isr_rtc
234 #define RTT_MAX_VALUE (0xffffffff)
235 #define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
236 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
237 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #endif /* PERIPH_CONF_H */
244 
select peripheral function D
USART_TypeDef * dev
USART device used.
select peripheral function E
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
PWM configuration structure.
select peripheral function C
UART device configuration.
use pad 2 for MOSI, pad 3 for SCK
SPI configuration data structure.
cc2538_ssi_t * dev
SSI device.