gpio.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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) 2024 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. * Free pins are configured automatically as Analog (this feature is enabled through
  36. * the Code Generation settings)
  37. */
  38. void MX_GPIO_Init(void)
  39. {
  40. GPIO_InitTypeDef GPIO_InitStruct = {0};
  41. /* GPIO Ports Clock Enable */
  42. __HAL_RCC_GPIOC_CLK_ENABLE();
  43. __HAL_RCC_GPIOH_CLK_ENABLE();
  44. __HAL_RCC_GPIOA_CLK_ENABLE();
  45. __HAL_RCC_GPIOB_CLK_ENABLE();
  46. __HAL_RCC_GPIOD_CLK_ENABLE();
  47. /*Configure GPIO pin Output Level */
  48. HAL_GPIO_WritePin(GPIOC, J2_Pin|J1_Pin|Point_Pin|D2_Pin
  49. |D1_Pin|J4_Pin, GPIO_PIN_RESET);
  50. /*Configure GPIO pin Output Level */
  51. HAL_GPIO_WritePin(GPIOA, Di3_Pin|Di2_Pin|Di1_Pin|J8_Pin
  52. |D0_Pin|D3_Pin|Latch_Pin|EN_Pin, GPIO_PIN_RESET);
  53. /*Configure GPIO pin Output Level */
  54. HAL_GPIO_WritePin(GPIOB, J7_Pin|J6_Pin|J5_Pin|WC_Pin, GPIO_PIN_RESET);
  55. /*Configure GPIO pin Output Level */
  56. HAL_GPIO_WritePin(J3_GPIO_Port, J3_Pin, GPIO_PIN_RESET);
  57. /*Configure GPIO pins : PCPin PCPin PCPin PCPin
  58. PCPin PCPin */
  59. GPIO_InitStruct.Pin = J2_Pin|J1_Pin|Point_Pin|D2_Pin
  60. |D1_Pin|J4_Pin;
  61. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  62. GPIO_InitStruct.Pull = GPIO_NOPULL;
  63. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  64. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  65. /*Configure GPIO pins : PC15 PC0 PC1 PC3
  66. PC6 PC7 PC8 PC9 */
  67. GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3
  68. |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
  69. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  70. GPIO_InitStruct.Pull = GPIO_NOPULL;
  71. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  72. /*Configure GPIO pins : PAPin PAPin PAPin PAPin
  73. PAPin PAPin PAPin PAPin */
  74. GPIO_InitStruct.Pin = Di3_Pin|Di2_Pin|Di1_Pin|J8_Pin
  75. |D0_Pin|D3_Pin|Latch_Pin|EN_Pin;
  76. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  77. GPIO_InitStruct.Pull = GPIO_NOPULL;
  78. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  79. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  80. /*Configure GPIO pins : PBPin PBPin */
  81. GPIO_InitStruct.Pin = Bout2_Pin|Bout1_Pin;
  82. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  83. GPIO_InitStruct.Pull = GPIO_NOPULL;
  84. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  85. /*Configure GPIO pins : PBPin PBPin PBPin PBPin */
  86. GPIO_InitStruct.Pin = J7_Pin|J6_Pin|J5_Pin|WC_Pin;
  87. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  88. GPIO_InitStruct.Pull = GPIO_NOPULL;
  89. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  90. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  91. /*Configure GPIO pins : PB10 PB11 PB13 PB14
  92. PB15 PB5 PB8 PB9 */
  93. GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_13|GPIO_PIN_14
  94. |GPIO_PIN_15|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9;
  95. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  96. GPIO_InitStruct.Pull = GPIO_NOPULL;
  97. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  98. /*Configure GPIO pins : PA8 PA10 PA15 */
  99. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15;
  100. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  101. GPIO_InitStruct.Pull = GPIO_NOPULL;
  102. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  103. /*Configure GPIO pin : PtPin */
  104. GPIO_InitStruct.Pin = J3_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(J3_GPIO_Port, &GPIO_InitStruct);
  109. /* EXTI interrupt init*/
  110. HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
  111. HAL_NVIC_EnableIRQ(EXTI0_IRQn);
  112. HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
  113. HAL_NVIC_EnableIRQ(EXTI3_IRQn);
  114. }
  115. /* USER CODE BEGIN 2 */
  116. /* USER CODE END 2 */