gpio.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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) 2020 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. PA9 ------> USB_OTG_FS_VBUS
  37. PA10 ------> USB_OTG_FS_ID
  38. PA11 ------> USB_OTG_FS_DM
  39. PA12 ------> USB_OTG_FS_DP
  40. */
  41. void MX_GPIO_Init(void)
  42. {
  43. GPIO_InitTypeDef GPIO_InitStruct = {0};
  44. /* GPIO Ports Clock Enable */
  45. __HAL_RCC_GPIOC_CLK_ENABLE();
  46. __HAL_RCC_GPIOH_CLK_ENABLE();
  47. __HAL_RCC_GPIOA_CLK_ENABLE();
  48. __HAL_RCC_GPIOB_CLK_ENABLE();
  49. __HAL_RCC_GPIOD_CLK_ENABLE();
  50. /*Configure GPIO pin Output Level */
  51. HAL_GPIO_WritePin(GPIOC, WC_Pin|LED_rouge_Pin|LED_vert_Pin, GPIO_PIN_RESET);
  52. /*Configure GPIO pin Output Level */
  53. HAL_GPIO_WritePin(aquit_GPIO_Port, aquit_Pin, GPIO_PIN_RESET);
  54. /*Configure GPIO pin Output Level */
  55. HAL_GPIO_WritePin(GPIOB, LED_orange_Pin|MFP_Pin, GPIO_PIN_RESET);
  56. /*Configure GPIO pins : PC13 PC15 PC0 PC1
  57. PC2 PC3 PC10 PC11
  58. PC12 */
  59. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
  60. |GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_10|GPIO_PIN_11
  61. |GPIO_PIN_12;
  62. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  63. GPIO_InitStruct.Pull = GPIO_NOPULL;
  64. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  65. /*Configure GPIO pins : PCPin PCPin PCPin */
  66. GPIO_InitStruct.Pin = WC_Pin|LED_rouge_Pin|LED_vert_Pin;
  67. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  68. GPIO_InitStruct.Pull = GPIO_NOPULL;
  69. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  70. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  71. /*Configure GPIO pin : PtPin */
  72. GPIO_InitStruct.Pin = aquit_Pin;
  73. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  74. GPIO_InitStruct.Pull = GPIO_NOPULL;
  75. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  76. HAL_GPIO_Init(aquit_GPIO_Port, &GPIO_InitStruct);
  77. /*Configure GPIO pin : PtPin */
  78. GPIO_InitStruct.Pin = MYPIN_Pin;
  79. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  80. GPIO_InitStruct.Pull = GPIO_NOPULL;
  81. HAL_GPIO_Init(MYPIN_GPIO_Port, &GPIO_InitStruct);
  82. /*Configure GPIO pins : PBPin PBPin */
  83. GPIO_InitStruct.Pin = LED_orange_Pin|MFP_Pin;
  84. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  85. GPIO_InitStruct.Pull = GPIO_NOPULL;
  86. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  87. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  88. /*Configure GPIO pins : PB12 PB13 PB14 PB15
  89. PB5 */
  90. GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
  91. |GPIO_PIN_5;
  92. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  93. GPIO_InitStruct.Pull = GPIO_NOPULL;
  94. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  95. /*Configure GPIO pin : PA9 */
  96. GPIO_InitStruct.Pin = GPIO_PIN_9;
  97. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  98. GPIO_InitStruct.Pull = GPIO_NOPULL;
  99. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  100. /*Configure GPIO pins : PA10 PA11 PA12 */
  101. GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
  102. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  103. GPIO_InitStruct.Pull = GPIO_NOPULL;
  104. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  105. GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
  106. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  107. /*Configure GPIO pin : PA15 */
  108. GPIO_InitStruct.Pin = GPIO_PIN_15;
  109. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  110. GPIO_InitStruct.Pull = GPIO_NOPULL;
  111. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  112. /*Configure GPIO pin : PD2 */
  113. GPIO_InitStruct.Pin = GPIO_PIN_2;
  114. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  115. GPIO_InitStruct.Pull = GPIO_NOPULL;
  116. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  117. }
  118. /* USER CODE BEGIN 2 */
  119. /* USER CODE END 2 */
  120. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/