From 434be00a44b6834a6610dd8cc6018407fb3c4471 Mon Sep 17 00:00:00 2001 From: alan Date: Wed, 25 Sep 2019 11:26:28 +0800 Subject: [PATCH 01/21] Elite 1.4-re try compile gptimer --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 2 +- .../examples/simple_peripheral/cc26xx/app/simple_peripheral.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 560a721cb..350245aff 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -42,4 +42,4 @@ static void headstage_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26X GPTimerCC26XX_setLoadValue(gptimer_handle, _load); \ } while (0) -#endif // HEADSTAGE_GPTIMER_H \ No newline at end of file +#endif // HEADSTAGE_GPTIMER_H 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 36651667a..c987ce0fe 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 @@ -527,6 +527,8 @@ static void SimpleBLEPeripheral_init(void) { HCI_LE_ReadMaxDataLenCmd(); } + +#include "EliteGPTimer.h" /********************************************************************* * @fn SimpleBLEPeripheral_taskFxn * From ae74c4e5cdac3659072cf9ef9c9b61379faf5797 Mon Sep 17 00:00:00 2001 From: YiChin Date: Wed, 25 Sep 2019 11:36:48 +0800 Subject: [PATCH 02/21] fix error --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 350245aff..4e3ba130b 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -13,7 +13,7 @@ static GPTimerCC26XX_Handle gptimer_handle; static void headstage_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { - flag_notify(EVT_PERIODIC_GPTIMER); +// flag_notify(EVT_PERIODIC_GPTIMER); } #define headstage_gptimer_start() GPTimerCC26XX_start(gptimer_handle) From 1f742b24df026edf088fb85b4d9c60951b0d566a Mon Sep 17 00:00:00 2001 From: alan Date: Wed, 25 Sep 2019 11:59:50 +0800 Subject: [PATCH 03/21] Elite 1.4-re try compile gptimer --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 4e3ba130b..862efb37e 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -32,6 +32,12 @@ static void headstage_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26X GPTimerCC26XX_registerInterrupt(gptimer_handle, headstage_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) + Types_FreqHz freq; + BIOS_getCpuFreq(&freq); + GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999 + GPTimerCC26XX_setLoadValue(hTimer, loadVal); + GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT); + #define headstage_gptimer_set_frequency(frequency) \ do { \ uint32_t _frequency = (uint32_t)(frequency); \ From 27c51a6c5421401ca1184873b22b2bfc3169be10 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 10:43:02 +0800 Subject: [PATCH 04/21] Elite 1.4-re gptimer test --- .../cc26xx/app/headstage/EliteGPTimer.h | 30 ++++++------------- .../cc26xx/app/headstage/impedance_meter.h | 2 +- .../cc26xx/app/simple_peripheral.c | 3 +- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 862efb37e..e1439956b 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -12,40 +12,28 @@ static GPTimerCC26XX_Handle gptimer_handle; -static void headstage_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { +static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { // flag_notify(EVT_PERIODIC_GPTIMER); } -#define headstage_gptimer_start() GPTimerCC26XX_start(gptimer_handle) -#define headstage_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle) -#define headstage_gptimer_close() GPTimerCC26XX_close(gptimer_handle) +#define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle) +#define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle) +#define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle) -#define headstage_gptimer_open() \ +#define elite_gptimer_open() \ do { \ GPTimerCC26XX_Params params; \ GPTimerCC26XX_Params_init(¶ms); \ params.width = GPT_CONFIG_16BIT; \ params.mode = GPT_MODE_PERIODIC_DOWN; \ params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; \ + Types_FreqHz freq; \ + BIOS_getCpuFreq(&freq); \ + GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ + GPTimerCC26XX_setLoadValue(hTimer, loadVal); \ gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ GPTimerCC26XX_setLoadValue(gptimer_handle, 0xFFFFFF); \ GPTimerCC26XX_registerInterrupt(gptimer_handle, headstage_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) - Types_FreqHz freq; - BIOS_getCpuFreq(&freq); - GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999 - GPTimerCC26XX_setLoadValue(hTimer, loadVal); - GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT); - -#define headstage_gptimer_set_frequency(frequency) \ - do { \ - uint32_t _frequency = (uint32_t)(frequency); \ - Types_FreqHz _cpu_freq; \ - BIOS_getCpuFreq(&_cpu_freq); \ - GPTimerCC26XX_Value _load = _cpu_freq.lo / _frequency - 1; \ - _load = (_load < 0xFFFF) ? _load : ((0xFA0000 | (_load / 250)) - 1); \ - GPTimerCC26XX_setLoadValue(gptimer_handle, _load); \ - } while (0) - #endif // HEADSTAGE_GPTIMER_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 f68886335..1d2f04b35 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 @@ -46,7 +46,7 @@ static void ZM_init() { InitEliteInstruction(); InitCurrentUserCode(); - + elite_gptimer_open(); // 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 c987ce0fe..707dd353f 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,10 +545,9 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { // Initialize application SimpleBLEPeripheral_init(); headstage_init_device_info(); - // headstage_gptimer_init(); - ZM_init(); Elite_SPI_init(); + ZM_init(); uint8_t key = 0; uint8_t counter6994 = 0; From 5576c071c50eb665a65ddf0450ad11de3f9deb97 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 10:52:01 +0800 Subject: [PATCH 05/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/impedance_meter.h | 4 ++++ 1 file changed, 4 insertions(+) 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 1d2f04b35..7c313a1a7 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 @@ -47,6 +47,10 @@ static void ZM_init() { InitEliteInstruction(); InitCurrentUserCode(); elite_gptimer_open(); + + // init DAC, set output ~= 0 V + DAC_outputV(Usercode_Correction_to_DAC(24999)); + // PIN_registerIntCb(pin_handle, switch_on_callback); // PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE); } From 2678b0c02f1bdc73161b56919798ab947a06db97 Mon Sep 17 00:00:00 2001 From: YiChin Date: Thu, 26 Sep 2019 11:06:55 +0800 Subject: [PATCH 06/21] smallZ-T curve --- .../examples/simple_peripheral/cc26xx/app/simple_peripheral.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 707dd353f..68f6b16e5 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 @@ -102,6 +102,7 @@ #include "simple_peripheral.h" +#include "EliteGPTimer.h" #include "headstage.h" #if defined(USE_FPGA) || defined(DEBUG_SW_TRACE) @@ -528,7 +529,7 @@ static void SimpleBLEPeripheral_init(void) { } -#include "EliteGPTimer.h" + /********************************************************************* * @fn SimpleBLEPeripheral_taskFxn * From 74742ca45b800bb71c341e98c0353dcf6abe1d69 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 11:10:05 +0800 Subject: [PATCH 07/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index e1439956b..b519e319c 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -30,7 +30,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In Types_FreqHz freq; \ BIOS_getCpuFreq(&freq); \ GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ - GPTimerCC26XX_setLoadValue(hTimer, loadVal); \ + GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ GPTimerCC26XX_setLoadValue(gptimer_handle, 0xFFFFFF); \ GPTimerCC26XX_registerInterrupt(gptimer_handle, headstage_gptimer_callback, GPT_INT_TIMEOUT); \ From d19b7093245a7ee02c01cf519ed8da39e33dc9b8 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 11:11:40 +0800 Subject: [PATCH 08/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index b519e319c..7e0239d0e 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -33,7 +33,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ GPTimerCC26XX_setLoadValue(gptimer_handle, 0xFFFFFF); \ - GPTimerCC26XX_registerInterrupt(gptimer_handle, headstage_gptimer_callback, GPT_INT_TIMEOUT); \ + GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) #endif // HEADSTAGE_GPTIMER_H From 0bc606c3a8b9f1ccb87640f8ce484ce8c28f8c69 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 11:12:28 +0800 Subject: [PATCH 09/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 7e0239d0e..9bcf38e96 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -20,7 +20,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In #define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle) #define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle) -#define elite_gptimer_open() \ +#define elite_gptimer_open() \ do { \ GPTimerCC26XX_Params params; \ GPTimerCC26XX_Params_init(¶ms); \ @@ -30,10 +30,10 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In Types_FreqHz freq; \ BIOS_getCpuFreq(&freq); \ GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ - GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ + GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ GPTimerCC26XX_setLoadValue(gptimer_handle, 0xFFFFFF); \ - GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ + GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) #endif // HEADSTAGE_GPTIMER_H From 91d68e665bd176d7b58d52ca4787eaf40071ee22 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 11:32:03 +0800 Subject: [PATCH 10/21] Elite 1.4-re gptimer test --- .../cc26xx/app/headstage/EliteGPTimer.h | 1 + .../simple_peripheral/cc26xx/app/simple_peripheral.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 9bcf38e96..7e8d184aa 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -14,6 +14,7 @@ static GPTimerCC26XX_Handle gptimer_handle; static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { // flag_notify(EVT_PERIODIC_GPTIMER); + Semaphore_post(semaphore); } #define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle) 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 68f6b16e5..f4ad2a1e1 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 @@ -554,8 +554,9 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { uint8_t counter6994 = 0; bool EliteOn = 0; - Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); // create a clock clockduration = 42(~=0.01 sec) - Util_startClock(&periodicClock); // start the clock, timeup => call SimpleBLEPeripheral_clockHandler => wake up the device +// Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); // create a clock clockduration = 42(~=0.01 sec) +// Util_startClock(&periodicClock); // start the clock, timeup => call SimpleBLEPeripheral_clockHandler => wake up the device + elite_gptimer_start(); // Application main loops for (;;) { @@ -606,7 +607,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { } if (!PeriodicEvent) { // if there is no periodic event - Util_startClock(&periodicClock); // manually restart the clock +// Util_startClock(&periodicClock); // manually restart the clock key = PIN_getInputValue(switch_on); if (EliteOn) { if (counter6994 < 175) { // counter6994 enable a IC after 35 counts @@ -629,7 +630,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { } // if(DAC_reset) DAC_outputV(0x0000); //set DAC to 0v when no periodic event } else { // if there is periodic event - Util_startClock(&periodicClock); // manually restart the clock +// Util_startClock(&periodicClock); // manually restart the clock SimpleBLEPeripheral_performPeriodicTask(); key = PIN_getInputValue(switch_on); From 53ed3f7d6c682d714eb81f7b15856f9d1d41bfc5 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 12:17:42 +0800 Subject: [PATCH 11/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/impedance_meter.h | 3 ++- .../examples/simple_peripheral/cc26xx/app/simple_peripheral.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 7c313a1a7..bf5b49d92 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 @@ -27,7 +27,8 @@ static void SimpleBLEPeripheral_clockHandler(UArg arg) { // events |= SBP_PERIODIC_EVT; // Wake up the application. - Semaphore_post(semaphore); // send samaphore to jump out of infinite waiting(simple_peripheral.c line570) +// Semaphore_post(semaphore); // send samaphore to jump out of infinite waiting(simple_peripheral.c line570) + LED_color(DARKLED, 0xFF, 0x00, 0x00); } static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins); 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 f4ad2a1e1..48b9d728f 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 @@ -557,7 +557,9 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { // Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); // create a clock clockduration = 42(~=0.01 sec) // Util_startClock(&periodicClock); // start the clock, timeup => call SimpleBLEPeripheral_clockHandler => wake up the device elite_gptimer_start(); - + PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V + TurnOn10V(); + LEDPowerON(); // Application main loops for (;;) { // Waits for a signal to the semaphore associated with the calling thread. From 4d3129782e28bdbc0f4de508c2f6c0bf021b5c1f Mon Sep 17 00:00:00 2001 From: YiChin Date: Thu, 26 Sep 2019 14:46:52 +0800 Subject: [PATCH 12/21] gptimer_open has a bug --- .../cc26xx/app/headstage/EliteGPTimer.h | 5 +---- .../cc26xx/app/headstage/impedance_meter.h | 11 +++++++---- .../simple_peripheral/cc26xx/app/simple_peripheral.c | 9 +++++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 7e8d184aa..eb853495d 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -12,10 +12,7 @@ static GPTimerCC26XX_Handle gptimer_handle; -static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { -// flag_notify(EVT_PERIODIC_GPTIMER); - Semaphore_post(semaphore); -} +static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask); #define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle) #define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle) 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 bf5b49d92..b6a55149a 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 @@ -28,9 +28,15 @@ static void SimpleBLEPeripheral_clockHandler(UArg arg) { // Wake up the application. // Semaphore_post(semaphore); // send samaphore to jump out of infinite waiting(simple_peripheral.c line570) + +} +static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { +// flag_notify(EVT_PERIODIC_GPTIMER); +// Semaphore_post(semaphore); LED_color(DARKLED, 0xFF, 0x00, 0x00); } + static void ZM_update_instruction_callback(uint8_t ins_type, uint8_t chip_ID, uint8_t *ins); static void ZM_init() { @@ -47,10 +53,7 @@ static void ZM_init() { InitEliteInstruction(); InitCurrentUserCode(); - elite_gptimer_open(); - - // init DAC, set output ~= 0 V - DAC_outputV(Usercode_Correction_to_DAC(24999)); +// elite_gptimer_open(); // 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 48b9d728f..a03537df0 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 @@ -547,8 +547,8 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { SimpleBLEPeripheral_init(); headstage_init_device_info(); - Elite_SPI_init(); ZM_init(); + Elite_SPI_init(); uint8_t key = 0; uint8_t counter6994 = 0; @@ -556,10 +556,15 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { // Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); // create a clock clockduration = 42(~=0.01 sec) // Util_startClock(&periodicClock); // start the clock, timeup => call SimpleBLEPeripheral_clockHandler => wake up the device - elite_gptimer_start(); + + // init DAC, set output ~= 0 V + DAC_outputV(Usercode_Correction_to_DAC(24999)); + PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V TurnOn10V(); LEDPowerON(); + +// elite_gptimer_start(); // Application main loops for (;;) { // Waits for a signal to the semaphore associated with the calling thread. From 8713d743e1ae2e301aee073befa261d2badff021 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 15:03:55 +0800 Subject: [PATCH 13/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 2 +- .../simple_peripheral/cc26xx/app/headstage/impedance_meter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index eb853495d..26f5262e6 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -25,11 +25,11 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In params.width = GPT_CONFIG_16BIT; \ params.mode = GPT_MODE_PERIODIC_DOWN; \ params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; \ + gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ Types_FreqHz freq; \ BIOS_getCpuFreq(&freq); \ GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ - gptimer_handle = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); \ GPTimerCC26XX_setLoadValue(gptimer_handle, 0xFFFFFF); \ GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) 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 b6a55149a..a4745ba9b 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 @@ -53,7 +53,7 @@ static void ZM_init() { InitEliteInstruction(); InitCurrentUserCode(); -// elite_gptimer_open(); + elite_gptimer_open(); // PIN_registerIntCb(pin_handle, switch_on_callback); // PIN_setInterrupt(pin_handle, switch_on | PIN_IRQ_POSEDGE); From a4093cdc70bfb90fc2a29306c97bfa51196b31fe Mon Sep 17 00:00:00 2001 From: YiChin Date: Thu, 26 Sep 2019 15:08:53 +0800 Subject: [PATCH 14/21] gptimer_open has a bug --- .../examples/simple_peripheral/cc26xx/app/simple_peripheral.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a03537df0..b20a7896c 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 @@ -564,7 +564,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { TurnOn10V(); LEDPowerON(); -// elite_gptimer_start(); + elite_gptimer_start(); // Application main loops for (;;) { // Waits for a signal to the semaphore associated with the calling thread. From 15a10b2405881e41d707aa9eb39478cdbc3f0e58 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 15:20:27 +0800 Subject: [PATCH 15/21] Elite 1.4-re gptimer test --- .../cc26xx/app/headstage/impedance_meter.h | 6 +- .../cc26xx/app/simple_peripheral.c | 73 +++++++++---------- 2 files changed, 39 insertions(+), 40 deletions(-) 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 a4745ba9b..f32004bd5 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 @@ -31,9 +31,9 @@ static void SimpleBLEPeripheral_clockHandler(UArg arg) { } static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { -// flag_notify(EVT_PERIODIC_GPTIMER); -// Semaphore_post(semaphore); - LED_color(DARKLED, 0xFF, 0x00, 0x00); + LED_color(DARKLED, 0x0F, 0x00, 0x0F); + events |= SBP_PERIODIC_EVT; + Semaphore_post(semaphore); } 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 b20a7896c..a23d1b357 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 @@ -613,44 +613,43 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { } } - if (!PeriodicEvent) { // if there is no periodic event -// Util_startClock(&periodicClock); // manually restart the clock - key = PIN_getInputValue(switch_on); - if (EliteOn) { - if (counter6994 < 175) { // counter6994 enable a IC after 35 counts - counter6994++; - } else if (counter6994 == 175) { - PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994 - - // #ifdef ELITE_VERSION_1_4 - // SPI_close(spiHandle0); - // I2Cinit(); - // I2C_close(I2Chandle); - // spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // LED SPI - // #endif - counter6994++; - } - EliteKeyPress(key); - - } else { - EliteOn = TurnOnElite(key); - } - // if(DAC_reset) DAC_outputV(0x0000); //set DAC to 0v when no periodic event - } else { // if there is periodic event -// Util_startClock(&periodicClock); // manually restart the clock - SimpleBLEPeripheral_performPeriodicTask(); - - key = PIN_getInputValue(switch_on); - EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650 - } +// if (!PeriodicEvent) { // if there is no periodic event +//// Util_startClock(&periodicClock); // manually restart the clock +// key = PIN_getInputValue(switch_on); +// if (EliteOn) { +// if (counter6994 < 175) { // counter6994 enable a IC after 35 counts +// counter6994++; +// } else if (counter6994 == 175) { +// PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994 +// +// // #ifdef ELITE_VERSION_1_4 +// // SPI_close(spiHandle0); +// // I2Cinit(); +// // I2C_close(I2Chandle); +// // spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // LED SPI +// // #endif +// counter6994++; +// } +// EliteKeyPress(key); +// +// } else { +// EliteOn = TurnOnElite(key); +// } +// // if(DAC_reset) DAC_outputV(0x0000); //set DAC to 0v when no periodic event +// } else { // if there is periodic event +//// Util_startClock(&periodicClock); // manually restart the clock +// SimpleBLEPeripheral_performPeriodicTask(); +// +// key = PIN_getInputValue(switch_on); +// EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650 +// } +// } + if(events & SBP_PERIODIC_EVT){ + events &= ~SBP_PERIODIC_EVT; + LED_color(DARKLED, 0x00, 0x00, 0xFF); +// Perform periodic application task +// SimpleBLEPeripheral_performPeriodicTask(); } -// if(events & SBP_PERIODIC_EVT){ -// Util_startClock(&periodicClock); -// events &= ~SBP_PERIODIC_EVT; - -// // Perform periodic application task -// SimpleBLEPeripheral_performPeriodicTask(); -// } // if (events & SBP_PERIODIC_EVT) // { // events &= ~SBP_PERIODIC_EVT; From 9bf2ab20a80c2d96ef3d9119ab78596a4e9c7799 Mon Sep 17 00:00:00 2001 From: YiChin Date: Thu, 26 Sep 2019 15:35:22 +0800 Subject: [PATCH 16/21] gptimer_open has no bug --- .../cc26xx/app/headstage/EliteGPTimer.h | 2 +- .../cc26xx/app/headstage/impedance_meter.h | 1 - .../simple_peripheral/cc26xx/app/simple_peripheral.c | 11 +++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 26f5262e6..e9a5d7a2a 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -30,7 +30,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In BIOS_getCpuFreq(&freq); \ GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ - GPTimerCC26XX_setLoadValue(gptimer_handle, 0xFFFFFF); \ + GPTimerCC26XX_setLoadValue(gptimer_handle, 47999); \ GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) 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 f32004bd5..0b59221bd 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 @@ -31,7 +31,6 @@ static void SimpleBLEPeripheral_clockHandler(UArg arg) { } static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { - LED_color(DARKLED, 0x0F, 0x00, 0x0F); events |= SBP_PERIODIC_EVT; Semaphore_post(semaphore); } 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 a23d1b357..50027be7f 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 @@ -643,10 +643,17 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { // key = PIN_getInputValue(switch_on); // EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650 // } -// } + } if(events & SBP_PERIODIC_EVT){ events &= ~SBP_PERIODIC_EVT; - LED_color(DARKLED, 0x00, 0x00, 0xFF); + if (counter6994 == 100){ + LED_color(DARKLED, 0x0F, 0x00, 0x0F); + } + else if(counter6994 == 200){ + LED_color(DARKLED, 0x00, 0x00, 0xFF); + counter6994 = 0; + } + counter6994 ++; // Perform periodic application task // SimpleBLEPeripheral_performPeriodicTask(); } From 95d3c0bbc4098ffea1909cafe38281646214386e Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 15:45:19 +0800 Subject: [PATCH 17/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h | 2 +- .../simple_peripheral/cc26xx/app/simple_peripheral.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index e9a5d7a2a..4e7f162e2 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -30,7 +30,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In BIOS_getCpuFreq(&freq); \ GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ - GPTimerCC26XX_setLoadValue(gptimer_handle, 47999); \ + GPTimerCC26XX_setLoadValue(gptimer_handle, 4799); /* 0.1 ms*/ \ GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) 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 50027be7f..27e763f6d 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 @@ -551,7 +551,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { Elite_SPI_init(); uint8_t key = 0; - uint8_t counter6994 = 0; + uint16_t counter6994 = 0; bool EliteOn = 0; // Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); // create a clock clockduration = 42(~=0.01 sec) @@ -646,10 +646,10 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { } if(events & SBP_PERIODIC_EVT){ events &= ~SBP_PERIODIC_EVT; - if (counter6994 == 100){ + if (counter6994 == 10000){ LED_color(DARKLED, 0x0F, 0x00, 0x0F); } - else if(counter6994 == 200){ + else if(counter6994 == 20000){ LED_color(DARKLED, 0x00, 0x00, 0xFF); counter6994 = 0; } From 6fa630e6e40cb7fbd04e09e4b865e92815dc8dae Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 16:03:48 +0800 Subject: [PATCH 18/21] Elite 1.4-re gptimer test --- .../cc26xx/app/headstage/EliteGPTimer.h | 3 +- .../cc26xx/app/headstage/EliteKeyDetect.h | 6 +- .../cc26xx/app/simple_peripheral.c | 79 +++++++------------ 3 files changed, 35 insertions(+), 53 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h index 4e7f162e2..bd2f0d598 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteGPTimer.h @@ -17,6 +17,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In #define elite_gptimer_start() GPTimerCC26XX_start(gptimer_handle) #define elite_gptimer_stop() GPTimerCC26XX_stop(gptimer_handle) #define elite_gptimer_close() GPTimerCC26XX_close(gptimer_handle) +#define CLOCK_FREQ 4000 // clock freq = 0.1 ms #define elite_gptimer_open() \ do { \ @@ -30,7 +31,7 @@ static void elite_gptimer_callback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_In BIOS_getCpuFreq(&freq); \ GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; /*47999*/ \ GPTimerCC26XX_setLoadValue(gptimer_handle, loadVal); \ - GPTimerCC26XX_setLoadValue(gptimer_handle, 4799); /* 0.1 ms*/ \ + GPTimerCC26XX_setLoadValue(gptimer_handle, CLOCK_FREQ); /* 0.1 ms*/ \ GPTimerCC26XX_registerInterrupt(gptimer_handle, elite_gptimer_callback, GPT_INT_TIMEOUT); \ } while (0) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h index 49ca81a37..20e11c43c 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h @@ -8,7 +8,7 @@ static bool TurnOnElite(uint8_t key) { if (key == 0) { // press 1 sec, power on LED - if (TurnOnCounter >= 75) { + if (TurnOnCounter >= CLOCK_ONE_SECOND) { PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V TurnOn10V(); LEDPowerON(); @@ -31,12 +31,12 @@ static void EliteKeyPress(uint8_t key) { if (key == 0) { // key = 0 if press // press key => bight LED - if (ShutDownCounter > 30 && ShutDownCounter <= 40) { + if (ShutDownCounter > CLOCK_ONE_SECOND*2 && ShutDownCounter <= CLOCK_ONE_SECOND*3) { KeyWorkModeLED(); } // press 3~4 sec, shutdown 2650 - else if (ShutDownCounter > 40) { + else if (ShutDownCounter > CLOCK_ONE_SECOND*3) { LED_color(DARKLED, 0xFF, 0xFF, 0x00); PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V } 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 27e763f6d..d447078fd 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 @@ -529,7 +529,7 @@ static void SimpleBLEPeripheral_init(void) { } - +#define CLOCK_ONE_SECOND 10000 /********************************************************************* * @fn SimpleBLEPeripheral_taskFxn * @@ -554,17 +554,10 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { uint16_t counter6994 = 0; bool EliteOn = 0; -// Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); // create a clock clockduration = 42(~=0.01 sec) -// Util_startClock(&periodicClock); // start the clock, timeup => call SimpleBLEPeripheral_clockHandler => wake up the device - // init DAC, set output ~= 0 V DAC_outputV(Usercode_Correction_to_DAC(24999)); - - PIN_setOutputValue(pin_handle, enable_5v, 1); // enable 5V - TurnOn10V(); - LEDPowerON(); - elite_gptimer_start(); + // Application main loops for (;;) { // Waits for a signal to the semaphore associated with the calling thread. @@ -612,51 +605,39 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { ICall_free(pMsg); } } - -// if (!PeriodicEvent) { // if there is no periodic event -//// Util_startClock(&periodicClock); // manually restart the clock -// key = PIN_getInputValue(switch_on); -// if (EliteOn) { -// if (counter6994 < 175) { // counter6994 enable a IC after 35 counts -// counter6994++; -// } else if (counter6994 == 175) { -// PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994 -// -// // #ifdef ELITE_VERSION_1_4 -// // SPI_close(spiHandle0); -// // I2Cinit(); -// // I2C_close(I2Chandle); -// // spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // LED SPI -// // #endif -// counter6994++; -// } -// EliteKeyPress(key); -// -// } else { -// EliteOn = TurnOnElite(key); -// } -// // if(DAC_reset) DAC_outputV(0x0000); //set DAC to 0v when no periodic event -// } else { // if there is periodic event -//// Util_startClock(&periodicClock); // manually restart the clock -// SimpleBLEPeripheral_performPeriodicTask(); -// -// key = PIN_getInputValue(switch_on); -// EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650 -// } } - if(events & SBP_PERIODIC_EVT){ + if(events & SBP_PERIODIC_EVT){ events &= ~SBP_PERIODIC_EVT; - if (counter6994 == 10000){ - LED_color(DARKLED, 0x0F, 0x00, 0x0F); + if (!PeriodicEvent) { // if there is no periodic event + key = PIN_getInputValue(switch_on); + if (EliteOn) { + if (counter6994 < CLOCK_ONE_SECOND/2) { // counter6994 enable a IC after 35 counts + counter6994++; + } else if (counter6994 == CLOCK_ONE_SECOND/2) { + PIN_setOutputValue(pin_handle, shutdown_6994, 1); // OFF = 1 => turn off 6994 + // #ifdef ELITE_VERSION_1_4 + // SPI_close(spiHandle0); + // I2Cinit(); + // I2C_close(I2Chandle); + // spiHandle0 = SPI_open(Board_SPI0, &spiParams0); // LED SPI + // #endif + counter6994++; + } + EliteKeyPress(key); + } else { + EliteOn = TurnOnElite(key); + } } - else if(counter6994 == 20000){ - LED_color(DARKLED, 0x00, 0x00, 0xFF); - counter6994 = 0; + // if there is periodic event + else { + // Perform periodic application task + SimpleBLEPeripheral_performPeriodicTask(); + + key = PIN_getInputValue(switch_on); + EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650 } - counter6994 ++; -// Perform periodic application task -// SimpleBLEPeripheral_performPeriodicTask(); } + // if (events & SBP_PERIODIC_EVT) // { // events &= ~SBP_PERIODIC_EVT; From 09a40e191274aade042a08df3fd6f5fc65846063 Mon Sep 17 00:00:00 2001 From: YiChin Date: Thu, 26 Sep 2019 16:45:46 +0800 Subject: [PATCH 19/21] turn on/off with new clock done --- .../cc26xx/app/headstage/EliteKeyDetect.h | 11 ++++++----- .../simple_peripheral/cc26xx/app/simple_peripheral.c | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h index 20e11c43c..6d94cfe1a 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteKeyDetect.h @@ -2,9 +2,10 @@ #ifndef ELITEKEYDETECT #define ELITEKEYDETECT +#define CLOCK_ONE_SECOND 10000 static bool TurnOnElite(uint8_t key) { - static uint8_t TurnOnCounter = 0; + static uint16_t TurnOnCounter = 0; if (key == 0) { // press 1 sec, power on LED @@ -25,22 +26,22 @@ static bool TurnOnElite(uint8_t key) { } static void EliteKeyPress(uint8_t key) { - static uint8_t ShutDownCounter = 0; + static uint16_t ShutDownCounter = 0; static uint8_t OriginEliteFxn = 0; if (key == 0) { // key = 0 if press // press key => bight LED - if (ShutDownCounter > CLOCK_ONE_SECOND*2 && ShutDownCounter <= CLOCK_ONE_SECOND*3) { + if (ShutDownCounter == CLOCK_ONE_SECOND) { KeyWorkModeLED(); } // press 3~4 sec, shutdown 2650 - else if (ShutDownCounter > CLOCK_ONE_SECOND*3) { + else if (ShutDownCounter > (CLOCK_ONE_SECOND*3) ) { LED_color(DARKLED, 0xFF, 0xFF, 0x00); PIN_setOutputValue(pin_handle, enable_5v, 0); // disable 5V } - ShutDownCounter++; + ShutDownCounter ++; } else { if (OriginEliteFxn == INSTRUCTION.eliteFxn) { // old function == currunt instruction if (ShutDownCounter != 0) { 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 d447078fd..1198b7e36 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 @@ -529,7 +529,7 @@ static void SimpleBLEPeripheral_init(void) { } -#define CLOCK_ONE_SECOND 10000 + /********************************************************************* * @fn SimpleBLEPeripheral_taskFxn * @@ -543,6 +543,8 @@ static void SimpleBLEPeripheral_init(void) { // static void detectKey_clockHandler(UArg arg); static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { + +#define CLOCK_ONE_SECOND 10000 // Initialize application SimpleBLEPeripheral_init(); headstage_init_device_info(); From b69e9017bf5175605c79f19d3bf8f1f3cebd1fb4 Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 17:07:59 +0800 Subject: [PATCH 20/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/headstage.h | 6 +++--- .../cc26xx/app/headstage/impedance_meter.h | 2 ++ 2 files changed, 5 insertions(+), 3 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 0170b206a..bf4903ab8 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 @@ -615,9 +615,9 @@ static int16_t avg_number = 0; static long long ADCRealCurrent_long = 0; // Step time macro -#define STEPTIME_HALF_SEC 40 -#define STEPTIME_ONE_SEC 120 -#define STEPTIME_TWO_SEC 200 +#define STEPTIME_HALF_SEC 5000 +#define STEPTIME_ONE_SEC 10000 +#define STEPTIME_TWO_SEC 20000 // Constant Current Mode function static uint8_t CCModeReset = 1; 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 0b59221bd..aa48fe690 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 @@ -90,6 +90,8 @@ static void DACCode2Real2Notify(uint16_t DACcode) { */ static void SimpleBLEPeripheral_performPeriodicTask() { if ( IsPeriodicMode() ){ + + // XXX Using nwe clock => StepTime/SampleRate should change if (StepTimeCounter == INSTRUCTION.StepTime){ StepTimeCounter = 1; } From b65ff2383aff551d836b654e40cd322e212350ff Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 26 Sep 2019 18:05:28 +0800 Subject: [PATCH 21/21] Elite 1.4-re gptimer test --- .../simple_peripheral/cc26xx/app/headstage/EliteCCMode.h | 1 - .../simple_peripheral/cc26xx/app/headstage/headstage.h | 3 +-- .../simple_peripheral/cc26xx/app/headstage/impedance_meter.h | 4 ++++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h index 19338bb02..b58eba3b9 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h @@ -40,7 +40,6 @@ typedef struct _CURRENT_USER_CODE { static CURRENT_USER_CODE CurrentUserCode; - static int32_t CCModeReadCurrent(CURRENT_USER_CODE *CurrentUserCode){ int32_t Real_Current = 0; CCModeReset = 0; // This flag will control DAC working 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 bf4903ab8..f28d9bb76 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 @@ -607,7 +607,7 @@ static int32_t DAC_to_realV(uint16_t DACcode); #define DAC_NEG_MAX 0xFFFF static uint16_t DACUserCode = 0x0000; -static uint16_t SampleRateTable[6] = {1, 10, 100, 500, 1000, 10000}; // 1 =>100 Hz, 10000=>0.01 Hz +static uint32_t SampleRateTable[6] = {10, 100, 1000, 5000, 10000, 100000}; // 1 =>100 Hz, 10000=>0.01 Hz static uint16_t SampleRate_counter = 1; // record value for IV curve to calculate average current @@ -859,7 +859,6 @@ static void update_ZM_instruction(uint8 *ins) { CleanBuffer(); INSTRUCTION.eliteFxn = IT_CURVE; // IT_Plot(); // enable 10v = 1 - break; } case SET_SAMPLE_RATE: { 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 aa48fe690..9086ad577 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 @@ -140,6 +140,10 @@ static void EliteDACControl() { DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant)); } } + else if(INSTRUCTION.ResisterMeter == CONSTANT_CURRENT){ + DAC_outputV(Usercode_Correction_to_DAC(CurrentUserCode.value)); + } + else{ // IT, VT need only ADC measure return;