stm32_gpio.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (C) 2013 Uwe Bonnes(bon@elektron.ikp.physik.tu-darmstadt.de)
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  21. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. *
  32. */
  33. /*
  34. * \verbatim
  35. * $Id$
  36. * \endverbatim
  37. */
  38. /* STM32 Remapping defines for L1/F2/3/4*/
  39. #define GPIO_Mode_IN 0
  40. #define GPIO_Mode_OUT 1
  41. #define GPIO_Mode_AF 2
  42. #define GPIO_Mode_AN 3
  43. #define GPIO_PuPd_NOPULL 0
  44. #define GPIO_PuPd_UP 1
  45. #define GPIO_PuPd_DOWN 2
  46. #define GPIO_AF_0 0
  47. #define GPIO_AF_1 1
  48. #define GPIO_AF_2 2
  49. #define GPIO_AF_3 3
  50. #define GPIO_AF_4 4
  51. #define GPIO_AF_5 5
  52. #define GPIO_AF_6 6
  53. #define GPIO_AF_7 7
  54. #define GPIO_AF_8 8
  55. #define GPIO_AF_9 9
  56. #define GPIO_AF_A 10
  57. #define GPIO_AF_B 11
  58. #define GPIO_AF_C 12
  59. #define GPIO_AF_D 13
  60. #define GPIO_AF_E 14
  61. #define GPIO_AF_F 15
  62. #define GPIO_AF_RTC_50Hz GPIO_AF_0
  63. #define GPIO_AF_MCO GPIO_AF_0
  64. #define GPIO_AF_TAMPER GPIO_AF_0
  65. #define GPIO_AF_SWJ GPIO_AF_0
  66. #define GPIO_AF_TRACE GPIO_AF_0
  67. #define GPIO_AF_TIM1 GPIO_AF_1
  68. #define GPIO_AF_TIM2 GPIO_AF_1
  69. #define GPIO_AF_TIM3 GPIO_AF_2
  70. #define GPIO_AF_TIM4 GPIO_AF_2
  71. #define GPIO_AF_TIM5 GPIO_AF_2
  72. #define GPIO_AF_TIM8 GPIO_AF_3
  73. #define GPIO_AF_TIM9 GPIO_AF_3
  74. #define GPIO_AF_TIM10 GPIO_AF_3
  75. #define GPIO_AF_TIM11 GPIO_AF_3
  76. #define GPIO_AF_I2C1 GPIO_AF_4
  77. #define GPIO_AF_I2C2 GPIO_AF_4
  78. #define GPIO_AF_I2C3 GPIO_AF_4
  79. #define GPIO_AF_SPI1 GPIO_AF_5
  80. #define GPIO_AF_SPI2 GPIO_AF_5
  81. #define GPIO_AF_SPI4 GPIO_AF_5
  82. #define GPIO_AF_SPI5 GPIO_AF_5
  83. #define GPIO_AF_SPI6 GPIO_AF_5
  84. #define GPIO_AF_SPI3 GPIO_AF_6
  85. #define GPIO_AF_USART1 GPIO_AF_7
  86. #define GPIO_AF_USART2 GPIO_AF_7
  87. #define GPIO_AF_USART3 GPIO_AF_7
  88. #define GPIO_AF_I2S3ext GPIO_AF_7
  89. #define GPIO_AF_UART4 GPIO_AF_8
  90. #define GPIO_AF_UART5 GPIO_AF_8
  91. #define GPIO_AF_USART6 GPIO_AF_8
  92. #define GPIO_AF_UART7 GPIO_AF_8
  93. #define GPIO_AF_UART8 GPIO_AF_8
  94. #define GPIO_AF_CAN1 GPIO_AF_9
  95. #define GPIO_AF_CAN2 GPIO_AF_9
  96. #define GPIO_AF_TIM12 GPIO_AF_9
  97. #define GPIO_AF_TIM13 GPIO_AF_9
  98. #define GPIO_AF_TIM14 GPIO_AF_9
  99. #define GPIO_AF_OTG_FS GPIO_AF_A
  100. #define GPIO_AF_OTG_HS GPIO_AF_A
  101. #define GPIO_AF_ETH GPIO_AF_B
  102. #define GPIO_AF_FSMC GPIO_AF_C
  103. #define GPIO_AF_OTG_HS_FS GPIO_AF_C
  104. #define GPIO_AF_SDIO GPIO_AF_C
  105. #define GPIO_AF_DCMI GPIO_AF_D
  106. #define GPIO_AF_EVENTOUT GPIO_AD_F
  107. void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, nutgpio_pin_t GPIO_PinSource, uint8_t GPIO_AF);