gpio.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 as
  30. * Analog
  31. * Input
  32. * Output
  33. * EVENT_OUT
  34. * EXTI
  35. */
  36. void MX_GPIO_Init(void)
  37. {
  38. GPIO_InitTypeDef GPIO_InitStruct = {0};
  39. /* GPIO Ports Clock Enable */
  40. __HAL_RCC_GPIOA_CLK_ENABLE();
  41. __HAL_RCC_GPIOB_CLK_ENABLE();
  42. /*Configure GPIO pin Output Level */
  43. HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
  44. /*Configure GPIO pin Output Level */
  45. HAL_GPIO_WritePin(GPIOB, ADS_RST_Pin|ADS_PDMN_Pin|IIC_SCL_Pin|IIC_SDA_Pin
  46. |IIC_SCL2_Pin|IIC_SDA2_Pin, GPIO_PIN_SET);
  47. /*Configure GPIO pin Output Level */
  48. HAL_GPIO_WritePin(GPIOB, FDC_SLEEP1_Pin|LED_R_Pin|LED_G_Pin|FDC_SLEEP2_Pin, GPIO_PIN_RESET);
  49. /*Configure GPIO pin Output Level */
  50. HAL_GPIO_WritePin(GPIOA, RS485_RD_Pin|BootLED_Pin, GPIO_PIN_RESET);
  51. /*Configure GPIO pin : PtPin */
  52. GPIO_InitStruct.Pin = ADS_DRDY_Pin;
  53. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  54. GPIO_InitStruct.Pull = GPIO_NOPULL;
  55. HAL_GPIO_Init(ADS_DRDY_GPIO_Port, &GPIO_InitStruct);
  56. /*Configure GPIO pins : PAPin PAPin PAPin */
  57. GPIO_InitStruct.Pin = SPI_CS_Pin|RS485_RD_Pin|BootLED_Pin;
  58. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  59. GPIO_InitStruct.Pull = GPIO_NOPULL;
  60. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  61. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  62. /*Configure GPIO pins : PBPin PBPin */
  63. GPIO_InitStruct.Pin = ADS_RST_Pin|ADS_PDMN_Pin;
  64. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  65. GPIO_InitStruct.Pull = GPIO_NOPULL;
  66. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  67. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  68. /*Configure GPIO pins : PBPin PBPin PBPin PBPin */
  69. GPIO_InitStruct.Pin = FDC_SLEEP1_Pin|LED_R_Pin|LED_G_Pin|FDC_SLEEP2_Pin;
  70. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  71. GPIO_InitStruct.Pull = GPIO_NOPULL;
  72. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  73. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  74. /*Configure GPIO pins : PBPin PBPin PBPin PBPin */
  75. GPIO_InitStruct.Pin = IIC_SCL_Pin|IIC_SDA_Pin|IIC_SCL2_Pin|IIC_SDA2_Pin;
  76. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
  77. GPIO_InitStruct.Pull = GPIO_PULLUP;
  78. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  79. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  80. }
  81. /* USER CODE BEGIN 2 */
  82. /* USER CODE END 2 */