This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2650MODA: TI RTOS Timer Restart

Part Number: CC2650MODA
Other Parts Discussed in Thread: CC2650

TI RTOS has Timer APIs to open, close, start and stop timers. But there is no API to restart/reset a timer. I am starting a timer in oneshot-up mode on an falling edge interrupt on a GPIO and I need to restart timer on following falling edges on GPIO, allowing Timer to elapse only when there is no falling edge on GPIO for defined time. I tried stopping and starting Timer but I dont think that is restarting a Timer. Is there something I am missing? what is a way to restart a timer?

inline void timer_start(uint32_t time_us) {
    GPTimerCC26XX_setLoadValue(hTimer, (timerTick_us * time_us) - 1);
    GPTimerCC26XX_start(hTimer);
}

inline void timer_stop() {
    GPTimerCC26XX_stop(hTimer);
}

void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
    timer_stop();
    DEBUG_TOGGLE;
}


void edgeTriggerCallback(PIN_Handle handle, PIN_Id pinId) {
    timer_stop();
    timer_start(480);
    edge_count++;
}

void timer_init() {
    // Timer config
    GPTimerCC26XX_Params params;
    GPTimerCC26XX_Params_init(&params);
    params.width          = GPT_CONFIG_16BIT;
    params.mode           = GPT_MODE_ONESHOT_UP;
    params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
    hTimer = GPTimerCC26XX_open(CONFIG_TIMER_0, &params);
    if(hTimer == NULL) {
      //Log_error0("Failed to open GPTimer");
    }

    Types_FreqHz  freq;
    BIOS_getCpuFreq(&freq);
    timerTick_us = (freq.lo/1000000);
    GPTimerCC26XX_Value loadVal = timerTick_us * TIME_RESET_MIN; //480us, 1-wire reset

    loadVal = timerTick_us * 480; //480us, 1-wire reset
    GPTimerCC26XX_setLoadValue(hTimer, loadVal);
    GPTimerCC26XX_registerInterrupt(hTimer, &timerCallback, GPT_INT_TIMEOUT);

}

void one_init(one_device * d, const uint8_t count) {
	if (count > 4) {
		return;
	}
	timer_init();
	state = state_idle;

    // Get handle to One Wire Pin
	hOwPin = PIN_open(&hOwPinState, aOwPin);
    if (!hOwPin) {
      // Handle allocation error
    }
    // Edge trigger
    PIN_registerIntCb(hOwPin,  edgeTriggerCallback);
    PIN_setInterrupt(hOwPin,  PIN_ID(ONE_PIN)| PIN_IRQ_NEGEDGE);
}