gpio.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. ******************************************************************************
  3. * File Name : gpio.c
  4. * Description : This file provides code for the configuration
  5. * of all used GPIO pins.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "gpio.h"
  21. /* USER CODE BEGIN 0 */
  22. /* USER CODE END 0 */
  23. /*----------------------------------------------------------------------------*/
  24. /* Configure GPIO */
  25. /*----------------------------------------------------------------------------*/
  26. /* USER CODE BEGIN 1 */
  27. /* USER CODE END 1 */
  28. /** Configure pins as
  29. * Analog
  30. * Input
  31. * Output
  32. * EVENT_OUT
  33. * EXTI
  34. * Free pins are configured automatically as Analog (this feature is enabled through
  35. * the Code Generation settings)
  36. PA8 ------> RCC_MCO_1
  37. */
  38. void MX_GPIO_Init(void)
  39. {
  40. GPIO_InitTypeDef GPIO_InitStruct = {0};
  41. /* GPIO Ports Clock Enable */
  42. __HAL_RCC_GPIOE_CLK_ENABLE();
  43. __HAL_RCC_GPIOC_CLK_ENABLE();
  44. __HAL_RCC_GPIOH_CLK_ENABLE();
  45. __HAL_RCC_GPIOA_CLK_ENABLE();
  46. __HAL_RCC_GPIOB_CLK_ENABLE();
  47. __HAL_RCC_GPIOD_CLK_ENABLE();
  48. /*Configure GPIO pin Output Level */
  49. HAL_GPIO_WritePin(GPIOA, nULPI_RESET_Pin|nSPICFG_CS_Pin, GPIO_PIN_RESET);
  50. /*Configure GPIO pin Output Level */
  51. HAL_GPIO_WritePin(GPIOB, nTERM_EN_Pin|LED_IO_Pin, GPIO_PIN_RESET);
  52. /*Configure GPIO pin Output Level */
  53. HAL_GPIO_WritePin(FPGA_RST_GPIO_Port, FPGA_RST_Pin, GPIO_PIN_RESET);
  54. /*Configure GPIO pins : PEPin PEPin */
  55. GPIO_InitStruct.Pin = FPGA_GPIO2_Pin|UNUSED_PE6_Pin;
  56. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  57. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  58. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  59. /*Configure GPIO pin : PtPin */
  60. GPIO_InitStruct.Pin = FPGA_GPIO3_Pin;
  61. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  62. GPIO_InitStruct.Pull = GPIO_NOPULL;
  63. HAL_GPIO_Init(FPGA_GPIO3_GPIO_Port, &GPIO_InitStruct);
  64. /*Configure GPIO pin : PE4 */
  65. GPIO_InitStruct.Pin = GPIO_PIN_4;
  66. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  67. GPIO_InitStruct.Pull = GPIO_NOPULL;
  68. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  69. /*Configure GPIO pin : PtPin */
  70. GPIO_InitStruct.Pin = USB_ID_PASSTHRU_Pin;
  71. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  72. GPIO_InitStruct.Pull = GPIO_NOPULL;
  73. HAL_GPIO_Init(USB_ID_PASSTHRU_GPIO_Port, &GPIO_InitStruct);
  74. /*Configure GPIO pins : PC13 PC14 PC15 PC1 */
  75. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_1;
  76. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  77. GPIO_InitStruct.Pull = GPIO_NOPULL;
  78. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  79. /*Configure GPIO pins : PAPin PAPin */
  80. GPIO_InitStruct.Pin = nULPI_RESET_Pin|nSPICFG_CS_Pin;
  81. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  82. GPIO_InitStruct.Pull = GPIO_NOPULL;
  83. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  84. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  85. /*Configure GPIO pins : PCPin PCPin */
  86. GPIO_InitStruct.Pin = VER_ID1_Pin|VER_ID2_Pin;
  87. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  88. GPIO_InitStruct.Pull = GPIO_PULLUP;
  89. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  90. /*Configure GPIO pin : PtPin */
  91. GPIO_InitStruct.Pin = BOOT1_Pin;
  92. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  93. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  94. HAL_GPIO_Init(BOOT1_GPIO_Port, &GPIO_InitStruct);
  95. /*Configure GPIO pin : PtPin */
  96. GPIO_InitStruct.Pin = nTERM_EN_Pin;
  97. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  98. GPIO_InitStruct.Pull = GPIO_NOPULL;
  99. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  100. HAL_GPIO_Init(nTERM_EN_GPIO_Port, &GPIO_InitStruct);
  101. /*Configure GPIO pin : PtPin */
  102. GPIO_InitStruct.Pin = LED_IO_Pin;
  103. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  104. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  105. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  106. HAL_GPIO_Init(LED_IO_GPIO_Port, &GPIO_InitStruct);
  107. /*Configure GPIO pins : PD11 PDPin */
  108. GPIO_InitStruct.Pin = GPIO_PIN_11|NWAIT_UNUSED_Pin;
  109. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  110. GPIO_InitStruct.Pull = GPIO_NOPULL;
  111. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  112. /*Configure GPIO pin : PtPin */
  113. GPIO_InitStruct.Pin = FPGA_RST_Pin;
  114. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  115. GPIO_InitStruct.Pull = GPIO_NOPULL;
  116. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  117. HAL_GPIO_Init(FPGA_RST_GPIO_Port, &GPIO_InitStruct);
  118. /*Configure GPIO pins : PCPin PCPin */
  119. GPIO_InitStruct.Pin = nFGPA_CRESET_B_Pin|nFGPA_CDONE_Pin;
  120. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  121. GPIO_InitStruct.Pull = GPIO_NOPULL;
  122. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  123. /*Configure GPIO pin : PA8 */
  124. GPIO_InitStruct.Pin = GPIO_PIN_8;
  125. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  126. GPIO_InitStruct.Pull = GPIO_NOPULL;
  127. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  128. GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
  129. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  130. /*Configure GPIO pin : PtPin */
  131. GPIO_InitStruct.Pin = OTG_FS_VBUS_UNUSED_Pin;
  132. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  133. GPIO_InitStruct.Pull = GPIO_NOPULL;
  134. HAL_GPIO_Init(OTG_FS_VBUS_UNUSED_GPIO_Port, &GPIO_InitStruct);
  135. /*Configure GPIO pin : PtPin */
  136. GPIO_InitStruct.Pin = FSMC_UNUSED_CLK_Pin;
  137. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  138. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  139. HAL_GPIO_Init(FSMC_UNUSED_CLK_GPIO_Port, &GPIO_InitStruct);
  140. /*Configure GPIO pin : PB6 */
  141. GPIO_InitStruct.Pin = GPIO_PIN_6;
  142. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  143. GPIO_InitStruct.Pull = GPIO_NOPULL;
  144. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  145. /*Configure GPIO pins : PBPin PBPin */
  146. GPIO_InitStruct.Pin = nSD_WP_Pin|nSD_CD_Pin;
  147. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  148. GPIO_InitStruct.Pull = GPIO_PULLUP;
  149. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  150. /* EXTI interrupt init*/
  151. HAL_NVIC_SetPriority(EXTI4_IRQn, 10, 0);
  152. HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  153. }
  154. /* USER CODE BEGIN 2 */
  155. /* USER CODE END 2 */
  156. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/