wiringPi.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. // Deprecated
  25. #define NUM_PINS 17
  26. #define WPI_MODE_PINS 0
  27. #define WPI_MODE_GPIO 1
  28. #define WPI_MODE_GPIO_SYS 2
  29. #define WPI_MODE_PIFACE 3
  30. #define WPI_MODE_UNINITIALISED -1
  31. // Pin modes
  32. #define INPUT 0
  33. #define OUTPUT 1
  34. #define PWM_OUTPUT 2
  35. #define GPIO_CLOCK 3
  36. #define LOW 0
  37. #define HIGH 1
  38. // Pull up/down/none
  39. #define PUD_OFF 0
  40. #define PUD_DOWN 1
  41. #define PUD_UP 2
  42. // PWM
  43. #define PWM_MODE_MS 0
  44. #define PWM_MODE_BAL 1
  45. // Interrupt levels
  46. #define INT_EDGE_SETUP 0
  47. #define INT_EDGE_FALLING 1
  48. #define INT_EDGE_RISING 2
  49. #define INT_EDGE_BOTH 3
  50. // Threads
  51. #define PI_THREAD(X) void *X (void *dummy)
  52. // Function prototypes
  53. // c++ wrappers thanks to a comment by Nick Lott
  54. // (and others on the Raspberry Pi forums)
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. // Basic wiringPi functions
  59. extern int wiringPiSetup (void) ;
  60. extern int wiringPiSetupSys (void) ;
  61. extern int wiringPiSetupGpio (void) ;
  62. extern int wiringPiSetupPiFace (void) ;
  63. extern int piBoardRev (void) ;
  64. extern int wpiPinToGpio (int wpiPin) ;
  65. extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only
  66. extern void (*pinMode) (int pin, int mode) ;
  67. extern int (*getAlt) (int pin) ;
  68. extern void (*pullUpDnControl) (int pin, int pud) ;
  69. extern void (*digitalWrite) (int pin, int value) ;
  70. extern void (*digitalWriteByte) (int value) ;
  71. extern void (*gpioClockSet) (int pin, int freq) ;
  72. extern void (*pwmWrite) (int pin, int value) ;
  73. extern void (*setPadDrive) (int group, int value) ;
  74. extern int (*digitalRead) (int pin) ;
  75. extern void (*pwmSetMode) (int mode) ;
  76. extern void (*pwmSetRange) (unsigned int range) ;
  77. extern void (*pwmSetClock) (int divisor) ;
  78. // Interrupts
  79. extern int (*waitForInterrupt) (int pin, int mS) ;
  80. extern int wiringPiISR (int pin, int mode, void (*function)(void)) ;
  81. // Threads
  82. extern int piThreadCreate (void *(*fn)(void *)) ;
  83. extern void piLock (int key) ;
  84. extern void piUnlock (int key) ;
  85. // Schedulling priority
  86. extern int piHiPri (int pri) ;
  87. // Extras from arduino land
  88. extern void delay (unsigned int howLong) ;
  89. extern void delayMicroseconds (unsigned int howLong) ;
  90. extern unsigned int millis (void) ;
  91. extern unsigned int micros (void) ;
  92. #ifdef __cplusplus
  93. }
  94. #endif