PageRenderTime 26ms CodeModel.GetById 40ms RepoModel.GetById 0ms app.codeStats 0ms

/tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F030R8/PinNames.h

https://github.com/tmk/tmk_keyboard
C Header | 188 lines | 136 code | 17 blank | 35 comment | 0 complexity | b54f8c7f63d96d6fe2818d376eae6547 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 stm32f0xx_hal_gpio.h and stm32f0xx_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_MODE(X) (((X) >> 0) & 0x0F)
  39. #define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
  40. #define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
  41. #define STM_MODE_INPUT (0)
  42. #define STM_MODE_OUTPUT_PP (1)
  43. #define STM_MODE_OUTPUT_OD (2)
  44. #define STM_MODE_AF_PP (3)
  45. #define STM_MODE_AF_OD (4)
  46. #define STM_MODE_ANALOG (5)
  47. #define STM_MODE_IT_RISING (6)
  48. #define STM_MODE_IT_FALLING (7)
  49. #define STM_MODE_IT_RISING_FALLING (8)
  50. #define STM_MODE_EVT_RISING (9)
  51. #define STM_MODE_EVT_FALLING (10)
  52. #define STM_MODE_EVT_RISING_FALLING (11)
  53. #define STM_MODE_IT_EVT_RESET (12)
  54. // High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
  55. // Low nibble = pin number
  56. #define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
  57. #define STM_PIN(X) ((uint32_t)(X) & 0xF)
  58. typedef enum {
  59. PIN_INPUT,
  60. PIN_OUTPUT
  61. } PinDirection;
  62. typedef enum {
  63. PA_0 = 0x00,
  64. PA_1 = 0x01,
  65. PA_2 = 0x02,
  66. PA_3 = 0x03,
  67. PA_4 = 0x04,
  68. PA_5 = 0x05,
  69. PA_6 = 0x06,
  70. PA_7 = 0x07,
  71. PA_8 = 0x08,
  72. PA_9 = 0x09,
  73. PA_10 = 0x0A,
  74. PA_11 = 0x0B,
  75. PA_12 = 0x0C,
  76. PA_13 = 0x0D,
  77. PA_14 = 0x0E,
  78. PA_15 = 0x0F,
  79. PB_0 = 0x10,
  80. PB_1 = 0x11,
  81. PB_2 = 0x12,
  82. PB_3 = 0x13,
  83. PB_4 = 0x14,
  84. PB_5 = 0x15,
  85. PB_6 = 0x16,
  86. PB_7 = 0x17,
  87. PB_8 = 0x18,
  88. PB_9 = 0x19,
  89. PB_10 = 0x1A,
  90. PB_11 = 0x1B,
  91. PB_12 = 0x1C,
  92. PB_13 = 0x1D,
  93. PB_14 = 0x1E,
  94. PB_15 = 0x1F,
  95. PC_0 = 0x20,
  96. PC_1 = 0x21,
  97. PC_2 = 0x22,
  98. PC_3 = 0x23,
  99. PC_4 = 0x24,
  100. PC_5 = 0x25,
  101. PC_6 = 0x26,
  102. PC_7 = 0x27,
  103. PC_8 = 0x28,
  104. PC_9 = 0x29,
  105. PC_10 = 0x2A,
  106. PC_11 = 0x2B,
  107. PC_12 = 0x2C,
  108. PC_13 = 0x2D,
  109. PC_14 = 0x2E,
  110. PC_15 = 0x2F,
  111. PD_2 = 0x32,
  112. PF_0 = 0x50,
  113. PF_1 = 0x51,
  114. PF_4 = 0x54,
  115. PF_5 = 0x55,
  116. PF_6 = 0x56,
  117. PF_7 = 0x57,
  118. // Arduino connector namings
  119. A0 = PA_0,
  120. A1 = PA_1,
  121. A2 = PA_4,
  122. A3 = PB_0,
  123. A4 = PC_1,
  124. A5 = PC_0,
  125. D0 = PA_3,
  126. D1 = PA_2,
  127. D2 = PA_10,
  128. D3 = PB_3,
  129. D4 = PB_5,
  130. D5 = PB_4,
  131. D6 = PB_10,
  132. D7 = PA_8,
  133. D8 = PA_9,
  134. D9 = PC_7,
  135. D10 = PB_6,
  136. D11 = PA_7,
  137. D12 = PA_6,
  138. D13 = PA_5,
  139. D14 = PB_9,
  140. D15 = PB_8,
  141. // Generic signals namings
  142. LED1 = PA_5,
  143. LED2 = PA_5,
  144. LED3 = PA_5,
  145. LED4 = PA_5,
  146. USER_BUTTON = PC_13,
  147. SERIAL_TX = PA_2,
  148. SERIAL_RX = PA_3,
  149. USBTX = PA_2,
  150. USBRX = PA_3,
  151. I2C_SCL = PB_8,
  152. I2C_SDA = PB_9,
  153. SPI_MOSI = PA_7,
  154. SPI_MISO = PA_6,
  155. SPI_SCK = PA_5,
  156. SPI_CS = PB_6,
  157. PWM_OUT = PC_7,
  158. // Not connected
  159. NC = (int)0xFFFFFFFF
  160. } PinName;
  161. typedef enum {
  162. PullNone = 0,
  163. PullUp = 1,
  164. PullDown = 2,
  165. OpenDrain = 3,
  166. PullDefault = PullNone
  167. } PinMode;
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif