gpio.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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) 2021 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, GPIO_PIN_RESET);
  46. /*Configure GPIO pin Output Level */
  47. HAL_GPIO_WritePin(GPIOB, output1_Pin|output2_Pin|AD_SYNC_Pin, GPIO_PIN_RESET);
  48. /*Configure GPIO pins : PC13 PCPin PCPin PCPin
  49. PC3 PCPin PCPin PCPin */
  50. GPIO_InitStruct.Pin = GPIO_PIN_13|AD_DIN_Pin|AD_CS_Pin|AD_CLK_Pin
  51. |GPIO_PIN_3|beep_Pin|led_Pin|alarm_Pin;
  52. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  53. GPIO_InitStruct.Pull = GPIO_NOPULL;
  54. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  55. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  56. /*Configure GPIO pins : PBPin PBPin PBPin PBPin
  57. PBPin */
  58. GPIO_InitStruct.Pin = B1_Pin|B2_Pin|B3_Pin|B4_Pin
  59. |AD_DOUT_Pin;
  60. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  61. GPIO_InitStruct.Pull = GPIO_PULLDOWN;
  62. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  63. /*Configure GPIO pins : PBPin PBPin PBPin */
  64. GPIO_InitStruct.Pin = output1_Pin|output2_Pin|AD_SYNC_Pin;
  65. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  66. GPIO_InitStruct.Pull = GPIO_NOPULL;
  67. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  68. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  69. }
  70. /* USER CODE BEGIN 2 */
  71. /* USER CODE END 2 */
  72. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/