mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 15:55:48 +03:00
Make SPI pins configurable
This commit is contained in:
parent
1388c3ee82
commit
7a52f91975
12 changed files with 598 additions and 274 deletions
63
src/main/drivers/bus_spi_impl.h
Normal file
63
src/main/drivers/bus_spi_impl.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
|
||||
#define MAX_SPI_PIN_SEL 2
|
||||
#else
|
||||
#define MAX_SPI_PIN_SEL 4
|
||||
#endif
|
||||
|
||||
typedef struct spiPinDef_s {
|
||||
ioTag_t pin;
|
||||
uint8_t af;
|
||||
} spiPinDef_t;
|
||||
|
||||
typedef struct spiHardware_s {
|
||||
SPIDevice device;
|
||||
SPI_TypeDef *reg;
|
||||
spiPinDef_t sckPins[MAX_SPI_PIN_SEL];
|
||||
spiPinDef_t misoPins[MAX_SPI_PIN_SEL];
|
||||
spiPinDef_t mosiPins[MAX_SPI_PIN_SEL];
|
||||
rccPeriphTag_t rcc;
|
||||
#if defined(USE_HAL_DRIVER)
|
||||
uint8_t dmaIrqHandler;
|
||||
#endif
|
||||
} spiHardware_t;
|
||||
|
||||
extern const spiHardware_t spiHardware[];
|
||||
|
||||
typedef struct SPIDevice_s {
|
||||
SPI_TypeDef *dev;
|
||||
ioTag_t sck;
|
||||
ioTag_t miso;
|
||||
ioTag_t mosi;
|
||||
uint8_t sckAF;
|
||||
uint8_t misoAF;
|
||||
uint8_t mosiAF;
|
||||
rccPeriphTag_t rcc;
|
||||
volatile uint16_t errorCount;
|
||||
bool leadingEdge;
|
||||
#if defined(USE_HAL_DRIVER)
|
||||
SPI_HandleTypeDef hspi;
|
||||
DMA_HandleTypeDef hdma;
|
||||
uint8_t dmaIrqHandler;
|
||||
#endif
|
||||
} spiDevice_t;
|
||||
|
||||
extern spiDevice_t spiDevice[SPIDEV_COUNT];
|
Loading…
Add table
Add a link
Reference in a new issue