gpio.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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) 2026 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. */
  36. void MX_GPIO_Init(void)
  37. {
  38. GPIO_InitTypeDef GPIO_InitStruct = {0};
  39. /* GPIO Ports Clock Enable */
  40. __HAL_RCC_GPIOD_CLK_ENABLE();
  41. __HAL_RCC_GPIOC_CLK_ENABLE();
  42. __HAL_RCC_GPIOA_CLK_ENABLE();
  43. __HAL_RCC_GPIOB_CLK_ENABLE();
  44. /*Configure GPIO pin Output Level */
  45. HAL_GPIO_WritePin(GPIOA, MINI7_V2_WIFI_MUX_Pin|MINI7_V2_BCK_S1_Pin, GPIO_PIN_SET);
  46. /*Configure GPIO pin Output Level */
  47. HAL_GPIO_WritePin(MINI7_V2_BEEPER_GPIO_Port, MINI7_V2_BEEPER_Pin, GPIO_PIN_RESET);
  48. /*Configure GPIO pin Output Level */
  49. HAL_GPIO_WritePin(MINI7_V2_BCK_S2_GPIO_Port, MINI7_V2_BCK_S2_Pin, GPIO_PIN_SET);
  50. /*Configure GPIO pin Output Level */
  51. HAL_GPIO_WritePin(GPIOB, MINI7_V2_LED_S2_Pin|MINI7_V2_indicator_light_Pin|MINI7_V2_SYS_B_Pin|MINI7_V2_SYS_R_Pin
  52. |MINI7_V2_LED_S1_Pin, GPIO_PIN_RESET);
  53. /*Configure GPIO pins : MINI7_V2_TUBE_SW_Pin MINI7_V2_DEC_S1_Pin PA7 */
  54. GPIO_InitStruct.Pin = MINI7_V2_TUBE_SW_Pin|MINI7_V2_DEC_S1_Pin|GPIO_PIN_7;
  55. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  56. GPIO_InitStruct.Pull = GPIO_NOPULL;
  57. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  58. /*Configure GPIO pins : MINI7_V2_WIFI_MUX_Pin MINI7_V2_BCK_S1_Pin */
  59. GPIO_InitStruct.Pin = MINI7_V2_WIFI_MUX_Pin|MINI7_V2_BCK_S1_Pin;
  60. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  61. GPIO_InitStruct.Pull = GPIO_NOPULL;
  62. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  63. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  64. /*Configure GPIO pin : MINI7_V2_BEEPER_Pin */
  65. GPIO_InitStruct.Pin = MINI7_V2_BEEPER_Pin;
  66. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  67. GPIO_InitStruct.Pull = GPIO_NOPULL;
  68. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  69. HAL_GPIO_Init(MINI7_V2_BEEPER_GPIO_Port, &GPIO_InitStruct);
  70. /*Configure GPIO pins : MINI7_V2_BCK_S2_Pin MINI7_V2_LED_S2_Pin MINI7_V2_SYS_B_Pin MINI7_V2_SYS_R_Pin
  71. MINI7_V2_LED_S1_Pin */
  72. GPIO_InitStruct.Pin = MINI7_V2_BCK_S2_Pin|MINI7_V2_LED_S2_Pin|MINI7_V2_SYS_B_Pin|MINI7_V2_SYS_R_Pin
  73. |MINI7_V2_LED_S1_Pin;
  74. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  75. GPIO_InitStruct.Pull = GPIO_NOPULL;
  76. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  77. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  78. /*Configure GPIO pins : MINI7_V2_DEC_S2_Pin MINI7_V2_Device_num3_Pin MINI7_V2_Device_num4_Pin */
  79. GPIO_InitStruct.Pin = MINI7_V2_DEC_S2_Pin|MINI7_V2_Device_num3_Pin|MINI7_V2_Device_num4_Pin;
  80. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  81. GPIO_InitStruct.Pull = GPIO_NOPULL;
  82. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  83. /*Configure GPIO pin : MINI7_V2_indicator_light_Pin */
  84. GPIO_InitStruct.Pin = MINI7_V2_indicator_light_Pin;
  85. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  86. GPIO_InitStruct.Pull = GPIO_NOPULL;
  87. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  88. HAL_GPIO_Init(MINI7_V2_indicator_light_GPIO_Port, &GPIO_InitStruct);
  89. /*Configure GPIO pin : MINI7_V2_REF_SW2_Pin */
  90. GPIO_InitStruct.Pin = MINI7_V2_REF_SW2_Pin;
  91. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
  92. GPIO_InitStruct.Pull = GPIO_NOPULL;
  93. HAL_GPIO_Init(MINI7_V2_REF_SW2_GPIO_Port, &GPIO_InitStruct);
  94. /*Configure GPIO pin : MINI7_V2_Device_num1_Pin */
  95. GPIO_InitStruct.Pin = MINI7_V2_Device_num1_Pin;
  96. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  97. GPIO_InitStruct.Pull = GPIO_NOPULL;
  98. HAL_GPIO_Init(MINI7_V2_Device_num1_GPIO_Port, &GPIO_InitStruct);
  99. /*Configure GPIO pin : MINI7_V2_Device_num2_Pin */
  100. GPIO_InitStruct.Pin = MINI7_V2_Device_num2_Pin;
  101. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  102. GPIO_InitStruct.Pull = GPIO_NOPULL;
  103. HAL_GPIO_Init(MINI7_V2_Device_num2_GPIO_Port, &GPIO_InitStruct);
  104. /*Configure GPIO pin : MINI7_V2_KEY_Pin */
  105. GPIO_InitStruct.Pin = MINI7_V2_KEY_Pin;
  106. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
  107. GPIO_InitStruct.Pull = GPIO_NOPULL;
  108. HAL_GPIO_Init(MINI7_V2_KEY_GPIO_Port, &GPIO_InitStruct);
  109. /* EXTI interrupt init*/
  110. HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
  111. HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
  112. }
  113. /* USER CODE BEGIN 2 */
  114. /* USER CODE END 2 */