drivers/c/timers.c
//*****************************************************************************
// Waits for 'ticks' number of clock cycles and then returns.
//
//The function returns true if the base_addr is a valid general purpose timer
//*****************************************************************************
Waits for 'ticks' number of clock cycles and then returns.
The function returns true if the base_addr is a valid general purpose timer
Waits for ' ticks ' number of clock cycles and then returns . The function returns true if the base_addr is a valid general purpose timer
bool gp_timer_wait(uint32_t base_addr, uint32_t ticks)
{
  TIMER0_Type *gp_timer;
  if ( ! verify_base_addr(base_addr) )
  {
    return false;
  }
  gp_timer = (TIMER0_Type *)base_addr;
	gp_timer->CTL &= ~(TIMER_CTL_TAEN | TIMER_CTL_TBEN); 
	gp_timer->TAILR = ticks;
	gp_timer->ICR |= (TIMER_ICR_TATOCINT);
	gp_timer->CTL |= (TIMER_CTL_TAEN);
  while (!(gp_timer->RIS & TIMER_RIS_TATORIS)) {;}
  return true;
}
bool gp_timer_wait ( uint32_t base_addr , uint32_t ticks ) { TIMER0_Type * gp_timer ; if ( ! verify_base_addr ( base_addr ) ) { return false ; } gp_timer = ( TIMER0_Type * ) base_addr ; gp_timer -> CTL &= ~ ( TIMER_CTL_TAEN | TIMER_CTL_TBEN ) ; gp_timer -> TAILR = ticks ; gp_timer -> ICR |= ( TIMER_ICR_TATOCINT ) ; gp_timer -> CTL |= ( TIMER_CTL_TAEN ) ; while ( ! ( gp_timer -> RIS & TIMER_RIS_TATORIS ) ) { ; } return true ; }
Waits for 'ticks' number of clock cycles and then returns.
Waits for ' ticks ' number of clock cycles and then returns .
// Verify the base address. // Type cast the base address to a TIMER0_Type struct //*********************     // ADD CODE //*********************