boards/common/arduino-mkr/include/periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freie Universit├Ąt Berlin
3  * 2016-2017 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 
24 #ifndef PERIPH_CONF_H
25 #define PERIPH_CONF_H
26 
27 #include "periph_cpu.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
64 #define CLOCK_USE_PLL (1)
65 
66 #if CLOCK_USE_PLL
67 /* edit these values to adjust the PLL output frequency */
68 #define CLOCK_PLL_MUL (47U) /* must be >= 31 & <= 95 */
69 #define CLOCK_PLL_DIV (1U) /* adjust to your needs */
70 /* generate the actual used core clock frequency */
71 #define CLOCK_CORECLOCK (((CLOCK_PLL_MUL + 1) * 1000000U) / CLOCK_PLL_DIV)
72 #else
73 /* edit this value to your needs */
74 #define CLOCK_DIV (1U)
75 /* generate the actual core clock frequency */
76 #define CLOCK_CORECLOCK (8000000 / CLOCK_DIV)
77 #endif
78 
84 #define TIMER_NUMOF (2U)
85 #define TIMER_0_EN 1
86 #define TIMER_1_EN 1
87 
88 /* Timer 0 configuration */
89 #define TIMER_0_DEV TC3->COUNT16
90 #define TIMER_0_CHANNELS 2
91 #define TIMER_0_MAX_VALUE (0xffff)
92 #define TIMER_0_ISR isr_tc3
93 
94 /* Timer 1 configuration */
95 #define TIMER_1_DEV TC4->COUNT32
96 #define TIMER_1_CHANNELS 2
97 #define TIMER_1_MAX_VALUE (0xffffffff)
98 #define TIMER_1_ISR isr_tc4
99 
105 static const uart_conf_t uart_config[] = {
106  {
107  .dev = &SERCOM5->USART,
108  .rx_pin = GPIO_PIN(PB,23), /* ARDUINO_PIN_13, RX Pin */
109  .tx_pin = GPIO_PIN(PB,22), /* ARDUINO_PIN_14, TX Pin */
110  .mux = GPIO_MUX_D,
111  .rx_pad = UART_PAD_RX_3,
112  .tx_pad = UART_PAD_TX_2,
113  .flags = UART_FLAG_NONE,
114  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
115  }
116 };
117 
118 /* interrupt function name mapping */
119 #define UART_0_ISR isr_sercom5
120 
121 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
122 
128 #define PWM_0_EN 1
129 #define PWM_MAX_CHANNELS (2U)
130 /* for compatibility with test application */
131 #define PWM_0_CHANNELS PWM_MAX_CHANNELS
132 
133 /* PWM device configuration */
134 static const pwm_conf_t pwm_config[] = {
135 #if PWM_0_EN
136  {TCC0, {
137  /* GPIO pin, MUX value, TCC channel */
138  { GPIO_PIN(PA, 10), GPIO_MUX_F, 2 }, /* ~2 */
139  { GPIO_PIN(PA, 11), GPIO_MUX_F, 3 }, /* ~3 */
140  }}
141 #endif
142 };
143 
144 /* number of devices that are actually defined */
145 #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
146 
152 #define ADC_0_EN 1
153 #define ADC_MAX_CHANNELS 14
154 /* ADC 0 device configuration */
155 #define ADC_0_DEV ADC
156 #define ADC_0_IRQ ADC_IRQn
157 
158 /* ADC 0 Default values */
159 #define ADC_0_CLK_SOURCE 0 /* GCLK_GENERATOR_0 */
160 #define ADC_0_PRESCALER ADC_CTRLB_PRESCALER_DIV512
161 
162 #define ADC_0_NEG_INPUT ADC_INPUTCTRL_MUXNEG_GND
163 #define ADC_0_GAIN_FACTOR_DEFAULT ADC_INPUTCTRL_GAIN_1X
164 #define ADC_0_REF_DEFAULT ADC_REFCTRL_REFSEL_INT1V
165 
166 static const adc_conf_chan_t adc_channels[] = {
167  /* port, pin, muxpos */
168  {GPIO_PIN(PA, 2), ADC_INPUTCTRL_MUXPOS_PIN0}, /* A0 */
169  {GPIO_PIN(PB, 2), ADC_INPUTCTRL_MUXPOS_PIN10}, /* A1 */
170  {GPIO_PIN(PB, 3), ADC_INPUTCTRL_MUXPOS_PIN11}, /* A2 */
171  {GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4}, /* A3 */
172  {GPIO_PIN(PA, 5), ADC_INPUTCTRL_MUXPOS_PIN5}, /* A4 */
173  {GPIO_PIN(PA, 6), ADC_INPUTCTRL_MUXPOS_PIN6}, /* A5 */
174  {GPIO_PIN(PA, 7), ADC_INPUTCTRL_MUXPOS_PIN7}, /* A6 */
175 };
176 
177 #define ADC_0_CHANNELS (7U)
178 #define ADC_NUMOF ADC_0_CHANNELS
179 
185 static const spi_conf_t spi_config[] = {
186  {
187  .dev = &SERCOM1->SPI,
188  .miso_pin = GPIO_PIN(PA, 19), /* ARDUINO_PIN_8, SERCOM1-MISO */
189  .mosi_pin = GPIO_PIN(PA, 16), /* ARDUINO_PIN_10, SERCOM1-MOSI */
190  .clk_pin = GPIO_PIN(PA, 17), /* ARDUINO_PIN_9, SERCOM1-SCK */
191  .miso_mux = GPIO_MUX_C,
192  .mosi_mux = GPIO_MUX_C,
193  .clk_mux = GPIO_MUX_C,
194  .miso_pad = SPI_PAD_MISO_3,
195  .mosi_pad = SPI_PAD_MOSI_0_SCK_1
196  },
197  {
198  .dev = &SERCOM2->SPI,
199  .miso_pin = GPIO_PIN(PA, 15),
200  .mosi_pin = GPIO_PIN(PA, 12),
201  .clk_pin = GPIO_PIN(PA, 13),
202  .miso_mux = GPIO_MUX_C,
203  .mosi_mux = GPIO_MUX_C,
204  .clk_mux = GPIO_MUX_C,
205  .miso_pad = SPI_PAD_MISO_3,
206  .mosi_pad = SPI_PAD_MOSI_0_SCK_1
207  }
208 };
209 
210 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
211 
217 #define I2C_NUMOF (1U)
218 #define I2C_0_EN 1
219 #define I2C_1_EN 0
220 #define I2C_2_EN 0
221 #define I2C_3_EN 0
222 #define I2C_IRQ_PRIO 1
223 
224 #define I2C_0_DEV SERCOM0->I2CM
225 #define I2C_0_IRQ SERCOM0_IRQn
226 #define I2C_0_ISR isr_sercom0
227 /* I2C 0 GCLK */
228 #define I2C_0_GCLK_ID SERCOM0_GCLK_ID_CORE
229 #define I2C_0_GCLK_ID_SLOW SERCOM0_GCLK_ID_SLOW
230 /* I2C 0 pin configuration */
231 #define I2C_0_SDA GPIO_PIN(PA, 8) /* SERCOM0-SDA, on-board pull-up */
232 #define I2C_0_SCL GPIO_PIN(PA, 9) /* SERCOM0-SCL, on-board pull-up */
233 #define I2C_0_MUX GPIO_MUX_C
234 
240 #define RTC_NUMOF (1U)
241 #define RTC_DEV RTC->MODE2
242 
248 #define RTT_NUMOF (1U)
249 #define RTT_DEV RTC->MODE0
250 #define RTT_IRQ RTC_IRQn
251 #define RTT_IRQ_PRIO 10
252 #define RTT_ISR isr_rtc
253 #define RTT_MAX_VALUE (0xffffffff)
254 #define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
255 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
256 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif /* PERIPH_CONF_H */
263 
select peripheral function D
void * dev
UART, USART or LEUART device used.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
select peripheral function F
ADC Channel Configuration.
PWM device configuration.
select peripheral function C
UART device configuration.
SPI module configuration options.
use pad 0 for MOSI, pad 1 for SCK
cc2538_ssi_t * dev
SSI device.