Exemplo n.º 1
0
/** Set interrupt for specified timestamp
 *
 * @param timestamp The time in ticks to be set
 */
void lp_ticker_set_interrupt(timestamp_t timestamp)
{
    if (timestamp == 0) {
        timestamp = 1;
    }

    GPT_StopTimer(GPT2);
    GPT_SetOutputCompareValue(GPT2, kGPT_OutputCompare_Channel1, timestamp);
    GPT_ClearStatusFlags(GPT2, kGPT_OutputCompare1Flag);
    GPT_EnableInterrupts(GPT2, kGPT_OutputCompare1InterruptEnable);
    GPT_StartTimer(GPT2);
}
Exemplo n.º 2
0
static rt_err_t rt1052_hwtimer_start(rt_hwtimer_t *timer, rt_uint32_t cnt, rt_hwtimer_mode_t mode)
{
    GPT_Type *hwtimer_dev;
    hwtimer_dev = (GPT_Type *)timer->parent.user_data;

    RT_ASSERT(timer != RT_NULL);

    hwtimer_dev->CR |= (mode == HWTIMER_MODE_PERIOD) ? GPT_CR_FRR_MASK : 0U;

    GPT_SetOutputCompareValue(hwtimer_dev, kGPT_OutputCompare_Channel1, cnt);

    GPT_EnableInterrupts(hwtimer_dev, kGPT_OutputCompare1InterruptEnable);

    NVIC_Configuration();

    GPT_StartTimer(hwtimer_dev);

    return RT_EOK;
}
Exemplo n.º 3
0
/** Initialize the low power ticker
 *
 */
void lp_ticker_init(void)
{
    gpt_config_t gptConfig;

    if (!lp_ticker_inited) {
        /* Setup GPT */
        GPT_GetDefaultConfig(&gptConfig);
        /* Use 32kHz drive */
        gptConfig.clockSource = kGPT_ClockSource_LowFreq;
        gptConfig.enableFreeRun = true;
        gptConfig.enableMode = false;

        GPT_Init(GPT2, &gptConfig);
        GPT_EnableInterrupts(GPT2, kGPT_OutputCompare1InterruptEnable);
        NVIC_ClearPendingIRQ(GPT2_IRQn);
        NVIC_SetVector(GPT2_IRQn, (uint32_t)gpt_isr);
        EnableIRQ(GPT2_IRQn);
        GPT_StartTimer(GPT2);
        lp_ticker_inited = true;
    } else {
        GPT_DisableInterrupts(GPT2, kGPT_OutputCompare1InterruptEnable);
    }
}