gpio.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. ******************************************************************************
  3. * @file gpio.c
  4. * @brief This file provides code for the configuration
  5. * of all used GPIO pins.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "gpio.h"
  21. /* USER CODE BEGIN 0 */
  22. /* USER CODE END 0 */
  23. /*----------------------------------------------------------------------------*/
  24. /* Configure GPIO */
  25. /*----------------------------------------------------------------------------*/
  26. /* USER CODE BEGIN 1 */
  27. /* USER CODE END 1 */
  28. /** Configure pins as
  29. * Analog
  30. * Input
  31. * Output
  32. * EVENT_OUT
  33. * EXTI
  34. */
  35. void MX_GPIO_Init(void)
  36. {
  37. GPIO_InitTypeDef GPIO_InitStruct = {0};
  38. /* GPIO Ports Clock Enable */
  39. __HAL_RCC_GPIOC_CLK_ENABLE();
  40. __HAL_RCC_GPIOD_CLK_ENABLE();
  41. __HAL_RCC_GPIOA_CLK_ENABLE();
  42. __HAL_RCC_GPIOB_CLK_ENABLE();
  43. /*Configure GPIO pin Output Level */
  44. HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|AD_DIN_Pin|AD_CS_Pin|AD_CLK_Pin
  45. |GPIO_PIN_3|beep_Pin|led_Pin|alarm_Pin
  46. |pwr_lock_Pin, GPIO_PIN_RESET);
  47. /*Configure GPIO pin Output Level */
  48. HAL_GPIO_WritePin(ble_c_GPIO_Port, ble_c_Pin, GPIO_PIN_RESET);
  49. /*Configure GPIO pin Output Level */
  50. HAL_GPIO_WritePin(GPIOB, output1_Pin|output2_Pin|AD_SYNC_Pin, GPIO_PIN_RESET);
  51. /*Configure GPIO pins : PC13 PCPin PCPin PCPin
  52. PC3 PCPin PCPin PCPin */
  53. GPIO_InitStruct.Pin = GPIO_PIN_13|AD_DIN_Pin|AD_CS_Pin|AD_CLK_Pin
  54. |GPIO_PIN_3|beep_Pin|led_Pin|alarm_Pin;
  55. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  56. GPIO_InitStruct.Pull = GPIO_NOPULL;
  57. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  58. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  59. /*Configure GPIO pin : PtPin */
  60. GPIO_InitStruct.Pin = pwr_Pin;
  61. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  62. GPIO_InitStruct.Pull = GPIO_PULLUP;
  63. HAL_GPIO_Init(pwr_GPIO_Port, &GPIO_InitStruct);
  64. /*Configure GPIO pins : PBPin PBPin PBPin PBPin
  65. PBPin */
  66. GPIO_InitStruct.Pin = B4_Pin|B3_Pin|B2_Pin|B1_Pin
  67. |AD_DOUT_Pin;
  68. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  69. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  70. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  71. /*Configure GPIO pin : PtPin */
  72. GPIO_InitStruct.Pin = pwr_lock_Pin;
  73. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  74. GPIO_InitStruct.Pull = GPIO_PULLUP;
  75. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  76. HAL_GPIO_Init(pwr_lock_GPIO_Port, &GPIO_InitStruct);
  77. /*Configure GPIO pin : PtPin */
  78. GPIO_InitStruct.Pin = ble_c_Pin;
  79. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  80. GPIO_InitStruct.Pull = GPIO_NOPULL;
  81. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  82. HAL_GPIO_Init(ble_c_GPIO_Port, &GPIO_InitStruct);
  83. /*Configure GPIO pins : PBPin PBPin PBPin */
  84. GPIO_InitStruct.Pin = output1_Pin|output2_Pin|AD_SYNC_Pin;
  85. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  86. GPIO_InitStruct.Pull = GPIO_NOPULL;
  87. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  88. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  89. }
  90. /* USER CODE BEGIN 2 */
  91. /* USER CODE END 2 */
  92. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/