variant.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. /*----------------------------------------------------------------------------
  21. * Pins
  22. *----------------------------------------------------------------------------*/
  23. // | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL |
  24. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  25. #define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | |
  26. #define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | |
  27. #define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | |
  28. #define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | |
  29. #define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | |
  30. #define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | |
  31. #define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | |
  32. #define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | |
  33. #define PA8 8 // | 8 | | | | TWI3_SCL | | |
  34. #define PA9 9 // | 9 | | | USART1_TX | | | |
  35. #define PA10 10 // | 10 | | | USART1_RX | | | |
  36. #define PA11 11 // | 11 | | | | | | |
  37. #define PA12 12 // | 12 | | | | | | |
  38. #define PA13 13 // | 13 | | | | | | SWD_SWDIO |
  39. #define PA14 14 // | 14 | | | | | | SWD_SWCLK |
  40. #define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | |
  41. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  42. #define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | |
  43. #define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | |
  44. #define PB2 18 // | 18 | | | | | | BOOT1 |
  45. #define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | |
  46. #define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | |
  47. #define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | |
  48. #define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | |
  49. #define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | |
  50. #define PB8 24 // | 24 | | | | TWI1_SCL | | |
  51. #define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | |
  52. #define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | |
  53. #define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | |
  54. #define PB12 28 // | 28 | | | | | SPI2_SS | |
  55. #define PB13 29 // | 29 | | | | | SPI2_SCK | |
  56. #define PB14 30 // | 30 | | | | | SPI2_MISO | |
  57. #define PB15 31 // | 31 | | | | | SPI2_MOSI | |
  58. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  59. #define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | |
  60. #define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | |
  61. #define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | |
  62. #define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | |
  63. #define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | |
  64. #define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | |
  65. #define PC6 38 // | 38 | | | USART6_TX | | | |
  66. #define PC7 39 // | 39 | | | USART6_RX | | | |
  67. #define PC8 40 // | 40 | | | | | | |
  68. #define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | |
  69. #define PC10 42 // | 42 | | | | | SPI3_SCK | |
  70. #define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | |
  71. #define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | |
  72. #define PC13 45 // | 45 | | | | | | |
  73. #define PC14 46 // | 46 | | | | | | OSC32_IN |
  74. #define PC15 47 // | 47 | | | | | | OSC32_OUT |
  75. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  76. #define PD0 48 // | 48 | | | | | | |
  77. #define PD1 49 // | 49 | | | | | | |
  78. #define PD2 50 // | 50 | | | UART5_RX | | | |
  79. #define PD3 51 // | 51 | | | | | | |
  80. #define PD4 52 // | 52 | | | | | | |
  81. #define PD5 53 // | 53 | | | USART2_TX | | | |
  82. #define PD6 54 // | 54 | | | USART2_RX | | | |
  83. #define PD7 55 // | 55 | | | | | | |
  84. #define PD8 56 // | 56 | | | USART3_TX | | | |
  85. #define PD9 57 // | 57 | | | USART3_RX | | | |
  86. #define PD10 58 // | 58 | | | | | | |
  87. #define PD11 59 // | 59 | | | | | | |
  88. #define PD12 60 // | 60 | | | | | | |
  89. #define PD13 61 // | 61 | | | | | | |
  90. #define PD14 62 // | 62 | | | | | | |
  91. #define PD15 63 // | 63 | | | | | | |
  92. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  93. #define PE0 64 // | 64 | | | | | | |
  94. #define PE1 65 // | 65 | | | | | | |
  95. #define PE2 66 // | 66 | | | | | | |
  96. #define PE3 67 // | 67 | | | | | | |
  97. #define PE4 68 // | 68 | | | | | | |
  98. #define PE5 69 // | 69 | | | | | | |
  99. #define PE6 70 // | 70 | | | | | | |
  100. #define PE7 71 // | 71 | | | | | | |
  101. #define PE8 72 // | 72 | | | | | | |
  102. #define PE9 73 // | 73 | | | | | | |
  103. #define PE10 74 // | 74 | | | | | | |
  104. #define PE11 75 // | 75 | | | | | | |
  105. #define PE12 76 // | 76 | | | | | | |
  106. #define PE13 77 // | 77 | | | | | | |
  107. #define PE14 78 // | 78 | | | | | | |
  108. #define PE15 79 // | 79 | | | | | | |
  109. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  110. #define PH0 80 // | 80 | | | | | | OSC_IN |
  111. #define PH1 81 // | 81 | | | | | | OSC_OUT |
  112. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  113. // This must be a literal
  114. #define NUM_DIGITAL_PINS 82
  115. #define NUM_ANALOG_INPUTS 16
  116. // On-board LED pin number
  117. #ifndef LED_BUILTIN
  118. #define LED_BUILTIN PA5
  119. #endif
  120. #define LED_GREEN LED_BUILTIN
  121. // On-board user button
  122. #ifndef USER_BTN
  123. #define USER_BTN PC13
  124. #endif
  125. // SPI definitions
  126. #define PIN_SPI_SS PA4
  127. #define PIN_SPI_SS1 PA4
  128. #define PIN_SPI_SS2 PB12
  129. #define PIN_SPI_SS3 PA15
  130. #define PIN_SPI_MOSI PA7
  131. #define PIN_SPI_MISO PA6
  132. #define PIN_SPI_SCK PA5
  133. // I2C definitions
  134. #ifndef PIN_WIRE_SDA
  135. #define PIN_WIRE_SDA PB9
  136. #endif
  137. #ifndef PIN_WIRE_SCL
  138. #define PIN_WIRE_SCL PB8
  139. #endif
  140. // Timer Definitions
  141. // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
  142. #ifndef TIMER_TONE
  143. #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file
  144. #endif
  145. #ifndef TIMER_SERVO
  146. #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file
  147. #endif
  148. #ifndef TIMER_SERIAL
  149. #define TIMER_SERIAL TIM5 // TIMER_SERIAL must be defined in this file
  150. #endif
  151. // UART Definitions
  152. #define SERIAL_UART_INSTANCE 2
  153. // Default pin used for 'Serial' instance
  154. // Mandatory for Firmata
  155. #define PIN_SERIAL_RX PA3
  156. #define PIN_SERIAL_TX PA2
  157. /* Extra HAL modules */
  158. #define HAL_DAC_MODULE_ENABLED
  159. #ifdef __cplusplus
  160. } // extern "C"
  161. #endif
  162. /*----------------------------------------------------------------------------
  163. * Arduino objects - C++ only
  164. *----------------------------------------------------------------------------*/
  165. #ifdef __cplusplus
  166. // These serial port names are intended to allow libraries and architecture-neutral
  167. // sketches to automatically default to the correct port name for a particular type
  168. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  169. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  170. //
  171. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  172. //
  173. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  174. //
  175. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  176. //
  177. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  178. //
  179. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  180. // pins are NOT connected to anything by default.
  181. #define SERIAL_PORT_MONITOR Serial
  182. #define SERIAL_PORT_HARDWARE Serial1
  183. #endif
  184. #endif /* _VARIANT_ARDUINO_STM32_ */