-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.c
114 lines (97 loc) · 3.3 KB
/
util.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/************************************************************************/
/* */
/* util.c -- Common Utility Procedures for the PIC32MX */
/* */
/************************************************************************/
/* Author: Michael T. Alexander */
/* Copyright 2009, Digilent Inc. */
/************************************************************************/
/* Module Description: */
/* */
/* This module contains definitions for common utility functions. */
/* */
/************************************************************************/
/* Revision History: */
/* */
/* 04/28/2009 (MichaelA): created */
/* */
/************************************************************************/
/* ------------------------------------------------------------ */
/* Include File Definitions */
/* ------------------------------------------------------------ */
#include "util.h"
/* ------------------------------------------------------------ */
/* Local Type Definitions */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Global Variables */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Local Variables */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Forward Declarations */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Procedure Definitions */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/*** DelayMs
**
** Synopsis:
** DelayMs(tmsDelay)
**
** Parameters:
** tmsDelay - the number of milliseconds you want to delay
**
** Return Values:
** none
**
** Errors:
** none
**
** Description:
** This procedure delays program execution for the specified number
** of miliseconds.
*/
void DelayMs( WORD tmsDelay )
{
while ( 0 < tmsDelay ) {
DelayUs(1000);
tmsDelay--;
}
}
/* ------------------------------------------------------------ */
/*** DelayUs
**
** Synopsis:
** DelayUs(tusDelay)
**
** Parameters:
** tusDelay - the amount of time you wish to delay in microseconds
**
** Return Values:
** none
**
** Errors:
** none
**
** Description:
** This procedure delays program execution for the specified number
** of microseconds. Please note that the minimal delay supported by
** this routine is 3 microseconds.
**
** Note:
** This routine is written with the assumption that the
** system clock is 64 MHz.
*/
void DelayUs( WORD tusDelay )
{
tusDelay -= 2;
while ( 0 < tusDelay )
{
asm volatile("nop");
tusDelay--;
} // end while
} // DelayUs
/*************************************************************************************/