I want switch on a LED and i decided to use libsoc.
I installed the libsoc in this way…
git clone https://github.com/jackmitch/libsoc.git libsoc.git
cd libsoc.git
autoreconf -i
./configure --enable-board=dragonboard410c
make
make install
and after i compiled the following code:
/************************************************************/
/* */
/* Written with libsoc C library */
/* */
/* */
/* You can do interrupt programming with this library */
/* */
/************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "libsoc_gpio.h"
#include "libsoc_debug.h"
#include "libsoc_board.h"
unsigned int GPIO_LED;
unsigned int GPIO_BUTTON;
int last_touch;
int led_state = 0;
int running = 1;
int c=0;
/* This bit of code below makes this example work on all */
/* 96Boards, Though you could just call this in main */
__attribute__((constructor)) static void _init()
{
board_config *config = libsoc_board_init();
GPIO_BUTTON = libsoc_board_gpio_id(config, "GPIO-A");
GPIO_LED = libsoc_board_gpio_id(config, "GPIO-C");
libsoc_board_free(config);
}
/* End of 96Boards special code */
int main()
{
gpio *gpio_led,*gpio_button;
int touch;
libsoc_set_debug(0);
gpio_led = libsoc_gpio_request(GPIO_LED,LS_SHARED);
gpio_button = libsoc_gpio_request(GPIO_BUTTON,LS_SHARED);
if((gpio_led == NULL) || (gpio_button == NULL))
{
return(-1);
}
libsoc_gpio_set_direction(gpio_led,OUTPUT);
libsoc_gpio_set_direction(gpio_button,INPUT);
if((libsoc_gpio_get_direction(gpio_led) != OUTPUT)
|| (libsoc_gpio_get_direction(gpio_button) != INPUT))
{
return(-1);
}
while(running)
{
usleep(100000);
libsoc_gpio_set_level(gpio_led,1);
usleep(100000);
libsoc_gpio_set_level(gpio_led,0);
}
if(gpio_led || gpio_button)
{
printf("apply gpio resource fail!\n");
libsoc_gpio_free(gpio_led);
libsoc_gpio_free(gpio_button);
}
return EXIT_SUCCESS;
}
the led is connected in this way and viceversa
i noted this:
l ogin as: linaro
linaro@192.168.1.102’s password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Mar 21 13:17:47 2017 from 192.168.1.101
-bash: export: `[board]': not a valid identifier
-bash: export: `[GPIO]': not a valid identifier
-bash: export: `GPIO-A=36': not a valid identifier
-bash: export: `GPIO-B=12': not a valid identifier
-bash: export: `GPIO-C=13': not a valid identifier
-bash: export: `GPIO-D=69': not a valid identifier
-bash: export: `GPIO-E=115': not a valid identifier
-bash: export: `GPIO-F=507': not a valid identifier
-bash: export: `GPIO-G=24': not a valid identifier
-bash: export: `GPIO-H=25': not a valid identifier
-bash: export: `GPIO-I=35': not a valid identifier
-bash: export: `GPIO-J=34': not a valid identifier
-bash: export: `GPIO-K=28': not a valid identifier
-bash: export: `GPIO-L=33': not a valid identifier
-bash: export: `GPIO-23=36': not a valid identifier
-bash: export: `GPIO-24=12': not a valid identifier
-bash: export: `GPIO-25=13': not a valid identifier
-bash: export: `GPIO-26=69': not a valid identifier
-bash: export: `GPIO-27=115': not a valid identifier
-bash: export: `GPIO-28=507': not a valid identifier
-bash: export: `GPIO-29=24': not a valid identifier
-bash: export: `GPIO-30=25': not a valid identifier
-bash: export: `GPIO-31=35': not a valid identifier
-bash: export: `GPIO-32=34': not a valid identifier
-bash: export: `GPIO-33=28': not a valid identifier
-bash: export: `GPIO-34=33': not a valid identifier