gpio.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 as
  30. * Analog
  31. * Input
  32. * Output
  33. * EVENT_OUT
  34. * EXTI
  35. PD8 ------> USART3_TX
  36. PD9 ------> USART3_RX
  37. */
  38. void MX_GPIO_Init(void)
  39. {
  40. LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
  41. /* GPIO Ports Clock Enable */
  42. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOC);
  43. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOH);
  44. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOB);
  45. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOD);
  46. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOE);
  47. /**/
  48. LL_GPIO_ResetOutputPin(GPIOB, LD1_Pin|LD3_Pin);
  49. /**/
  50. LL_GPIO_ResetOutputPin(LD2_GPIO_Port, LD2_Pin);
  51. /**/
  52. GPIO_InitStruct.Pin = B1_Pin;
  53. GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
  54. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  55. LL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  56. /**/
  57. GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin;
  58. GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
  59. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
  60. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  61. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  62. LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  63. /**/
  64. GPIO_InitStruct.Pin = STLINK_RX_Pin|STLINK_TX_Pin;
  65. GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
  66. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
  67. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  68. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  69. GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
  70. LL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  71. /**/
  72. GPIO_InitStruct.Pin = LD2_Pin;
  73. GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
  74. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
  75. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  76. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  77. LL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
  78. }
  79. /* USER CODE BEGIN 2 */
  80. /* USER CODE END 2 */