Open laurivosandi opened 7 years ago
According to A20 datasheet, GPADC voltage reference is 3.0V.
Tree with backported GPADC v6 patches - https://github.com/plaes/linux/commits/chip-iio-adc
multi_v7_defconfig
/boot/iio-zImage
.bootcmd
to tell u-boot to load our own iio-zImage
: setenv bootcmd 'gpio set PB2; if test -n ${fel_booted} && test -n ${scriptaddr}; then echo (FEL boot); source ${scriptaddr}; fi; mtdparts; ubi part UBI; ubifsmount ubi0:rootfs; ubifsload $fdt_addr_r /boot/sun5i-r8-chip.dtb; ubifsload $kernel_addr_r /boot/iio-zImage; setenv bootargs $bootargs $kernelarg_video; bootz $kernel_addr_r - $fdt_addr_r'
boot
command.cat /sys/devices/platform/soc@01c00000/1c25000.rtp/sun5i-a13-gpadc-iio.0/iio:device0/in_voltage*
Enjoy ;)
X2 and Y2 confirmed working, nice job @plaes Going to add pins to PCB layout
OK, apparently X1 channel is somewhat buggy, and when reading from all 4 channels, only X2 and Y2 are show correct readouts.
Output voltage for channel is: (value / 4096.) * 3.0
(There should be actually a in_voltage_scale
file, but should be fixed in v7 patchset).
Possible fix(es) for channel change stability issue:
@plaes said that X1, X2, Y1 and Y2 pins of CHIP which are intended for touchscreen can be used as general purpose ADC-s. We could expose these pins to be used for eg Sharp GP2Y0A21YK0F distance sensors. It's still not very clear what voltage range is intended for the ADC-s, we might have to add some resistors to compensate, the Sharp sensor outputs voltage range 0-3.2V and requires 5V for power supply.