CF/BF - move adc current sensor default scale and offset to target.h instead of

target specific config.c
This commit is contained in:
Hydra 2017-03-16 22:28:09 +00:00 committed by Dominic Clifton
parent f3e740c598
commit dbd819c85a
9 changed files with 25 additions and 26 deletions

View File

@ -45,6 +45,10 @@ static biquadFilter_t adciBatFilter;
#define CURRENT_METER_SCALE_DEFAULT 400 // for Allegro ACS758LCB-100U (40mV/A)
#endif
#ifndef CURRENT_METER_OFFSET_DEFAULT
#define CURRENT_METER_OFFSET_DEFAULT 0
#endif
PG_REGISTER_ARRAY_WITH_RESET_FN(currentMeterADCOrVirtualConfig_t, MAX_ADC_OR_VIRTUAL_CURRENT_METERS, currentMeterADCOrVirtualConfig, PG_CURRENT_SENSOR_ADC_OR_VIRTUAL_CONFIG, 0);
void pgResetFn_currentMeterADCOrVirtualConfig(currentMeterADCOrVirtualConfig_t *instance)
@ -53,6 +57,7 @@ void pgResetFn_currentMeterADCOrVirtualConfig(currentMeterADCOrVirtualConfig_t *
if (i == CURRENT_METER_ADC) {
RESET_CONFIG(currentMeterADCOrVirtualConfig_t, &instance[i],
.scale = CURRENT_METER_SCALE_DEFAULT,
.offset = CURRENT_METER_OFFSET_DEFAULT,
);
}
}

View File

@ -44,9 +44,6 @@
#include "hardware_revision.h"
#define CURRENTOFFSET 2500 // ACS712/714-30A - 0A = 2.5V
#define CURRENTSCALE -667 // ACS712/714-30A - 66.666 mV/A inverted mode
#ifdef BRUSHED_MOTORS_PWM_RATE
#undef BRUSHED_MOTORS_PWM_RATE
#endif
@ -56,8 +53,6 @@
// alternative defaults settings for AlienFlight targets
void targetConfiguration(void)
{
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->offset = CURRENTOFFSET;
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->scale = CURRENTSCALE;
compassConfigMutable()->mag_hardware = MAG_NONE; // disabled by default
if (hardwareMotorType == MOTOR_BRUSHED) {

View File

@ -145,11 +145,15 @@
#define USE_ADC
//#define BOARD_HAS_VOLTAGE_DIVIDER
//#define BOARD_HAS_CURRENT_SENSOR
#define VBAT_ADC_PIN PC0
#define CURRENT_METER_ADC_PIN PC1
#define RSSI_ADC_PIN PC4
#define EXTERNAL1_ADC_GPIO_PIN PC5
#define CURRENT_METER_OFFSET_DEFAULT 2500 // ACS712/714-30A - 0A = 2.5V
#define CURRENT_METER_SCALE_DEFAULT -667 // ACS712/714-30A - 66.666 mV/A inverted mode
#define SPEKTRUM_BIND_PIN UART2_RX_PIN
#define BINDPLUG_PIN PB2

View File

@ -43,9 +43,6 @@
#include "hardware_revision.h"
#define CURRENTOFFSET 2500 // ACS712/714-30A - 0A = 2.5V
#define CURRENTSCALE -667 // ACS712/714-30A - 66.666 mV/A inverted mode
#ifdef BRUSHED_MOTORS_PWM_RATE
#undef BRUSHED_MOTORS_PWM_RATE
#endif
@ -55,8 +52,6 @@
// alternative defaults settings for AlienFlight targets
void targetConfiguration(void)
{
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->offset = CURRENTOFFSET;
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->scale = CURRENTSCALE;
compassConfigMutable()->mag_hardware = MAG_NONE; // disabled by default
if (hardwareMotorType == MOTOR_BRUSHED) {

View File

@ -156,10 +156,14 @@
#define USE_ADC
#define BOARD_HAS_VOLTAGE_DIVIDER
#define BOARD_HAS_CURRENT_SENSOR
#define VBAT_ADC_PIN PC0
#define CURRENT_METER_ADC_PIN PC1
#define RSSI_ADC_PIN PC4
#define CURRENT_METER_OFFSET_DEFAULT 2500 // ACS712/714-30A - 0A = 2.5V
#define CURRENT_METER_SCALE_DEFAULT -667 // ACS712/714-30A - 66.666 mV/A inverted mode
// LED strip configuration.
#define LED_STRIP

View File

@ -29,8 +29,6 @@
#include "io/osd.h"
#define VBAT_SCALE 113
#define CURRENTSCALE 1000
#define CURRENTOFFSET 0
#define OSD_POS(x,y) (x | (y << 5))
@ -38,8 +36,6 @@
void targetConfiguration(void)
{
voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatscale = VBAT_SCALE;
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->offset = CURRENTOFFSET;
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->scale = CURRENTSCALE;
barometerConfigMutable()->baro_hardware = 0;
compassConfigMutable()->mag_hardware = 0;
osdConfigMutable()->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(12, 1) | VISIBLE_FLAG;

View File

@ -93,6 +93,9 @@
#define CURRENT_METER_ADC_PIN PC2
#define RSSI_ADC_PIN PC0
#define CURRENT_METER_SCALE_DEFAULT 1000
#define CURRENT_METER_OFFSET_DEFAULT 0
#define USE_VCP
//#define VBUS_SENSING_PIN PA9

View File

@ -36,21 +36,9 @@
#include "telemetry/telemetry.h"
#define TARGET_CPU_VOLTAGE 3.0
#define CURRENTOFFSET 0
// board uses an ina139, RL=0.005, Rs=30000
// V/A = (0.005 * 0.001 * 30000) * I
// rescale to 1/10th mV / A -> * 1000 * 10
// use 3.0V as cpu and adc voltage -> rescale by 3.0/3.3
#define CURRENTSCALE (0.005 * 0.001 * 30000) * 1000 * 10 * (TARGET_CPU_VOLTAGE / 3.3)
// set default settings to match our target
void targetConfiguration(void)
{
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->offset = CURRENTOFFSET;
currentMeterADCOrVirtualConfigMutable(CURRENT_SENSOR_ADC)->scale = CURRENTSCALE;
// use the same uart for frsky telemetry and SBUS, both non inverted
const int index = findSerialPortIndexByIdentifier(SBUS_TELEMETRY_UART);
serialConfigMutable()->portConfigs[index].functionMask = FUNCTION_TELEMETRY_FRSKY | FUNCTION_RX_SERIAL;

View File

@ -100,6 +100,15 @@
#define ADC_INSTANCE ADC3
#define VBAT_SCALE_DEFAULT 100
#define CURRENT_TARGET_CPU_VOLTAGE 3.0
// board uses an ina139, RL=0.005, Rs=30000
// V/A = (0.005 * 0.001 * 30000) * I
// rescale to 1/10th mV / A -> * 1000 * 10
// use 3.0V as cpu and adc voltage -> rescale by 3.0/3.3
#define CURRENT_METER_SCALE_DEFAULT (0.005 * 0.001 * 30000) * 1000 * 10 * (CURRENT_TARGET_CPU_VOLTAGE / 3.3)
#define CURRENT_METER_OFFSET_DEFAULT 0
#define WS2811_PIN PA8
#define WS2811_TIMER TIM1
#define WS2811_DMA_CHANNEL DMA1_Channel2