mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Initial rework - removing target specific code from main.c
Moved FLASH to masterConfig Moved LED (named statusLeds) to masterConfig Fixed up some targets to remove defines from main.c
This commit is contained in:
parent
3a634ae5c5
commit
f7518203aa
21 changed files with 288 additions and 165 deletions
|
@ -124,6 +124,10 @@
|
|||
#include "build/build_config.h"
|
||||
#include "build/debug.h"
|
||||
|
||||
#ifdef TARGET_BUS_INIT
|
||||
void targetBusInit(void);
|
||||
#endif
|
||||
|
||||
extern uint8_t motorControlEnable;
|
||||
|
||||
#ifdef SOFTSERIAL_LOOPBACK
|
||||
|
@ -172,11 +176,7 @@ void init(void)
|
|||
// Latch active features to be used for feature() in the remainder of init().
|
||||
latchActiveFeatures();
|
||||
|
||||
#ifdef ALIENFLIGHTF3
|
||||
ledInit(hardwareRevision == AFF3_REV_1 ? false : true);
|
||||
#else
|
||||
ledInit(false);
|
||||
#endif
|
||||
ledInit(&masterConfig.statusLedConfig);
|
||||
LED2_ON;
|
||||
|
||||
#ifdef USE_EXTI
|
||||
|
@ -291,7 +291,6 @@ void init(void)
|
|||
pwmRxSetInputFilteringMode(masterConfig.inputFilteringMode);
|
||||
#endif
|
||||
|
||||
|
||||
systemState |= SYSTEM_STATE_MOTORS_READY;
|
||||
|
||||
#ifdef BEEPER
|
||||
|
@ -306,74 +305,48 @@ void init(void)
|
|||
bstInit(BST_DEVICE);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SPI
|
||||
#ifdef USE_SPI_DEVICE_1
|
||||
spiInit(SPIDEV_1);
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_2
|
||||
spiInit(SPIDEV_2);
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_3
|
||||
#ifdef ALIENFLIGHTF3
|
||||
if (hardwareRevision == AFF3_REV_2) {
|
||||
spiInit(SPIDEV_3);
|
||||
}
|
||||
#ifdef TARGET_BUS_INIT
|
||||
targetBusInit();
|
||||
#else
|
||||
spiInit(SPIDEV_3);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_4
|
||||
spiInit(SPIDEV_4);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_SPI
|
||||
#ifdef USE_SPI_DEVICE_1
|
||||
spiInit(SPIDEV_1);
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_2
|
||||
spiInit(SPIDEV_2);
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_3
|
||||
spiInit(SPIDEV_3);
|
||||
#endif
|
||||
#ifdef USE_SPI_DEVICE_4
|
||||
spiInit(SPIDEV_4);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VTX
|
||||
vtxInit();
|
||||
#ifdef USE_I2C
|
||||
i2cInit(I2C_DEVICE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||
updateHardwareRevision();
|
||||
#endif
|
||||
|
||||
#if defined(NAZE)
|
||||
if (hardwareRevision == NAZE32_SP) {
|
||||
serialRemovePort(SERIAL_PORT_SOFTSERIAL2);
|
||||
} else {
|
||||
serialRemovePort(SERIAL_PORT_USART3);
|
||||
}
|
||||
#ifdef VTX
|
||||
vtxInit();
|
||||
#endif
|
||||
|
||||
#if defined(SPRACINGF3) && defined(SONAR) && defined(USE_SOFTSERIAL2)
|
||||
#if defined(SONAR_SOFTSERIAL2_EXCLUSIVE) && defined(SONAR) && defined(USE_SOFTSERIAL2)
|
||||
if (feature(FEATURE_SONAR) && feature(FEATURE_SOFTSERIAL)) {
|
||||
serialRemovePort(SERIAL_PORT_SOFTSERIAL2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SPRACINGF3MINI) || defined(OMNIBUS) || defined(X_RACERSPI)
|
||||
#if defined(SONAR) && defined(USE_SOFTSERIAL1)
|
||||
#if defined(SONAR_SOFTSERIAL1_EXCLUSIVE) && defined(SONAR) && defined(USE_SOFTSERIAL1)
|
||||
if (feature(FEATURE_SONAR) && feature(FEATURE_SOFTSERIAL)) {
|
||||
serialRemovePort(SERIAL_PORT_SOFTSERIAL1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_I2C
|
||||
#if defined(NAZE)
|
||||
if (hardwareRevision != NAZE32_SP) {
|
||||
i2cInit(I2C_DEVICE);
|
||||
} else {
|
||||
if (!doesConfigurationUsePort(SERIAL_PORT_USART3)) {
|
||||
i2cInit(I2C_DEVICE);
|
||||
}
|
||||
}
|
||||
#elif defined(CC3D)
|
||||
if (!doesConfigurationUsePort(SERIAL_PORT_USART3)) {
|
||||
i2cInit(I2C_DEVICE);
|
||||
}
|
||||
#else
|
||||
i2cInit(I2C_DEVICE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_ADC
|
||||
/* these can be removed from features! */
|
||||
|
@ -383,7 +356,6 @@ void init(void)
|
|||
adcInit(&masterConfig.adcConfig);
|
||||
#endif
|
||||
|
||||
|
||||
initBoardAlignment(&masterConfig.boardAlignment);
|
||||
|
||||
#ifdef CMS
|
||||
|
@ -513,12 +485,8 @@ void init(void)
|
|||
#endif
|
||||
|
||||
#ifdef USE_FLASHFS
|
||||
#ifdef NAZE
|
||||
if (hardwareRevision == NAZE32_REV5) {
|
||||
m25p16_init(IO_TAG_NONE);
|
||||
}
|
||||
#elif defined(USE_FLASH_M25P16)
|
||||
m25p16_init(IO_TAG_NONE);
|
||||
#if defined(USE_FLASH_M25P16)
|
||||
m25p16_init(&masterConfig.flashConfig);
|
||||
#endif
|
||||
|
||||
flashfsInit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue