gpio.c 2.5 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) 2025 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_GPIOA_CLK_ENABLE();
  36. __HAL_RCC_GPIOB_CLK_ENABLE();
  37. /*Configure GPIO pin Output Level */
  38. HAL_GPIO_WritePin(GPIOB, MOTOR_EN_Pin|SPI2_CS_Pin, GPIO_PIN_SET);
  39. /*Configure GPIO pin Output Level */
  40. HAL_GPIO_WritePin(GPIOA, IBUTTON_LED_GREEN_Pin|IBUTTON_LED_RED_Pin, GPIO_PIN_RESET);
  41. /*Configure GPIO pin Output Level */
  42. HAL_GPIO_WritePin(GPIOB, RS485_RE_Pin|LED_GREEN_Pin|LED_RED_Pin, GPIO_PIN_RESET);
  43. /*Configure GPIO pins : PBPin PBPin PBPin PBPin */
  44. GPIO_InitStruct.Pin = MOTOR_EN_Pin|RS485_RE_Pin|LED_GREEN_Pin|LED_RED_Pin;
  45. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  46. GPIO_InitStruct.Pull = GPIO_NOPULL;
  47. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  48. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  49. /*Configure GPIO pin : PtPin */
  50. GPIO_InitStruct.Pin = SPI2_CS_Pin;
  51. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  52. GPIO_InitStruct.Pull = GPIO_NOPULL;
  53. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  54. HAL_GPIO_Init(SPI2_CS_GPIO_Port, &GPIO_InitStruct);
  55. /*Configure GPIO pins : PAPin PAPin */
  56. GPIO_InitStruct.Pin = IBUTTON_LED_GREEN_Pin|IBUTTON_LED_RED_Pin;
  57. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  58. GPIO_InitStruct.Pull = GPIO_NOPULL;
  59. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  60. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  61. }
  62. /* USER CODE BEGIN 2 */
  63. /* USER CODE END 2 */