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 
20 #ifndef PERIPH_CONF_H
21 #define PERIPH_CONF_H
22 
23 /* Add specific clock configuration (HSE, LSE) for this board here */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 #ifndef CONFIG_BOARD_HAS_HSE
29 #define CONFIG_BOARD_HAS_HSE 1
30 #endif
31 
32 #define CLOCK_HSE MHZ(32)
33 
34 /* EXTAHB (HCLK2) max freq 32 Mhz*/
35 #define CLOCK_EXTAHB_DIV RCC_EXTCFGR_C2HPRE_3
36 #define CLOCK_EXTAHB (CLOCK_CORECLOCK / 2)
37 
38 #include "periph_cpu.h"
39 #include "clk_conf.h"
40 #include "cfg_i2c1_pb8_pb9.h"
41 #include "cfg_rtt_default.h"
42 #include "cfg_timer_tim2.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
52 static const uart_conf_t uart_config[] = {
53  {
54  .dev = USART1,
55  .rcc_mask = RCC_APB2ENR_USART1EN,
56  .rx_pin = GPIO_PIN(PORT_B, 7),
57  .tx_pin = GPIO_PIN(PORT_B, 6),
58  .rx_af = GPIO_AF7,
59  .tx_af = GPIO_AF7,
60  .bus = APB2,
61  .irqn = USART1_IRQn,
62  .type = STM32_USART,
63  .clk_src = 0, /* Use APB clock */
64  },
65  {
66  .dev = LPUART1,
67  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
68  .rx_pin = GPIO_PIN(PORT_A, 3),
69  .tx_pin = GPIO_PIN(PORT_A, 2),
70  .rx_af = GPIO_AF8,
71  .tx_af = GPIO_AF8,
72  .bus = APB12,
73  .irqn = LPUART1_IRQn,
74  .type = STM32_LPUART,
75  .clk_src = 0, /* Use APB clock */
76  },
77 };
78 
79 #define UART_0_ISR (isr_usart1)
80 #define UART_1_ISR (isr_lpuart1)
81 
82 #define UART_NUMOF ARRAY_SIZE(uart_config)
83 
89 static const spi_conf_t spi_config[] = {
90  {
91  .dev = SPI1,
92  .mosi_pin = GPIO_PIN(PORT_A, 7),
93  .miso_pin = GPIO_PIN(PORT_A, 6),
94  .sclk_pin = GPIO_PIN(PORT_A, 5),
95  .cs_pin = GPIO_UNDEF,
96  .mosi_af = GPIO_AF5,
97  .miso_af = GPIO_AF5,
98  .sclk_af = GPIO_AF5,
99  .cs_af = GPIO_AF5,
100  .rccmask = RCC_APB2ENR_SPI1EN,
101  .apbbus = APB2,
102  }
103 };
104 
105 #define SPI_NUMOF ARRAY_SIZE(spi_config)
106 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* PERIPH_CONF_H */
113 
GPIO_AF8
@ GPIO_AF8
use alternate function 8
Definition: periph_cpu_common.h:94
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
STM32_USART
@ STM32_USART
STM32 USART module type.
Definition: periph_cpu.h:583
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
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
STM32_LPUART
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition: periph_cpu.h:584
cfg_timer_tim2.h
Common configuration for STM32 Timer peripheral based on TIM2.
cfg_i2c1_pb8_pb9.h
Common configuration for STM32 I2C.
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