Advertisement
Guest User

gpio

a guest
Oct 4th, 2015
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. #include "gpio_lib.h"
  5. #define PB09    SUNXI_GPB(9)
  6.  
  7. int main()
  8. {
  9.     int value;
  10.  
  11.     if(SETUP_OK!=sunxi_gpio_init()){
  12.         printf("Failed to initialize GPIO\n");
  13.         return -1;
  14.     }
  15.     if(SETUP_OK!=sunxi_gpio_set_cfgpin(PB09,INPUT)){
  16.         printf("Failed to config GPIO pin\n");
  17.         return -1;
  18.     }
  19.     while(1)
  20.     {
  21.  
  22.         value = sunxi_gpio_input(PB09);
  23.         printf("value: %i\n", value);
  24.         usleep(50000);
  25.     }
  26.     sunxi_gpio_cleanup();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement