periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
3  * 2017 OTA keys
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 
9 #pragma once
10 
22 #include "periph_cpu.h"
23 #include "clk_conf.h"
24 #include "cfg_timer_tim2.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
34 static const uart_conf_t uart_config[] = {
35  {
36  .dev = USART1,
37  .rcc_mask = RCC_APB2ENR_USART1EN,
38  .rx_pin = GPIO_PIN(PORT_A, 15),
39  .tx_pin = GPIO_PIN(PORT_A, 2),
40  .rx_af = GPIO_AF1,
41  .tx_af = GPIO_AF1,
42  .bus = APB2,
43  .irqn = USART1_IRQn
44  }
45 };
46 
47 #define UART_0_ISR (isr_usart1)
48 
49 #define UART_NUMOF ARRAY_SIZE(uart_config)
56 static const pwm_conf_t pwm_config[] = {
57  {
58  .dev = TIM1,
59  .rcc_mask = RCC_APB2ENR_TIM1EN,
60  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
61  { .pin = GPIO_UNDEF, .cc_chan = 0 },
62  { .pin = GPIO_UNDEF, .cc_chan = 0 },
63  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
64  .af = GPIO_AF2,
65  .bus = APB2
66  },
67  {
68  .dev = TIM14,
69  .rcc_mask = RCC_APB1ENR_TIM14EN,
70  .chan = { { .pin = GPIO_PIN(PORT_B, 1) /* D6 */, .cc_chan = 0 },
71  { .pin = GPIO_UNDEF, .cc_chan = 0 },
72  { .pin = GPIO_UNDEF, .cc_chan = 0 },
73  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
74  .af = GPIO_AF0,
75  .bus = APB1
76  },
77  {
78  .dev = TIM3,
79  .rcc_mask = RCC_APB1ENR_TIM3EN,
80  .chan = { { .pin = GPIO_PIN(PORT_B, 0) /* D3 */, .cc_chan = 2 },
81  { .pin = GPIO_UNDEF, .cc_chan = 0 },
82  { .pin = GPIO_UNDEF, .cc_chan = 0 },
83  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
84  .af = GPIO_AF1,
85  .bus = APB1
86  },
87 };
88 
89 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
96 static const spi_conf_t spi_config[] = {
97  {
98  .dev = SPI1,
99  .mosi_pin = GPIO_PIN(PORT_B, 5),
100  .miso_pin = GPIO_PIN(PORT_B, 4),
101  .sclk_pin = GPIO_PIN(PORT_B, 3),
102  .cs_pin = SPI_CS_UNDEF,
103  .mosi_af = GPIO_AF0,
104  .miso_af = GPIO_AF0,
105  .sclk_af = GPIO_AF0,
106  .cs_af = GPIO_AF0,
107  .rccmask = RCC_APB2ENR_SPI1EN,
108  .apbbus = APB2
109  }
110 };
111 
112 #define SPI_NUMOF ARRAY_SIZE(spi_config)
119 static const adc_conf_t adc_config[] = {
120  { GPIO_PIN(PORT_A, 0), 0 },
121  { GPIO_PIN(PORT_A, 1), 1 },
122  { GPIO_PIN(PORT_A, 3), 3 },
123  { GPIO_PIN(PORT_A, 4), 4 },
124  { GPIO_PIN(PORT_A, 7), 7 },
125  { GPIO_UNDEF, 18 }, /* VBAT */
126 };
127 
128 #define VBAT_ADC ADC_LINE(5)
129 #define ADC_NUMOF ARRAY_SIZE(adc_config)
132 #ifdef __cplusplus
133 }
134 #endif
135 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_A
port A
Definition: periph_cpu.h:46
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:38
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:103
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:362
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
ADC device configuration.
Definition: periph_cpu.h:377
PWM device configuration.
mini_timer_t * dev
Timer used.
SPI device configuration.
Definition: periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218