Merge branch 'dev/elite1.5re/fix_auto_gain' into elite/edc1.5re

This commit is contained in:
ROY
2022-08-01 18:12:59 +08:00
7 changed files with 18 additions and 58 deletions
@@ -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;
@@ -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)
@@ -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;
@@ -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);
@@ -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
@@ -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;
@@ -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);