#include "common.h"
#include <string.h>

void wait_10n4clk(unsigned char i){
  while(i--);
/*_asm
start_wait_10n4:
  mov r2,dpl            ; 2clk
  mov ar3,r2            ; 2clk
  dec r2                ; 1clk
  mov a,r3              ; 1clk
  jnz start_wait_10n4   ; 2/4clk
_endasm;*/
  //ret                 ; 6clk
}

/**
 * Delay function with declared wait time in microseconds
 * 
 * @param count time in ns
 */
void wait_us(unsigned int count){
  while(count--) wait_10n4clk(4); // (2+2+1+1+4)*4 - (4-2) + 6 = 44clk
}

/**
 * Delay function with declared wait time in milliseconds
 * 
 * @param count - time in ms
 */
void wait_ms(unsigned int count){
  int i;
  for(i = 0; i < count; i++) wait_us(1000);
}
