sumochip
sumochip copied to clipboard
Add infrared distance sensor support
@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.
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
HOWTO
- Fetch chip-iio-adc branch and compile new kernel using
multi_v7_defconfig
- Copy newly compiled kernel to CHIP as
/boot/iio-zImage
. - Attach UART-Serial and boot into u-boot shell
- Override
bootcmd
to tell u-boot to load our owniio-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 using
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:
- http://code.bulix.org/29344w-107051
- http://code.bulix.org/q71nva-107053