Using GPIO and FOXBONE syscalls
Syscalls are used to allow userspace apps to access kernel functions. FS and Net access use this for example. With the Phrozen SDK patch
new syscalls for GPIO and VHDL were introduced
Using GPIO syscalls
After installing a patched SDK you will have a folder apps/gpio_test.
It contains the following application, which toggles PA0, PB7, PG8 and PG24 from 0 to 1 and back.
It also reads back in the state of PG2. This is not done using the GPIO driver, but a using direct syscall access.
This is much faster.
@source='gpiosyscalls.c'
In order to use the syscalls in your custom app you will need to include #include which makes the following functions and defines available :
@source='gpiosyscalls.h'
Using FOXBONE syscalls
After installing a patched SDK you will have a folder apps/vhdl_test. It contains the following application, which writes and reads some foxbone registers. This is much faster than using the /dev/foxbone driver.
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/ioctl.h"
#include "fcntl.h"
#include "time.h"
#include "string.h"
#include
int main(int argc, char **argv) {
printf("%d\n", foxboneread(0x04));
foxbonewrite(0x13, 0x0);
foxbonewrite(0x13, 0x111);
printf("%d\n", foxboneread(0x13));
unsigned short int buffer[16];
foxbonebulkread(0x13, buffer, 16);
unsigned int i = 0;
for(i = 0; i < 16; i++){
printf(" -> %d\n", buffer[i]);
};
for(i = 0; i < 16; i++){
buffer[i] = i%2;
};
foxbonewrite(0x13, 0x0);
foxbonebulkwrite(0x13, buffer, 16);
return(0);
} // end main()