//****************************************************************************
//
//! The delay function uses timer to implement the delay time in milliseconds
//!
//! \param time in millisecond
//
//!  \return void
//****************************************************************************
static void delay(int time_ms)
{
    // Initialize Timer 0B as one-shot down counter.
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_TIMERA0);
    MAP_TimerConfigure(TIMERA0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT);
    MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_B, PRESCALE);
    //Load the value in milisecond
    MAP_TimerLoadSet(TIMERA0_BASE, TIMER_B, MILLISECONDS_TO_TICKS(time_ms));
    // Enable the timer
    MAP_TimerEnable(TIMERA0_BASE, TIMER_B);
    //Stall during debug
    MAP_TimerControlStall(TIMERA0_BASE, TIMER_B, 1);
    // Enable interrupt upon Time-out
    MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
    // Clear Interrupt Flag
    MAP_TimerIntClear(TIMERA0_BASE, MAP_TimerIntStatus(TIMERA0_BASE, true));
    //Wait until timer time-out
    while (MAP_TimerIntStatus(TIMERA0_BASE, true) != TIMER_TIMB_TIMEOUT){}
    //Disable the timer
    MAP_TimerDisable(TIMERA0_BASE, TIMER_B);
    //Disable Interrupt
    MAP_TimerIntDisable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
    MAP_TimerIntUnregister(TIMERA0_BASE, TIMER_B);
}
예제 #2
0
//*****************************************************************************
//
//!    De-Initialize the timer
//!
//! \param uiGPTBaseAddr
//! \param ulTimer
//!
//! This function 
//!        1. disable the timer interrupts
//!        2. unregister the timer interrupt
//!
//!    \return None.
//
//*****************************************************************************
void Timer_IF_DeInit(unsigned long ulBase,unsigned long ulTimer)
{
    //
    // Disable the timer interrupt
    //
    MAP_TimerIntDisable(ulBase,TIMER_TIMA_TIMEOUT|TIMER_TIMB_TIMEOUT);
    //
    // Unregister the timer interrupt
    //
    MAP_TimerIntUnregister(ulBase,ulTimer);
}