gpio.c.bak 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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) 2022 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
  30. */
  31. void MX_GPIO_Init(void)
  32. {
  33. GPIO_InitTypeDef GPIO_InitStruct = {0};
  34. /* GPIO Ports Clock Enable */
  35. __HAL_RCC_GPIOF_CLK_ENABLE();
  36. __HAL_RCC_GPIOA_CLK_ENABLE();
  37. __HAL_RCC_GPIOB_CLK_ENABLE();
  38. /*Configure GPIO pin Output Level */
  39. HAL_GPIO_WritePin(GPIOA, ENC_RST_Pin|ENC_CS_Pin, GPIO_PIN_RESET);
  40. /*Configure GPIO pin Output Level */
  41. HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET);
  42. /*Configure GPIO pin : PF1 */
  43. GPIO_InitStruct.Pin = GPIO_PIN_1;
  44. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  45. GPIO_InitStruct.Pull = GPIO_NOPULL;
  46. HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  47. /*Configure GPIO pins : PAPin PAPin */
  48. GPIO_InitStruct.Pin = ENC_RST_Pin|ENC_CS_Pin;
  49. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  50. GPIO_InitStruct.Pull = GPIO_NOPULL;
  51. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  52. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  53. /*Configure GPIO pin : PtPin */
  54. GPIO_InitStruct.Pin = LED1_Pin;
  55. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  56. GPIO_InitStruct.Pull = GPIO_NOPULL;
  57. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  58. HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct);
  59. /* EXTI interrupt init*/
  60. HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
  61. HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
  62. }
  63. /* USER CODE BEGIN 2 */
  64. /* USER CODE END 2 */