1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Merge pull request #697 from Supersopp/sonar_and_ADC_current_sensor

Updates sonar so that it can be used together with ADC current meter
This commit is contained in:
Dominic Clifton 2015-05-06 22:14:52 +01:00
commit e0af5f41ef
4 changed files with 10 additions and 9 deletions

View file

@ -368,7 +368,7 @@ void init(void)
#ifdef SONAR
if (feature(FEATURE_SONAR)) {
sonarInit();
sonarInit(&masterConfig.batteryConfig);
}
#endif

View file

@ -37,7 +37,7 @@
static int32_t calculatedAltitude;
void sonarInit(void)
void sonarInit(batteryConfig_t *batteryConfig)
{
#if defined(NAZE) || defined(EUSTM32F103RC) || defined(PORT103R)
static const sonarHardware_t const sonarPWM56 = {
@ -54,8 +54,8 @@ void sonarInit(void)
.exti_pin_source = GPIO_PinSource1,
.exti_irqn = EXTI1_IRQn
};
// If we are using parallel PWM for our receiver, then use motor pins 5 and 6 for sonar, otherwise use rc pins 7 and 8
if (feature(FEATURE_RX_PARALLEL_PWM)) {
// If we are using parallel PWM for our receiver or ADC current sensor, then use motor pins 5 and 6 for sonar, otherwise use rc pins 7 and 8
if (feature(FEATURE_RX_PARALLEL_PWM ) || (feature(FEATURE_CURRENT_METER) && batteryConfig->currentMeterType == CURRENT_SENSOR_ADC) ) {
hcsr04_init(&sonarPWM56);
} else {
hcsr04_init(&sonarRC78);

View file

@ -16,8 +16,9 @@
*/
#pragma once
#include "sensors/battery.h"
void sonarInit(void);
void sonarInit(batteryConfig_t *batteryConfig);
void sonarUpdate(void);
int32_t sonarRead(void);