gpio.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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) 2024 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_GPIOF_CLK_ENABLE();
  41. __HAL_RCC_GPIOA_CLK_ENABLE();
  42. __HAL_RCC_GPIOB_CLK_ENABLE();
  43. /*Configure GPIO pin Output Level */
  44. HAL_GPIO_WritePin(GPIOA, CE_Pin|RESET_Pin|BUZZ_Pin|GLED1_Pin
  45. |RLED2_Pin, GPIO_PIN_RESET);
  46. /*Configure GPIO pin Output Level */
  47. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);
  48. /*Configure GPIO pins : PAPin PAPin PAPin */
  49. GPIO_InitStruct.Pin = CE_Pin|GLED1_Pin|RLED2_Pin;
  50. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  51. GPIO_InitStruct.Pull = GPIO_PULLUP;
  52. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  53. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  54. /*Configure GPIO pin : PtPin */
  55. GPIO_InitStruct.Pin = RESET_Pin;
  56. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  57. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  58. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  59. HAL_GPIO_Init(RESET_GPIO_Port, &GPIO_InitStruct);
  60. /*Configure GPIO pin : PtPin */
  61. GPIO_InitStruct.Pin = BUZZ_Pin;
  62. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
  63. GPIO_InitStruct.Pull = GPIO_PULLUP;
  64. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  65. HAL_GPIO_Init(BUZZ_GPIO_Port, &GPIO_InitStruct);
  66. /*Configure GPIO pin : PtPin */
  67. GPIO_InitStruct.Pin = CANCEL_Pin;
  68. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
  69. GPIO_InitStruct.Pull = GPIO_PULLUP;
  70. HAL_GPIO_Init(CANCEL_GPIO_Port, &GPIO_InitStruct);
  71. /*Configure GPIO pin : PB1 */
  72. GPIO_InitStruct.Pin = GPIO_PIN_1;
  73. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  74. GPIO_InitStruct.Pull = GPIO_PULLUP;
  75. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  76. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  77. /* EXTI interrupt init*/
  78. HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
  79. HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
  80. }
  81. /* USER CODE BEGIN 2 */
  82. /* USER CODE END 2 */