#include "timer.h"

extern unsigned short AlarmCnt;//Global incremented in AlarmISR

// *****************************************************************************
void msWait (unsigned long ms)
 { 
   if (ms < 1) return; //illegal
 
   //wait 1 ms
   unsigned long j=0;
   AlarmCnt=0;
   
   //while( (AlarmCnt < ms ) && j<N_WAIT){j++;};
   while( (AlarmCnt < ms ) ){j++;};
   //TODO, could add nop() here to save E   
   return;
 } 
// *****************************************************************************
void DelaySecs ( int secs )  //delay for secs seconds
 {
  int i;
  if (secs < 1) return; // ^^^ illegal wait
  for(i=0;i<secs;i++) 
   {msWait(1000);//delay for 1 second
   
   }
  return;
 }  //end DelaySecs 
// *****************************************************************************
void usWait (unsigned long us)
{   unsigned long i=0;
    while ( i < (us*10) )
    {
        i++;
    }
    return;
}
//---------------------------------------------------------------------