gpio.c.bak 2.3 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. 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_GPIOA);
  37. /**/
  38. LL_GPIO_ResetOutputPin(ENC_CS_GPIO_Port, ENC_CS_Pin);
  39. /**/
  40. LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE1);
  41. /**/
  42. LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_1, LL_GPIO_PULL_NO);
  43. /**/
  44. LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_1, LL_GPIO_MODE_INPUT);
  45. /**/
  46. EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_1;
  47. EXTI_InitStruct.LineCommand = ENABLE;
  48. EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
  49. EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
  50. LL_EXTI_Init(&EXTI_InitStruct);
  51. /**/
  52. GPIO_InitStruct.Pin = ENC_CS_Pin;
  53. GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
  54. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
  55. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  56. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  57. LL_GPIO_Init(ENC_CS_GPIO_Port, &GPIO_InitStruct);
  58. /* EXTI interrupt init*/
  59. NVIC_SetPriority(EXTI0_1_IRQn, 0);
  60. NVIC_EnableIRQ(EXTI0_1_IRQn);
  61. }
  62. /* USER CODE BEGIN 2 */
  63. /* USER CODE END 2 */