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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to