gpio.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. ******************************************************************************
  3. * File Name : gpio.c
  4. * Description : This file provides code for the configuration
  5. * of all used GPIO pins.
  6. ******************************************************************************
  7. *
  8. * COPYRIGHT(c) 2019 STMicroelectronics
  9. *
  10. * Redistribution and use in source and binary forms, with or without modification,
  11. * are permitted provided that the following conditions are met:
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  25. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. ******************************************************************************
  33. */
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "gpio.h"
  36. /* USER CODE BEGIN 0 */
  37. /* USER CODE END 0 */
  38. /*----------------------------------------------------------------------------*/
  39. /* Configure GPIO */
  40. /*----------------------------------------------------------------------------*/
  41. /* USER CODE BEGIN 1 */
  42. /* USER CODE END 1 */
  43. /** Configure pins as
  44. * Analog
  45. * Input
  46. * Output
  47. * EVENT_OUT
  48. * EXTI
  49. * Free pins are configured automatically as Analog (this feature is enabled through
  50. * the Code Generation settings)
  51. PA8 ------> RCC_MCO_1
  52. */
  53. void MX_GPIO_Init(void)
  54. {
  55. GPIO_InitTypeDef GPIO_InitStruct;
  56. /* GPIO Ports Clock Enable */
  57. __GPIOE_CLK_ENABLE();
  58. __GPIOC_CLK_ENABLE();
  59. __GPIOH_CLK_ENABLE();
  60. __GPIOA_CLK_ENABLE();
  61. __GPIOB_CLK_ENABLE();
  62. __GPIOD_CLK_ENABLE();
  63. /*Configure GPIO pins : PEPin PEPin */
  64. GPIO_InitStruct.Pin = FPGA_GPIO2_Pin|UNUSED_PE6_Pin;
  65. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  66. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  67. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  68. /*Configure GPIO pin : PtPin */
  69. GPIO_InitStruct.Pin = FPGA_GPIO3_Pin;
  70. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  71. GPIO_InitStruct.Pull = GPIO_NOPULL;
  72. HAL_GPIO_Init(FPGA_GPIO3_GPIO_Port, &GPIO_InitStruct);
  73. /*Configure GPIO pin : PE4 */
  74. GPIO_InitStruct.Pin = GPIO_PIN_4;
  75. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  76. GPIO_InitStruct.Pull = GPIO_NOPULL;
  77. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  78. /*Configure GPIO pin : PtPin */
  79. GPIO_InitStruct.Pin = USB_ID_PASSTHRU_Pin;
  80. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  81. GPIO_InitStruct.Pull = GPIO_NOPULL;
  82. HAL_GPIO_Init(USB_ID_PASSTHRU_GPIO_Port, &GPIO_InitStruct);
  83. /*Configure GPIO pins : PC13 PC14 PC15 PC1 */
  84. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_1;
  85. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  86. GPIO_InitStruct.Pull = GPIO_NOPULL;
  87. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  88. /*Configure GPIO pins : PAPin PAPin */
  89. GPIO_InitStruct.Pin = nULPI_RESET_Pin|nSPICFG_CS_Pin;
  90. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  91. GPIO_InitStruct.Pull = GPIO_NOPULL;
  92. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  93. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  94. /*Configure GPIO pins : PCPin PCPin */
  95. GPIO_InitStruct.Pin = VER_ID1_Pin|VER_ID2_Pin;
  96. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  97. GPIO_InitStruct.Pull = GPIO_PULLUP;
  98. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  99. /*Configure GPIO pin : PtPin */
  100. GPIO_InitStruct.Pin = BOOT1_Pin;
  101. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  102. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  103. HAL_GPIO_Init(BOOT1_GPIO_Port, &GPIO_InitStruct);
  104. /*Configure GPIO pins : PBPin */
  105. GPIO_InitStruct.Pin = nTERM_EN_Pin;
  106. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  107. GPIO_InitStruct.Pull = GPIO_NOPULL;
  108. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  109. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  110. /*Configure GPIO pins : PBPin */
  111. GPIO_InitStruct.Pin = LED_IO_Pin;
  112. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  113. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  114. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  115. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  116. /*Configure GPIO pins : PD11 PDPin */
  117. GPIO_InitStruct.Pin = GPIO_PIN_11|NWAIT_UNUSED_Pin;
  118. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  119. GPIO_InitStruct.Pull = GPIO_NOPULL;
  120. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  121. /*Configure GPIO pin : PtPin */
  122. GPIO_InitStruct.Pin = FPGA_RST_Pin;
  123. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  124. GPIO_InitStruct.Pull = GPIO_NOPULL;
  125. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  126. HAL_GPIO_Init(FPGA_RST_GPIO_Port, &GPIO_InitStruct);
  127. /*Configure GPIO pins : PCPin PCPin */
  128. GPIO_InitStruct.Pin = nFGPA_CRESET_B_Pin|nFGPA_CDONE_Pin;
  129. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  130. GPIO_InitStruct.Pull = GPIO_NOPULL;
  131. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  132. /*Configure GPIO pin : PA8 */
  133. GPIO_InitStruct.Pin = GPIO_PIN_8;
  134. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  135. GPIO_InitStruct.Pull = GPIO_NOPULL;
  136. GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  137. GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
  138. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  139. /*Configure GPIO pin : PtPin */
  140. GPIO_InitStruct.Pin = OTG_FS_VBUS_UNUSED_Pin;
  141. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  142. GPIO_InitStruct.Pull = GPIO_NOPULL;
  143. HAL_GPIO_Init(OTG_FS_VBUS_UNUSED_GPIO_Port, &GPIO_InitStruct);
  144. /*Configure GPIO pin : PtPin */
  145. GPIO_InitStruct.Pin = FSMC_UNUSED_CLK_Pin;
  146. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  147. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  148. HAL_GPIO_Init(FSMC_UNUSED_CLK_GPIO_Port, &GPIO_InitStruct);
  149. /*Configure GPIO pin : PB6 */
  150. GPIO_InitStruct.Pin = GPIO_PIN_6;
  151. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  152. GPIO_InitStruct.Pull = GPIO_NOPULL;
  153. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  154. /*Configure GPIO pins : PBPin PBPin */
  155. GPIO_InitStruct.Pin = nSD_WP_Pin|nSD_CD_Pin;
  156. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  157. GPIO_InitStruct.Pull = GPIO_PULLUP;
  158. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  159. /* EXTI interrupt init*/
  160. HAL_NVIC_SetPriority(EXTI4_IRQn, 10, 0);
  161. HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  162. }
  163. /* USER CODE BEGIN 2 */
  164. /* USER CODE END 2 */
  165. /**
  166. * @}
  167. */
  168. /**
  169. * @}
  170. */
  171. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/