Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

pins_arduino.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * 1. The above copyright notice and this permission notice shall be
  14. * included in all copies or substantial portions of the Software.
  15. *
  16. * 2. If the Software is incorporated into a build system that allows
  17. * selection among a list of target devices, then similar target
  18. * devices manufactured by PJRC.COM must be included in the list of
  19. * target devices and selectable in the same manner.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  25. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. */
  30. #ifndef pins_macros_for_arduino_compatibility_h
  31. #define pins_macros_for_arduino_compatibility_h
  32. #include <stdint.h>
  33. const static uint8_t A0 = 14;
  34. const static uint8_t A1 = 15;
  35. const static uint8_t A2 = 16;
  36. const static uint8_t A3 = 17;
  37. const static uint8_t A4 = 18;
  38. const static uint8_t A5 = 19;
  39. const static uint8_t A6 = 20;
  40. const static uint8_t A7 = 21;
  41. const static uint8_t A8 = 22;
  42. const static uint8_t A9 = 23;
  43. const static uint8_t A10 = 34;
  44. const static uint8_t A11 = 35;
  45. const static uint8_t A12 = 36;
  46. const static uint8_t A13 = 37;
  47. const static uint8_t SS = 10;
  48. const static uint8_t MOSI = 11;
  49. const static uint8_t MISO = 12;
  50. const static uint8_t SCK = 13;
  51. const static uint8_t LED_BUILTIN = 13;
  52. const static uint8_t SDA = 18;
  53. const static uint8_t SCL = 19;
  54. #define NUM_DIGITAL_PINS 34
  55. #define NUM_ANALOG_INPUTS 14
  56. #define analogInputToDigitalPin(p) (((p) < 10) ? (p) + 14 : -1)
  57. #define digitalPinHasPWM(p) (((p) >= 3 && (p) <= 6) || (p) == 9 || (p) == 10 || ((p) >= 20 && (p) <= 23))
  58. #define NOT_AN_INTERRUPT -1
  59. #define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)
  60. struct digital_pin_bitband_and_config_table_struct {
  61. volatile uint32_t *reg;
  62. volatile uint32_t *config;
  63. };
  64. extern const struct digital_pin_bitband_and_config_table_struct digital_pin_to_info_PGM[];
  65. // compatibility macros
  66. #define digitalPinToPort(pin) (pin)
  67. #define digitalPinToBitMask(pin) (1)
  68. #define portOutputRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 0))
  69. #define portSetRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 32))
  70. #define portClearRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 64))
  71. #define portToggleRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 96))
  72. #define portInputRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 128))
  73. #define portModeRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 160))
  74. #define portConfigRegister(pin) ((volatile uint32_t *)(digital_pin_to_info_PGM[(pin)].config))
  75. #define digitalPinToPortReg(pin) (portOutputRegister(pin))
  76. #define digitalPinToBit(pin) (1)
  77. #define NOT_ON_TIMER 0
  78. static inline uint8_t digitalPinToTimer(uint8_t) __attribute__((always_inline, unused));
  79. static inline uint8_t digitalPinToTimer(uint8_t pin)
  80. {
  81. if (pin >= 3 && pin <= 6) return pin - 2;
  82. if (pin >= 9 && pin <= 10) return pin - 4;
  83. if (pin >= 20 && pin <= 23) return pin - 13;
  84. return NOT_ON_TIMER;
  85. }
  86. #endif