pin_defs_stm32.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2013, 2014 Damien P. George
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. // This file contains pin definitions that are specific to the stm32 port.
  27. // This file should only ever be #included by pin.h and not directly.
  28. enum {
  29. PORT_A,
  30. PORT_B,
  31. PORT_C,
  32. PORT_D,
  33. PORT_E,
  34. PORT_F,
  35. PORT_G,
  36. PORT_H,
  37. PORT_I,
  38. PORT_J,
  39. PORT_K,
  40. };
  41. // Must have matching entries in SUPPORTED_FN in boards/make-pins.py
  42. enum {
  43. AF_FN_TIM,
  44. AF_FN_I2C,
  45. AF_FN_USART,
  46. AF_FN_UART = AF_FN_USART,
  47. AF_FN_SPI,
  48. AF_FN_I2S,
  49. AF_FN_SDMMC,
  50. AF_FN_CAN,
  51. };
  52. enum {
  53. AF_PIN_TYPE_TIM_CH1 = 0,
  54. AF_PIN_TYPE_TIM_CH2,
  55. AF_PIN_TYPE_TIM_CH3,
  56. AF_PIN_TYPE_TIM_CH4,
  57. AF_PIN_TYPE_TIM_CH1N,
  58. AF_PIN_TYPE_TIM_CH2N,
  59. AF_PIN_TYPE_TIM_CH3N,
  60. AF_PIN_TYPE_TIM_CH1_ETR,
  61. AF_PIN_TYPE_TIM_ETR,
  62. AF_PIN_TYPE_TIM_BKIN,
  63. AF_PIN_TYPE_I2C_SDA = 0,
  64. AF_PIN_TYPE_I2C_SCL,
  65. AF_PIN_TYPE_USART_TX = 0,
  66. AF_PIN_TYPE_USART_RX,
  67. AF_PIN_TYPE_USART_CTS,
  68. AF_PIN_TYPE_USART_RTS,
  69. AF_PIN_TYPE_USART_CK,
  70. AF_PIN_TYPE_UART_TX = AF_PIN_TYPE_USART_TX,
  71. AF_PIN_TYPE_UART_RX = AF_PIN_TYPE_USART_RX,
  72. AF_PIN_TYPE_UART_CTS = AF_PIN_TYPE_USART_CTS,
  73. AF_PIN_TYPE_UART_RTS = AF_PIN_TYPE_USART_RTS,
  74. AF_PIN_TYPE_SPI_MOSI = 0,
  75. AF_PIN_TYPE_SPI_MISO,
  76. AF_PIN_TYPE_SPI_SCK,
  77. AF_PIN_TYPE_SPI_NSS,
  78. AF_PIN_TYPE_I2S_CK = 0,
  79. AF_PIN_TYPE_I2S_MCK,
  80. AF_PIN_TYPE_I2S_SD,
  81. AF_PIN_TYPE_I2S_WS,
  82. AF_PIN_TYPE_I2S_EXTSD,
  83. AF_PIN_TYPE_SDMMC_CK = 0,
  84. AF_PIN_TYPE_SDMMC_CMD,
  85. AF_PIN_TYPE_SDMMC_D0,
  86. AF_PIN_TYPE_SDMMC_D1,
  87. AF_PIN_TYPE_SDMMC_D2,
  88. AF_PIN_TYPE_SDMMC_D3,
  89. AF_PIN_TYPE_CAN_TX = 0,
  90. AF_PIN_TYPE_CAN_RX,
  91. };
  92. // The HAL uses a slightly different naming than we chose, so we provide
  93. // some #defines to massage things. Also I2S and SPI share the same
  94. // peripheral.
  95. #define GPIO_AF5_I2S2 GPIO_AF5_SPI2
  96. #define GPIO_AF5_I2S3 GPIO_AF5_I2S3ext
  97. #define GPIO_AF6_I2S2 GPIO_AF6_I2S2ext
  98. #define GPIO_AF6_I2S3 GPIO_AF6_SPI3
  99. #define GPIO_AF7_I2S2 GPIO_AF7_SPI2
  100. #define GPIO_AF7_I2S3 GPIO_AF7_I2S3ext
  101. #define I2S2 SPI2
  102. #define I2S3 SPI3
  103. enum {
  104. PIN_ADC1 = (1 << 0),
  105. PIN_ADC2 = (1 << 1),
  106. PIN_ADC3 = (1 << 2),
  107. };
  108. typedef GPIO_TypeDef pin_gpio_t;