variant.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. Copyright (c) 2011 Arduino. All right reserved.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. #ifndef _VARIANT_ARDUINO_STM32_
  16. #define _VARIANT_ARDUINO_STM32_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif // __cplusplus
  20. // | DIGITAL | ANALOG | USART | TWI | SPI | SPECIAL |
  21. // |---------|--------|-----------|----------|------------------------|-----------|
  22. #define PA0 A0 // | 0 | A0 | | | | |
  23. #define PA1 A1 // | 1 | A1 | | | | |
  24. #define PA2 A2 // | 2 | A2 | USART2_TX | | | |
  25. #define PA3 A3 // | 3 | A3 | USART2_RX | | | |
  26. #define PA4 A4 // | 4 | A4 | | | SPI1_SS, (SPI3_SS) | |
  27. #define PA5 A5 // | 5 | A5 | | | SPI1_SCK | |
  28. #define PA6 A6 // | 6 | A6 | | | SPI1_MISO | |
  29. #define PA7 A7 // | 7 | A7 | | | SPI1_MOSI | |
  30. #define PA8 8 // | 8 | | | TWI3_SCL | | |
  31. #define PA9 9 // | 9 | | USART1_TX | | | |
  32. #define PA10 10 // | 10 | | USART1_RX | | | |
  33. #define PA11 11 // | 11 | | USART6_TX | | | |
  34. #define PA12 12 // | 12 | | USART6_RX | | | |
  35. #define PA13 13 // | 13 | | | | | SWD_SWDIO |
  36. #define PA14 14 // | 14 | | | | | SWD_SWCLK |
  37. #define PA15 15 // | 15 | | | | SPI3_SS, (SPI1_SS) | |
  38. // |---------|--------|-----------|----------|------------------------|-----------|
  39. #define PB0 A8 // | 16 | A8 | | | | |
  40. #define PB1 A9 // | 17 | A9 | | | | |
  41. #define PB2 18 // | 18 | | | | | BOOT1 |
  42. #define PB3 19 // | 19 | | | TWI2_SDA | SPI3_SCK, (SPI1_SCK) | |
  43. #define PB4 20 // | 20 | | | TWI3_SDA | SPI3_MISO, (SPI1_MISO) | |
  44. #define PB5 21 // | 21 | | | | SPI3_MOSI, (SPI1_MOSI) | |
  45. #define PB6 22 // | 22 | | USART1_TX | TWI1_SCL | | |
  46. #define PB7 23 // | 23 | | USART1_RX | TWI1_SDA | | |
  47. #define PB8 24 // | 24 | | | TWI1_SCL | | |
  48. #define PB9 25 // | 25 | | | TWI1_SDA | SPI2_SS | |
  49. #define PB10 26 // | 26 | | | TWI2_SCL | SPI2_SCK | |
  50. #define PB12 27 // | 27 | | | | SPI2_SS | |
  51. #define PB13 28 // | 28 | | | | SPI2_SCK | |
  52. #define PB14 29 // | 29 | | | | SPI2_MISO | |
  53. #define PB15 30 // | 30 | | | | SPI2_MOSI | |
  54. // |---------|--------|-----------|----------|------------------------|-----------|
  55. #define PC0 A10 // | 31 | A10 | | | | |
  56. #define PC1 A11 // | 32 | A11 | | | | |
  57. #define PC2 A12 // | 33 | A12 | | | SPI2_MISO | |
  58. #define PC3 A13 // | 34 | A13 | | | SPI2_MOSI | |
  59. #define PC4 A14 // | 35 | A14 | | | | |
  60. #define PC5 A15 // | 36 | A15 | | | | |
  61. #define PC6 37 // | 37 | | USART6_TX | | | |
  62. #define PC7 38 // | 38 | | USART6_RX | | | |
  63. #define PC8 39 // | 39 | | | | | |
  64. #define PC9 40 // | 40 | | | TWI3_SDA | | |
  65. #define PC10 41 // | 41 | | | | SPI3_SCK | |
  66. #define PC11 42 // | 42 | | | | SPI3_MISO | |
  67. #define PC12 43 // | 43 | | | | SPI3_MOSI | |
  68. #define PC13 44 // | 44 | | | | | |
  69. #define PC14 45 // | 45 | | | | | OSC32_IN |
  70. #define PC15 46 // | 46 | | | | | OSC32_OUT |
  71. // |---------|--------|-----------|----------|------------------------|-----------|
  72. #define PD2 47 // | 47 | | | | | |
  73. // |---------|--------|-----------|----------|------------------------|-----------|
  74. #define PH0 48 // | 48 | | | | | OSC_IN |
  75. #define PH1 49 // | 49 | | | | | OSC_OUT |
  76. // |---------|--------|-----------|----------|------------------------|-----------|
  77. // This must be a literal
  78. #define NUM_DIGITAL_PINS 50
  79. #define NUM_ANALOG_INPUTS 16
  80. // SPI definitions
  81. #define PIN_SPI_SS PA4
  82. #define PIN_SPI_SS1 PA4
  83. #define PIN_SPI_MOSI PA7
  84. #define PIN_SPI_MISO PA6
  85. #define PIN_SPI_SCK PA5
  86. // Timer Definitions
  87. #define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file
  88. #define TIMER_SERVO TIM3 // TIMER_SERVO must be defined in this file
  89. #define TIMER_SERIAL TIM11 // TIMER_SERIAL must be defined in this file
  90. // UART Definitions
  91. //#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below
  92. #define ENABLE_HWSERIAL2
  93. // Define here Serial instance number to map on Serial generic name (if not already used by SerialUSB)
  94. #define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1)
  95. // Default pin used for 'Serial' instance
  96. // Mandatory for Firmata
  97. #define PIN_SERIAL_RX PA10
  98. #define PIN_SERIAL_TX PA9
  99. // Used when the user instantiates a hardware Serial using its peripheral name.
  100. // Example: HardwareSerial mySerial(USART3);
  101. // will use PIN_SERIAL3_RX and PIN_SERIAL3_TX if defined.
  102. #define PIN_SERIAL1_RX PA10
  103. #define PIN_SERIAL1_TX PA9
  104. #define PIN_SERIAL2_RX PA3
  105. #define PIN_SERIAL2_TX PA2
  106. #ifdef __cplusplus
  107. } // extern "C"
  108. #endif
  109. /*----------------------------------------------------------------------------
  110. * Arduino objects - C++ only
  111. *----------------------------------------------------------------------------*/
  112. #ifdef __cplusplus
  113. // These serial port names are intended to allow libraries and architecture-neutral
  114. // sketches to automatically default to the correct port name for a particular type
  115. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  116. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  117. //
  118. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  119. //
  120. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  121. //
  122. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  123. //
  124. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  125. //
  126. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  127. // pins are NOT connected to anything by default.
  128. #define SERIAL_PORT_MONITOR Serial
  129. #define SERIAL_PORT_HARDWARE Serial1
  130. #define SERIAL_PORT_HARDWARE_OPEN Serial2
  131. #endif
  132. #endif /* _VARIANT_ARDUINO_STM32_ */