gpio.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "core/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. PA8 ------> RCC_MCO
  67. */
  68. void MX_GPIO_Init(void)
  69. {
  70. GPIO_InitTypeDef GPIO_InitStruct = {0};
  71. /* GPIO Ports Clock Enable */
  72. __HAL_RCC_GPIOC_CLK_ENABLE();
  73. __HAL_RCC_GPIOH_CLK_ENABLE();
  74. __HAL_RCC_GPIOA_CLK_ENABLE();
  75. __HAL_RCC_GPIOB_CLK_ENABLE();
  76. /*Configure GPIO pins : PC13 PC14 PC15 */
  77. GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
  78. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  79. GPIO_InitStruct.Pull = GPIO_NOPULL;
  80. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  81. /*Configure GPIO pins : PA0...PA15, except PA13,PA14 for SWD */
  82. // GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
  83. // |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8
  84. // |GPIO_PIN_11|GPIO_PIN_12 // added 08/05/19
  85. // |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_15;
  86. GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12; // USB
  87. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  88. GPIO_InitStruct.Pull = GPIO_NOPULL;
  89. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  90. /*Configure Initial state of GPIO Trigger pins : */
  91. // PA1 - green diod
  92. // PA2 - red diod
  93. // PA3 - +5VRF_EN
  94. // PA8 - PA9 - Trigger
  95. // PA10 - INPTRG_EN
  96. GPIO_InitStruct.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10;
  97. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  98. GPIO_InitStruct.Pull = GPIO_NOPULL;
  99. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  100. /*Configure GPIO pins : PB0-PB15 */
  101. // GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
  102. // |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
  103. // |GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
  104. // |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
  105. // GPIO_InitStruct.Pin = GPIO_PIN_0;
  106. // GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  107. // GPIO_InitStruct.Pull = GPIO_NOPULL;
  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****/