Merge remote-tracking branch 'origin/Elite_OBJ_Version' into Elite_OBJ_Version

This commit is contained in:
weiting2
2019-11-04 09:44:21 +08:00
5 changed files with 59 additions and 22 deletions
@@ -2,6 +2,8 @@
#ifndef ELITEIT
#define ELITEIT
#define absolute(a) ((a<0)? -a:a)
//static int32_t IT_Plot() {
// // read ADC current
// int32_t Real_Current = 0;
@@ -20,7 +22,23 @@
// return Real_Current;
//}
static int32_t IT_Plot(ITMode *IT) {
static int32_t IT_Plot(WorkMode *WorkModeData) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
#define CURRENT_MODE WorkModeData->IV
break;
}
case CV_CURVE:{
#define CURRENT_MODE WorkModeData->CV
break;
}
case IT_CURVE:{
#define CURRENT_MODE WorkModeData->IT
break;
}
}
// read ADC current
int32_t Real_Current = 0;
@@ -31,9 +49,19 @@ static int32_t IT_Plot(ITMode *IT) {
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
IT->SetMeasureData((struct Measure *) IT, Real_Current);
Real_Current = IT->GetMeasureData((struct Measure *) IT);
// IT->SetMeasureData((struct Measure *) IT, Real_Current);
// Real_Current = IT->GetMeasureData((struct Measure *) IT);
CURRENT_MODE->_MeasureData = Real_Current;
if(INSTRUCTION.eliteFxn == IV_CURVE){
if(absolute(Real_Current) > CURRENT_MODE->_LimitValue){
// PeriodicEvent = false; //Real current exceed expected limit value, force stop
// DACReset = true;
reset();
}
}
NotifyCurrent[0] = (uint8_t) (Real_Current >> 24);
NotifyCurrent[1] = (uint8_t) ((Real_Current & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((Real_Current & 0x0000FF00) >> 8);
@@ -42,4 +70,5 @@ static int32_t IT_Plot(ITMode *IT) {
return Real_Current;
}
#endif
@@ -74,8 +74,9 @@ static uint16_t OneWayVoltScan(IVMode *IV) {
// end IV task if we reach INSTRUCTION.VoltFinal
if (DACUserCode <= IV->_VStop){
PeriodicEvent = false;
DACReset = true;
// PeriodicEvent = false;
// DACReset = true;
reset();
}
}
}
@@ -85,9 +85,9 @@ typedef void (*InitWorkData) ();
// uint16_t (*GetCycleNumber) (struct VoltOutPara *)
#define LIMIT \
uint16_t _LimitValue; \
void (*SetLimitValue) (struct Limit *, uint16_t); \
uint16_t (*GetLimitValue) (struct Limit*)
uint32_t _LimitValue; \
void (*SetLimitValue) (struct Limit *, uint32_t); \
uint32_t (*GetLimitValue) (struct Limit*)
struct Measure{
MEASURE;
@@ -112,9 +112,20 @@ int32_t _GetMeasureData(struct Measure *self){
return self->_MeasureData;
}
/**** Limit Mode ****/
//LimitValue
void _SetLimitValue(struct Limit *self, uint32_t LimitValue){
self->_LimitValue = LimitValue;
}
uint32_t _GetLimitValue(struct Limit *self){
return self->_LimitValue;
}
/* IT Mode Data */
typedef struct _ITMode{
MEASURE;
LIMIT;
}ITMode;
ITMode * InitITMode(){
@@ -122,6 +133,11 @@ ITMode * InitITMode(){
ret->_MeasureData = 0;
ret->SetMeasureData = &_SetMeasureData;
ret->GetMeasureData = &_GetMeasureData;
ret->_LimitValue = 0;
ret->SetLimitValue = &_SetLimitValue;
ret->GetLimitValue = &_GetLimitValue;
return ret;
}
/* End of IT Mode Data */
@@ -191,15 +207,6 @@ uint16_t _GetCycleNumber(struct VoltOutPara *self){
return self->_CycleNumber;
}
/**** Limit Mode ****/
//LimitValue
void _SetLimitValue(struct Limit *self, uint16_t LimitValue){
self->_LimitValue = LimitValue;
}
uint16_t _GetLimitValue(struct Limit *self){
return self->_LimitValue;
}
/* VoltOut Mode Data */
typedef struct _VoltOutMode{
@@ -267,7 +274,7 @@ IVMode *InitIVMode(){
// ret->SetCycleNumber = &_SetCycleNumber;
// ret->GetCycleNumber = &_GetCycleNumber;
ret->_LimitValue = 0;
ret->_LimitValue = 1e5;
ret->SetLimitValue = &_SetLimitValue;
ret->GetLimitValue = &_GetLimitValue;
@@ -638,7 +638,7 @@ static void DACCode2Real2Notify(uint16_t DACcode); // send notify voltage a
//static void VOLT_OUTPUT();
static void ZT_Plot(RTMode *RT);
static void VT_Plot(VTMode *VT);
static int32_t IT_Plot(ITMode *IT);
static int32_t IT_PlotIT_Plot(WorkMode *WorkModeData);
// the following fxn do the same thing
// IVCurve_T is called if Vorigin > Vfinal, vice versa
@@ -179,15 +179,15 @@ static void EliteADCControl(WorkMode *WorkModeData) {
if (SampleRate_counter == INSTRUCTION.SampleRate - 1) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
IT_Plot(WorkModeData->IT);
IT_Plot(WorkModeData);
break;
}
case CV_CURVE:{
IT_Plot(WorkModeData->IT);
IT_Plot(WorkModeData);
break;
}
case IT_CURVE:{
IT_Plot(WorkModeData->IT);
IT_Plot(WorkModeData);
break;
}
case VT_CURVE:{