Elite 1.4-re gptimer test
This commit is contained in:
+2
-1
@@ -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)
|
||||
|
||||
|
||||
+3
-3
@@ -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
|
||||
}
|
||||
|
||||
+30
-49
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user