BeagleBone-GPIO
BeagleBone-GPIO copied to clipboard
Analog read needs adc_init call, maybe run ADC in continuous mode? Averaging seems wrong bits?
Changed these lines in gpio.c map[(ADCSTEPCONFIG1-MMAP_OFFSET)/4] = 0x00<<19 | ADC_AVG16<<2 | 0x01;
the averaging is set by bit 2-4 (TRM 12.5.20) not 0-2 and I changed the mode to 01 = SW enabled, continuous. With one-shot the call to analogRead() returns the value from the previous call to analogRead(), in continous mode you get the current value. There may be a better way to do this.
Also there needs to be at least one call to adc_init() in the setup otherwise the above does not get set. I assumed that this line would do it, but it was not calling adc_init(), because I guess the clock was already enabled.
if(map[(CM_WKUP_ADC_TSC_CLKCTRL-MMAP_OFFSET)/4] & CM_WKUP_IDLEST_DISABLED) adc_init();