Restore accidentally deleted code in 4e61155
This commit is contained in:
parent
6c94180d77
commit
92c3842ca9
@ -5,7 +5,7 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
volatile uint32_t trig_counter;
|
volatile uint32_t trig_counter;
|
||||||
uint32_t no_of_ticks;
|
volatile uint32_t no_of_ticks;
|
||||||
|
|
||||||
void init_sonar(void)
|
void init_sonar(void)
|
||||||
{
|
{
|
||||||
@ -36,15 +36,19 @@ uint16_t read_sonar(void)
|
|||||||
sei();
|
sei();
|
||||||
// Count cycles until ECHO goes low
|
// Count cycles until ECHO goes low
|
||||||
while (CHK(ECHO_PIN, ECHO_BIT)) {
|
while (CHK(ECHO_PIN, ECHO_BIT)) {
|
||||||
++no_of_ticks;
|
if (no_of_ticks + TCNT1 > SONAR_TIMEOUT) {
|
||||||
if (no_of_ticks > SONAR_TIMEOUT) {
|
|
||||||
return SONAR_ERROR;
|
return SONAR_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TCCR1B = 0x00;
|
TCCR1B = 0x00;
|
||||||
cli();
|
cli();
|
||||||
|
|
||||||
|
no_of_ticks += TCNT1;
|
||||||
|
|
||||||
return (uint16_t)(no_of_ticks / (CYCLES_PER_US * 58));
|
return (uint16_t)(no_of_ticks / (CYCLES_PER_US * 58));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISR(TIMER1_OVF_vect)
|
||||||
|
{
|
||||||
|
no_of_ticks += TIMER_MAX;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user