gpio.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. * 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. GPIO_InitStruct.Pin = GPIO_PIN_13|AD_DIN_Pin|AD_CS_Pin|AD_CLK_Pin
  56. |GPIO_PIN_3|beep_Pin|led_Pin|alarm_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(GPIOC, &GPIO_InitStruct);
  61. /*Configure GPIO pins : PC14 PC15 PC4 */
  62. GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4;
  63. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  64. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  65. /*Configure GPIO pins : PA0 PA1 PA4 PA5
  66. PA6 PA7 PA11 PA12
  67. PA15 */
  68. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5
  69. |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_11|GPIO_PIN_12
  70. |GPIO_PIN_15;
  71. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  72. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  73. /*Configure GPIO pin : PtPin */
  74. GPIO_InitStruct.Pin = pwr_Pin;
  75. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  76. GPIO_InitStruct.Pull = GPIO_PULLUP;
  77. HAL_GPIO_Init(pwr_GPIO_Port, &GPIO_InitStruct);
  78. /*Configure GPIO pins : PB0 PB1 PB2 PB3
  79. PB4 PB5 */
  80. GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  81. |GPIO_PIN_4|GPIO_PIN_5;
  82. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  83. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  84. /*Configure GPIO pins : PBPin PBPin PBPin PBPin
  85. PBPin */
  86. GPIO_InitStruct.Pin = B4_Pin|B3_Pin|B2_Pin|B1_Pin
  87. |AD_DOUT_Pin;
  88. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  89. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  90. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  91. /*Configure GPIO pin : PtPin */
  92. GPIO_InitStruct.Pin = pwr_lock_Pin;
  93. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  94. GPIO_InitStruct.Pull = GPIO_PULLUP;
  95. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  96. HAL_GPIO_Init(pwr_lock_GPIO_Port, &GPIO_InitStruct);
  97. /*Configure GPIO pin : PtPin */
  98. GPIO_InitStruct.Pin = ble_c_Pin;
  99. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  100. GPIO_InitStruct.Pull = GPIO_NOPULL;
  101. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  102. HAL_GPIO_Init(ble_c_GPIO_Port, &GPIO_InitStruct);
  103. /*Configure GPIO pins : PBPin PBPin PBPin */
  104. GPIO_InitStruct.Pin = output1_Pin|output2_Pin|AD_SYNC_Pin;
  105. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  106. GPIO_InitStruct.Pull = GPIO_NOPULL;
  107. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  108. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  109. }
  110. /* USER CODE BEGIN 2 */
  111. /* USER CODE END 2 */
  112. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/