wiringPi.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * wiringPi:
  3. * Arduino compatable (ish) Wiring library for the Raspberry Pi
  4. * Copyright (c) 2012 Gordon Henderson
  5. ***********************************************************************
  6. * This file is part of wiringPi:
  7. * https://projects.drogon.net/raspberry-pi/wiringpi/
  8. *
  9. * wiringPi is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * wiringPi is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
  21. ***********************************************************************
  22. */
  23. // Handy defines
  24. #define NUM_PINS 17
  25. #define WPI_MODE_PINS 0
  26. #define WPI_MODE_GPIO 1
  27. #define WPI_MODE_GPIO_SYS 2
  28. #define WPI_MODE_PIFACE 3
  29. #define INPUT 0
  30. #define OUTPUT 1
  31. #define PWM_OUTPUT 2
  32. #define LOW 0
  33. #define HIGH 1
  34. #define PUD_OFF 0
  35. #define PUD_DOWN 1
  36. #define PUD_UP 2
  37. // Function prototypes
  38. // c++ wrappers thanks to a commend by Nick Lott
  39. // (and others on the Raspberry Pi forums)
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. // Basic wiringPi functions
  44. extern int wiringPiSetup (void) ;
  45. extern int wiringPiSetupSys (void) ;
  46. extern int wiringPiSetupGpio (void) ;
  47. extern int wiringPiSetupPiFace (void) ;
  48. extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only
  49. extern void (*pinMode) (int pin, int mode) ;
  50. extern void (*pullUpDnControl) (int pin, int pud) ;
  51. extern void (*digitalWrite) (int pin, int value) ;
  52. extern void (*pwmWrite) (int pin, int value) ;
  53. extern int (*digitalRead) (int pin) ;
  54. // Interrupts
  55. extern int (*waitForInterrupt) (int pin, int mS) ;
  56. // Threads
  57. #define PI_THREAD(X) void *X (void *dummy)
  58. extern int piThreadCreate (void *(*fn)(void *)) ;
  59. extern void piLock (int key) ;
  60. extern void piUnlock (int key) ;
  61. // Schedulling priority
  62. extern int piHiPri (int pri) ;
  63. // Extras from arduino land
  64. extern void delay (unsigned int howLong) ;
  65. extern void delayMicroseconds (unsigned int howLong) ;
  66. extern unsigned int millis (void) ;
  67. #ifdef __cplusplus
  68. }
  69. #endif