variant.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. *******************************************************************************
  3. * Copyright (c) 2017, STMicroelectronics
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice,
  10. * this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *******************************************************************************
  29. */
  30. #ifndef _VARIANT_ARDUINO_STM32_
  31. #define _VARIANT_ARDUINO_STM32_
  32. /*----------------------------------------------------------------------------
  33. * Headers
  34. *----------------------------------------------------------------------------*/
  35. // #include "PeripheralPins.h"
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif // __cplusplus
  39. /*----------------------------------------------------------------------------
  40. * Pins
  41. *----------------------------------------------------------------------------*/
  42. //extern const PinName digitalPin[];
  43. #define PC13 0
  44. #define PC14 1 //OSC32_IN
  45. #define PC15 2 //OSC32_OUT
  46. #define PH0 3 //OSC_IN
  47. #define PH1 4 //OSC_OUT
  48. #define PB2 5 //BOOT1
  49. #define PB10 6 //1:SPI2_SCK / I2C2_SCL / USART3_TX / TIM2_CH3
  50. #define PB11 7 //1:I2C2_SDA / USART3_RX / TIM2_CH4
  51. #define PB12 8 //1:SPI2_NSS / OTG_HS_ID
  52. #define PB13 9 //1:SPI2_SCK 2:OTG_HS_VBUS
  53. #define PB14 10 //1:SPI2_MISO / TIM12_CH1 / OTG_HS_DM
  54. #define PB15 11 //SPI2_MOSI / TIM12_CH2 / OTG_HS_DP
  55. #define PC6 12 //1:TIM8_CH1 / SDIO_D6 / USART6_TX / TIM3_CH1
  56. #define PC7 13 //1:TIM8_CH2 / SDIO_D7 / USART6_RX / TIM3_CH2
  57. #define PC8 14 //1:TIM8_CH3 / SDIO_D0 / TIM3_CH3
  58. #define PC9 15 //1:TIM8_CH4 / SDIO_D1 / TIM3_CH4
  59. #define PA8 16 //1:TIM1_CH1 / I2C3_SCL / OTG_FS_SOF
  60. #define PA9 17 //1:USART1_TX / TIM1_CH2 2:OTG_FS_VBUS
  61. #define PA10 18 //1:USART1_RX / TIM1_CH3 / OTG_FS_ID
  62. #define PA11 19 //1:TIM1_CH4 / OTG_FS_DM
  63. #define PA12 20 //1:OTG_FS_DP
  64. #define PA13 21 //0:JTMS-SWDIO
  65. #define PA14 22 //0:JTCK-SWCLK
  66. #define PA15 23 //0:JTDI 1:SPI3_NSS / SPI1_NSS
  67. #define PC10 24 //1:UART4_TX / SPI3_SCK / SDIO_D2 / USART3_TX
  68. #define PC11 25 //1:UART4_RX / SPI3_MISO / SDIO_D3 / USART3_RX
  69. #define PC12 26 //1:UART5_TX / SPI3_MOSI / SDIO_CK
  70. #define PD2 27 //1:UART5_RX / SDIO_CMD
  71. #define PB3 28 //0:JTDO 1:SPI3_SCK / TIM2_CH2 / SPI1_SCK
  72. #define PB4 29 //0:NJTRST 1:SPI3_MISO / TIM3_CH1 / SPI1_MISO
  73. #define PB5 30 //1:TIM3_CH2 / SPI1_MOSI / SPI3_MOSI
  74. #define PB6 31 //1:I2C1_SCL / TIM4_CH1 / USART1_TX
  75. #define PB7 32 //1:I2C1_SDA / TIM4_CH2 / USART1_RX
  76. #define PB8 33 //1:I2C1_SCL / TIM4_CH3 / SDIO_D4 / TIM10_CH1
  77. #define PB9 34 //1:I2C1_SDA / TIM4_CH4 / SDIO_D5 / TIM11_CH1 / SPI2_NSS
  78. #define PE2 35 //1:FSMC_A23
  79. #define PE3 36 //1:FSMC_A19
  80. #define PE4 37 //1:FSMC_A20
  81. #define PE5 38 //1:FSMC_A21
  82. #define PE6 39 //1:FSMC_A22
  83. #define PE7 40 //1:FSMC_D4
  84. #define PE8 41 //1:FSMC_D5
  85. #define PE9 42 //1:FSMC_D6 / TIM1_CH1
  86. #define PE10 43 //1:FSMC_D7
  87. #define PE11 44 //1:FSMC_D8 / TIM1_CH2
  88. #define PE12 45 //1:FSMC_D9
  89. #define PE13 46 //1:FSMC_D10 / TIM1_CH3
  90. #define PE14 47 //1:FSMC_D11 / TIM1_CH4
  91. #define PE15 48 //1:FSMC_D12
  92. #define PD8 49 //1:FSMC_D13 / USART3_TX
  93. #define PD9 50 //1:FSMC_D14 / USART3_RX
  94. #define PD10 51 //1:FSMC_D15
  95. #define PD11 52 //1:FSMC_A16
  96. #define PD12 53 //1:FSMC_A17 / TIM4_CH1
  97. #define PD13 54 //1:FSMC_A18 / TIM4_CH2
  98. #define PD14 55 //1:FSMC_D0 / TIM4_CH3
  99. #define PD15 56 //1:FSMC_D1 / TIM4_CH4
  100. #define PD0 57 //1:FSMC_D2
  101. #define PD1 58 //1:FSMC_D3
  102. #define PD3 59 //1:FSMC_CLK
  103. #define PD4 60 //1:FSMC_NOE
  104. #define PD5 61 //1:USART2_TX
  105. #define PD6 62 //1:USART2_RX
  106. #define PD7 63
  107. #define PE0 64
  108. #define PE1 65
  109. #define PF0 66 //1:FSMC_A0 / I2C2_SDA
  110. #define PF1 67 //1:FSMC_A1 / I2C2_SCL
  111. #define PF2 68 //1:FSMC_A2
  112. #define PF11 69
  113. #define PF12 70 //1:FSMC_A6
  114. #define PF13 71 //1:FSMC_A7
  115. #define PF14 72 //1:FSMC_A8
  116. #define PF15 73 //1:FSMC_A9
  117. #define PG0 74 //1:FSMC_A10
  118. #define PG1 75 //1:FSMC_A11
  119. #define PG2 76 //1:FSMC_A12
  120. #define PG3 77 //1:FSMC_A13
  121. #define PG4 78 //1:FSMC_A14
  122. #define PG5 79 //1:FSMC_A15
  123. #define PG6 80
  124. #define PG7 81
  125. #define PG8 82
  126. #define PG9 83 //1:USART6_RX
  127. #define PG10 84 //1:FSMC_NE3
  128. #define PG11 85
  129. #define PG12 86 //1:FSMC_NE4
  130. #define PG13 87 //1:FSMC_A24
  131. #define PG14 88 //1:FSMC_A25 / USART6_TX
  132. #define PG15 89
  133. #define PA0 90 //1:UART4_TX / TIM5_CH1 2:ADC123_IN0
  134. #define PA1 91 //1:UART4_RX / TIM5_CH2 / TIM2_CH2 2:ADC123_IN1
  135. #define PA2 92 //1:USART2_TX /TIM5_CH3 / TIM9_CH1 / TIM2_CH3 2:ADC123_IN2
  136. #define PA3 93 //1:USART2_RX /TIM5_CH4 / TIM9_CH2 / TIM2_CH4 2:ADC123_IN3
  137. #define PA4 94 //NOT FT 1:SPI1_NSS / SPI3_NSS / USART2_CK 2:ADC12_IN4 / DAC_OUT1
  138. #define PA5 95 //NOT FT 1:SPI1_SCK 2:ADC12_IN5 / DAC_OUT2
  139. #define PA6 96 //1:SPI1_MISO / TIM13_CH1 / TIM3_CH1 2:ADC12_IN6
  140. #define PA7 97 //1:SPI1_MOSI / TIM14_CH1 / TIM3_CH2 2:ADC12_IN7
  141. #define PB0 98 //1:TIM3_CH3 2:ADC12_IN8
  142. #define PB1 99 //1:TIM3_CH4 2:ADC12_IN9
  143. #define PC0 100 //1: 2:ADC123_IN10
  144. #define PC1 101 //1: 2:ADC123_IN11
  145. #define PC2 102 //1:SPI2_MISO 2:ADC123_IN12
  146. #define PC3 103 //1:SPI2_MOSI 2:ADC123_IN13
  147. #define PC4 104 //1: 2:ADC12_IN14
  148. #define PC5 105 //1: 2:ADC12_IN15
  149. #define PF3 106 //1:FSMC_A3 2:ADC3_IN9
  150. #define PF4 107 //1:FSMC_A4 2:ADC3_IN14
  151. #define PF5 108 //1:FSMC_A5 2:ADC3_IN15
  152. #define PF6 109 //1:TIM10_CH1 2:ADC3_IN4
  153. #define PF7 110 //1:TIM11_CH1 2:ADC3_IN5
  154. #define PF8 111 //1:TIM13_CH1 2:ADC3_IN6
  155. #define PF9 112 //1;TIM14_CH1 2:ADC3_IN7
  156. #define PF10 113 //2:ADC3_IN8
  157. // This must be a literal
  158. #define NUM_DIGITAL_PINS 114
  159. // This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS
  160. #define NUM_ANALOG_INPUTS 24
  161. #define NUM_ANALOG_FIRST 90
  162. // Below ADC, DAC and PWM definitions already done in the core
  163. // Could be redefined here if needed
  164. // ADC resolution is 12bits
  165. //#define ADC_RESOLUTION 12
  166. //#define DACC_RESOLUTION 12
  167. // PWM resolution
  168. #define PWM_RESOLUTION 8
  169. #define PWM_FREQUENCY 20000
  170. #define PWM_MAX_DUTY_CYCLE 255
  171. // Below SPI and I2C definitions already done in the core
  172. // Could be redefined here if differs from the default one
  173. // SPI Definitions
  174. #define PIN_SPI_MOSI PB15
  175. #define PIN_SPI_MISO PB14
  176. #define PIN_SPI_SCK PB13
  177. #define PIN_SPI_SS PB12
  178. // I2C Definitions
  179. #define PIN_WIRE_SDA PB7
  180. #define PIN_WIRE_SCL PB6
  181. // Timer Definitions
  182. //Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
  183. #define TIMER_TONE TIM6
  184. // Do not use basic timer: OC is required
  185. #define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
  186. // UART Definitions
  187. // Define here Serial instance number to map on Serial generic name
  188. #define SERIAL_UART_INSTANCE 3 //ex: 2 for Serial2 (USART2)
  189. // DEBUG_UART could be redefined to print on another instance than 'Serial'
  190. //#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3
  191. // DEBUG_UART baudrate, default: 9600 if not defined
  192. //#define DEBUG_UART_BAUDRATE x
  193. // DEBUG_UART Tx pin name, default: the first one found in PinMap_UART_TX for DEBUG_UART
  194. //#define DEBUG_PINNAME_TX PX_n // PinName used for TX
  195. // Default pin used for 'Serial' instance (ex: ST-Link)
  196. // Mandatory for Firmata
  197. #define PIN_SERIAL_RX PB11//PA10
  198. #define PIN_SERIAL_TX PB10//PA9
  199. #ifdef __cplusplus
  200. } // extern "C"
  201. #endif
  202. /*----------------------------------------------------------------------------
  203. * Arduino objects - C++ only
  204. *----------------------------------------------------------------------------*/
  205. #ifdef __cplusplus
  206. // These serial port names are intended to allow libraries and architecture-neutral
  207. // sketches to automatically default to the correct port name for a particular type
  208. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  209. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  210. //
  211. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  212. //
  213. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  214. //
  215. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  216. //
  217. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  218. //
  219. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  220. // pins are NOT connected to anything by default.
  221. #define SERIAL_PORT_MONITOR Serial
  222. #define SERIAL_PORT_HARDWARE Serial1
  223. #endif
  224. #endif /* _VARIANT_ARDUINO_STM32_ */