Revision 807483bf
ID | 807483bfcb4c1490e8ef4794cf6c19b93211894a |
Fixed range sensor code to support 2
Also, tested (with only one sensor) and it seemed to work adequately.
scout_avr/src/range.cpp | ||
---|---|---|
14 | 14 |
* 37.5ms * 8 MHz / 8 prescaler = 37500 max wait |
15 | 15 |
*/ |
16 | 16 |
|
17 |
// so that we can test on a 328 |
|
18 |
#if defined(__AVR_ATmega128RFA1__) |
|
17 |
// so that we can test on a 328 or the stk600
|
|
18 |
#if defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega2560__)
|
|
19 | 19 |
# define read_INT0 (PIND & _BV(PD0)) |
20 | 20 |
# define read_INT1 (PIND & _BV(PD1)) |
21 | 21 |
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) |
... | ... | |
32 | 32 |
|
33 | 33 |
static void on_edge(int which) |
34 | 34 |
{ |
35 |
unsigned char int_high; |
|
35 | 36 |
unsigned int time = TCNT1; |
36 |
if (read_INT0) |
|
37 |
|
|
38 |
if (which) |
|
39 |
{ |
|
40 |
int_high = read_INT1; |
|
41 |
} |
|
42 |
else |
|
43 |
{ |
|
44 |
int_high = read_INT0; |
|
45 |
} |
|
46 |
|
|
47 |
if (int_high) |
|
37 | 48 |
{ |
38 | 49 |
range[which].start = time; |
39 | 50 |
} |
Also available in: Unified diff