stable version VERY NICE
This commit is contained in:
+13
-24
@@ -18,11 +18,11 @@ static int32_t CCModeReadCurrent(CCMode *CC){
|
||||
|
||||
// Use 9-th measure value as real-measure value
|
||||
// because some value in the begin are garbage
|
||||
if(VoltCurrentSwitch < 9){
|
||||
if(VoltCurrentSwitch < 5){
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
VoltCurrentSwitch ++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 9){
|
||||
else if(VoltCurrentSwitch == 5){
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
CC->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
@@ -33,12 +33,12 @@ static int32_t CCModeReadCurrent(CCMode *CC){
|
||||
}
|
||||
VoltCurrentSwitch ++;
|
||||
}
|
||||
else if(VoltCurrentSwitch <18){
|
||||
else if(VoltCurrentSwitch <10){
|
||||
// read volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
VoltCurrentSwitch++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 18){
|
||||
else if(VoltCurrentSwitch == 10){
|
||||
// read volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
CC->BatteryV = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
@@ -89,11 +89,11 @@ static int32_t CCModeVoltOut(CCMode *CC){
|
||||
// NotifyCurrent[2] = (uint8_t) ((IUCCurrent & 0x0000FF00) >> 8);
|
||||
// NotifyCurrent[3] = (uint8_t) (IUCCurrent & 0x000000FF);
|
||||
//
|
||||
IUCCurrent = INSTRUCTION.ADCGainLevel;
|
||||
NotifyImpedance[0] = (uint8_t) (IUCCurrent >> 24);
|
||||
NotifyImpedance[1] = (uint8_t) ((IUCCurrent & 0x00FF0000) >> 16);
|
||||
NotifyImpedance[2] = (uint8_t) ((IUCCurrent & 0x0000FF00) >> 8);
|
||||
NotifyImpedance[3] = (uint8_t) (IUCCurrent & 0x000000FF);
|
||||
// IUCCurrent = INSTRUCTION.ADCGainLevel;
|
||||
// NotifyImpedance[0] = (uint8_t) (IUCCurrent >> 24);
|
||||
// NotifyImpedance[1] = (uint8_t) ((IUCCurrent & 0x00FF0000) >> 16);
|
||||
// NotifyImpedance[2] = (uint8_t) ((IUCCurrent & 0x0000FF00) >> 8);
|
||||
// NotifyImpedance[3] = (uint8_t) (IUCCurrent & 0x000000FF);
|
||||
|
||||
// DACCode2Real2Notify(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
|
||||
// if(IUCCurrent > 1000){
|
||||
@@ -114,25 +114,14 @@ static int32_t CCModeVoltOut(CCMode *CC){
|
||||
|
||||
static void CCModeDACControl(int32_t IUC_Measure_Difference){
|
||||
int32_t step;
|
||||
if(IUC_Measure_Difference < 10 && IUC_Measure_Difference > -10){
|
||||
step = (IUC_Measure_Difference > 0) ? 1:-1;
|
||||
}
|
||||
else if(IUC_Measure_Difference < 100 && IUC_Measure_Difference > -100){
|
||||
step = (IUC_Measure_Difference > 0) ? 5:-5;
|
||||
}
|
||||
else if(IUC_Measure_Difference < 1000 && IUC_Measure_Difference > -1000){
|
||||
step = IUC_Measure_Difference / 1e3;
|
||||
}
|
||||
else if(IUC_Measure_Difference < 10000 && IUC_Measure_Difference > -10000){
|
||||
step = IUC_Measure_Difference / 1e4;
|
||||
}
|
||||
else if(IUC_Measure_Difference < 1e5 && IUC_Measure_Difference > -1e5){
|
||||
step = IUC_Measure_Difference / 1e5;
|
||||
if(IUC_Measure_Difference < 300 && IUC_Measure_Difference > -300){
|
||||
step = 0;
|
||||
}
|
||||
else{
|
||||
step = IUC_Measure_Difference / 1e6;
|
||||
step = (IUC_Measure_Difference > 0) ? 1:-1;
|
||||
}
|
||||
|
||||
|
||||
// over/under flow
|
||||
if( (INSTRUCTION.VoltConstant + step) > MAX_DAC_UC || (INSTRUCTION.VoltConstant + step) < MIN_DAC_UC ){
|
||||
if(step > 0){
|
||||
|
||||
Reference in New Issue
Block a user