mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
CC3D - Add sonar.
This also ensures that the PWM mapping does not use the sonar pins when sonar is enabled in a board agnostic way. Conflicts: src/main/config/config.c src/main/drivers/pwm_mapping.h src/main/main.c src/main/target/CC3D/target.h
This commit is contained in:
parent
a370d60595
commit
4ed6fdfea5
13 changed files with 91 additions and 34 deletions
|
@ -47,6 +47,7 @@
|
|||
#include "drivers/bus_spi.h"
|
||||
#include "drivers/inverter.h"
|
||||
#include "drivers/flash_m25p16.h"
|
||||
#include "drivers/sonar_hcsr04.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
|
||||
|
@ -114,6 +115,8 @@ void displayInit(rxConfig_t *intialRxConfig);
|
|||
void ledStripInit(ledConfig_t *ledConfigsToUse, hsvColor_t *colorsToUse);
|
||||
void loop(void);
|
||||
void spektrumBind(rxConfig_t *rxConfig);
|
||||
const sonarHardware_t *sonarGetHardwareConfiguration(batteryConfig_t *batteryConfig);
|
||||
void sonarInit(const sonarHardware_t *sonarHardware);
|
||||
|
||||
#ifdef STM32F303xC
|
||||
// from system_stm32f30x.c
|
||||
|
@ -193,6 +196,21 @@ void init(void)
|
|||
mixerInit(masterConfig.mixerMode, masterConfig.customMixer);
|
||||
|
||||
memset(&pwm_params, 0, sizeof(pwm_params));
|
||||
|
||||
#ifdef SONAR
|
||||
const sonarHardware_t *sonarHardware = NULL;
|
||||
|
||||
if (feature(FEATURE_SONAR)) {
|
||||
sonarHardware = sonarGetHardwareConfiguration(&masterConfig.batteryConfig);
|
||||
sonarGPIOConfig_t sonarGPIOConfig = {
|
||||
.echoPin = sonarHardware->trigger_pin,
|
||||
.triggerPin = sonarHardware->echo_pin,
|
||||
.gpio = SONAR_GPIO
|
||||
};
|
||||
pwm_params.sonarGPIOConfig = &sonarGPIOConfig;
|
||||
}
|
||||
#endif
|
||||
|
||||
// when using airplane/wing mixer, servo/motor outputs are remapped
|
||||
if (masterConfig.mixerMode == MIXER_AIRPLANE || masterConfig.mixerMode == MIXER_FLYING_WING)
|
||||
pwm_params.airplane = true;
|
||||
|
@ -383,7 +401,7 @@ void init(void)
|
|||
|
||||
#ifdef SONAR
|
||||
if (feature(FEATURE_SONAR)) {
|
||||
sonarInit(&masterConfig.batteryConfig);
|
||||
sonarInit(sonarHardware);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue