From e8d8b7730e3edca9ee2eb0d493216a394adde5dc Mon Sep 17 00:00:00 2001 From: YiChin Date: Mon, 19 Aug 2019 15:32:40 +0800 Subject: [PATCH] Elite 1.4-re LED --- .../cc26xx/app/headstage/headstage.h | 4 +-- .../cc26xx/app/headstage/impedance_meter.h | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h index 3311171b6..65a728dfe 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h @@ -1148,7 +1148,7 @@ static void headstage_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26X #include "EliteNotify.h" #include "impedance_meter.h" -#endif // HEADSTAGE_H + /*======================== ==== gap information ==== @@ -1261,4 +1261,4 @@ static void headstage_init_device_info() { GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, p - scanRspData, scanRspData); } - +#endif // HEADSTAGE_H diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h index c1a3e8df9..872fc311d 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h @@ -176,7 +176,7 @@ static uint8_t ADC_overflow(uint8_t gain, uint16_t rawdata){ } } else if(gain == 1){ - if( ((0x5fb2 < rawdata) && (rawdata < 0x6589)) || ((0x5999 < rawdata) && (rawdata < 0x5f75)) ){ + if( ((0x5f97 < rawdata) && (rawdata < 0x6589)) || ((0x5999 < rawdata) && (rawdata < 0x5f93)) ){ return 1; }; } @@ -188,13 +188,12 @@ static void IT_Plot() { // ADC gain is don't care when measuring voltage uint8_t ADCGain = 0; - for(int i=0 ; i<3 ; i++){ - ADCGain = i; + for(int ADCGain=0 ; ADCGain<3 ; ADCGain++){ // read ADC volt ADCGainControl(ADCGain); ADCChannelSelect(ADC_CH_CURRENT); - CPUdelay(1600); + CPUdelay(8000); ADC_read(spi_ADC_rxbuf); uint16_t rawdata = ( ((uint16_t) (spi_ADC_rxbuf[0] << 8 )) | (spi_ADC_rxbuf[1]) ); @@ -205,6 +204,25 @@ static void IT_Plot() { } } + // use LED to check auto shifting function + switch(ADCGain){ + case 0:{ + LED_color(DARKLED, 0xFF, 0xB4, 0x00); + break; + } + case 1:{ + LED_color(DARKLED, 0x14, 0xC8, 0xFF); + break; + } + case 2:{ + LED_color(DARKLED, 0xFF, 0xFF, 0xFF); + break; + } + default:{ + break; + } + } + // decode ADC value and put it into notify buffer DecodeADCValue(ADCGain, ADC_CH_CURRENT, spi_ADC_rxbuf); }