read current
This commit is contained in:
+9
-10
@@ -221,13 +221,13 @@ static uint8_t DecodeADCCurrent_level1(){
|
||||
CPUdelay(8000);
|
||||
ADC_read(AIN1);
|
||||
|
||||
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
|
||||
spi_ADC_rxbuf[i] = AIN1[i];
|
||||
}
|
||||
// if (ADC_stage1full()){
|
||||
if(AIN1[0] >= 0xFE) || {
|
||||
if ((AIN1[0] >= 0xFE) || (AIN1[0] <= 02)){
|
||||
return 0;
|
||||
} else {
|
||||
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
|
||||
spi_ADC_rxbuf[i] = AIN1[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ static uint8_t DecodeADCCurrent_level2(){
|
||||
ADC_read(AIN2);
|
||||
|
||||
// if (ADC_stage2full()){
|
||||
if(AIN2[0] >= 0x3B){
|
||||
if ((AIN2[0] >= 0x3B) || (AIN2[0] <= 01)){
|
||||
return DecodeADCCurrent_level1();
|
||||
} else {
|
||||
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
|
||||
@@ -258,7 +258,7 @@ static uint8_t DecodeADCCurrent_level3(){
|
||||
CPUdelay(8000);
|
||||
ADC_read(AIN3);
|
||||
|
||||
if (ADC_stage2full()){
|
||||
if ((AIN3[0] >= 0x3B) || (AIN3[0] <= 01)){
|
||||
return DecodeADCCurrent_level2();
|
||||
} else {
|
||||
for(int i=0 ; i<SPI_ADC_SIZE ; i++){
|
||||
@@ -273,13 +273,13 @@ static int32_t DecodeADCCurrent(uint8_t ADCin){
|
||||
int32_t Iin = 0;
|
||||
|
||||
float Vo;
|
||||
uint8_t stage = DecodeADCCurrent_level2();
|
||||
uint8_t stage = DecodeADCCurrent_level3();
|
||||
// CPUdelay(8000);
|
||||
|
||||
int16_t decode;
|
||||
|
||||
// SendNotify();
|
||||
SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, 4, spi_ADC_rxbuf);
|
||||
// SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, 4, spi_ADC_rxbuf);
|
||||
switch(stage){
|
||||
case 1:
|
||||
// Vo = 101*1500000 - 100 * decode*LSBuV / 10e6;
|
||||
@@ -536,8 +536,7 @@ static void SimpleBLEPeripheral_performPeriodicTask() {
|
||||
}
|
||||
case ITCurve: {
|
||||
IT_Plot();
|
||||
|
||||
// SendNotify();
|
||||
SendNotify();
|
||||
break;
|
||||
}
|
||||
case VIS_RST: {
|
||||
|
||||
Reference in New Issue
Block a user