-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathnull_sensor.c
52 lines (41 loc) · 1.24 KB
/
null_sensor.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
/* See license.txt for license information. */
#include "mywisp.h"
#if (ACTIVE_SENSOR == SENSOR_NULL)
#include "dlwisp41.h"
#include "rfid.h"
#include "null_sensor.h"
void init_sensor()
{
return;
}
void read_sensor(unsigned char volatile *target)
{
// slow down clock
BCSCTL1 = XT2OFF + RSEL1; // select internal resistor (still has effect when DCOR=1)
DCOCTL = DCO1+DCO0; // set DCO step.
if(!is_power_good())
sleep();
P1OUT &= ~RX_EN_PIN; // turn off comparator
unsigned int k = 0;
#define USE_SENSOR_COUNTER 1
#if USE_SENSOR_COUNTER
*(target + k + 1 ) = __swap_bytes(sensor_counter);
*(target + k) = sensor_counter;
if ( sensor_counter == 0xffff ) sensor_counter = 0; else sensor_counter++;
#else
*(target + k + 1 ) = 0x03;
// grab msb bits and store it
*(target + k) = 0x02;
#endif
return;
}
// used to sleep while taking adc, this wakes us
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
ADC10CTL0 &= ~ENC; // make sure this is off otherwise settings are locked.
ADC10CTL0 &= ~(ADC10IFG | ADC10IE);
LPM4_EXIT;
return;
}
#endif // (ACTIVE_SENSOR == SENSOR_NULL)