From 7c8addc5c5f811eefbed901fcd182a3012e2e75b Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 2 Nov 2016 17:30:34 -0400 Subject: gpio: Merge gpio_adc_sample_time() into gpio_adc_sample() Return the number of clock ticks to wait directly from gpio_adc_sample(). This simplifies the ADC interface. Signed-off-by: Kevin O'Connor --- src/avr/gpio.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/avr/gpio.c') diff --git a/src/avr/gpio.c b/src/avr/gpio.c index 9919cdd1..3df6e9e8 100644 --- a/src/avr/gpio.c +++ b/src/avr/gpio.c @@ -282,27 +282,24 @@ gpio_adc_setup(uint8_t pin) shutdown("Not a valid ADC pin"); } -uint32_t -gpio_adc_sample_time(void) -{ - return (13 + 1) * 128 + 200; -} - enum { ADC_DUMMY=0xff }; static uint8_t last_analog_read = ADC_DUMMY; -uint8_t +// Try to sample a value. Returns zero if sample ready, otherwise +// returns the number of clock ticks the caller should wait before +// retrying this function. +uint32_t gpio_adc_sample(struct gpio_adc g) { if (ADCSRA & (1<