diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_batt.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_batt.h index 6286b8002..00b7e5c65 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_batt.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_batt.h @@ -37,4 +37,19 @@ static uint8_t headstage_battery_volt2() { return battery_volt; } +static uint8_t headstage_battery_volt(){ + uint16_t bat_volt = 0; + ReadBatVolt(spi_ADC_rxbuf); + 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); + }else{ + PIN_setOutputValue(pin_handle, enable_5v, 1); + } + + return battery_volt; +} + #endif // HEADSTAGE_BATT_H diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h index f062332c7..1dfa827b1 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h @@ -4,9 +4,9 @@ #define VERSION_DATE_YEAR 20 #define VERSION_DATE_MONTH 6 -#define VERSION_DATE_DAY 24 -#define VERSION_DATE_HOUR 17 -#define VERSION_DATE_MINUTE 42 +#define VERSION_DATE_DAY 29 +#define VERSION_DATE_HOUR 15 +#define VERSION_DATE_MINUTE 35 // this is NOT the version hash !! // it's the last version hash 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 ddb34abcb..1a9207e46 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 @@ -1380,14 +1380,6 @@ static void update_ZM_instruction(uint8 *ins) { cis_buf[2] = headstage_battery_volt2(); SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf); - - #define THREE_POINT_THREE_VOLT 845 - if (AONBatMonBatteryVoltageGet() < THREE_POINT_THREE_VOLT){ - LED_color(DARKLED, 0xFF, 0xFF, 0x00); - PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V - headstage_power_shutdown(); - } - #undef THREE_POINT_THREE_VOLT break; } 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 8dc2738a9..bab62acc9 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 @@ -57,14 +57,6 @@ static void ZM_init() { ADCGainControl(GAIN_AUTO); elite_gptimer_open(); - #define THREE_POINT_THREE_VOLT 845 - if (AONBatMonBatteryVoltageGet() < THREE_POINT_THREE_VOLT){ -// LED_color(DARKLED, 0xFF, 0xFF, 0x00); -// PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V -// headstage_power_shutdown(); - } - #undef THREE_POINT_THREE_VOLT - // PIN_registerIntCb(pin_handle, switch_on_callback); // PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE); } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c index 84aa5d174..94c66be26 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c @@ -545,18 +545,13 @@ static void SimpleBLEPeripheral_init(void) { static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { #define CLOCK_ONE_SECOND 10000 +uint16_t bat_counter = 0; + // Initialize application SimpleBLEPeripheral_init(); headstage_init_device_info(); ZM_init(); - #define THREE_POINT_THREE_VOLT 845 - if (AONBatMonBatteryVoltageGet() < THREE_POINT_THREE_VOLT){ - LED_color(DARKLED, 0xFF, 0xFF, 0x00); - PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V - headstage_power_shutdown(); - } - #undef THREE_POINT_THREE_VOLT Elite_SPI_init(); WorkMode *WorkModeData = CreateWorkMode(); @@ -622,6 +617,32 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { events &= ~SBP_PERIODIC_EVT; if (!PeriodicEvent) { // if there is no periodic event key = PIN_getInputValue(switch_on); + if (bat_counter == CLOCK_ONE_SECOND*1) { +// #define THREE_POINT_THREE_VOLT 845 +// // Battery voltage < 3.3V, turn off Elite. +// if ((AONBatMonBatteryVoltageGet() < THREE_POINT_THREE_VOLT) && (AONBatMonBatteryVoltageGet() > 256)){ +// LED_color(DARKLED, 0xFF, 0xFF, 0x00); +// PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V +// headstage_power_shutdown(); +// }else{ +// PIN_setOutputValue(pin_handle, enable_5v, 1); +// } +// #undef THREE_POINT_THREE_VOLT + + uint16_t bat_volt = 0; + ReadBatVolt(spi_ADC_rxbuf); + 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); + }else{ + PIN_setOutputValue(pin_handle, enable_5v, 1); + } + bat_counter = 0; + } else { + bat_counter++; + } if (EliteOn) { if (counter6994 < CLOCK_ONE_SECOND/2) { // counter6994 enable a IC after 35 counts counter6994++;