mirror of https://github.com/ArduPilot/ardupilot
uncrustify libraries/AP_AnalogSource/AP_AnalogSource_Arduino.cpp
This commit is contained in:
parent
5e7867f972
commit
bf75296577
|
@ -16,8 +16,8 @@ static uint8_t num_pins_watched;
|
||||||
static uint8_t next_pin_index;
|
static uint8_t next_pin_index;
|
||||||
static uint8_t next_pin_count;
|
static uint8_t next_pin_count;
|
||||||
static volatile struct {
|
static volatile struct {
|
||||||
uint8_t pin;
|
uint8_t pin;
|
||||||
uint8_t sum_count;
|
uint8_t sum_count;
|
||||||
uint16_t output;
|
uint16_t output;
|
||||||
uint16_t sum;
|
uint16_t sum;
|
||||||
} pins[MAX_PIN_SOURCES];
|
} pins[MAX_PIN_SOURCES];
|
||||||
|
@ -27,7 +27,7 @@ static volatile struct {
|
||||||
// each conversion takes about 125 microseconds
|
// each conversion takes about 125 microseconds
|
||||||
static void adc_timer(uint32_t t)
|
static void adc_timer(uint32_t t)
|
||||||
{
|
{
|
||||||
if (bit_is_set(ADCSRA, ADSC) || num_pins_watched == 0) {
|
if (bit_is_set(ADCSRA, ADSC) || num_pins_watched == 0) {
|
||||||
// conversion is still running. This should be
|
// conversion is still running. This should be
|
||||||
// very rare, as we are called at 1kHz
|
// very rare, as we are called at 1kHz
|
||||||
return;
|
return;
|
||||||
|
@ -69,7 +69,7 @@ static void adc_timer(uint32_t t)
|
||||||
ADMUX = _BV(REFS0) | (pin & 0x07);
|
ADMUX = _BV(REFS0) | (pin & 0x07);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the next conversion
|
// start the next conversion
|
||||||
ADCSRA |= _BV(ADSC);
|
ADCSRA |= _BV(ADSC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void AP_AnalogSource_Arduino::assign_pin_index(uint8_t pin)
|
||||||
num_pins_watched++;
|
num_pins_watched++;
|
||||||
if (num_pins_watched == 1) {
|
if (num_pins_watched == 1) {
|
||||||
// enable the ADC
|
// enable the ADC
|
||||||
PRR0 &= ~_BV(PRADC);
|
PRR0 &= ~_BV(PRADC);
|
||||||
ADCSRA |= _BV(ADEN);
|
ADCSRA |= _BV(ADEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue