Exemple #1
0
/**
 * Initialize the low power ticker
 */
void lp_ticker_init(void)
{
    uint32_t lp_ticker_irqn = 0;
    /* Verify if lp_ticker has been already Initialized */
    if (lp_ticker_initialized == 1)
    {
        return;
    }
    lp_ticker_initialized = 1;

    /* Dualtimer Initialize */
    DualTimer_Initialize(DUALTIMER0, lp_ticker_reload);
    /* Dualtimer Enable */
    DualTimer_Enable(DUALTIMER0, DUALTIMER_COUNT_32
            //| DUALTIMER_PERIODIC
            );
    /* DualTimer get IRQn */
    lp_ticker_irqn = DualTimer_GetIRQn(DUALTIMER0);
    /* Enable lp_ticker IRQ */
    NVIC_SetVector((IRQn_Type)lp_ticker_irqn,
                (uint32_t)__lp_ticker_irq_handler);
    NVIC_EnableIRQ((IRQn_Type)lp_ticker_irqn);
}
Exemple #2
0
/**
 * Initialize the low power ticker
 */
void lp_ticker_init(void)
{
    uint32_t lp_ticker_irqn = 0;
    /* Verify if lp_ticker has been already Initialized */
    if (lp_ticker_initialized == 1)
    {
        return;
    }
    lp_ticker_initialized = 1;

    /* Dualtimer Initialize */
    DualTimer_Initialize(DUALTIMER0, lp_ticker_reload);
    /* Dualtimer Enable */
    DualTimer_Enable(DUALTIMER0, DUALTIMER_COUNT_32
            //| DUALTIMER_PERIODIC
            );
    /* DualTimer get IRQn */
    lp_ticker_irqn = DualTimer_GetIRQn(DUALTIMER0);
    /* Enable lp_ticker IRQ */
    NVIC_SetVector((IRQn_Type)lp_ticker_irqn,
                (uint32_t)__lp_ticker_irq_handler);
    NVIC_EnableIRQ((IRQn_Type)lp_ticker_irqn);

    /* DualTimer set interrupt on SINGLETIMER2 */
    DualTimer_SetInterrupt_2(DUALTIMER0, DUALTIMER_DEFAULT_RELOAD,
                DUALTIMER_COUNT_32 | DUALTIMER_PERIODIC);

    /*
     * Set lp_ticker Overflow limit. The lp_ticker overflow limit is required
     * to calculated the return value of the lp_ticker read function in us
     * on 32bit.
     * A 32bit us value cannot be represented directly in the Dual Timer Load
     * register if it is greater than (0xFFFFFFFF ticks)/DUALTIMER_DIVIDER_US.
     */
    lp_ticker_overflow_limit = DualTimer_GetReloadValue(DUALTIMER0,
                SINGLETIMER2);
}