gpio.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
  34. LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
  35. /* GPIO Ports Clock Enable */
  36. LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOF);
  37. LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
  38. /**/
  39. LL_GPIO_ResetOutputPin(ENC_RST_GPIO_Port, ENC_RST_Pin);
  40. /**/
  41. LL_GPIO_ResetOutputPin(ENC_CS_GPIO_Port, ENC_CS_Pin);
  42. /**/
  43. LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTF, LL_SYSCFG_EXTI_LINE1);
  44. /**/
  45. LL_GPIO_SetPinPull(GPIOF, LL_GPIO_PIN_1, LL_GPIO_PULL_NO);
  46. /**/
  47. LL_GPIO_SetPinMode(GPIOF, LL_GPIO_PIN_1, LL_GPIO_MODE_INPUT);
  48. /**/
  49. EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_1;
  50. EXTI_InitStruct.LineCommand = ENABLE;
  51. EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
  52. EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
  53. LL_EXTI_Init(&EXTI_InitStruct);
  54. /**/
  55. GPIO_InitStruct.Pin = ENC_RST_Pin;
  56. GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
  57. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
  58. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  59. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  60. LL_GPIO_Init(ENC_RST_GPIO_Port, &GPIO_InitStruct);
  61. /**/
  62. GPIO_InitStruct.Pin = ENC_CS_Pin;
  63. GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
  64. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
  65. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  66. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  67. LL_GPIO_Init(ENC_CS_GPIO_Port, &GPIO_InitStruct);
  68. /* EXTI interrupt init*/
  69. NVIC_SetPriority(EXTI0_1_IRQn, 0);
  70. NVIC_EnableIRQ(EXTI0_1_IRQn);
  71. }
  72. /* USER CODE BEGIN 2 */
  73. /* USER CODE END 2 */