gpio.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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) 2018 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. PA3 ------> ADCx_IN3
  65. PA8 ------> USB_OTG_FS_SOF
  66. PA9 ------> USB_OTG_FS_VBUS
  67. PA10 ------> USB_OTG_FS_ID
  68. PA11 ------> USB_OTG_FS_DM
  69. */
  70. void MX_GPIO_Init(void)
  71. {
  72. GPIO_InitTypeDef GPIO_InitStruct;
  73. /* GPIO Ports Clock Enable */
  74. __HAL_RCC_GPIOE_CLK_ENABLE();
  75. __HAL_RCC_GPIOC_CLK_ENABLE();
  76. __HAL_RCC_GPIOF_CLK_ENABLE();
  77. __HAL_RCC_GPIOH_CLK_ENABLE();
  78. __HAL_RCC_GPIOA_CLK_ENABLE();
  79. __HAL_RCC_GPIOB_CLK_ENABLE();
  80. __HAL_RCC_GPIOG_CLK_ENABLE();
  81. __HAL_RCC_GPIOD_CLK_ENABLE();
  82. /*Configure GPIO pin Output Level */
  83. HAL_GPIO_WritePin(GPIOG, USB_PowerSwitchOn_Pin|CS_Druck_Pin|SD_EN_2_Pin|SD_EN_1_Pin, GPIO_PIN_RESET);
  84. /*Configure GPIO pin Output Level */
  85. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
  86. /*Configure GPIO pin : PtPin */
  87. GPIO_InitStruct.Pin = USER_Btn_Pin;
  88. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  89. GPIO_InitStruct.Pull = GPIO_NOPULL;
  90. HAL_GPIO_Init(USER_Btn_GPIO_Port, &GPIO_InitStruct);
  91. /*Configure GPIO pin : PtPin */
  92. GPIO_InitStruct.Pin = PT1000_Pin;
  93. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  94. GPIO_InitStruct.Pull = GPIO_NOPULL;
  95. HAL_GPIO_Init(PT1000_GPIO_Port, &GPIO_InitStruct);
  96. /*Configure GPIO pin : PtPin */
  97. GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;
  98. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  99. GPIO_InitStruct.Pull = GPIO_NOPULL;
  100. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  101. HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
  102. /*Configure GPIO pin : PtPin */
  103. GPIO_InitStruct.Pin = USB_OverCurrent_Pin;
  104. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  105. GPIO_InitStruct.Pull = GPIO_NOPULL;
  106. HAL_GPIO_Init(USB_OverCurrent_GPIO_Port, &GPIO_InitStruct);
  107. /*Configure GPIO pins : PGPin PGPin PGPin */
  108. GPIO_InitStruct.Pin = CS_Druck_Pin|SD_EN_2_Pin|SD_EN_1_Pin;
  109. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  110. GPIO_InitStruct.Pull = GPIO_NOPULL;
  111. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  112. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  113. /*Configure GPIO pins : PAPin PAPin PAPin */
  114. GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin;
  115. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  116. GPIO_InitStruct.Pull = GPIO_NOPULL;
  117. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  118. GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
  119. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  120. /*Configure GPIO pin : PtPin */
  121. GPIO_InitStruct.Pin = USB_VBUS_Pin;
  122. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  123. GPIO_InitStruct.Pull = GPIO_NOPULL;
  124. HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);
  125. /*Configure GPIO pin : PA12 */
  126. GPIO_InitStruct.Pin = GPIO_PIN_12;
  127. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  128. GPIO_InitStruct.Pull = GPIO_NOPULL;
  129. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  130. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  131. }
  132. /* USER CODE BEGIN 2 */
  133. /* USER CODE END 2 */
  134. /**
  135. * @}
  136. */
  137. /**
  138. * @}
  139. */
  140. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/