![]() |
C GPIO - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4) +--- Forum: Pine A64 Hardware, Accessories and POT (https://forum.pine64.org/forumdisplay.php?fid=32) +---- Forum: Pi2, Euler and Exp GPIO Ports (https://forum.pine64.org/forumdisplay.php?fid=34) +---- Thread: C GPIO (/showthread.php?tid=1327) |
C GPIO - igna09 - 06-10-2016 Hi guys, i've found some materials about sunxi c gpio controlling at these link: http://docs.cubieboard.org/tutorials/common/gpio_on_lubuntu http://linux-sunxi.org/GPIO#C.2FC.2B.2B_program. When i try to run it return me segmentation fault. Is a problem of my pine or isn't good for all pine64? RE: C GPIO - martinayotte - 06-10-2016 I've took a quick look and it seems to fail in the mmap initialization providing wrong address used in setcfg(). In the mean time I will figured out, maybe you should look at https://github.com/swkim01/RPi.GPIO-PineA64 Although it is for python, the python is only a wrapper around their own c_gpio, so it can be used in plain C too. RE: C GPIO - igna09 - 06-10-2016 Thank you, yes i arleady use the python code but i was searching for a c code because i was thinking that it was faster. RE: C GPIO - martinayotte - 06-10-2016 Ok ! I found the issue and got it working : like many other libs, a 32bits pointer used in 64bits environment ! You need to change the "unsigned int SUNXI_PIO_BASE" for "unsigned long SUNXI_PIO_BASE" in both gpio_lib.c and gpio_lib.h (BTW, about speed of python vs C/C++, that all depends of you apps. Of course, if you wish to toggle gpio at maximum speed, C/C++ could do better.) RE: C GPIO - igna09 - 06-11-2016 Thank you, it has worked!! RE: C GPIO - martind1983 - 08-24-2016 (06-10-2016, 03:10 PM)martinayotte Wrote: Ok ! I found the issue and got it working : like many other libs, a 32bits pointer used in 64bits environment ! RE: C GPIO - martinayotte - 08-25-2016 The PB0/PB1 are used by the UART by default. If you wish to use them as plain GPIOs, you first need to disable the UART is the DTS. RE: C GPIO - martind1983 - 08-25-2016 (08-25-2016, 07:35 AM)martinayotte Wrote: The PB0/PB1 are used by the UART by default. Thank you very much man. One more question. All the pins led out on the board and which are also dedicated to some peripherals I have to first turn off special functionality before using them as normal GPIO? Thanks. Martin ![]() RE: C GPIO - MarkHaysHarris777 - 08-25-2016 (08-25-2016, 08:24 AM)martind1983 Wrote: One more question. All the pins led out on the board and which are also dedicated to some peripherals I have to first turn off special functionality before using them as normal GPIO? No, not necessarily. ... as long as the pins (channels) are not actually being used 'now' you can use them for what-ever you want. But, that's a big if. If a driver is running that uses the channel, you will need to stop and unload the driver... but, you don't necessarily have to edit the dtb|dts in order to do this. That said, it is best to use GPIO pins that are 'free' first. On the diagram , the green and then maybe the blue. The main exception right now is the pin(7) GPIO04 which is s-pwm and used for the LCD backlight... because it is on a pwm channel even though you can turn it on and off (if you have the correct base address, or use sysfs) it still doesn't work right, because it is 'very' dim ... and, it has a pwm signal on it. In this case you must not only edit the dtb|dts, but also unassociate the pin, and you need to stop the driver and unload it (a lot of work, just use another GPIO pin). RE: C GPIO - martind1983 - 08-29-2016 (08-25-2016, 11:17 AM)MarkHaysHarris777 Wrote:(08-25-2016, 08:24 AM)martind1983 Wrote: Hi Mark. |