RPi.GPIO with C
#1
Related to this thread http://forum.pine64.org/showthread.php?tid=723 I am trying to build and use the functions in C. I copied all files from RPi.GPIO-PineA64/source and I made these files


test.c
Code:
#include "c_gpio.h"
#include "test.h"

int main(void)
{
   printf("testfunktoin()=%i\n", testfunktion());
   
   setup();
   
   return 0;
}
makefile
Code:
HEADERS = test.h c_gpio.h
OBJECTS = test.o c_gpio.o

default: test

%.o: %.c $(HEADERS)
    gcc -c $< -o $@

test: $(OBJECTS)
    gcc $(OBJECTS) -o $@

clean:
    -rm -f $(OBJECTS)
    -rm -f test
test.h
Code:
int testfunktion(void)
{
   return 44;
}


And I get this compile error:
Code:
$ make
gcc test.o c_gpio.o -o test
c_gpio.o: In function `setup':
c_gpio.c:(.text+0x40): undefined reference to `pinea64_found'
c_gpio.c:(.text+0x44): undefined reference to `pinea64_found'
c_gpio.c:(.text+0x2cc): undefined reference to `pinea64_found'
c_gpio.c:(.text+0x2d0): undefined reference to `pinea64_found'
c_gpio.o: In function `clear_event_detect':
c_gpio.c:(.text+0x378): undefined reference to `pinea64_found'
c_gpio.o:c_gpio.c:(.text+0x37c): more undefined references to `pinea64_found' follow
collect2: error: ld returned 1 exit status
makefile:12: recipe for target 'test' failed
make: *** [test] Error 1
  Reply
#2
Wolfenstein, I am so pleased to see you working on this.

... this is a very good step towards porting pigpio from Raspberry PI over to PineA64. Also, the more you understand about the RPi.GPIO-PinA64 source, the better we'll be positioned to implement a working i2S SPI i2c, and soft PWM.

Keep at it... I will also look at what you are proposing this next week--- keep working on it !

As long as we're sharing failures, i opened up the device-tree-compiler dtc and removed all references to spwm PL10 to see if by disabling that in the dtb we could reclaim pin(7) GPIO04. No luck so far... i removed the references and recompiled the dtb (with appropriate renaming) but there is a driver in there that I need to disable too... so I still don't have GPII04 working yet...

Stay in touch on this thread. tnx
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#3
The "pinea64_found" variable is located in RPi.GPIO-PineA64-master/source/cpuinfo.c and initialized to 1 if the identified board is a PineA64.
You can bypass that code by simply adding a global variable "int pinea64_found = 1;" somewhere in your code.
  Reply
#4
(08-14-2016, 02:35 PM)MarkHaysHarris777 Wrote: Wolfenstein, I am so pleased to see you working on this.

... this is a very good step towards porting pigpio from Raspberry PI over to PineA64.  Also, the more you understand about the RPi.GPIO-PinA64 source, the better we'll be positioned to implement a working i2S SPI i2c, and soft PWM.

Keep at it... I will also look at what you are proposing this next week--- keep working on it !

As long as we're sharing failures, i opened up the device-tree-compiler dtc and removed all references to spwm PL10 to see if by disabling that in the dtb we could reclaim pin(7) GPIO04.  No luck so far... i removed the references and recompiled the dtb (with appropriate renaming) but there is a driver in there that I need to disable too... so I still don't have GPII04 working yet...

Stay in touch on this thread.   tnx

Could it be that the reason for the PL10 («GPIO4» on the PI-2-Bus pin #7) is in a different Peripheral area. I went in and tried the code discussed in the thread «C GPIO» http://forum.pine64.org/showthread.php?tid=1327 and noticed that while it worked as expected for all the ports in the PB-PH series, the PL ones wouldn't move.

The reason that I found for that is that PB thru PH are all in the registers beginning at 0x01c20800 (defined as the SW_PORTC_IO_BASE) while the PL ports are in a similar data structure in a different location, at 0x01f02c00.

I found those addresses in the sections 3.21.1 and 3.22.1 in the Allwinner_A64_User_Manual_V1.0.pdf

When I re-used the code with this alternate IO base address, I could get the test-program (flash an LED on PL10) to work as
expected. Have similar problems shown up with PL9 and PL8 (PI-2-Bus pins 27 and 28)?

It might be something else, but having just seen a similar-looking problem here, I thought maybe this is the solution.
  Reply
#5
Nice work. That explains why just disabling the PL10 pin in the dts does not allow the pin to work as a PI bus IN|OUT pin, because the base register is different (very nice).
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to use dts or other setup to declare gpio pin Interrupt (e.g. a button)? dkebler 2 4,000 11-26-2024, 09:58 AM
Last Post: disesob294
  RPi.GPIO python module for Pine A64/A64+ aquilegia 98 148,131 10-26-2024, 07:17 AM
Last Post: Garesdq1d
  fm transmitter with gpio weasel18 2 5,473 09-10-2019, 04:28 AM
Last Post: desai_amogh
Lightbulb Sample GPIO codes highlighting RPi.GPIO-PineA64 and the PI bus MarkHaysHarris777 6 12,382 06-07-2019, 12:37 AM
Last Post: tllim
Star GPIO, SPI and I2C C++ Lib databit 7 12,457 02-04-2019, 05:45 AM
Last Post: Jeff R
Information Howto: Controlling Pine64 GPIO via the filesystem (sysfs) on linux pfeerick 4 12,778 01-24-2019, 03:36 AM
Last Post: Fifth
  GPIO and SPI SamR1 20 35,064 03-15-2018, 10:32 AM
Last Post: jomoengineer
Question GPIO shockr 7 16,298 03-11-2018, 01:52 AM
Last Post: jomoengineer
  Read GPIO problem shworker 14 23,794 08-17-2017, 01:21 PM
Last Post: martinayotte
  GPIO fiq capability joseph 3 6,774 11-10-2016, 06:07 PM
Last Post: joseph

Forum Jump:


Users browsing this thread: 2 Guest(s)