fix bug
This commit is contained in:
+18
-16
@@ -55,7 +55,6 @@ static void ZM_init() {
|
||||
ADCGainControl(GAIN_AUTO);
|
||||
elite_gptimer_open();
|
||||
|
||||
ADCvalid = true;
|
||||
// PIN_registerIntCb(pin_handle, switch_on_callback);
|
||||
// PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE);
|
||||
}
|
||||
@@ -207,8 +206,18 @@ static void EliteDACControl(WorkMode *WorkModeData) {
|
||||
}
|
||||
|
||||
static void EliteADCControl(WorkMode *WorkModeData) {
|
||||
if (ADCvalid) {
|
||||
if (CT.SampleRate_counter == INSTRUCTION.SampleRate - 1) {
|
||||
if (CT.SampleRate_counter == INSTRUCTION.SampleRate - 1) {
|
||||
if(!ADCvalid) {
|
||||
ReadBatVolt(spi_ADC_rxbuf);
|
||||
uint16_t bat_volt = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
// Battery voltage < 3V, turn off Elite.
|
||||
if(bat_volt < 8500 && bat_volt > 200) {
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}
|
||||
// LED_color(DARKLED, 0x30, 0x00, 0x50);
|
||||
ADCvalid = false;
|
||||
} else {
|
||||
// LED_color(DARKLED, 0x50, 0x00, 0x00);
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IV_CURVE:{
|
||||
IV_Plot(WorkModeData->IV);
|
||||
@@ -256,21 +265,13 @@ static void EliteADCControl(WorkMode *WorkModeData) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ADCvalid = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ReadBatVolt(spi_ADC_rxbuf);
|
||||
uint16_t bat_volt = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
// Battery voltage < 3V, turn off Elite.
|
||||
if(bat_volt < 8500 && bat_volt > 200) {
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}
|
||||
ADCvalid = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void EliteNotifyControl() {
|
||||
if (ADCvalid) {
|
||||
// if (ADCvalid) {
|
||||
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
|
||||
// output the last notify, and reset Elite
|
||||
if (!PeriodicEvent) {
|
||||
@@ -288,9 +289,10 @@ static void EliteNotifyControl() {
|
||||
else if (CT.SampleRate_counter == INSTRUCTION.SampleRate) {
|
||||
SendNotify();
|
||||
}
|
||||
} else {
|
||||
ADCvalid = false;
|
||||
}
|
||||
// ADCvalid = true;
|
||||
// } else {
|
||||
// ADCvalid = false;
|
||||
// }
|
||||
}
|
||||
|
||||
//static void EliteBattery(uint8_t *ins_type, uint8_t *oper) {
|
||||
|
||||
+6
-5
@@ -102,7 +102,7 @@
|
||||
|
||||
#include "simple_peripheral.h"
|
||||
|
||||
static bool ADCvalid = true;
|
||||
static bool ADCvalid;
|
||||
|
||||
#include "EliteGPTimer.h"
|
||||
#include "headstage.h"
|
||||
@@ -620,7 +620,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
if (!PeriodicEvent) { // if there is no periodic event
|
||||
key = PIN_getInputValue(switch_on);
|
||||
|
||||
if (bat_counter == CLOCK_ONE_SECOND*5) {
|
||||
if (bat_counter == CLOCK_ONE_SECOND*1) {
|
||||
ReadBatVolt(spi_ADC_rxbuf);
|
||||
uint16_t bat_volt = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
// Battery voltage < 3V, turn off Elite.
|
||||
@@ -662,12 +662,13 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
|
||||
}
|
||||
// if there is periodic event
|
||||
else {
|
||||
if (bat_counter == CLOCK_ONE_SECOND*5) {
|
||||
bat_counter = 0;
|
||||
ADCvalid = true;
|
||||
|
||||
if (bat_counter == CLOCK_ONE_SECOND*1) {
|
||||
ADCvalid = false;
|
||||
bat_counter = 0;
|
||||
} else {
|
||||
bat_counter++;
|
||||
ADCvalid = true;
|
||||
}
|
||||
|
||||
if(InitPeriodicEvent){
|
||||
|
||||
Reference in New Issue
Block a user