variant.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. // * = F103R8-B-C-D-E-F-G
  21. // ** = F103RC-D-E-F-G
  22. // | DIGITAL | ANALOG | USART | TWI | SPI | SPECIAL |
  23. // |---------|----------------|--------------------------|-----------|-----------------------|-----------|
  24. #define PA0 PIN_A0 // | 0 | A0 | | | | |
  25. #define PA1 PIN_A1 // | 1 | A1 | | | | |
  26. #define PA2 PIN_A2 // | 2 | A2 | USART2_TX | | | |
  27. #define PA3 PIN_A3 // | 2 | A2, DAC_OUT1** | USART2_RX | | | |
  28. #define PA4 PIN_A4 // | 4 | A4, DAC_OUT2** | | | SPI1_SS | |
  29. #define PA5 PIN_A5 // | 5 | A5 | | | SPI1_SCK | |
  30. #define PA6 PIN_A6 // | 6 | A6 | | | SPI1_MISO | |
  31. #define PA7 PIN_A7 // | 7 | A7 | | | SPI1_MOSI | |
  32. #define PA8 8 // | 8 | | | | | |
  33. #define PA9 9 // | 9 | | USART1_TX | | | |
  34. #define PA10 10 // | 10 | | USART1_RX | | | |
  35. #define PA11 11 // | 11 | | | | | USB_DM |
  36. #define PA12 12 // | 12 | | | | | USB_DP |
  37. #define PA13 13 // | 13 | | | | | SWD_SWDIO |
  38. #define PA14 14 // | 14 | | | | | SWD_SWCLK |
  39. #define PA15 15 // | 15 | | | | SPI1_SS/SPI3_SS** | |
  40. // |---------|----------------|--------------------------|-----------|-----------------------|-----------|
  41. #define PB0 PIN_A8 // | 16 | A8 | | | | |
  42. #define PB1 PIN_A9 // | 17 | A9 | | | | |
  43. #define PB2 18 // | 18 | | | | | BOOT1 |
  44. #define PB3 19 // | 19 | | | | SPI1_SCK/SPI3_SCK** | |
  45. #define PB4 20 // | 20 | | | | SPI1_MISO/SPI3_MISO** | |
  46. #define PB5 21 // | 21 | | | | SPI1_MOSI/SPI3_MOSI** | |
  47. #define PB6 22 // | 22 | | USART1_TX | TWI1_SCL | | |
  48. #define PB7 23 // | 23 | | USART1_RX | TWI1_SDA | | |
  49. #define PB8 24 // | 24 | | | TWI1_SCL | | |
  50. #define PB9 25 // | 25 | | | TWI1_SDA | | |
  51. #define PB10 26 // | 26 | | USART3_TX* | TWI2_SCL* | | |
  52. #define PB11 27 // | 27 | | USART3_RX* | TWI2_SDA* | | |
  53. #define PB12 28 // | 28 | | | | SPI2_SS* | |
  54. #define PB13 29 // | 29 | | | | SPI2_SCK* | |
  55. #define PB14 30 // | 30 | | | | SPI2_MISO* | |
  56. #define PB15 31 // | 31 | | | | SPI2_MOSI* | |
  57. // |---------|----------------|--------------------------|-----------|-----------------------|-----------|
  58. #define PC0 PIN_A10 // | 32 | A10 | | | | |
  59. #define PC1 PIN_A11 // | 33 | A11 | | | | |
  60. #define PC2 PIN_A12 // | 34 | A12 | | | | |
  61. #define PC3 PIN_A13 // | 35 | A13 | | | | |
  62. #define PC4 PIN_A14 // | 36 | A14 | | | | |
  63. #define PC5 PIN_A15 // | 37 | A15 | | | | |
  64. #define PC6 38 // | 38 | | | | | |
  65. #define PC7 39 // | 39 | | | | | |
  66. #define PC8 40 // | 40 | | | | | |
  67. #define PC9 41 // | 41 | | | | | |
  68. #define PC10 42 // | 42 | | USART3_TX*/UART4_TX** | | | |
  69. #define PC11 43 // | 43 | | USART3_RX*/UART4_RX** | | | |
  70. #define PC12 44 // | 44 | | UART5_TX** | | | |
  71. #define PC13 45 // | 45 | | | | | |
  72. #define PC14 46 // | 46 | | | | | OSC32_IN |
  73. #define PC15 47 // | 47 | | | | | OSC32_OUT |
  74. // |---------|----------------|--------------------------|-----------|-----------------------|-----------|
  75. #define PD0 48 // | 48 | | | | | OSC_IN |
  76. #define PD1 49 // | 48 | | | | | OSC_OUT |
  77. #define PD2 50 // | 50 | | UART5_RX** | | | |
  78. // |---------|----------------|--------------------------|-----------|-----------------------|-----------|
  79. // This must be a literal
  80. #define NUM_DIGITAL_PINS 51
  81. // This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
  82. #define NUM_ANALOG_INPUTS 16
  83. // On-board LED pin number
  84. #ifndef LED_BUILTIN
  85. #define LED_BUILTIN PB11
  86. #endif
  87. #define LED_GREEN LED_BUILTIN
  88. // On-board user button
  89. #ifndef USER_BTN
  90. #define USER_BTN PC13
  91. #endif
  92. // Override default Arduino configuration
  93. // SPI Definitions
  94. #if DEFAULT_SPI == 3
  95. #define PIN_SPI_SS PA15
  96. #define PIN_SPI_MOSI PB5
  97. #define PIN_SPI_MISO PB4
  98. #define PIN_SPI_SCK PB3
  99. #elif DEFAULT_SPI == 2
  100. #define PIN_SPI_SS PB12
  101. #define PIN_SPI_MOSI PB15
  102. #define PIN_SPI_MISO PB14
  103. #define PIN_SPI_SCK PB13
  104. #else
  105. #define PIN_SPI_SS PA4
  106. #define PIN_SPI_MOSI PA7
  107. #define PIN_SPI_MISO PA6
  108. #define PIN_SPI_SCK PA5
  109. #endif
  110. // I2C Definitions
  111. #define PIN_WIRE_SDA PB7
  112. #define PIN_WIRE_SCL PB6
  113. // Timer Definitions
  114. #ifndef TIMER_TONE
  115. #define TIMER_TONE TIM3 // TIMER_TONE must be defined in this file
  116. #endif
  117. #ifndef TIMER_SERVO
  118. #define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file
  119. #endif
  120. // UART Definitions
  121. // Define here Serial instance number to map on Serial generic name
  122. #define SERIAL_UART_INSTANCE 1
  123. // Default pin used for 'Serial1' instance
  124. #define PIN_SERIAL_RX PA10
  125. #define PIN_SERIAL_TX PA9
  126. // Extra HAL modules
  127. #if defined(STM32F103xE) || defined(STM32F103xG)
  128. #ifndef HAL_DAC_MODULE_ENABLED
  129. #define HAL_DAC_MODULE_ENABLED
  130. #endif
  131. #endif
  132. #ifdef __cplusplus
  133. } // extern "C"
  134. #endif
  135. /*----------------------------------------------------------------------------
  136. * Arduino objects - C++ only
  137. *----------------------------------------------------------------------------*/
  138. #ifdef __cplusplus
  139. // These serial port names are intended to allow libraries and architecture-neutral
  140. // sketches to automatically default to the correct port name for a particular type
  141. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  142. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  143. //
  144. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  145. //
  146. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  147. //
  148. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  149. //
  150. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  151. //
  152. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  153. // pins are NOT connected to anything by default.
  154. #define SERIAL_PORT_MONITOR Serial
  155. #define SERIAL_PORT_HARDWARE Serial1
  156. #endif
  157. #endif /* _VARIANT_ARDUINO_STM32_ */