cfg_spi_default.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Koen Zandberg <koen@bergzand.net>
3  * 2023 Gunar Schorcht <gunar@schorcht.net>
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
21 #ifndef CFG_SPI_DEFAULT_H
22 #define CFG_SPI_DEFAULT_H
23 
24 #include "periph_cpu.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
44 #ifndef SPI_DEV_1_USED
45 #define SPI_DEV_1_USED 0
46 #endif
47 
54 #ifndef SPI_DEV_0_CS
55 #define SPI_DEV_0_CS GPIO_PIN(PORT_B, 12)
56 #endif
57 
64 #ifndef SPI_DEV_1_CS
65 #define SPI_DEV_1_CS GPIO_PIN(PORT_B, 5)
66 #endif
67 
79 static const spi_conf_t spi_config[] = {
80  {
81  .dev = SPI1,
82  .mosi_pin = GPIO_PIN(PORT_B, 15),
83  .miso_pin = GPIO_PIN(PORT_B, 14),
84  .sclk_pin = GPIO_PIN(PORT_B, 13),
85  .cs_pin = SPI_DEV_0_CS,
86  .rcumask = RCU_APB1EN_SPI1EN_Msk,
87  .apbbus = APB1,
88  },
89 #if SPI_DEV_1_USED
90  {
91  .dev = SPI0,
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 = SPI_DEV_1_CS,
96  .rcumask = RCU_APB2EN_SPI0EN_Msk,
97  .apbbus = APB2,
98  },
99 #endif
100 };
101 
102 #define SPI_NUMOF ARRAY_SIZE(spi_config)
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* CFG_SPI_DEFAULT_H */
@ PORT_B
port B
Definition: periph_cpu.h:48
@ PORT_A
port A
Definition: periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
#define SPI_DEV_0_CS
Defines PB12 as the default CS signal for SPI_DEV(0)
#define SPI_DEV_1_CS
Defines PA4 as the default CS signal for SPI_DEV(1)
static const spi_conf_t spi_config[]
Default SPI device configuration.
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:80
SPI device configuration.
Definition: periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:338