forked from DanielBretts/Spaceship-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.c
73 lines (66 loc) · 2.07 KB
/
utils.c
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* ************************************************************************** */
/** Descriptive File Name
@Company
Digilent
@File Name
utils.c
@Description
This library implements the delay functionality used in other libraries.
The delay is implemented using loop, so the delay time is not exact.
For exact timing use timers.
Include the file in the project, together with utils.h, when this library is needed
*/
/* ************************************************************************** */
/* ************************************************************************** */
/* ************************************************************************** */
/* Section: Included Files */
/* ************************************************************************** */
#include <xc.h>
#include <sys/attribs.h>
#include "config.h"
#include "utils.h"
/* ************************************************************************** */
/* ------------------------------------------------------------ */
/*** Delay100Us
**
** Synopsis:
** Delay100Us(100)
**
** Parameters:
** t100usDelay - the amount of time you wish to delay in hundreds of microseconds
**
** Return Values:
** none
**
** Errors:
** none
**
** Description:
** This procedure delays program execution for the specified number
** of microseconds. This delay is not precise.
**
** Note:
** This routine is written with the assumption that the
** system clock is 40 MHz.
*/
void DelayAprox10Us( unsigned int t100usDelay )
{
int j;
while ( 0 < t100usDelay )
{
t100usDelay--;
j = 14;
while ( 0 < j )
{
j--;
} // end while
asm volatile("nop"); // do nothing
asm volatile("nop"); // do nothing
asm volatile("nop"); // do nothing
asm volatile("nop"); // do nothing
asm volatile("nop"); // do nothing
} // end while
}
/* *****************************************************************************
End of File
*/