projetoarduino Posted December 1, 2017 Posted December 1, 2017 Hello. I am trying read to directly access GPIO PL11 (IRTX) from nano Pi DUO without success, other pins with this same code work very well. Via Userspace work well echo "363" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio363/direction cat /sys/class/gpio/gpio363/value Then i receive 0 or 1 (This proves that hardware is ok.) My example code To compile gcc gpio_lib.c simple_gpio.c -o blink #include <stdlib.h> #include <stdio.h> #include "gpio_lib.h" int main() { sunxi_gpio_init(); //gpio_PA3 sunxi_gpio_set_cfgpin(SUNXI_GPA(4), SUNXI_GPIO_OUTPUT); sunxi_gpio_set_cfgpin(SUNXI_GPL(11), SUNXI_GPIO_INPUT); while(1) { unsigned int b = sunxi_gpio_input(SUNXI_GPL(11)); printf("%x\n", b); sunxi_gpio_output(SUNXI_GPA(4), 1); sleep(1); sunxi_gpio_output(SUNXI_GPA(4), 0); sleep(1); } return 0; } gpio_lib.c gpio_lib.h simple_gpio.c
Larry Bank Posted December 1, 2017 Posted December 1, 2017 Not sure where you got that code from, but my ArmbianIO library seems to work correctly. Make sure the pin isn't enabled as a tty or the system will keep you from using the pin as a GPIO.
Recommended Posts