Wixel SDK
Main Page
Modules
Data Structures
Files
File List
Globals
src
adc
adc.c
1
#include <
cc2511_map.h
>
2
#include <
cc2511_types.h
>
3
#include <
adc.h
>
4
5
uint16
adcRead
(
uint8
channel)
6
{
7
ADCIF = 0;
// Clear the flag.
8
ADCCON3 = 0b10110000 ^ channel;
9
while
(!ADCIF){};
// Wait for the reading to finish.
10
11
if
(ADCH & 0x80)
12
{
13
// Despite what the datasheet says, the result was negative.
14
return
0;
15
}
16
else
17
{
18
// Note: Despite what the datasheet says, bits 2 and 3 of ADCL are not
19
// always zero (they seem to be pretty random). We throw them away
20
// here.
21
return
ADC >> 4;
22
}
23
}
24
25
int16
adcReadDifferential
(
uint8
channel)
26
{
27
ADCIF = 0;
// Clear the flag.
28
ADCCON3 = 0b10110000 ^ channel;
29
while
(!ADCIF){};
// Wait for the reading to finish.
30
31
return
(
int16
)ADC >> 4;
32
}
int16
signed short int16
Definition:
cc2511_types.h:18
cc2511_types.h
adc.h
uint16
unsigned short uint16
Definition:
cc2511_types.h:15
adcReadDifferential
int16 adcReadDifferential(uint8 channel)
Definition:
adc.c:25
uint8
unsigned char uint8
Definition:
cc2511_types.h:9
adcRead
uint16 adcRead(uint8 channel)
Definition:
adc.c:5
cc2511_map.h
Generated on Mon Sep 28 2015 11:52:10 for Wixel SDK by
1.8.10