151 |
kaklik |
1 |
/*
|
|
|
2 |
Copyright (C) 2004 John Orlando
|
|
|
3 |
|
|
|
4 |
AVRcam: a small real-time image processing engine.
|
|
|
5 |
|
|
|
6 |
This program is free software; you can redistribute it and/or
|
|
|
7 |
modify it under the terms of the GNU General Public
|
|
|
8 |
License as published by the Free Software Foundation; either
|
|
|
9 |
version 2 of the License, or (at your option) any later version.
|
|
|
10 |
|
|
|
11 |
This program is distributed in the hope that it will be useful,
|
|
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
14 |
General Public License for more details.
|
|
|
15 |
|
|
|
16 |
You should have received a copy of the GNU General Public
|
|
|
17 |
License along with this program; if not, write to the Free Software
|
|
|
18 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
19 |
|
|
|
20 |
For more information on the AVRcam, please contact:
|
|
|
21 |
|
|
|
22 |
john@jrobot.net
|
|
|
23 |
|
|
|
24 |
or go to www.jrobot.net for more details regarding the system.
|
|
|
25 |
*/
|
|
|
26 |
/***********************************************************
|
|
|
27 |
Module Name: Utility.c
|
|
|
28 |
Module Date: 04/13/2004
|
|
|
29 |
Module Auth: John Orlando
|
|
|
30 |
|
|
|
31 |
Description: This module provides a basic set of
|
|
|
32 |
general purpose utilities that can be used by any
|
|
|
33 |
module needing them.
|
|
|
34 |
|
|
|
35 |
Revision History:
|
|
|
36 |
Date Rel Ver. Notes
|
|
|
37 |
4/10/2004 0.1 Module created
|
|
|
38 |
6/30/2004 1.0 Initial release for Circuit Cellar
|
|
|
39 |
contest.
|
|
|
40 |
***********************************************************/
|
|
|
41 |
|
|
|
42 |
/* Includes */
|
|
|
43 |
#include "CommonDefs.h"
|
|
|
44 |
|
|
|
45 |
/* Local Variables */
|
|
|
46 |
|
|
|
47 |
/* Local Structures and Typedefs */
|
|
|
48 |
|
|
|
49 |
/* Extern Variables */
|
|
|
50 |
|
|
|
51 |
/* Definitions */
|
|
|
52 |
|
|
|
53 |
/***********************************************************
|
|
|
54 |
Function Name: Utility_delay
|
|
|
55 |
Function Description: This function provides a busy-wait
|
|
|
56 |
delay for a specified number of milliseconds.
|
|
|
57 |
Inputs: numMs - the number of milliseconds to delay
|
|
|
58 |
Outputs: none
|
|
|
59 |
NOTES: The delay_loop_1 and delay_loop_2 functions found
|
|
|
60 |
in avr/delay.h provide accurate 3 and 4 cycle delay loops
|
|
|
61 |
if needed...this isn't really a millisecond, so DON'T
|
|
|
62 |
depend on it for exact timing...
|
|
|
63 |
***********************************************************/
|
|
|
64 |
void Utility_delay(unsigned short numMs)
|
|
|
65 |
{
|
|
|
66 |
volatile unsigned short i=0,j=0;
|
|
|
67 |
#ifndef SIMULATION
|
|
|
68 |
for (i=0; i<numMs; i++)
|
|
|
69 |
{
|
|
|
70 |
for (j=0; j<1000; j++)
|
|
|
71 |
{
|
|
|
72 |
asm volatile("nop"::);
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
#endif
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
|