The friendly Operating System for the Internet of Things
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_CONFIG { \
172  { GPIO_PIN(PA, 2), 0, 0 }, \
173  { GPIO_PIN(PB, 8), 0, 2 }, \
174  { GPIO_PIN(PB, 9), 0, 3 }, \
175  { GPIO_PIN(PA, 4), 0, 4 }, \
176  { GPIO_PIN(PA, 5), 0, 5 }, \
177  { GPIO_PIN(PB, 2), 0, 10 }}
178 
179 #define ADC_NUMOF (6)
180 
186 static const spi_conf_t spi_config[] = {
187  {
188  .dev = &SERCOM4->SPI,
189  .miso_pin = GPIO_PIN(PA, 12),
190  .mosi_pin = GPIO_PIN(PB, 10),
191  .clk_pin = GPIO_PIN(PB, 11),
192  .miso_mux = GPIO_MUX_D,
193  .mosi_mux = GPIO_MUX_D,
194  .clk_mux = GPIO_MUX_D,
195  .miso_pad = SPI_PAD_MISO_0,
196  .mosi_pad = SPI_PAD_MOSI_2_SCK_3
197  }
198 };
199 
200 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
201 
207 #define I2C_NUMOF (1U)
208 #define I2C_0_EN 1
209 #define I2C_1_EN 0
210 #define I2C_2_EN 0
211 #define I2C_3_EN 0
212 #define I2C_IRQ_PRIO 1
213 
214 #define I2C_0_DEV SERCOM3->I2CM
215 #define I2C_0_IRQ SERCOM3_IRQn
216 #define I2C_0_ISR isr_sercom3
217 /* I2C 0 GCLK */
218 #define I2C_0_GCLK_ID SERCOM3_GCLK_ID_CORE
219 #define I2C_0_GCLK_ID_SLOW SERCOM3_GCLK_ID_SLOW
220 /* I2C 0 pin configuration */
221 #define I2C_0_SDA GPIO_PIN(PA, 22)
222 #define I2C_0_SCL GPIO_PIN(PA, 23)
223 #define I2C_0_MUX GPIO_MUX_C
224 
229 #define RTC_NUMOF (1U)
230 #define RTC_DEV RTC->MODE2
231 
237 #define RTT_NUMOF (1U)
238 #define RTT_DEV RTC->MODE0
239 #define RTT_IRQ RTC_IRQn
240 #define RTT_IRQ_PRIO 10
241 #define RTT_ISR isr_rtc
242 #define RTT_MAX_VALUE (0xffffffff)
243 #define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
244 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
245 
247 #ifdef __cplusplus
248 }
249 #endif
250 
251 #endif /* PERIPH_CONF_H */
252 
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.