gpio.c 6.6 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(GPIOB, LED_IO_Pin|nTERM_EN_Pin, GPIO_PIN_RESET);
  50. /*Configure GPIO pin Output Level */
  51. HAL_GPIO_WritePin(FPGA_RST_GPIO_Port, FPGA_RST_Pin, GPIO_PIN_RESET);
  52. /*Configure GPIO pins : PEPin PEPin PEPin PEPin */
  53. GPIO_InitStruct.Pin = FPGA_GPIO2_Pin|FPGA_GPIO3_Pin|UNUSED_PE5_Pin|UNUSED_PE6_Pin;
  54. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  55. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  56. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  57. /*Configure GPIO pin : PE4 */
  58. GPIO_InitStruct.Pin = GPIO_PIN_4;
  59. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  60. GPIO_InitStruct.Pull = GPIO_NOPULL;
  61. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  62. /*Configure GPIO pins : PCPin PCPin PCPin PCPin
  63. PCPin PCPin PCPin */
  64. GPIO_InitStruct.Pin = UNUSED_PC13_Pin|UNUSED_PC14_Pin|UNUSED_PC15_Pin|UNUSED_PC0_Pin
  65. |UNUSED_PC1_Pin|UNUSED_PC2_Pin|UNUSED_PC3_Pin;
  66. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  67. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  68. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  69. /*Configure GPIO pins : PAPin PAPin PAPin PAPin */
  70. GPIO_InitStruct.Pin = UNUSED_PA0_Pin|UNUSED_PA1_Pin|UNUSED_PA2_Pin|UNUSED_PA3_Pin;
  71. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  72. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  73. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  74. /*Configure GPIO pin : PtPin */
  75. GPIO_InitStruct.Pin = nSPICFG_CS_Pin;
  76. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  77. GPIO_InitStruct.Pull = GPIO_NOPULL;
  78. HAL_GPIO_Init(nSPICFG_CS_GPIO_Port, &GPIO_InitStruct);
  79. /*Configure GPIO pins : PCPin PCPin */
  80. GPIO_InitStruct.Pin = VER_ID1_Pin|VER_ID2_Pin;
  81. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  82. GPIO_InitStruct.Pull = GPIO_PULLUP;
  83. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  84. /*Configure GPIO pin : PtPin */
  85. GPIO_InitStruct.Pin = LED_IO_Pin;
  86. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  87. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  88. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  89. HAL_GPIO_Init(LED_IO_GPIO_Port, &GPIO_InitStruct);
  90. /*Configure GPIO pin : PtPin */
  91. GPIO_InitStruct.Pin = nTERM_EN_Pin;
  92. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  93. GPIO_InitStruct.Pull = GPIO_NOPULL;
  94. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  95. HAL_GPIO_Init(nTERM_EN_GPIO_Port, &GPIO_InitStruct);
  96. /*Configure GPIO pins : PBPin PBPin PBPin */
  97. GPIO_InitStruct.Pin = BOOT1_Pin|UNUSED_PB5_Pin|UNUSED_PB6_Pin;
  98. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  99. GPIO_InitStruct.Pull = GPIO_NOPULL;
  100. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  101. /*Configure GPIO pins : PBPin PBPin */
  102. GPIO_InitStruct.Pin = UNUSED_PB12_Pin|UNUSED_PB13_Pin;
  103. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  104. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  105. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  106. /*Configure GPIO pins : PB14 PB15 PB3 PB4 */
  107. GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4;
  108. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  109. GPIO_InitStruct.Pull = GPIO_NOPULL;
  110. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  111. /*Configure GPIO pins : PDPin PDPin */
  112. GPIO_InitStruct.Pin = UNUSED_PD11_Pin|FSMC_UNUSED_CLK_Pin;
  113. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  114. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  115. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  116. /*Configure GPIO pin : PtPin */
  117. GPIO_InitStruct.Pin = FPGA_RST_Pin;
  118. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  119. GPIO_InitStruct.Pull = GPIO_NOPULL;
  120. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  121. HAL_GPIO_Init(FPGA_RST_GPIO_Port, &GPIO_InitStruct);
  122. /*Configure GPIO pins : PCPin PCPin */
  123. GPIO_InitStruct.Pin = nFGPA_CRESET_B_Pin|nFGPA_CDONE_Pin;
  124. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  125. GPIO_InitStruct.Pull = GPIO_NOPULL;
  126. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  127. /*Configure GPIO pin : PA8 */
  128. GPIO_InitStruct.Pin = GPIO_PIN_8;
  129. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  130. GPIO_InitStruct.Pull = GPIO_NOPULL;
  131. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  132. GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
  133. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  134. /*Configure GPIO pins : PA9 PA10 PA13 PA14
  135. PA15 */
  136. GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_13|GPIO_PIN_14
  137. |GPIO_PIN_15;
  138. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  139. GPIO_InitStruct.Pull = GPIO_NOPULL;
  140. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  141. /*Configure GPIO pin : PD6 */
  142. GPIO_InitStruct.Pin = GPIO_PIN_6;
  143. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  144. GPIO_InitStruct.Pull = GPIO_NOPULL;
  145. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  146. /*Configure GPIO pins : PBPin PBPin */
  147. GPIO_InitStruct.Pin = nSD_WP_Pin|nSD_CD_Pin;
  148. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  149. GPIO_InitStruct.Pull = GPIO_PULLUP;
  150. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  151. /* EXTI interrupt init*/
  152. HAL_NVIC_SetPriority(EXTI4_IRQn, 10, 0);
  153. HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  154. }
  155. /* USER CODE BEGIN 2 */
  156. /* USER CODE END 2 */
  157. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/