1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
/* utils.c -- various utilities for microHOPE
Copyright (C) 2008 Ajith Kumar, Inter-University Accelerator Centre,
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
*/
#include <avr/io.h>
void delay_us (uint16_t k) // k* 10 usecs delay, valid only for 8MHz clock
{
while (k--) {asm("nop");}
}
void delay_10us (uint16_t k) // k* 10 usecs delay, valid only for 8MHz clock
{
volatile uint16_t x;
while (k--) {x=5; while (x--);}
}
void delay_100us (uint16_t k) // k* 100 usecs delay, valid only for 8MHz clock
{
volatile uint16_t x;
while (k--) {x=52; while (x--);}
}
void delay_ms (uint16_t k) // idle for k milliseconds, only for 8MHz clock
{
volatile uint16_t x;
while(k--) {x=532; while (x--);}
}
|