boards/sodaq-autonomo/include/periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kees Bakker, SODAQ
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 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 #include <stdint.h>
23 
24 #include "cpu.h"
25 #include "periph_cpu.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
62 #define CLOCK_USE_PLL (1)
63 
64 #if CLOCK_USE_PLL
65 /* edit these values to adjust the PLL output frequency */
66 #define CLOCK_PLL_MUL (47U) /* must be >= 31 & <= 95 */
67 #define CLOCK_PLL_DIV (1U) /* adjust to your needs */
68 /* generate the actual used core clock frequency */
69 #define CLOCK_CORECLOCK (((CLOCK_PLL_MUL + 1) * 1000000U) / CLOCK_PLL_DIV)
70 #else
71 /* edit this value to your needs */
72 #define CLOCK_DIV (1U)
73 /* generate the actual core clock frequency */
74 #define CLOCK_CORECLOCK (8000000 / CLOCK_DIV)
75 #endif
76 
82 #define TIMER_NUMOF (2U)
83 #define TIMER_0_EN 1
84 #define TIMER_1_EN 1
85 
86 /* Timer 0 configuration */
87 #define TIMER_0_DEV TC3->COUNT16
88 #define TIMER_0_CHANNELS 2
89 #define TIMER_0_MAX_VALUE (0xffff)
90 #define TIMER_0_ISR isr_tc3
91 
92 /* Timer 1 configuration */
93 #define TIMER_1_DEV TC4->COUNT32
94 #define TIMER_1_CHANNELS 2
95 #define TIMER_1_MAX_VALUE (0xffffffff)
96 #define TIMER_1_ISR isr_tc4
97 
104 static const uart_conf_t uart_config[] = {
105  {
106  .dev = &SERCOM0->USART,
107  .rx_pin = GPIO_PIN(PA,9),
108  .tx_pin = GPIO_PIN(PA,10),
109  .mux = GPIO_MUX_C,
110  .rx_pad = UART_PAD_RX_1,
111  .tx_pad = UART_PAD_TX_2,
112  .flags = UART_FLAG_NONE,
113  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
114  },
115  {
116  .dev = &SERCOM5->USART,
117  .rx_pin = GPIO_PIN(PB,31),
118  .tx_pin = GPIO_PIN(PB,30),
119  .mux = GPIO_MUX_D,
120  .rx_pad = UART_PAD_RX_1,
121  .tx_pad = UART_PAD_TX_0_RTS_2_CTS_3,
122  .flags = UART_FLAG_NONE,
123  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
124  },
125  {
126  .dev = &SERCOM4->USART,
127  .rx_pin = GPIO_PIN(PB,13),
128  .tx_pin = GPIO_PIN(PB,14),
129  .mux = GPIO_MUX_C,
130  .rx_pad = UART_PAD_RX_1,
131  .tx_pad = UART_PAD_TX_2,
132  .flags = UART_FLAG_NONE,
133  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
134  },
135  {
136  .dev = &SERCOM1->USART,
137  .rx_pin = GPIO_PIN(PA,17),
138  .tx_pin = GPIO_PIN(PA,18),
139  .mux = GPIO_MUX_C,
140  .rx_pad = UART_PAD_RX_1,
141  .tx_pad = UART_PAD_TX_2,
142  .flags = UART_FLAG_NONE,
143  .gclk_src = GCLK_CLKCTRL_GEN_GCLK0
144  },
145 };
146 
147 /* interrupt function name mapping */
148 #define UART_0_ISR isr_sercom0
149 #define UART_1_ISR isr_sercom5
150 #define UART_2_ISR isr_sercom4
151 #define UART_3_ISR isr_sercom1
152 
153 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
154 
160 #define PWM_0_EN 1
161 #define PWM_1_EN 1
162 #define PWM_MAX_CHANNELS 3
163 /* for compatibility with test application */
164 #define PWM_0_CHANNELS PWM_MAX_CHANNELS
165 #define PWM_1_CHANNELS PWM_MAX_CHANNELS
166 
167 /* PWM device configuration */
168 static const pwm_conf_t pwm_config[] = {
169 #if PWM_0_EN
170  {TCC1, {
171  /* GPIO pin, MUX value, TCC channel */
172  { GPIO_PIN(PA, 6), GPIO_MUX_E, 0 },
173  { GPIO_PIN(PA, 7), GPIO_MUX_E, 1 },
174  { GPIO_UNDEF, (gpio_mux_t)0, 2 }
175  }},
176 #endif
177 #if PWM_1_EN
178  {TCC0, {
179  /* GPIO pin, MUX value, TCC channel */
180  { GPIO_PIN(PA, 16), GPIO_MUX_F, 0 },
181  { GPIO_PIN(PA, 18), GPIO_MUX_F, 2 },
182  { GPIO_PIN(PA, 19), GPIO_MUX_F, 3 }
183  }}
184 #endif
185 };
186 
187 /* number of devices that are actually defined */
188 #define PWM_NUMOF (2U)
189 
195 static const spi_conf_t spi_config[] = {
196  {
197  .dev = &SERCOM3->SPI,
198  .miso_pin = GPIO_PIN(PA, 22),
199  .mosi_pin = GPIO_PIN(PA, 20),
200  .clk_pin = GPIO_PIN(PA, 21),
201  .miso_mux = GPIO_MUX_C,
202  .mosi_mux = GPIO_MUX_D,
203  .clk_mux = GPIO_MUX_D,
204  .miso_pad = SPI_PAD_MISO_0,
205  .mosi_pad = SPI_PAD_MOSI_2_SCK_3,
206  },
207 };
208 
209 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
210 
216 #define I2C_NUMOF (1U)
217 #define I2C_0_EN 1
218 #define I2C_1_EN 0
219 #define I2C_2_EN 0
220 #define I2C_3_EN 0
221 #define I2C_IRQ_PRIO 1
222 
223 #define I2C_0_DEV SERCOM2->I2CM
224 #define I2C_0_IRQ SERCOM2_IRQn
225 #define I2C_0_ISR isr_sercom2
226 /* I2C 0 GCLK */
227 #define I2C_0_GCLK_ID SERCOM2_GCLK_ID_CORE
228 #define I2C_0_GCLK_ID_SLOW SERCOM2_GCLK_ID_SLOW
229 /* I2C 0 pin configuration */
230 #define I2C_0_SDA GPIO_PIN(PA, 12)
231 #define I2C_0_SCL GPIO_PIN(PA, 13)
232 #define I2C_0_MUX GPIO_MUX_C
233 
238 #define RTC_NUMOF (1U)
239 #define RTC_DEV RTC->MODE2
240 
246 #define RTT_NUMOF (1U)
247 #define RTT_DEV RTC->MODE0
248 #define RTT_IRQ RTC_IRQn
249 #define RTT_IRQ_PRIO 10
250 #define RTT_ISR isr_rtc
251 #define RTT_MAX_VALUE (0xffffffff)
252 #define RTT_FREQUENCY (32768U) /* in Hz. For changes see `rtt.c` */
253 #define RTT_RUNSTDBY (1) /* Keep RTT running in sleep states */
254 
256 #ifdef __cplusplus
257 }
258 #endif
259 
260 #endif /* PERIPH_CONF_H */
261 
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.
select peripheral function F
PWM configuration structure.
select peripheral function C
gpio_mux_t
Available MUX values for configuring a pin&#39;s alternate function.
UART device configuration.
use pad 2 for MOSI, pad 3 for SCK
#define GPIO_UNDEF
Define a custom GPIO_UNDEF value.
SPI module configuration options.
TX is pad 0, on top RTS on pad 2 and CTS on pad 3.
cc2538_ssi_t * dev
SSI device.