From caf6985e66532f03065b573606dfc797b88e998d Mon Sep 17 00:00:00 2001 From: ROY Date: Mon, 1 Aug 2022 18:12:25 +0800 Subject: [PATCH] [update] fix auto gain --- .../cc26xx/app/headstage/EliteADC.h | 36 +++---------------- .../cc26xx/app/headstage/EliteDAC.h | 5 --- .../cc26xx/app/headstage/EliteInstruction.h | 6 ++-- .../cc26xx/app/headstage/EliteReset.h | 6 ++-- .../cc26xx/app/headstage/Elite_version.h | 8 ++--- .../cc26xx/app/headstage/headstage.h | 4 --- .../cc26xx/app/headstage/impedance_meter.h | 11 ++---- 7 files changed, 18 insertions(+), 58 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h index f4f64bc..a3c2e24 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteADC.h @@ -210,6 +210,8 @@ static void __small_switch_lv2(uint8_t gain2_en, uint16_t plot, uint16_t *no_rec void IinADCGainCtrl(uint8_t IinADCLevel) { + if (IinADCLevel>= 4) + return; /* hardware need open before close, so don't change position*/ if (IinADCLevel == 0) { // ADC gain level = 0, using 2M resister @@ -239,28 +241,11 @@ void IinADCGainCtrl(uint8_t IinADCLevel) update_latch_stat(E_LATCH_I_SMALL_ON, 0); latch_multi_ctrl(); - } else if (IinADCLevel == 4) { - // ADC gain level = 3, auto gain (using 200R resister) - update_latch_stat(E_LATCH_I_LARGE_ON, 1); /* need open first */ - update_latch_stat(E_LATCH_I_MID_ON, 0); - update_latch_stat(E_LATCH_I_SMALL_ON, 0); - latch_multi_ctrl(); - - } else { - // default using 100R resister - update_latch_stat(E_LATCH_I_LARGE_ON, 1); /* need open first */ - update_latch_stat(E_LATCH_I_MID_ON, 0); - update_latch_stat(E_LATCH_I_SMALL_ON, 0); - latch_multi_ctrl(); - } if (IinADCLevel == 0 || IinADCLevel == 1 || IinADCLevel == 2 || IinADCLevel == 3) { lastIinADCGainLevel = IinADCLevel; - } else { - lastIinADCGainLevel = 3; - } curr_rec_en = false; @@ -270,6 +255,9 @@ void IinADCGainCtrl(uint8_t IinADCLevel) void VinADCGainCtrl(uint8_t VinADCLevel) { + if (VinADCLevel >= 3) + return; + /* hardware need open before close, so don't change position*/ if (VinADCLevel == 0) { // Vin ADC gain level = 0, using 1M resister @@ -289,24 +277,10 @@ void VinADCGainCtrl(uint8_t VinADCLevel) update_latch_stat(E_LATCH_V_MID_ON, 0); latch_multi_ctrl(); - } else if (VinADCLevel == 3) { - // Vin ADC gain level = 3, auto gain (using 1K resister) - update_latch_stat(E_LATCH_V_SMALL_ON, 1); /* need open first */ - update_latch_stat(E_LATCH_V_MID_ON, 0); - latch_multi_ctrl(); - - } else { - // default using 1K resister - update_latch_stat(E_LATCH_V_SMALL_ON, 1); /* need open first */ - update_latch_stat(E_LATCH_V_MID_ON, 0); - latch_multi_ctrl(); - } if (VinADCLevel == 0 || VinADCLevel == 1 || VinADCLevel == 2) { lastVinADCGainLv = VinADCLevel; - } else { - lastVinADCGainLv = 2; } volt_rec_en = false; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h index 00cbad7..9d3cbe1 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h @@ -44,11 +44,6 @@ static void AutoGainChangeVout(int32_t userCode){ // switch to 1 level volt(small) 15K // switch to 2 level volt(large) 240K - if(instru.VoutGainLv == VOUT_GAIN_AUTO){ - instru.VoutGainLv = VOUT_GAIN_15K; - VoutGainControl(instru.VoutGainLv); - } - if(instru.VoutGainLv == VOUT_GAIN_15K){ if(RealVolt > DAC_VOUT_GAIN_LARGE_BOUNDARY || RealVolt < -1 * DAC_VOUT_GAIN_LARGE_BOUNDARY){ // switch to 2 level volt(large) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteInstruction.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteInstruction.h index a6293db..957fef9 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteInstruction.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteInstruction.h @@ -141,9 +141,9 @@ static void InitEliteInstruction(void) instru.IinADCAutoGainEn = 1; instru.VinADCAutoGainEn = 1; instru.VoutAutoGainEn = 1; - instru.IinADCGainLv = I_GAIN_AUTO; - instru.VinADCGainLv = VIN_GAIN_AUTO; - instru.VoutGainLv = VOUT_GAIN_AUTO; + instru.IinADCGainLv = I_GAIN_100R; + instru.VinADCGainLv = VIN_GAIN_1K; + instru.VoutGainLv = VOUT_GAIN_15K; instru.gain_switch_on = 0b11110000; // cur auto gain switch, |lv0|lv1|lv2|lv3|none|none|none|none| instru.AdcChannel = 0; // RIS_ADC_IIN: 0x00, RIS_ADC_VIN: 0x01, RIS_DAC_VOUT: 0x02, RIS_HIGH_Z: 0x03 instru.hign_z_en = 0; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteReset.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteReset.h index 50eba80..4142b88 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteReset.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteReset.h @@ -12,8 +12,10 @@ static void reset() { latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open; - VinADCGainCtrl(VIN_GAIN_AUTO); - IinADCGainCtrl(I_GAIN_AUTO); + instru.VinADCGainLv = VIN_GAIN_1K; + VinADCGainCtrl(instru.VinADCGainLv); + instru.IinADCGainLv = I_GAIN_100R; + IinADCGainCtrl(instru.IinADCGainLv); instru.VoutGainLv = VOUT_GAIN_15K; VoutGainControl(instru.VoutGainLv); diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h index 7d8ef0c..fa1fdb6 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h @@ -3,10 +3,10 @@ #define VERSION_DATE #define VERSION_DATE_YEAR 22 -#define VERSION_DATE_MONTH 7 -#define VERSION_DATE_DAY 29 -#define VERSION_DATE_HOUR 13 -#define VERSION_DATE_MINUTE 9 +#define VERSION_DATE_MONTH 8 +#define VERSION_DATE_DAY 1 +#define VERSION_DATE_HOUR 18 +#define VERSION_DATE_MINUTE 12 // this is NOT the version hash !! // it's the last version hash diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h index 24628a9..a7c952f 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h @@ -852,10 +852,6 @@ static void update_ZM_instruction(uint8 *ins) { break; } case RIS_DAC_VOUT : { -// instru.VoutGainLv = ins[4]; -// if(instru.VoutGainLv == VOUT_GAIN_AUTO){ -// instru.VoutGainLv = VOUT_GAIN_15K; -// } instru.VoutGainLv = ins[4]; VoutGainControl(instru.VoutGainLv); break; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h index d6db12a..479466b 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h @@ -44,7 +44,8 @@ static void ZM_init() { /* when elite open, must change vin level, measure battery value will be right */ - VinADCGainCtrl(VIN_GAIN_AUTO); + instru.VinADCGainLv = VIN_GAIN_1K; + VinADCGainCtrl(instru.VinADCGainLv); elite_gptimer_open(); //elite_gptimer_start(); @@ -317,14 +318,6 @@ static void mode_init_set(void) instru.gain_switch_on = 0b01110000; } - if (instru.IinADCGainLv == I_GAIN_AUTO) { - instru.IinADCGainLv = I_GAIN_100R; - } - - if (instru.VinADCAutoGainEn == VIN_GAIN_AUTO) { - instru.VinADCGainLv = VIN_GAIN_1K; - } - VinADCGainCtrl(instru.VinADCGainLv); IinADCGainCtrl(instru.IinADCGainLv); VoutGainControl(instru.VoutGainLv);