wiringPi.h 3.2 KB

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