Exemplo n.º 1
0
/*FUNCTION**********************************************************************
 *
 * Function Name : PIT_DRV_StartTimer
 * Description   : Start timer counting.
 * After calling this function, timers load period value, count down to 0 and
 * then load the respective start value again. Each time a timer reaches 0,
 * it will generate a trigger pulse and set the timeout interrupt flag.
 *
 *END**************************************************************************/
void PIT_DRV_StartTimer(uint32_t instance, uint32_t channel)
{
    assert(instance < PIT_INSTANCE_COUNT);

    PIT_Type * base = g_pitBase[instance];
    PIT_HAL_StartTimer(base, channel);
}
Exemplo n.º 2
0
/*FUNCTION**********************************************************************
 *
 * Function Name : PIT_DRV_InitUs
 * Description   : Initializes two PIT channels to serve as a microseconds unit.
 * This function is in parallel with PIT_DRV_InitChannel, they will overwrite
 * each other. PIT_DRV_Init must be called before calling this function.
 * The microseconds unit will use two chained channels to simulate a lifetime
 * timer, the channel number passed in and the "channel -1" channel will be used.
 * Note:
 * 1. These two channels will be occupied and could not be used with other purposes.
 * 2. The channel number passed in must be greater than 0.

 *END**************************************************************************/
void PIT_DRV_InitUs(uint32_t instance, uint32_t channel)
{
    assert(instance < PIT_INSTANCE_COUNT);
    assert(channel > 0U);

    PIT_Type * base = g_pitBase[instance];
    g_pitUsInstance = instance;
    g_pitUsChannel = channel;

    PIT_HAL_SetTimerChainCmd(base, channel, true);
    PIT_HAL_SetTimerPeriodByCount(base, channel, 0xFFFFFFFFU);
    PIT_HAL_SetTimerPeriodByCount(base, channel - 1U, 0xFFFFFFFFU);

    PIT_HAL_StartTimer(base, channel);
    PIT_HAL_StartTimer(base, channel - 1U);
}
Exemplo n.º 3
0
/*!
 * @cond DOXYGEN_PRIVATE
 *
 * @brief Start pit timer module
 *
 * This function enables the timer and leaves it running, timer is
 * periodically generating interrupts.
 *
 * @param hwtimer[in] Pointer to hwtimer structure.
 *
 * @return kHwtimerSuccess Success.
 *
 * @see HWTIMER_SYS_PitInit
 * @see HWTIMER_SYS_PitDeinit
 * @see HWTIMER_SYS_PitSetDiv
 * @see HWTIMER_SYS_PitStop
 * @see HWTIMER_SYS_PitGet_time
 * @see HWTIMER_SYS_PitIsr
 * @see HWTIMER_SYS_PitIsrShared
 */
static _hwtimer_error_code_t HWTIMER_SYS_PitStart(hwtimer_t * hwtimer)
{
    uint32_t pitChannel;
    uint32_t baseAddr = g_pitBaseAddr[0];
    assert(NULL != hwtimer);

    pitChannel = hwtimer->llContext[0U];
    assert(pitChannel < FSL_FEATURE_PIT_TIMER_COUNT);

    PIT_HAL_StopTimer(baseAddr, pitChannel);
    PIT_HAL_ClearIntFlag(baseAddr, pitChannel);
    PIT_HAL_SetIntCmd(baseAddr, pitChannel, true);
    PIT_HAL_StartTimer(baseAddr, pitChannel);

    return kHwtimerSuccess;
}
Exemplo n.º 4
0
/*!
 * @brief Function ltc_timer_start start pit timer.
 */
static void ltc_timer_start(void)
{
    PIT_HAL_StartTimer(pitBase[0], LTC_TIMER_PIT_CHANNEL);
}