gpio.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. ******************************************************************************
  3. * File Name : gpio.c
  4. * Description : This file provides code for the configuration
  5. * of all used GPIO pins.
  6. ******************************************************************************
  7. * This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * Copyright (c) 2019 STMicroelectronics International N.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted, provided that the following conditions are met:
  18. *
  19. * 1. Redistribution of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of other
  25. * contributors to this software may be used to endorse or promote products
  26. * derived from this software without specific written permission.
  27. * 4. This software, including modifications and/or derivative works of this
  28. * software, must execute solely and exclusively on microcontroller or
  29. * microprocessor devices manufactured by or for STMicroelectronics.
  30. * 5. Redistribution and use of this software other than as permitted under
  31. * this license is void and will automatically terminate your rights under
  32. * this license.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  37. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  38. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  39. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  40. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  42. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  45. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* Includes ------------------------------------------------------------------*/
  50. #include "gpio.h"
  51. /* USER CODE BEGIN 0 */
  52. /* USER CODE END 0 */
  53. /*----------------------------------------------------------------------------*/
  54. /* Configure GPIO */
  55. /*----------------------------------------------------------------------------*/
  56. /* USER CODE BEGIN 1 */
  57. /* USER CODE END 1 */
  58. /** Configure pins as
  59. * Analog
  60. * Input
  61. * Output
  62. * EVENT_OUT
  63. * EXTI
  64. * Free pins are configured automatically as Analog (this feature is enabled through
  65. * the Code Generation settings)
  66. PA9 ------> USB_OTG_FS_VBUS
  67. PA10 ------> USB_OTG_FS_ID
  68. PA11 ------> USB_OTG_FS_DM
  69. PA12 ------> USB_OTG_FS_DP
  70. */
  71. void MX_GPIO_Init(void) {
  72. GPIO_InitTypeDef GPIO_InitStruct = { 0 };
  73. /* GPIO Ports Clock Enable */
  74. __HAL_RCC_GPIOC_CLK_ENABLE()
  75. ;
  76. __HAL_RCC_GPIOH_CLK_ENABLE()
  77. ;
  78. __HAL_RCC_GPIOA_CLK_ENABLE()
  79. ;
  80. __HAL_RCC_GPIOB_CLK_ENABLE()
  81. ;
  82. __HAL_RCC_GPIOD_CLK_ENABLE()
  83. ;
  84. /*Configure GPIO pin Output Level */
  85. HAL_GPIO_WritePin(GPIOC, WC_Pin | LED_rouge_Pin | LED_vert_Pin,
  86. GPIO_PIN_RESET);
  87. /*Configure GPIO pin Output Level */
  88. HAL_GPIO_WritePin(aquit_GPIO_Port, aquit_Pin, GPIO_PIN_RESET);
  89. /*Configure GPIO pin Output Level */
  90. HAL_GPIO_WritePin(GPIOB, LED_orange_Pin | MFP_Pin, GPIO_PIN_RESET);
  91. /*Configure GPIO pins : PC13 PC15 PC0 PC1
  92. PC2 PC3 PC10 PC11
  93. PC12 */
  94. GPIO_InitStruct.Pin = GPIO_PIN_13 | GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1
  95. | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
  96. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  97. GPIO_InitStruct.Pull = GPIO_NOPULL;
  98. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  99. /*Configure GPIO pins : PCPin PCPin PCPin */
  100. GPIO_InitStruct.Pin = WC_Pin | LED_rouge_Pin | LED_vert_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(GPIOC, &GPIO_InitStruct);
  105. /*Configure GPIO pin : PtPin */
  106. GPIO_InitStruct.Pin = aquit_Pin;
  107. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  108. GPIO_InitStruct.Pull = GPIO_NOPULL;
  109. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  110. HAL_GPIO_Init(aquit_GPIO_Port, &GPIO_InitStruct);
  111. /*Configure GPIO pins : PBPin PBPin */
  112. GPIO_InitStruct.Pin = LED_orange_Pin | MFP_Pin;
  113. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  114. GPIO_InitStruct.Pull = GPIO_NOPULL;
  115. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  116. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  117. /*Configure GPIO pins : PB12 PB13 PB14 PB15
  118. PB5 */
  119. GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15
  120. | GPIO_PIN_5;
  121. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  122. GPIO_InitStruct.Pull = GPIO_NOPULL;
  123. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  124. /*Configure GPIO pin : PA9 */
  125. GPIO_InitStruct.Pin = GPIO_PIN_9;
  126. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  127. GPIO_InitStruct.Pull = GPIO_NOPULL;
  128. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  129. /*Configure GPIO pins : PA10 PA11 PA12 */
  130. GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
  131. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  132. GPIO_InitStruct.Pull = GPIO_NOPULL;
  133. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  134. GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
  135. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  136. /*Configure GPIO pin : PA15 */
  137. GPIO_InitStruct.Pin = GPIO_PIN_15;
  138. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  139. GPIO_InitStruct.Pull = GPIO_NOPULL;
  140. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  141. /*Configure GPIO pin : PD2 */
  142. GPIO_InitStruct.Pin = GPIO_PIN_2;
  143. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  144. GPIO_InitStruct.Pull = GPIO_NOPULL;
  145. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  146. }
  147. /* USER CODE BEGIN 2 */
  148. /* USER CODE END 2 */
  149. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/