periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 BISSELL Homecare, Inc.
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 
9 #pragma once
10 
21 /* Add specific clock configuration (HSE, LSE) for this board here */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 #include "clk_conf.h"
27 #include "cfg_i2c1_pb8_pb9.h"
28 #include "cfg_rtt_default.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 static const timer_conf_t timer_config[] = {
39  {
40  .dev = TIM3,
41  .max = 0x0000ffff,
42  .rcc_mask = RCC_APBENR1_TIM3EN,
43  .bus = APB1,
44  .irqn = TIM3_IRQn
45  }
46 };
47 
48 #define TIMER_0_ISR isr_tim3
49 
50 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
57 static const uart_conf_t uart_config[] = {
58  {
59  .dev = USART2,
60  .rcc_mask = RCC_APBENR1_USART2EN,
61  .rx_pin = GPIO_PIN(PORT_A, 3),
62  .tx_pin = GPIO_PIN(PORT_A, 2),
63  .rx_af = GPIO_AF1,
64  .tx_af = GPIO_AF1,
65  .bus = APB1,
66  .irqn = USART2_IRQn,
67  },
68  { /* Arduino pinout on D0/D1 */
69  .dev = USART1,
70  .rcc_mask = RCC_APBENR2_USART1EN,
71  .rx_pin = GPIO_PIN(PORT_B, 7),
72  .tx_pin = GPIO_PIN(PORT_B, 6),
73  .rx_af = GPIO_AF0,
74  .tx_af = GPIO_AF0,
75  .bus = APB12, //?
76  .irqn = USART1_IRQn,
77  },
78 };
79 
80 #define UART_0_ISR (isr_usart2)
81 #define UART_1_ISR (isr_usart1)
82 
83 #define UART_NUMOF ARRAY_SIZE(uart_config)
110 static const adc_conf_t adc_config[] = {
111  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 }, /* ARD_A0_IN0 */
112  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 }, /* ARD_A1_IN1 */
113  { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 }, /* ARD_A2_IN4 */
114  { .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 18 }, /* ARD_A3_IN18 */
115  { .pin = GPIO_PIN(PORT_A, 11), .dev = 0, .chan = 11 }, /* ARD_A4_IN11 */
116  { .pin = GPIO_PIN(PORT_A, 12), .dev = 0, .chan = 12 }, /* ARD_A5_IN12 */
117 };
118 
119 #define ADC_NUMOF ARRAY_SIZE(adc_config)
137 static const pwm_conf_t pwm_config[] = {
138  {
139  .dev = TIM3,
140  .rcc_mask = RCC_APBENR1_TIM3EN,
141  .chan = { { .pin = GPIO_PIN(PORT_B, 5) /*CN9 D6 */, .cc_chan = 1 },
142  { .pin = GPIO_PIN(PORT_B, 0) /*CN5 D10 */, .cc_chan = 2 },
143  { .pin = GPIO_PIN(PORT_B, 1) /*CN8 A3 */, .cc_chan = 3 },
144  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
145  .af = GPIO_AF1,
146  .bus = APB1
147  },
148 };
149 
150 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
157 static const spi_conf_t spi_config[] = {
158  {
159  .dev = SPI1,
160  .mosi_pin = GPIO_PIN(PORT_A, 7), /* Arduino D11 */
161  .miso_pin = GPIO_PIN(PORT_A, 6), /* Arduino D12 */
162  .sclk_pin = GPIO_PIN(PORT_A, 5), /* Arduino D13 */
163  .cs_pin = GPIO_UNDEF,
164  .mosi_af = GPIO_AF0,
165  .miso_af = GPIO_AF0,
166  .sclk_af = GPIO_AF0,
167  .cs_af = GPIO_AF0,
168  .rccmask = RCC_APBENR2_SPI1EN,
169  .apbbus = APB12,
170  },
171 };
172 
173 #define SPI_NUMOF ARRAY_SIZE(spi_config)
176 #ifdef __cplusplus
177 }
178 #endif
179 
@ 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 timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
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 I2C.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
ADC device configuration.
Definition: periph_cpu.h:377
gpio_t pin
pin connected to the channel
Definition: periph_cpu.h:287
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
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218