gpio.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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) 2023 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. * Free pins are configured automatically as Analog (this feature is enabled through
  35. * the Code Generation settings)
  36. */
  37. void MX_GPIO_Init(void)
  38. {
  39. GPIO_InitTypeDef GPIO_InitStruct = {0};
  40. /* GPIO Ports Clock Enable */
  41. __HAL_RCC_GPIOC_CLK_ENABLE();
  42. __HAL_RCC_GPIOD_CLK_ENABLE();
  43. __HAL_RCC_GPIOA_CLK_ENABLE();
  44. __HAL_RCC_GPIOB_CLK_ENABLE();
  45. /*Configure GPIO pin Output Level */
  46. HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|AD_DIN_Pin|AD_CS_Pin|AD_CLK_Pin
  47. |GPIO_PIN_3|beep_Pin|led_Pin|alarm_Pin
  48. |pwr_lock_Pin, GPIO_PIN_RESET);
  49. /*Configure GPIO pin Output Level */
  50. HAL_GPIO_WritePin(ble_c_GPIO_Port, ble_c_Pin, GPIO_PIN_RESET);
  51. /*Configure GPIO pin Output Level */
  52. HAL_GPIO_WritePin(GPIOB, output1_Pin|output2_Pin|AD_SYNC_Pin, GPIO_PIN_RESET);
  53. /*Configure GPIO pins : PC13 PCPin PCPin PCPin
  54. PC3 PCPin PCPin PCPin
  55. PCPin */
  56. GPIO_InitStruct.Pin = GPIO_PIN_13|AD_DIN_Pin|AD_CS_Pin|AD_CLK_Pin
  57. |GPIO_PIN_3|beep_Pin|led_Pin|alarm_Pin
  58. |pwr_lock_Pin;
  59. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  60. GPIO_InitStruct.Pull = GPIO_NOPULL;
  61. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  62. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  63. /*Configure GPIO pins : PC14 PC15 PC4 */
  64. GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4;
  65. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  66. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  67. /*Configure GPIO pins : PA0 PA1 PA4 PA5
  68. PA6 PA7 PA11 PA12
  69. PA15 */
  70. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
  71. |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_11|GPIO_PIN_12
  72. |GPIO_PIN_15;
  73. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  74. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  75. /*Configure GPIO pin : PtPin */
  76. GPIO_InitStruct.Pin = pwr_Pin;
  77. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  78. GPIO_InitStruct.Pull = GPIO_PULLUP;
  79. HAL_GPIO_Init(pwr_GPIO_Port, &GPIO_InitStruct);
  80. /*Configure GPIO pins : PB0 PB1 PB2 PB3
  81. PB4 PB5 */
  82. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  83. |GPIO_PIN_4|GPIO_PIN_5;
  84. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  85. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  86. /*Configure GPIO pins : PBPin PBPin PBPin PBPin
  87. PBPin */
  88. GPIO_InitStruct.Pin = B4_Pin|B3_Pin|B2_Pin|B1_Pin
  89. |AD_DOUT_Pin;
  90. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  91. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  92. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  93. /*Configure GPIO pin : PtPin */
  94. GPIO_InitStruct.Pin = ble_c_Pin;
  95. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  96. GPIO_InitStruct.Pull = GPIO_NOPULL;
  97. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  98. HAL_GPIO_Init(ble_c_GPIO_Port, &GPIO_InitStruct);
  99. /*Configure GPIO pins : PBPin PBPin PBPin */
  100. GPIO_InitStruct.Pin = output1_Pin|output2_Pin|AD_SYNC_Pin;
  101. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  102. GPIO_InitStruct.Pull = GPIO_NOPULL;
  103. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  104. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  105. }
  106. /* USER CODE BEGIN 2 */
  107. /* USER CODE END 2 */
  108. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/