Subversion Repositories svnkaklik

Rev

Rev 409 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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