-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha2d_sub.cpp
More file actions
43 lines (34 loc) · 827 Bytes
/
a2d_sub.cpp
File metadata and controls
43 lines (34 loc) · 827 Bytes
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
#include "predef.h"
#include <basictypes.h>
#include <a2d.h>
#include <Pins.h>
#include "filereporter.h"
REPORT_FILE;
void Inita2DSub()
{ // Configure the A2D pins as analog inputs
Pins[11].function( PIN11_AN2 );
Pins[12].function( PIN12_AN1 );
Pins[13].function( PIN13_AN0 );
Pins[14].function( PIN14_AN3 );
Pins[15].function( PIN15_AN7 );
Pins[16].function( PIN16_AN6 );
Pins[17].function( PIN17_AN5 );
Pins[18].function( PIN18_AN4 );
/*
Enable the A2D. The A2D subsystem will run in the background
doing samples at 98.742Khz per channel. This is all done in
hardware with no CPU overhead.
*/
EnableAD();
}
int ReadA2D(int ch)
{
return ( ReadA2DResult( ch ) >> 3);
}
int ReadBVx1000()
{
//7.66v =2972
//6.46= 2510
//8.09 =3146
return (ReadA2D(0)*168703)>>16;
}