parent
8fcffa1454
commit
3b77626dd8
|
@ -35,6 +35,7 @@ typedef struct adc_config_t {
|
|||
} adc_config_t;
|
||||
|
||||
typedef struct drv_adc_config_t {
|
||||
bool enableVBat;
|
||||
bool enableRSSI;
|
||||
bool enableCurrentMeter;
|
||||
bool enableExternal1;
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
//
|
||||
// NAZE rev.5 hardware has PA5 (ADC1_IN5) on breakout pad on bottom of board
|
||||
//
|
||||
// CC3D Only one ADC channel supported currently, for battery on S5_IN/PA0
|
||||
|
||||
|
||||
void adcInit(drv_adc_config_t *init)
|
||||
|
@ -64,12 +63,14 @@ void adcInit(drv_adc_config_t *init)
|
|||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||
|
||||
#ifdef VBAT_ADC_GPIO
|
||||
GPIO_InitStructure.GPIO_Pin = VBAT_ADC_GPIO_PIN;
|
||||
GPIO_Init(VBAT_ADC_GPIO, &GPIO_InitStructure);
|
||||
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL;
|
||||
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
|
||||
adcConfig[ADC_BATTERY].enabled = true;
|
||||
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5;
|
||||
if (init->enableVBat) {
|
||||
GPIO_InitStructure.GPIO_Pin = VBAT_ADC_GPIO_PIN;
|
||||
GPIO_Init(VBAT_ADC_GPIO, &GPIO_InitStructure);
|
||||
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL;
|
||||
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
|
||||
adcConfig[ADC_BATTERY].enabled = true;
|
||||
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EXTERNAL1_ADC_GPIO
|
||||
|
|
|
@ -52,14 +52,16 @@ void adcInit(drv_adc_config_t *init)
|
|||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
|
||||
#ifdef VBAT_ADC_GPIO
|
||||
GPIO_InitStructure.GPIO_Pin = VBAT_ADC_GPIO_PIN;
|
||||
GPIO_Init(VBAT_ADC_GPIO, &GPIO_InitStructure);
|
||||
if (init->enableVBat) {
|
||||
GPIO_InitStructure.GPIO_Pin = VBAT_ADC_GPIO_PIN;
|
||||
GPIO_Init(VBAT_ADC_GPIO, &GPIO_InitStructure);
|
||||
|
||||
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL;
|
||||
adcConfig[ADC_BATTERY].dmaIndex = adcChannelCount;
|
||||
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_601Cycles5;
|
||||
adcConfig[ADC_BATTERY].enabled = true;
|
||||
adcChannelCount++;
|
||||
adcConfig[ADC_BATTERY].adcChannel = VBAT_ADC_CHANNEL;
|
||||
adcConfig[ADC_BATTERY].dmaIndex = adcChannelCount;
|
||||
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_601Cycles5;
|
||||
adcConfig[ADC_BATTERY].enabled = true;
|
||||
adcChannelCount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CURRENT_METER_ADC_GPIO
|
||||
|
|
|
@ -882,7 +882,7 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
case MSP_ANALOG:
|
||||
headSerialReply(7);
|
||||
serialize8((uint8_t)constrain(vbat, 0, 255));
|
||||
serialize16((uint16_t)constrain(mAhDrawn, 0, 0xFFFF)); // milliamphours drawn from battery
|
||||
serialize16((uint16_t)constrain(mAhDrawn, 0, 0xFFFF)); // milliamp hours drawn from battery
|
||||
serialize16(rssi);
|
||||
if(masterConfig.batteryConfig.multiwiiCurrentMeterOutput) {
|
||||
serialize16((uint16_t)constrain(amperage * 10, 0, 0xFFFF)); // send amperage in 0.001 A steps. Negative range is truncated to zero
|
||||
|
@ -890,7 +890,7 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
serialize16((int16_t)constrain(amperage, -0x8000, 0x7FFF)); // send amperage in 0.01 A steps, range is -320A to 320A
|
||||
break;
|
||||
case MSP_RC_TUNING:
|
||||
headSerialReply(8 + 2);//allow for returning tpa_breakpoint
|
||||
headSerialReply(10);
|
||||
serialize8(currentControlRateProfile->rcRate8);
|
||||
serialize8(currentControlRateProfile->rcExpo8);
|
||||
for (i = 0 ; i < 3; i++) {
|
||||
|
@ -899,7 +899,6 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
serialize8(currentControlRateProfile->dynThrPID);
|
||||
serialize8(currentControlRateProfile->thrMid8);
|
||||
serialize8(currentControlRateProfile->thrExpo8);
|
||||
//Configurator pid-tuning can allow tpa_breakpoint update, agnostic if older Configurator versions are used
|
||||
serialize16(currentControlRateProfile->tpa_breakpoint);
|
||||
break;
|
||||
case MSP_PID:
|
||||
|
|
|
@ -290,6 +290,7 @@ void init(void)
|
|||
#ifdef USE_ADC
|
||||
drv_adc_config_t adc_params;
|
||||
|
||||
adc_params.enableVBat = feature(FEATURE_VBAT);
|
||||
adc_params.enableRSSI = feature(FEATURE_RSSI_ADC);
|
||||
adc_params.enableCurrentMeter = feature(FEATURE_CURRENT_METER);
|
||||
adc_params.enableExternal1 = false;
|
||||
|
|
Loading…
Reference in New Issue