您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

107 行
2.9 KiB

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