1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include "libgiohot.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(){
int entrer = ((GIO_LINE_16) | (GIO_LINE_17) | (GIO_LINE_18) | (GIO_LINE_19)) ;
int sortie = ((GIO_LINE_8) | (GIO_LINE_9) | (GIO_LINE_10) | (GIO_LINE_11)) ;
int fd , i=0, bin ;
if (( fd = open("/dev/gpiog",O_RDWR)) < 0){
printf("GPIOG port not opened \n");
}
giohot_init_output(fd, 0x0000FF00 );//mise en sortie des lignes 8 à 15
giohot_init_input(fd, 0x00FF0000 );//mise en entrée des lignes 16 à 23
while(i<=100){
giohot_clear_output(fd, sortie); //mise a zéro sur
//l'entrée 16,17,18,19
bin = giohot_get_input(fd, entrer); //lecture des entré
//suivant le mansk proposé
sleep (1);
giohot_bitprintf(bin);
i++;
}
close ( fd);
return 0;
} |