variant.h 12 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. /*----------------------------------------------------------------------------
  21. * Pins (STM32F405RG and STM32F415RG)
  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 | | SPI2_SCK | |
  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 | 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) | | | | | |
  65. #define PC6 38 // | 38 | | | USART6_TX | | | |
  66. #define PC7 39 // | 39 | | | USART3_RX | | SPI2_SCK | |
  67. #define PC8 40 // | 40 | | | | | | |
  68. #define PC9 41 // | 41 | | | | TWI3_SDA | | |
  69. #define PC10 42 // | 42 | | | USART3_TX, (UART4_TX) | | 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 PD2 48 // | 48 | | | UART5_RX | | | |
  77. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  78. #define PH0 49 // | 49 | | | | | | OSC_IN |
  79. #define PH1 50 // | 50 | | | | | | OSC_OUT |
  80. // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|
  81. /// This must be a literal
  82. #define NUM_DIGITAL_PINS 51
  83. #define NUM_ANALOG_INPUTS 16
  84. // On-board LED pin number
  85. #ifndef LED_BUILTIN
  86. #define LED_BUILTIN PA5
  87. #endif
  88. #define LED_GREEN LED_BUILTIN
  89. // On-board user button
  90. #ifndef USER_BTN
  91. #define USER_BTN PC13
  92. #endif
  93. // Timer Definitions
  94. // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
  95. #define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file
  96. #define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file
  97. // UART Definitions
  98. // Define here Serial instance number to map on Serial generic name
  99. #define SERIAL_UART_INSTANCE 1
  100. // Default pin used for 'Serial' instance
  101. // Mandatory for Firmata
  102. #define PIN_SERIAL_RX PA10
  103. #define PIN_SERIAL_TX PA9
  104. /* Extra HAL modules */
  105. #define HAL_DAC_MODULE_ENABLED
  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 Serial
  130. #endif
  131. #endif /* _VARIANT_ARDUINO_STM32_ */