-
Notifications
You must be signed in to change notification settings - Fork 0
/
delay.c
112 lines (93 loc) · 3.05 KB
/
delay.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
/************************************************************************/
/* */
/* delay.c -- Time Delay Functions */
/* */
/************************************************************************/
/* Author: Gene Apperson */
/* Convert to StellarisWare - David Glover 04/09/2014 */
/* Copyright 2011, Digilent Inc. */
/************************************************************************/
/* Module Description: */
/* */
/* */
/************************************************************************/
/* Revision History: */
/* */
/* 04/29/2011(GeneA): created
/ 07/09/2014(DavidG): Ported to StellarisWare.
/ Replaced timer implementation with
/ SysCtrlDelay() call.
/ */
/* */
/************************************************************************/
/* ------------------------------------------------------------ */
/* Include File Definitions */
/* ------------------------------------------------------------ */
#include <stdint.h>
#include <stdbool.h>
//#include <p32xxxx.h>
//#include <plib.h>
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "delay.h"
/* ------------------------------------------------------------ */
/* Local Type Definitions */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Global Variables */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Local Variables */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Forward Declarations */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* Procedure Definitions */
/* ------------------------------------------------------------ */
/*** DelayInit
**
** Parameters:
** none
**
** Return Value:
** none
**
** Errors:
** none
**
** Description:
** No initialization needed for Stellarisware SysCtlDelay()
*/
void
DelayInit()
{
//unsigned int tcfg;
/* Configure Timer 1. This sets it up to count a 10Mhz.
*/
//tcfg = T1_ON|T1_IDLE_CON|T1_SOURCE_INT|T1_PS_1_8|T1_GATE_OFF|T1_SYNC_EXT_OFF;
//OpenTimer1(tcfg, 0xFFFF);
}
/* ------------------------------------------------------------ */
/*** DelayMs
**
** Parameters:
** cms - number of milliseconds to delay
**
** Return Value:
** none
**
** Errors:
** none
**
** Description:
** Delay the requested number of milliseconds. Uses SysCtlDelay().
*/
void
DelayMs(int cms)
{
unsigned long ulCount;
// number of delay loops per ms = frequency / (1000 * 3)
ulCount = (ROM_SysCtlClockGet() / (1000 * 3)) * cms;
ROM_SysCtlDelay(ulCount);
}