PageRenderTime 30ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/mbed_hufan/hal/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F407VG/PinNames.h

https://gitlab.com/hufan/mbed_hufan
C Header | 261 lines | 208 code | 19 blank | 34 comment | 0 complexity | 05dea2dadf2d265cac667d1ff476ddea MD5 | raw file
  1. /* mbed Microcontroller Library
  2. *******************************************************************************
  3. * Copyright (c) 2014, 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 MBED_PINNAMES_H
  31. #define MBED_PINNAMES_H
  32. #include "cmsis.h"
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. // See stm32f4xx_hal_gpio.h and stm32f4xx_hal_gpio_ex.h for values of MODE, PUPD and AFNUM
  37. #define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
  38. #define STM_PIN_DATA_EXT(MODE, PUPD, AFNUM, CHANNEL, INVERTED) ((int)(((INVERTED & 0x01) << 15) | ((CHANNEL & 0x0F) << 11) | ((AFNUM & 0x0F) << 7) | ((PUPD & 0x07) << 4) | ((MODE & 0x0F) << 0)))
  39. #define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
  40. #define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
  41. #define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
  42. #define STM_PIN_CHANNEL(X) (((X) >> 11) & 0x0F)
  43. #define STM_PIN_INVERTED(X) (((X) >> 15) & 0x01)
  44. #define STM_MODE_INPUT (0)
  45. #define STM_MODE_OUTPUT_PP (1)
  46. #define STM_MODE_OUTPUT_OD (2)
  47. #define STM_MODE_AF_PP (3)
  48. #define STM_MODE_AF_OD (4)
  49. #define STM_MODE_ANALOG (5)
  50. #define STM_MODE_IT_RISING (6)
  51. #define STM_MODE_IT_FALLING (7)
  52. #define STM_MODE_IT_RISING_FALLING (8)
  53. #define STM_MODE_EVT_RISING (9)
  54. #define STM_MODE_EVT_FALLING (10)
  55. #define STM_MODE_EVT_RISING_FALLING (11)
  56. #define STM_MODE_IT_EVT_RESET (12)
  57. // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
  58. // Low nibble = pin number
  59. #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
  60. #define STM_PIN(X) ((uint32_t)(X) & 0xF)
  61. typedef enum {
  62. PIN_INPUT,
  63. PIN_OUTPUT
  64. } PinDirection;
  65. typedef enum {
  66. PA_0 = 0x00,
  67. PA_1 = 0x01,
  68. PA_2 = 0x02,
  69. PA_3 = 0x03,
  70. PA_4 = 0x04,
  71. PA_5 = 0x05,
  72. PA_6 = 0x06,
  73. PA_7 = 0x07,
  74. PA_8 = 0x08,
  75. PA_9 = 0x09,
  76. PA_10 = 0x0A,
  77. PA_11 = 0x0B,
  78. PA_12 = 0x0C,
  79. PA_13 = 0x0D,
  80. PA_14 = 0x0E,
  81. PA_15 = 0x0F,
  82. PB_0 = 0x10,
  83. PB_1 = 0x11,
  84. PB_2 = 0x12,
  85. PB_3 = 0x13,
  86. PB_4 = 0x14,
  87. PB_5 = 0x15,
  88. PB_6 = 0x16,
  89. PB_7 = 0x17,
  90. PB_8 = 0x18,
  91. PB_9 = 0x19,
  92. PB_10 = 0x1A,
  93. PB_11 = 0x1B,
  94. PB_12 = 0x1C,
  95. PB_13 = 0x1D,
  96. PB_14 = 0x1E,
  97. PB_15 = 0x1F,
  98. PC_0 = 0x20,
  99. PC_1 = 0x21,
  100. PC_2 = 0x22,
  101. PC_3 = 0x23,
  102. PC_4 = 0x24,
  103. PC_5 = 0x25,
  104. PC_6 = 0x26,
  105. PC_7 = 0x27,
  106. PC_8 = 0x28,
  107. PC_9 = 0x29,
  108. PC_10 = 0x2A,
  109. PC_11 = 0x2B,
  110. PC_12 = 0x2C,
  111. PC_13 = 0x2D,
  112. PC_14 = 0x2E,
  113. PC_15 = 0x2F,
  114. PD_0 = 0x30,
  115. PD_1 = 0x31,
  116. PD_2 = 0x32,
  117. PD_3 = 0x33,
  118. PD_4 = 0x34,
  119. PD_5 = 0x35,
  120. PD_6 = 0x36,
  121. PD_7 = 0x37,
  122. PD_8 = 0x38,
  123. PD_9 = 0x39,
  124. PD_10 = 0x3A,
  125. PD_11 = 0x3B,
  126. PD_12 = 0x3C,
  127. PD_13 = 0x3D,
  128. PD_14 = 0x3E,
  129. PD_15 = 0x3F,
  130. PE_0 = 0x40,
  131. PE_1 = 0x41,
  132. PE_2 = 0x42,
  133. PE_3 = 0x43,
  134. PE_4 = 0x44,
  135. PE_5 = 0x45,
  136. PE_6 = 0x46,
  137. PE_7 = 0x47,
  138. PE_8 = 0x48,
  139. PE_9 = 0x49,
  140. PE_10 = 0x4A,
  141. PE_11 = 0x4B,
  142. PE_12 = 0x4C,
  143. PE_13 = 0x4D,
  144. PE_14 = 0x4E,
  145. PE_15 = 0x4F,
  146. PF_0 = 0x50,
  147. PF_1 = 0x51,
  148. PF_2 = 0x52,
  149. PF_3 = 0x53,
  150. PF_4 = 0x54,
  151. PF_5 = 0x55,
  152. PF_6 = 0x56,
  153. PF_7 = 0x57,
  154. PF_8 = 0x58,
  155. PF_9 = 0x59,
  156. PF_10 = 0x5A,
  157. PF_11 = 0x5B,
  158. PF_12 = 0x5C,
  159. PF_13 = 0x5D,
  160. PF_14 = 0x5E,
  161. PF_15 = 0x5F,
  162. PG_0 = 0x60,
  163. PG_1 = 0x61,
  164. PG_2 = 0x62,
  165. PG_3 = 0x63,
  166. PG_4 = 0x64,
  167. PG_5 = 0x65,
  168. PG_6 = 0x66,
  169. PG_7 = 0x67,
  170. PG_8 = 0x68,
  171. PG_9 = 0x69,
  172. PG_10 = 0x6A,
  173. PG_11 = 0x6B,
  174. PG_12 = 0x6C,
  175. PG_13 = 0x6D,
  176. PG_14 = 0x6E,
  177. PG_15 = 0x6F,
  178. PH_0 = 0x70,
  179. PH_1 = 0x71,
  180. PH_2 = 0x72,
  181. PH_3 = 0x73,
  182. PH_4 = 0x74,
  183. PH_5 = 0x75,
  184. PH_6 = 0x76,
  185. PH_7 = 0x77,
  186. PH_8 = 0x78,
  187. PH_9 = 0x79,
  188. PH_10 = 0x7A,
  189. PH_11 = 0x7B,
  190. PH_12 = 0x7C,
  191. PH_13 = 0x7D,
  192. PH_14 = 0x7E,
  193. PH_15 = 0x7F,
  194. PI_0 = 0x80,
  195. PI_1 = 0x81,
  196. PI_2 = 0x82,
  197. PI_3 = 0x83,
  198. PI_4 = 0x84,
  199. PI_5 = 0x85,
  200. PI_6 = 0x86,
  201. PI_7 = 0x87,
  202. PI_8 = 0x88,
  203. PI_9 = 0x89,
  204. PI_10 = 0x8A,
  205. PI_11 = 0x8B,
  206. PI_12 = 0x8C,
  207. PI_13 = 0x8D,
  208. PI_14 = 0x8E,
  209. PI_15 = 0x8F,
  210. // Generic signals namings
  211. LED1 = PD_13,
  212. LED2 = PD_12,
  213. LED3 = PD_13,
  214. LED4 = PD_12,
  215. LED5 = PD_14,
  216. LED6 = PD_15,
  217. USER_BUTTON = PA_0,
  218. SERIAL_TX = PA_2, /* USART2 */
  219. SERIAL_RX = PA_3,
  220. USBTX = PA_2, /* USART2 */
  221. USBRX = PA_3,
  222. I2C_SCL = PB_8, /* I2C1 */
  223. I2C_SDA = PB_9,
  224. SPI_MOSI = PA_7,
  225. SPI_MISO = PA_6,
  226. SPI_SCK = PA_5,
  227. SPI_CS = PB_6,
  228. PWM_OUT = PB_3,
  229. // Not connected
  230. NC = (int)0xFFFFFFFF
  231. } PinName;
  232. typedef enum {
  233. PullNone = 0,
  234. PullUp = 1,
  235. PullDown = 2,
  236. OpenDrain = 3,
  237. PullDefault = PullNone
  238. } PinMode;
  239. #ifdef __cplusplus
  240. }
  241. #endif
  242. #endif