[Gambas-user] Declaring external C libraries
wally
wally at ...2037...
Wed Aug 1 13:12:49 CEST 2012
On Wednesday 01 August 2012 12:28:12 Christer Johansson wrote:
> With some luck and Google I managed to compile a shared version of the
> C library to RaspberryPi I/O by Mike McCauley and it seems to work
> (at least partly) within Gambas3 using the EXTERN function.
>
> I started with the simplest function there was in the library and that
> was pretty strait forward and it works fine in Gambas3 using the
> code below...
>
> ' Declare external function
> Public Extern delay(millis As Integer) In "libbcm2835"
>
> ' Delay 2 sec
> delay(2000)
>
> Next up was to declare an actual I/O function to toggle I/O pins
> and looks like this in the C code (bcm2835.c from the library at
> http://www.open.com.au/mikem/bcm2835/index.html)...
>
> ...
> // Set putput pin
> void bcm2835_gpio_set(uint8_t pin)
> {
> volatile uint32_t* paddr = gpio + BCM2835_GPSET0/4 + pin/32;
> uint8_t shift = pin % 32;
> bcm2835_peri_write(paddr, 1 << shift);
> }
> ...
>
> Since my C knowledge is very limited I wonder what to declare "uint8_t"
> as? According to Google it seems to be the same as unsigned char so I
> tried to use Byte in the declaration but no go, I get segmentation
> fault when calling that function.
>
> Public Extern bcm2835_gpio_set(pin As Byte) In "libbcm2835"
>
> Anyone have any ideas what I am doing wrong?
>
> BTW: Let me know if anyone wants the shared library file and I will
> upload it somewhere, it's compiled in Debain Squeeze.
>
> /CJ
Hi,
your posting is very interesting, thank you
I use GB3 on Opensuse so far and now i'm learning for RaspBerry PI.
1st step was to make a Virtual machine of debian.
2nd is to get Gmabs3 working on it ...
but this failed.
Your information sounds as you successfully run ganbas3 on debian.
How did you install Gambas3 ?
> BTW: Let me know if anyone wants the shared library file and I will
> upload it somewhere, it's compiled in Debain Squeeze.
Yes, i will interested soon i think.
wally
More information about the User
mailing list