File: mh-utils.c

package info (click to toggle)
kuttypy 2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,896 kB
  • sloc: python: 58,651; javascript: 14,686; xml: 5,767; ansic: 2,716; makefile: 453; asm: 254; sh: 48
file content (39 lines) | stat: -rw-r--r-- 939 bytes parent folder | download | duplicates (3)
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--);}
    }