periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
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 "periph_cpu.h"
23 #include "cfg_clock_default.h"
24 #include "cfg_rtc_default.h"
25 #include "cfg_rtt_default.h"
26 #include "cfg_spi_default.h"
27 #include "cfg_timer_default.h"
28 #include "cfg_usbdev_default.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 static const uart_conf_t uart_config[] = {
39  {
40  .dev = &SERCOM5->USART,
41  .rx_pin = GPIO_PIN(PB,31), /* D0, RX Pin */
42  .tx_pin = GPIO_PIN(PB,30), /* D1, TX Pin */
43 #ifdef MODULE_PERIPH_UART_HW_FC
44  .rts_pin = GPIO_UNDEF,
45  .cts_pin = GPIO_UNDEF,
46 #endif
47  .mux = GPIO_MUX_D,
48  .rx_pad = UART_PAD_RX_1,
49  .tx_pad = UART_PAD_TX_0_RTS_2_CTS_3,
50  .flags = UART_FLAG_NONE,
51  .gclk_src = SAM0_GCLK_MAIN,
52  },
53  {
54  .dev = &SERCOM4->USART,
55  .rx_pin = GPIO_PIN(PB,13),
56  .tx_pin = GPIO_PIN(PB,14),
57 #ifdef MODULE_PERIPH_UART_HW_FC
58  .rts_pin = GPIO_UNDEF,
59  .cts_pin = GPIO_UNDEF,
60 #endif
61  .mux = GPIO_MUX_C,
62  .rx_pad = UART_PAD_RX_1,
63  .tx_pad = UART_PAD_TX_2,
64  .flags = UART_FLAG_NONE,
65  .gclk_src = SAM0_GCLK_MAIN,
66  },
67  { /* Connected to RN2483 */
68  .dev = &SERCOM0->USART,
69  .rx_pin = GPIO_PIN(PA,5),
70  .tx_pin = GPIO_PIN(PA,6),
71 #ifdef MODULE_PERIPH_UART_HW_FC
72  .rts_pin = GPIO_UNDEF,
73  .cts_pin = GPIO_UNDEF,
74 #endif
75  .mux = GPIO_MUX_D,
76  .rx_pad = UART_PAD_RX_1,
77  .tx_pad = UART_PAD_TX_2,
78  .flags = UART_FLAG_NONE,
79  .gclk_src = SAM0_GCLK_MAIN,
80  },
81 };
82 
83 /* interrupt function name mapping */
84 #define UART_0_ISR isr_sercom5
85 #define UART_1_ISR isr_sercom4
86 #define UART_2_ISR isr_sercom0
87 
88 #define UART_NUMOF ARRAY_SIZE(uart_config)
89 
96 /* ADC Default values */
97 #define ADC_PRESCALER ADC_CTRLB_PRESCALER_DIV512
98 
99 #define ADC_NEG_INPUT ADC_INPUTCTRL_MUXNEG_GND
100 #define ADC_GAIN_FACTOR_DEFAULT ADC_INPUTCTRL_GAIN_DIV2
101 #define ADC_REF_DEFAULT ADC_REFCTRL_REFSEL_INTVCC1
102 
103 static const adc_conf_chan_t adc_channels[] = {
104  /* port, pin, muxpos */
105  {GPIO_PIN(PB, 0), ADC_INPUTCTRL_MUXPOS_PIN8}, /* A0 */
106  {GPIO_PIN(PB, 1), ADC_INPUTCTRL_MUXPOS_PIN9}, /* A1 */
107  {GPIO_PIN(PB, 2), ADC_INPUTCTRL_MUXPOS_PIN10}, /* A2 */
108  {GPIO_PIN(PB, 3), ADC_INPUTCTRL_MUXPOS_PIN11}, /* A3 */
109  {GPIO_PIN(PA, 8), ADC_INPUTCTRL_MUXPOS_PIN16}, /* A4 */
110  {GPIO_PIN(PA, 9), ADC_INPUTCTRL_MUXPOS_PIN17}, /* A5 */
111  {GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4}, /* A6 (temperature) */
112  {GPIO_PIN(PA, 10), ADC_INPUTCTRL_MUXPOS_PIN18}, /* A7 */
113  {GPIO_PIN(PA, 11), ADC_INPUTCTRL_MUXPOS_PIN19}, /* A8 */
114  {GPIO_PIN(PB, 5), ADC_INPUTCTRL_MUXPOS_PIN13}, /* BATVOLT */
115 };
116 
117 #define ADC_NUMOF ARRAY_SIZE(adc_channels)
118 
124 static const i2c_conf_t i2c_config[] = {
125  {
126  .dev = &(SERCOM1->I2CM),
127  .speed = I2C_SPEED_NORMAL,
128  .scl_pin = GPIO_PIN(PA, 17),
129  .sda_pin = GPIO_PIN(PA, 16),
130  .mux = GPIO_MUX_C,
131  .gclk_src = SAM0_GCLK_MAIN,
132  .flags = I2C_FLAG_NONE,
133  },
134  {
135  .dev = &(SERCOM2->I2CM),
136  .speed = I2C_SPEED_NORMAL,
137  .scl_pin = GPIO_PIN(PA, 9),
138  .sda_pin = GPIO_PIN(PA, 8),
139  .mux = GPIO_MUX_C,
140  .gclk_src = SAM0_GCLK_MAIN,
141  .flags = I2C_FLAG_NONE
142  }
143 };
144 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
145 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* PERIPH_CONF_H */
152 
UART_PAD_TX_0_RTS_2_CTS_3
@ UART_PAD_TX_0_RTS_2_CTS_3
TX is pad 0, on top RTS on pad 2 and CTS on pad 3.
Definition: periph_cpu_common.h:163
SAM0_GCLK_MAIN
@ SAM0_GCLK_MAIN
48 MHz main clock
Definition: periph_cpu.h:59
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
I2C_FLAG_NONE
@ I2C_FLAG_NONE
No flags set.
Definition: periph_cpu_common.h:407
UART_FLAG_NONE
@ UART_FLAG_NONE
No flags set.
Definition: periph_cpu_common.h:171
PB
@ PB
port B
Definition: periph_cpu_common.h:89
UART_PAD_RX_1
@ UART_PAD_RX_1
select pad 1
Definition: periph_cpu_common.h:152
cfg_rtc_default.h
Default RTC configuration for SODAQ boards.
UART_PAD_TX_2
@ UART_PAD_TX_2
select pad 2
Definition: periph_cpu_common.h:162
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
adc_channels
static const gpio_t adc_channels[]
Static array with declared ADC channels.
Definition: periph_conf_common.h:53
GPIO_MUX_C
@ GPIO_MUX_C
select peripheral function C
Definition: periph_cpu_common.h:138
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
adc_conf_chan_t
ADC Channel Configuration.
Definition: periph_cpu_common.h:765
GPIO_MUX_D
@ GPIO_MUX_D
select peripheral function D
Definition: periph_cpu_common.h:139
cfg_usbdev_default.h
Default usbdev configuration for SODAQ boards.
PA
@ PA
port A
Definition: periph_cpu_common.h:88
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247