periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 /*
23  * This board provides an LSE, so enable it before including the default clock config
24  */
25 #ifndef CONFIG_BOARD_HAS_LSE
26 #define CONFIG_BOARD_HAS_LSE 1
27 #endif
28 
29 #include "periph_cpu.h"
30 #include "clk_conf.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
40 static const timer_conf_t timer_config[] = {
41  {
42  .dev = TIM3,
43  .max = 0x0000ffff,
44  .rcc_mask = RCC_APB1ENR_TIM3EN,
45  .bus = APB1,
46  .irqn = TIM3_IRQn
47  }
48 };
49 
50 #define TIMER_0_ISR (isr_tim3)
51 
52 #define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
53 
59 static const uart_conf_t uart_config[] = {
60  {
61  .dev = USART1,
62  .rcc_mask = RCC_APB2ENR_USART1EN,
63  .rx_pin = GPIO_PIN(PORT_A, 10),
64  .tx_pin = GPIO_PIN(PORT_A, 9),
65  .rx_af = GPIO_AF7,
66  .tx_af = GPIO_AF7,
67  .bus = APB2,
68  .irqn = USART1_IRQn
69  },
70 };
71 
72 #define UART_0_ISR (isr_usart1)
73 
74 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
75 
81 static const spi_conf_t spi_config[] = {
82  {
83  .dev = SPI1,
84  .mosi_pin = GPIO_PIN(PORT_A, 7),
85  .miso_pin = GPIO_PIN(PORT_A, 6),
86  .sclk_pin = GPIO_PIN(PORT_A, 5),
87  .cs_pin = GPIO_UNDEF,
88  .mosi_af = GPIO_AF5,
89  .miso_af = GPIO_AF5,
90  .sclk_af = GPIO_AF5,
91  .cs_af = GPIO_AF5,
92  .rccmask = RCC_APB2ENR_SPI1EN,
93  .apbbus = APB2
94  },
95  {
96  .dev = SPI2,
97  .mosi_pin = GPIO_PIN(PORT_B, 14),
98  .miso_pin = GPIO_PIN(PORT_B, 15),
99  .sclk_pin = GPIO_PIN(PORT_B, 13),
100  .cs_pin = GPIO_PIN(PORT_B, 12),
101  .mosi_af = GPIO_AF5,
102  .miso_af = GPIO_AF5,
103  .sclk_af = GPIO_AF5,
104  .cs_af = GPIO_AF5,
105  .rccmask = RCC_APB1ENR_SPI2EN,
106  .apbbus = APB1
107  }
108 };
109 
110 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
111 
117 static const i2c_conf_t i2c_config[] = {
118  {
119  .dev = I2C1,
120  .speed = I2C_SPEED_NORMAL,
121  .scl_pin = GPIO_PIN(PORT_B, 8),
122  .sda_pin = GPIO_PIN(PORT_B, 9),
123  .scl_af = GPIO_AF4,
124  .sda_af = GPIO_AF4,
125  .bus = APB1,
126  .rcc_mask = RCC_APB1ENR_I2C1EN,
127  .clk = CLOCK_APB1,
128  .irqn = I2C1_EV_IRQn
129  }
130 };
131 
132 #define I2C_0_ISR isr_i2c1_ev
133 
134 #define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))
135 
141 static const adc_conf_t adc_config[] = {
142  { GPIO_PIN(PORT_A, 0), 0 }, /* P14 */
143  { GPIO_PIN(PORT_A, 1), 1 }, /* P15 */
144  { GPIO_PIN(PORT_A, 3), 3 }, /* P17 */
145  /* ADC Temperature channel */
146  { GPIO_UNDEF, 16 },
147  /* ADC VREF channel */
148  { GPIO_UNDEF, 17 },
149 };
150 
151 #define ADC_NUMOF ARRAY_SIZE(adc_config)
152 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif /* PERIPH_CONF_H */
159 
GPIO_AF4
@ GPIO_AF4
use alternate function 4
Definition: periph_cpu_common.h:90
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
GPIO_AF5
@ GPIO_AF5
use alternate function 5
Definition: periph_cpu_common.h:91
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
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
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
timer_conf_t
Timer configuration.
Definition: periph_cpu.h:288
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
adc_conf_t
ADC device configuration.
Definition: periph_cpu.h:74
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
APB2
@ APB2
APB2 bus.
Definition: periph_cpu.h:177
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
spi_conf_t::dev
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:465
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176