gpio.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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) 2016 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 PEPin PEPin */
  64. GPIO_InitStruct.Pin = FPGA_GPIO2_Pin|UNUSED_PE5_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 : PE3 */
  69. GPIO_InitStruct.Pin = FPGA_GPIO3_Pin;
  70. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  71. GPIO_InitStruct.Pull = GPIO_NOPULL;
  72. HAL_GPIO_Init(GPIOE, &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 pins : PCPin PCPin PCPin PCPin
  79. PCPin PCPin PCPin PCPin
  80. PCPin */
  81. GPIO_InitStruct.Pin = UNUSED_PC13_Pin|UNUSED_PC14_Pin|UNUSED_PC15_Pin|UNUSED_PC0_Pin
  82. |UNUSED_PC1_Pin|UNUSED_PC2_Pin|UNUSED_PC3_Pin;
  83. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  84. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  85. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  86. // Pins are used to sense scsi2sd hardware version, must be pullup
  87. GPIO_InitStruct.Pin = UNUSED_PC4_Pin|UNUSED_PC5_Pin;
  88. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  89. GPIO_InitStruct.Pull = GPIO_PULLUP;
  90. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  91. /*Configure GPIO pins : PAPin PAPin PAPin PAPin */
  92. GPIO_InitStruct.Pin = UNUSED_PA0_Pin|UNUSED_PA1_Pin|UNUSED_PA2_Pin|UNUSED_PA3_Pin;
  93. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  94. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  95. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  96. /*Configure GPIO pin : PtPin */
  97. GPIO_InitStruct.Pin = nSPICFG_CS_Pin;
  98. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  99. GPIO_InitStruct.Pull = GPIO_NOPULL;
  100. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  101. HAL_GPIO_Init(nSPICFG_CS_GPIO_Port, &GPIO_InitStruct);
  102. /*Configure GPIO pin : PtPin */
  103. GPIO_InitStruct.Pin = LED_Pin;
  104. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  105. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  106. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  107. HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
  108. /*Configure GPIO pin : PtPin */
  109. GPIO_InitStruct.Pin = nTERM_EN_Pin;
  110. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  111. GPIO_InitStruct.Pull = GPIO_NOPULL;
  112. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  113. HAL_GPIO_Init(nTERM_EN_GPIO_Port, &GPIO_InitStruct);
  114. /*Configure GPIO pins : PBPin PBPin PBPin */
  115. GPIO_InitStruct.Pin = BOOT1_Pin|UNUSED_PB5_Pin|UNUSED_PB6_Pin;
  116. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  117. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  118. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  119. /*Configure GPIO pins : PBPin PBPin */
  120. GPIO_InitStruct.Pin = UNUSED_PB12_Pin|UNUSED_PB13_Pin;
  121. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  122. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  123. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  124. /*Configure GPIO pins : PD6, PD12 */
  125. // PD6: FSMC NWAIT, not used yet.PULLED UP in fpga pin config
  126. // PD12: FPGA_GPIO1, not used.
  127. GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_12;
  128. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  129. GPIO_InitStruct.Pull = GPIO_PULLUP;
  130. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  131. /*Configure GPIO pins : PDPin PDPin */
  132. GPIO_InitStruct.Pin = UNUSED_PD11_Pin|FSMC_UNUSED_CLK_Pin;
  133. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  134. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  135. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  136. /*Configure GPIO pin : PtPin */
  137. GPIO_InitStruct.Pin = FPGA_RST_Pin;
  138. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  139. GPIO_InitStruct.Pull = GPIO_NOPULL;
  140. GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  141. HAL_GPIO_Init(FPGA_RST_GPIO_Port, &GPIO_InitStruct);
  142. /*Configure GPIO pins : PCPin PCPin */
  143. GPIO_InitStruct.Pin = nFGPA_CRESET_B_Pin|nFGPA_CDONE_Pin;
  144. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  145. GPIO_InitStruct.Pull = GPIO_NOPULL;
  146. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  147. /*Configure GPIO pin : PA8 */
  148. GPIO_InitStruct.Pin = GPIO_PIN_8;
  149. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  150. GPIO_InitStruct.Pull = GPIO_NOPULL;
  151. GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  152. GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
  153. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  154. /*Configure GPIO pin : PA10 */
  155. // USB Host OTG ID pin
  156. GPIO_InitStruct.Pin = GPIO_PIN_10;
  157. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  158. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  159. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  160. // USB Host pins, currently unused.
  161. GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
  162. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  163. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  164. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  165. /*Configure GPIO pins : PBPin PBPin */
  166. GPIO_InitStruct.Pin = nSD_WP_Pin|nSD_CD_Pin;
  167. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  168. GPIO_InitStruct.Pull = GPIO_PULLUP;
  169. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  170. /* EXTI interrupt init*/
  171. HAL_NVIC_SetPriority(EXTI4_IRQn, 10, 0);
  172. HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  173. }
  174. /* USER CODE BEGIN 2 */
  175. /* USER CODE END 2 */
  176. /**
  177. * @}
  178. */
  179. /**
  180. * @}
  181. */
  182. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/