Debian Codegraph @

kpy/mh-utils.c

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