Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

pins_arduino.h 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2018 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. // A0-A9 are always digital 14-23, for Arduino compatibility
  34. #define PIN_A0 (14)
  35. #define PIN_A1 (15)
  36. #define PIN_A2 (16)
  37. #define PIN_A3 (17)
  38. #define PIN_A4 (18)
  39. #define PIN_A5 (19)
  40. #define PIN_A6 (20)
  41. #define PIN_A7 (21)
  42. #define PIN_A8 (22)
  43. #define PIN_A9 (23)
  44. const static uint8_t A0 = PIN_A0;
  45. const static uint8_t A1 = PIN_A1;
  46. const static uint8_t A2 = PIN_A2;
  47. const static uint8_t A3 = PIN_A3;
  48. const static uint8_t A4 = PIN_A4;
  49. const static uint8_t A5 = PIN_A5;
  50. const static uint8_t A6 = PIN_A6;
  51. const static uint8_t A7 = PIN_A7;
  52. const static uint8_t A8 = PIN_A8;
  53. const static uint8_t A9 = PIN_A9;
  54. #if defined(__IMXRT1052__)
  55. #define PIN_A10 (24)
  56. #define PIN_A11 (25)
  57. const static uint8_t A10 = PIN_A10;
  58. const static uint8_t A11 = PIN_A11;
  59. #endif
  60. #define LED_BUILTIN (13)
  61. #define PIN_SPI_SS (10)
  62. #define PIN_SPI_MOSI (11)
  63. #define PIN_SPI_MISO (12)
  64. #define PIN_SPI_SCK (13)
  65. const static uint8_t SS = 10;
  66. const static uint8_t MOSI = 11;
  67. const static uint8_t MISO = 12;
  68. const static uint8_t SCK = 13;
  69. #define PIN_WIRE_SDA (18)
  70. #define PIN_WIRE_SCL (19)
  71. const static uint8_t SDA = 18;
  72. const static uint8_t SCL = 19;
  73. #define PIN_SERIAL_RX (0)
  74. #define PIN_SERIAL_TX (1)
  75. #define NUM_DIGITAL_PINS 34
  76. #define NUM_ANALOG_INPUTS 12
  77. #define NOT_AN_INTERRUPT -1
  78. #if defined(__IMXRT1052__)
  79. #define analogInputToDigitalPin(p) (((p) <= 9) ? (p) + 14 : (((p) >= 14 && (p) <= 25) ? (p) : -1))
  80. #define digitalPinHasPWM(p) ((p) <= 15 || (p) == 18 || (p) == 19 || ((p) >= 22 && (p) <= 25) || ((p) >= 28 && (p) <= 31) || (p) == 33)
  81. #define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)
  82. #endif
  83. #define digitalPinToPCICR(p) ((volatile uint8_t *)0)
  84. #define digitalPinToPCICRbit(p) (0)
  85. #define digitalPinToPCIFR(p) ((volatile uint8_t *)0)
  86. #define digitalPinToPCIFRbit(p) (0)
  87. #define digitalPinToPCMSK(p) ((volatile uint8_t *)0)
  88. #define digitalPinToPCMSKbit(p) (0)
  89. struct digital_pin_bitband_and_config_table_struct { // not really bitband, old name from Teensy3
  90. volatile uint32_t *reg;
  91. volatile uint32_t *mux;
  92. volatile uint32_t *pad;
  93. uint32_t mask;
  94. };
  95. extern const struct digital_pin_bitband_and_config_table_struct digital_pin_to_info_PGM[];
  96. #define digitalPinToPort(pin) (pin)
  97. #define digitalPinToBitMask(pin) (digital_pin_to_info_PGM[(pin)].mask)
  98. #define portOutputRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 0))
  99. #define portSetRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 4))
  100. #define portClearRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 8))
  101. #define portToggleRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 12))
  102. #define portInputRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 16))
  103. #define portModeRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 20))
  104. #define portConfigRegister(pin) ((digital_pin_to_info_PGM[(pin)].mux))
  105. #define digitalPinToPortReg(pin) (portOutputRegister(pin))
  106. #define digitalPinToBit(pin) // TODO, is this needed?
  107. #define NOT_ON_TIMER 0
  108. static inline uint8_t digitalPinToTimer(uint8_t) __attribute__((always_inline, unused));
  109. static inline uint8_t digitalPinToTimer(uint8_t pin)
  110. {
  111. // TODO: does anything meaningful use this?
  112. return NOT_ON_TIMER;
  113. }
  114. // These serial port names are intended to allow libraries and architecture-neutral
  115. // sketches to automatically default to the correct port name for a particular type
  116. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  117. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  118. //
  119. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  120. //
  121. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  122. //
  123. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  124. //
  125. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  126. //
  127. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  128. // pins are NOT connected to anything by default.
  129. //
  130. #if F_CPU >= 20000000 && !defined(USB_DISABLED)
  131. #define SERIAL_PORT_MONITOR Serial
  132. #else
  133. #define SERIAL_PORT_MONITOR Serial1
  134. #endif
  135. #define SERIAL_PORT_USBVIRTUAL Serial
  136. #define SERIAL_PORT_HARDWARE Serial1
  137. #define SERIAL_PORT_HARDWARE1 Serial2
  138. #define SERIAL_PORT_HARDWARE2 Serial3
  139. #define SERIAL_PORT_HARDWARE_OPEN Serial1
  140. #define SERIAL_PORT_HARDWARE_OPEN1 Serial2
  141. #define SERIAL_PORT_HARDWARE_OPEN2 Serial3
  142. #define SERIAL_PORT_HARDWARE3 Serial4
  143. #define SERIAL_PORT_HARDWARE4 Serial5
  144. #define SERIAL_PORT_HARDWARE5 Serial6
  145. #define SERIAL_PORT_HARDWARE6 Serial7
  146. #define SERIAL_PORT_HARDWARE7 Serial8
  147. #define SERIAL_PORT_HARDWARE_OPEN3 Serial4
  148. #define SERIAL_PORT_HARDWARE_OPEN4 Serial5
  149. #define SERIAL_PORT_HARDWARE_OPEN5 Serial6
  150. #define SERIAL_PORT_HARDWARE_OPEN6 Serial7
  151. #define SERIAL_PORT_HARDWARE_OPEN7 Serial8
  152. #define SerialUSB Serial
  153. #endif // pins_macros_for_arduino_compatibility_h