mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
NAZE32 - Add hardware revision detection.
This commit is contained in:
parent
d3fc10fd83
commit
8ef70abaa0
12 changed files with 2616 additions and 2452 deletions
|
@ -30,6 +30,7 @@ static volatile uint16_t spi2ErrorCount = 0;
|
|||
static volatile uint16_t spi3ErrorCount = 0;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SPI_DEVICE_1
|
||||
void initSpi1(void)
|
||||
{
|
||||
// Specific to the STM32F103
|
||||
|
@ -76,7 +77,9 @@ void initSpi1(void)
|
|||
SPI_Init(SPI1, &spi);
|
||||
SPI_Cmd(SPI1, ENABLE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SPI_DEVICE_2
|
||||
void initSpi2(void)
|
||||
{
|
||||
|
||||
|
@ -108,6 +111,8 @@ void initSpi2(void)
|
|||
gpio.mode = Mode_Out_PP;
|
||||
gpioInit(GPIOB, &gpio);
|
||||
|
||||
GPIO_SetBits(GPIOB, GPIO_Pin_12);
|
||||
|
||||
// Init SPI2 hardware
|
||||
SPI_I2S_DeInit(SPI2);
|
||||
|
||||
|
@ -124,18 +129,23 @@ void initSpi2(void)
|
|||
SPI_Init(SPI2, &spi);
|
||||
SPI_Cmd(SPI2, ENABLE);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool spiInit(SPI_TypeDef *instance)
|
||||
{
|
||||
#ifdef USE_SPI_DEVICE_1
|
||||
if (instance == SPI1) {
|
||||
initSpi1();
|
||||
} else if (instance == SPI2) {
|
||||
initSpi2();
|
||||
} else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_2
|
||||
if (instance == SPI1) {
|
||||
initSpi2();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t spiTimeoutUserCallback(SPI_TypeDef *instance)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue