-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAD.cpp
102 lines (88 loc) · 1.89 KB
/
AD.cpp
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
/*
* AD.cpp
*
* Created on: Feb 9, 2017
* Author: nem1
*/
#include "AD.h"
#include <basictypes.h>
#include <sim.h>
AD::AD() {
// TODO Auto-generated constructor stub
}
AD::~AD() {
// TODO Auto-generated destructor stub
}
/* Name:Init
* Description: Initializes the entire register map
* of the AD converters
* Inputs: none
* Outputs: none
*/
void AD::Init(void){
volatile WORD vw;
//See MCF5441X RM Chapter 29
sim2.adc.cr1 = 0;
sim2.adc.cr2 = 0;
sim2.adc.zccr = 0;
sim2.adc.lst1 = 0x3210; //Ch 0....
sim2.adc.lst2 = 0x7654; //ch 7 in result 0..7
sim2.adc.sdis = 0; //All channels enabled
sim2.adc.sr = 0xFFFF;
for (int i = 0; i < 8; i++)
{
vw = sim2.adc.rslt[i];
sim2.adc.ofs[i] = 0;
}
sim2.adc.lsr = 0xFFFF;
sim2.adc.zcsr = 0xFFFF;
sim2.adc.pwr = 0; //Everything is turned on
sim2.adc.cal = 0x0000;
sim2.adc.pwr2 = 0x0005;
sim2.adc.div = 0x505;
sim2.adc.asdiv = 0x13;
}
/* Name:StartAD
* Description: Starts the AD conversion. Only a single sample is
* converted
* Inputs: none
* Outputs: none
*/
void AD::StartAD(void){
// Registers to modify for ex2
// sim2.adc.sr
// sim2.adc.cr1
}
/* Name:StopAD
* Description: Turn off the AD converter
* Inputs: none
* Outputs: none
*/
void AD::StopAD(void)
{
// Registers to modify for ex2
// sim2.adc.cr1 ;
}
/* Name:ADDone
* Description: This method checks the status of
* the AD conversion.
* Inputs: none
* Outputs: Should return a boolean: true if the AD
* conversion is done and false if not done
*/
bool AD::ADDone(void)
{
// Register to check for ex2
// sim2.adc.sr
}
/* Name: GetADResult
* Description: Reads the result of the AD conversion once
* the status register indicates that the conversion is done is ADDone
* Inputs: none
* Outputs: none
*/
WORD AD::GetADResult(int ch) //Get the AD Result
{
// Register to modify for ex2
// sim2.adc.rslt[ch]
}