[update] pulse module
This commit is contained in:
+108
-107
@@ -3,111 +3,112 @@
|
||||
|
||||
#define Vset INSTRUCTION.Vset
|
||||
|
||||
//static void pulse_vscan(void){
|
||||
// struct PULSEMode *PULSE = (struct PULSEMode *)WM;
|
||||
//
|
||||
// static uint16_t lastVolt;
|
||||
// if (stiFirstTime) {
|
||||
// stiFirstTime = false;
|
||||
// lastVolt = 25000;
|
||||
// PULSE->_sti_t_flag = 1;
|
||||
// PULSE->_sti_v = PULSE->_sti_v1;
|
||||
// PULSE->_sti_t = PULSE->_sti_t1;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else if(!stiFirstTime) {
|
||||
// if (GPT.StiCounter >= PULSE->_sti_t) {
|
||||
// GPT.StiCounter -= PULSE->_sti_t; //to get right time
|
||||
//
|
||||
// if (PULSE->_sti_lp > 0) {
|
||||
// if (PULSE->_sti_cy > 0) {
|
||||
// if (PULSE->_sti_t_flag == 1) {
|
||||
// PULSE->_sti_t_flag = 2;
|
||||
// PULSE->_sti_v = PULSE->_sti_v2;
|
||||
// PULSE->_sti_t = PULSE->_sti_t2;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else if (PULSE->_sti_t_flag == 2) {
|
||||
// PULSE->_sti_t_flag = 3;
|
||||
// PULSE->_sti_v = PULSE->_sti_v3;
|
||||
// PULSE->_sti_t = PULSE->_sti_t3;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else if (PULSE->_sti_t_flag == 3) {
|
||||
// PULSE->_sti_cy -- ;
|
||||
// if (PULSE->_sti_cy == 0) {
|
||||
// PULSE->_sti_t_flag = 4;
|
||||
// PULSE->_sti_v = PULSE->_sti_v4;
|
||||
// PULSE->_sti_t = PULSE->_sti_t4;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else {
|
||||
// PULSE->_sti_t_flag = 2;
|
||||
// PULSE->_sti_v = PULSE->_sti_v2;
|
||||
// PULSE->_sti_t = PULSE->_sti_t2;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else if (PULSE->_sti_cy <= 0){
|
||||
// if (PULSE->_sti_t_flag == 4) {
|
||||
// PULSE->_sti_lp -- ;
|
||||
// if (PULSE->_sti_lp > 0) {
|
||||
// PULSE->_sti_cy = INSTRUCTION.sti_cy;
|
||||
// PULSE->_sti_t_flag = 2;
|
||||
// PULSE->_sti_v = PULSE->_sti_v2;
|
||||
// PULSE->_sti_t = PULSE->_sti_t2;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else {
|
||||
// PULSE->_sti_t_flag = 5;
|
||||
// PULSE->_sti_v = PULSE->_sti_v5;
|
||||
// PULSE->_sti_t = PULSE->_sti_t5;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else if (PULSE->_sti_lp <= 0) {
|
||||
// if (PULSE->_sti_t_flag == 5) {
|
||||
// PULSE->_sti_t_flag = 6;
|
||||
// PULSE->_sti_v = PULSE->_sti_v6;
|
||||
// PULSE->_sti_t = PULSE->_sti_t6;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else if (PULSE->_sti_t_flag == 6) {
|
||||
// PULSE->_sti_t_flag = 7;
|
||||
// PULSE->_sti_v = PULSE->_sti_v7;
|
||||
// PULSE->_sti_t = PULSE->_sti_t7;
|
||||
// if (PULSE->_sti_t == 1) {
|
||||
// PULSE->_sti_v = lastVolt;
|
||||
// }
|
||||
// } else if (PULSE->_sti_t_flag == 7) {
|
||||
// PULSE->_sti_v = 25000;
|
||||
// PeriodicEvent = false;
|
||||
// ModeLED(NO_EVENT);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (lastVolt != PULSE->_sti_v) {
|
||||
// lastVolt = PULSE->_sti_v;
|
||||
// //if (PULSE->_sti_v == 25000) {
|
||||
// // PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
|
||||
// //} else {
|
||||
// // PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
// //}
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, PULSE->_sti_v));
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, PULSE->_sti_v));
|
||||
// }
|
||||
//}
|
||||
static void pulse_vscan(void)
|
||||
{
|
||||
struct wm_pulse_ctx_t *pulse = (struct wm_pulse_ctx_t *)wm_get();
|
||||
static uint16_t lastVolt;
|
||||
|
||||
if (stiFirstTime) {
|
||||
stiFirstTime = false;
|
||||
lastVolt = 25000;
|
||||
pulse->_sti_t_flag = 1;
|
||||
pulse->_sti_v = pulse->_sti_v1;
|
||||
pulse->_sti_t = pulse->_sti_t1;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if(!stiFirstTime) {
|
||||
if (GPT.StiCounter >= pulse->_sti_t) {
|
||||
GPT.StiCounter -= pulse->_sti_t; //to get right time
|
||||
|
||||
if (pulse->_sti_lp > 0) {
|
||||
if (pulse->_sti_cy > 0) {
|
||||
if (pulse->_sti_t_flag == 1) {
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 2) {
|
||||
pulse->_sti_t_flag = 3;
|
||||
pulse->_sti_v = pulse->_sti_v3;
|
||||
pulse->_sti_t = pulse->_sti_t3;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 3) {
|
||||
pulse->_sti_cy -- ;
|
||||
if (pulse->_sti_cy == 0) {
|
||||
pulse->_sti_t_flag = 4;
|
||||
pulse->_sti_v = pulse->_sti_v4;
|
||||
pulse->_sti_t = pulse->_sti_t4;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else {
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pulse->_sti_cy <= 0){
|
||||
if (pulse->_sti_t_flag == 4) {
|
||||
pulse->_sti_lp -- ;
|
||||
if (pulse->_sti_lp > 0) {
|
||||
pulse->_sti_cy = INSTRUCTION.sti_cy;
|
||||
pulse->_sti_t_flag = 2;
|
||||
pulse->_sti_v = pulse->_sti_v2;
|
||||
pulse->_sti_t = pulse->_sti_t2;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else {
|
||||
pulse->_sti_t_flag = 5;
|
||||
pulse->_sti_v = pulse->_sti_v5;
|
||||
pulse->_sti_t = pulse->_sti_t5;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pulse->_sti_lp <= 0) {
|
||||
if (pulse->_sti_t_flag == 5) {
|
||||
pulse->_sti_t_flag = 6;
|
||||
pulse->_sti_v = pulse->_sti_v6;
|
||||
pulse->_sti_t = pulse->_sti_t6;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 6) {
|
||||
pulse->_sti_t_flag = 7;
|
||||
pulse->_sti_v = pulse->_sti_v7;
|
||||
pulse->_sti_t = pulse->_sti_t7;
|
||||
if (pulse->_sti_t == 1) {
|
||||
pulse->_sti_v = lastVolt;
|
||||
}
|
||||
} else if (pulse->_sti_t_flag == 7) {
|
||||
pulse->_sti_v = 25000;
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastVolt != pulse->_sti_v) {
|
||||
lastVolt = pulse->_sti_v;
|
||||
//if (pulse->_sti_v == 25000) {
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
|
||||
//} else {
|
||||
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
|
||||
//}
|
||||
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, pulse->_sti_v));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+69
-65
@@ -102,31 +102,30 @@ struct wm_ca_ctx_t {
|
||||
int32_t _Vset;
|
||||
};
|
||||
|
||||
//struct PULSEMode {
|
||||
// /* WARNING: please keep MEASURE at first!! */
|
||||
// struct wm_meas_t measure;
|
||||
//
|
||||
// int32_t _Vset;
|
||||
// int32_t _sti_v1;
|
||||
// int32_t _sti_v2;
|
||||
// int32_t _sti_v3;
|
||||
// int32_t _sti_v4;
|
||||
// int32_t _sti_v5;
|
||||
// int32_t _sti_v6;
|
||||
// int32_t _sti_v7;
|
||||
// int32_t _sti_t1;
|
||||
// int32_t _sti_t2;
|
||||
// int32_t _sti_t3;
|
||||
// int32_t _sti_t4;
|
||||
// int32_t _sti_t5;
|
||||
// int32_t _sti_t6;
|
||||
// int32_t _sti_t7;
|
||||
// int32_t _sti_t;
|
||||
// int32_t _sti_v; //output voltage now
|
||||
// int32_t _sti_t_flag; //Where's the time stage turn
|
||||
// uint16_t _sti_cy;
|
||||
// uint16_t _sti_lp;
|
||||
//};
|
||||
struct wm_pulse_ctx_t {
|
||||
/* WARNING: please keep MEASURE at first!! */
|
||||
struct wm_meas_t measure;
|
||||
int32_t _Vset;
|
||||
int32_t _sti_v1;
|
||||
int32_t _sti_v2;
|
||||
int32_t _sti_v3;
|
||||
int32_t _sti_v4;
|
||||
int32_t _sti_v5;
|
||||
int32_t _sti_v6;
|
||||
int32_t _sti_v7;
|
||||
int32_t _sti_t1;
|
||||
int32_t _sti_t2;
|
||||
int32_t _sti_t3;
|
||||
int32_t _sti_t4;
|
||||
int32_t _sti_t5;
|
||||
int32_t _sti_t6;
|
||||
int32_t _sti_t7;
|
||||
int32_t _sti_t;
|
||||
int32_t _sti_v; //output voltage now
|
||||
int32_t _sti_t_flag; //Where's the time stage turn
|
||||
uint16_t _sti_cy;
|
||||
uint16_t _sti_lp;
|
||||
};
|
||||
|
||||
int wm_init(void); //(void *instr_ctx);
|
||||
int wm_deinit(void);
|
||||
@@ -402,47 +401,47 @@ static int __ca_create(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//void *InitPULSEMode() {
|
||||
// struct PULSEMode *ret = malloc(sizeof(struct PULSEMode));
|
||||
// ret->_measureCurrent = 0;
|
||||
// ret->_measureVin = 0;
|
||||
// ret->_measureVout = 0;
|
||||
// ret->_measureBat = 0;
|
||||
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
|
||||
// ret->_Vset = 0;
|
||||
// ret->_sti_v1 = INSTRUCTION.sti_v1;
|
||||
// ret->_sti_v2 = INSTRUCTION.sti_v2;
|
||||
// ret->_sti_v3 = INSTRUCTION.sti_v3;
|
||||
// ret->_sti_v4 = INSTRUCTION.sti_v4;
|
||||
// ret->_sti_v5 = INSTRUCTION.sti_v5;
|
||||
// ret->_sti_v6 = INSTRUCTION.sti_v6;
|
||||
// ret->_sti_v7 = INSTRUCTION.sti_v7;
|
||||
// ret->_sti_t1 = INSTRUCTION.sti_t1;
|
||||
// ret->_sti_t2 = INSTRUCTION.sti_t2;
|
||||
// ret->_sti_t3 = INSTRUCTION.sti_t3;
|
||||
// ret->_sti_t4 = INSTRUCTION.sti_t4;
|
||||
// ret->_sti_t5 = INSTRUCTION.sti_t5;
|
||||
// ret->_sti_t6 = INSTRUCTION.sti_t6;
|
||||
// ret->_sti_t7 = INSTRUCTION.sti_t7;
|
||||
// ret->_sti_t = INSTRUCTION.sti_t1;
|
||||
// ret->_sti_v = INSTRUCTION.sti_v1;
|
||||
// ret->_sti_t_flag = 1;
|
||||
// ret->_sti_cy = INSTRUCTION.sti_cy;
|
||||
// ret->_sti_lp = INSTRUCTION.sti_loop;
|
||||
// return (void *)ret;
|
||||
//} /* CURVE_PULSE Mode */
|
||||
static int __pulse_create(void)
|
||||
{
|
||||
struct wm_meas_t *m;
|
||||
struct wm_pulse_ctx_t *p;
|
||||
void **wm = &workMode_p;
|
||||
|
||||
//void InitWorkMode(void **WM)
|
||||
//{
|
||||
// switch(INSTRUCTION.eliteFxn) {
|
||||
// case CURVE_CALI_DAC:
|
||||
// *WM = InitVoltOutMode();
|
||||
// break;
|
||||
// case CURVE_PULSE:
|
||||
// *WM = InitPULSEMode();
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
p = malloc(sizeof(struct wm_pulse_ctx_t));
|
||||
if (!p) return -1;
|
||||
|
||||
m = (struct wm_meas_t *)p;
|
||||
m->_measureCurrent = 0;
|
||||
m->_measureVin = 0;
|
||||
m->_measureVout = 0;
|
||||
m->_measureBat = 0;
|
||||
m->_VoViSwitch = INSTRUCTION.VoViSwitch;
|
||||
|
||||
p->_Vset = 0;
|
||||
p->_sti_v1 = INSTRUCTION.sti_v1;
|
||||
p->_sti_v2 = INSTRUCTION.sti_v2;
|
||||
p->_sti_v3 = INSTRUCTION.sti_v3;
|
||||
p->_sti_v4 = INSTRUCTION.sti_v4;
|
||||
p->_sti_v5 = INSTRUCTION.sti_v5;
|
||||
p->_sti_v6 = INSTRUCTION.sti_v6;
|
||||
p->_sti_v7 = INSTRUCTION.sti_v7;
|
||||
p->_sti_t1 = INSTRUCTION.sti_t1;
|
||||
p->_sti_t2 = INSTRUCTION.sti_t2;
|
||||
p->_sti_t3 = INSTRUCTION.sti_t3;
|
||||
p->_sti_t4 = INSTRUCTION.sti_t4;
|
||||
p->_sti_t5 = INSTRUCTION.sti_t5;
|
||||
p->_sti_t6 = INSTRUCTION.sti_t6;
|
||||
p->_sti_t7 = INSTRUCTION.sti_t7;
|
||||
p->_sti_t = INSTRUCTION.sti_t1;
|
||||
p->_sti_v = INSTRUCTION.sti_v1;
|
||||
p->_sti_t_flag = 1;
|
||||
p->_sti_cy = INSTRUCTION.sti_cy;
|
||||
p->_sti_lp = INSTRUCTION.sti_loop;
|
||||
|
||||
*wm = p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wm_init(void)
|
||||
{
|
||||
@@ -453,6 +452,7 @@ int wm_init(void)
|
||||
|
||||
switch (mode) {
|
||||
case CURVE_VO:
|
||||
case CURVE_CALI_DAC:
|
||||
if (__vo_create()) return -2;
|
||||
break;
|
||||
|
||||
@@ -492,6 +492,10 @@ int wm_init(void)
|
||||
if (__ca_create()) return -2;
|
||||
break;
|
||||
|
||||
case CURVE_PULSE:
|
||||
if (__pulse_create()) return -2;
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("DO NOT support!!");
|
||||
return -3;
|
||||
|
||||
+126
-129
@@ -202,126 +202,126 @@ static void SimpleBLEPeripheral_performPeriodicTask(void) {
|
||||
|
||||
mode_done();
|
||||
}
|
||||
// else if (INSTRUCTION.eliteFxn == CURVE_PULSE){
|
||||
// /** Periodic Event **/
|
||||
// // Default working flow is vscan -> ADC read -> send notify
|
||||
// // We will need a flag to control vscan, ADC and notify
|
||||
//
|
||||
// GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
// GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
//
|
||||
// if(EliteWorkReset){
|
||||
// InitEliteGPtimer();
|
||||
// EliteWorkReset = false;
|
||||
// batteryADC_flag = false;
|
||||
// record_flag = true;
|
||||
// firstTimeReset = true;
|
||||
// //pulsemode variable
|
||||
// stiFirstTime = true;
|
||||
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
// VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
// if (Ve1MatchVe2Mode()) {
|
||||
// if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
|
||||
// PeriodicEvent = false;
|
||||
// ModeLED(NO_EVENT);
|
||||
// }
|
||||
// } else if (INSTRUCTION.eliteFxn == CURVE_PULSE) {
|
||||
// if(!megaStiEnable){
|
||||
// PeriodicEvent = false;
|
||||
// ModeLED(NO_EVENT);
|
||||
// }
|
||||
else if (INSTRUCTION.eliteFxn == CURVE_PULSE) {
|
||||
/** Periodic Event **/
|
||||
// Default working flow is vscan -> ADC read -> send notify
|
||||
// We will need a flag to control vscan, ADC and notify
|
||||
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
if(EliteWorkReset){
|
||||
InitEliteGPtimer();
|
||||
EliteWorkReset = false;
|
||||
batteryADC_flag = false;
|
||||
record_flag = true;
|
||||
firstTimeReset = true;
|
||||
//pulsemode variable
|
||||
stiFirstTime = true;
|
||||
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
|
||||
IinADCGainControl(INSTRUCTION.ADCGainLevel);
|
||||
VoutGainControl(INSTRUCTION.VoutGainLevel);
|
||||
if (Ve1MatchVe2Mode()) {
|
||||
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
} else if (INSTRUCTION.eliteFxn == CURVE_PULSE) {
|
||||
if(!megaStiEnable){
|
||||
PeriodicEvent = false;
|
||||
ModeLED(NO_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
|
||||
vscanReset = true;
|
||||
}else{
|
||||
if(notifyFirst_flag){
|
||||
GPT.NotifyCounter = INSTRUCTION.notifyRate - 20;
|
||||
notifyFirst_flag = false;
|
||||
}
|
||||
vscanReset = false;
|
||||
leadTimeReset = false;
|
||||
}
|
||||
|
||||
//vscan counter
|
||||
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
//pulse mode counter
|
||||
GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
|
||||
if (vscanReset) {
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
//vscanReset = false;
|
||||
}else{
|
||||
if (megaStiEnable) {
|
||||
pulse_vscan();
|
||||
}
|
||||
}
|
||||
|
||||
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
|
||||
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
|
||||
// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
|
||||
// }else{
|
||||
// GPT.GptimerMultiple = 1;
|
||||
// }
|
||||
// GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
// vscan_flag = true;
|
||||
// if(vscan_flag){
|
||||
// EliteVscanControl();
|
||||
// vscan_flag = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
|
||||
// if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
|
||||
// vscanReset = true;
|
||||
// }else{
|
||||
// if(notifyFirst_flag){
|
||||
// GPT.NotifyCounter = INSTRUCTION.notifyRate - 20;
|
||||
// notifyFirst_flag = false;
|
||||
// }
|
||||
// vscanReset = false;
|
||||
// leadTimeReset = false;
|
||||
// }
|
||||
//
|
||||
// //vscan counter
|
||||
// GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
|
||||
// //pulse mode counter
|
||||
// GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
|
||||
// if (vscanReset) {
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
|
||||
// //vscanReset = false;
|
||||
// }else{
|
||||
// if (megaStiEnable) {
|
||||
// pulse_vscan();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
|
||||
//// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
|
||||
//// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
|
||||
//// }else{
|
||||
//// GPT.GptimerMultiple = 1;
|
||||
//// }
|
||||
//// GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
|
||||
//// vscan_flag = true;
|
||||
//// if(vscan_flag){
|
||||
//// EliteVscanControl();
|
||||
//// vscan_flag = false;
|
||||
//// }
|
||||
//// }
|
||||
//
|
||||
// //battery counter
|
||||
// GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
// GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
// if(GPT.BatteryCheckCounter >= 50000){
|
||||
// GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
// batteryCheck_flag = true;
|
||||
// }
|
||||
//
|
||||
// uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
// if( bat < 768 && bat > 20){
|
||||
// PIN15_setOutputValue(enable_5v, 0);
|
||||
// }
|
||||
//
|
||||
// //ADC counter
|
||||
// GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
// if(GPT.SampleRateCounter >= INSTRUCTION.sampleRate){
|
||||
// GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
// ADC_flag = true;
|
||||
// if(ADC_flag){
|
||||
// EliteADCControl();
|
||||
// ADC_flag = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //Notify counter(Notify control, check if we need to send notify)
|
||||
// //please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
// GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
// if(GPT.NotifyCounter >= INSTRUCTION.notifyRate){
|
||||
// GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
|
||||
// notify_flag = true;
|
||||
// if(vscanReset){
|
||||
// notify_flag = false;
|
||||
// }
|
||||
// if(notify_flag){
|
||||
// SendNotify();
|
||||
// notify_flag = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// mode_done();
|
||||
// }
|
||||
// else if(INSTRUCTION.eliteFxn == CURVE_CALI_DAC){
|
||||
// DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
// wm_deinit();
|
||||
// PeriodicEvent = false;
|
||||
// }
|
||||
|
||||
//battery counter
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
batteryCheck_flag = true;
|
||||
}
|
||||
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN15_setOutputValue(enable_5v, 0);
|
||||
}
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= INSTRUCTION.sampleRate){
|
||||
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
|
||||
ADC_flag = true;
|
||||
if(ADC_flag){
|
||||
EliteADCControl();
|
||||
ADC_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Notify counter(Notify control, check if we need to send notify)
|
||||
//please don't put Notify counter before ADC counter, maybe get wrong data
|
||||
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.NotifyCounter >= INSTRUCTION.notifyRate){
|
||||
GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
|
||||
notify_flag = true;
|
||||
if(vscanReset){
|
||||
notify_flag = false;
|
||||
}
|
||||
if(notify_flag){
|
||||
SendNotify();
|
||||
notify_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
mode_done();
|
||||
}
|
||||
else if(INSTRUCTION.eliteFxn == CURVE_CALI_DAC){
|
||||
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
|
||||
wm_deinit();
|
||||
PeriodicEvent = false;
|
||||
}
|
||||
else{
|
||||
// InitFlag();
|
||||
}
|
||||
@@ -331,14 +331,14 @@ static void EliteADCControl(void)
|
||||
{
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case CURVE_IV:
|
||||
case CURVE_IV_CY:
|
||||
case CURVE_RT:
|
||||
case CURVE_CC:
|
||||
case CURVE_CV:
|
||||
case CURVE_LSV:
|
||||
case CURVE_CA:
|
||||
// case CURVE_PULSE:
|
||||
case CURVE_VO:
|
||||
case CURVE_LSV:
|
||||
case CURVE_IV_CY:
|
||||
case CURVE_PULSE:
|
||||
CC_Plot();
|
||||
break;
|
||||
|
||||
@@ -350,13 +350,10 @@ static void EliteADCControl(void)
|
||||
VT_Plot();
|
||||
break;
|
||||
|
||||
// case CURVE_CALI_ADC:
|
||||
// if (INSTRUCTION.AdcChannel == IIN_ADC) {
|
||||
// cali_IT_plot();
|
||||
// } else if (INSTRUCTION.AdcChannel == VIN_ADC) {
|
||||
// cali_VT_plot();
|
||||
// }
|
||||
// break;
|
||||
case CURVE_CALI_ADC:
|
||||
if (INSTRUCTION.AdcChannel == IIN_ADC) cali_IT_plot();
|
||||
else if (INSTRUCTION.AdcChannel == VIN_ADC) cali_VT_plot();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -366,7 +363,7 @@ static void EliteADCControl(void)
|
||||
static void mode_done(void)
|
||||
{
|
||||
if ((INSTRUCTION.eliteFxn == CURVE_IV) ||
|
||||
(INSTRUCTION.eliteFxn == CURVE_CV)||
|
||||
(INSTRUCTION.eliteFxn == CURVE_CV) ||
|
||||
(INSTRUCTION.eliteFxn == CURVE_IV_CY)) {
|
||||
if (!PeriodicEvent) {
|
||||
SendNotify();
|
||||
|
||||
Reference in New Issue
Block a user