You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file gpio.c
  5. * @brief This file provides code for the configuration
  6. * of all used GPIO pins.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2023 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "gpio.h"
  22. /* USER CODE BEGIN 0 */
  23. /* USER CODE END 0 */
  24. /*----------------------------------------------------------------------------*/
  25. /* Configure GPIO */
  26. /*----------------------------------------------------------------------------*/
  27. /* USER CODE BEGIN 1 */
  28. /* USER CODE END 1 */
  29. /** Configure pins as
  30. * Analog
  31. * Input
  32. * Output
  33. * EVENT_OUT
  34. * EXTI
  35. * Free pins are configured automatically as Analog (this feature is enabled through
  36. * the Code Generation settings)
  37. PC9 ------> RCC_MCO_2
  38. */
  39. void MX_GPIO_Init(void)
  40. {
  41. GPIO_InitTypeDef GPIO_InitStruct = {0};
  42. /* GPIO Ports Clock Enable */
  43. __HAL_RCC_GPIOE_CLK_ENABLE();
  44. __HAL_RCC_GPIOC_CLK_ENABLE();
  45. __HAL_RCC_GPIOH_CLK_ENABLE();
  46. __HAL_RCC_GPIOA_CLK_ENABLE();
  47. __HAL_RCC_GPIOB_CLK_ENABLE();
  48. __HAL_RCC_GPIOD_CLK_ENABLE();
  49. /*Configure GPIO pins : PE2 PE3 PE4 PE5
  50. PE6 PE7 PE8 PE9
  51. PE10 PE11 PE12 PE13
  52. PE14 PE15 PE0 PE1 */
  53. GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
  54. |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
  55. |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
  56. |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
  57. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  58. GPIO_InitStruct.Pull = GPIO_NOPULL;
  59. HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  60. /*Configure GPIO pins : PC13 PC14 PC15 PC1
  61. PC2 PC3 PC5 PC6
  62. PC7 PC8 PC10 PC11
  63. PC12 */
  64. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_1
  65. |GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_6
  66. |GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_11
  67. |GPIO_PIN_12;
  68. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  69. GPIO_InitStruct.Pull = GPIO_NOPULL;
  70. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  71. /*Configure GPIO pins : PC0 PC4 */
  72. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4;
  73. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  74. GPIO_InitStruct.Pull = GPIO_NOPULL;
  75. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  76. /*Configure GPIO pins : PA0 PA1 PA4 PA8
  77. PA15 */
  78. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_8
  79. |GPIO_PIN_15;
  80. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  81. GPIO_InitStruct.Pull = GPIO_NOPULL;
  82. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  83. /*Configure GPIO pins : PB0 PB1 PB2 PB12
  84. PB13 PB14 PB15 PB3
  85. PB4 PB5 PB8 PB9 */
  86. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_12
  87. |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_3
  88. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9;
  89. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  90. GPIO_InitStruct.Pull = GPIO_NOPULL;
  91. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  92. /*Configure GPIO pins : PD8 PD9 PD10 PD11
  93. PD12 PD13 PD14 PD15
  94. PD0 PD1 PD2 PD3
  95. PD4 PD5 PD6 PD7 */
  96. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
  97. |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
  98. |GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  99. |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
  100. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  101. GPIO_InitStruct.Pull = GPIO_NOPULL;
  102. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  103. /*Configure GPIO pin : PC9 */
  104. GPIO_InitStruct.Pin = GPIO_PIN_9;
  105. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  106. GPIO_InitStruct.Pull = GPIO_NOPULL;
  107. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  108. GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
  109. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  110. }
  111. /* USER CODE BEGIN 2 */
  112. /* USER CODE END 2 */