stm32f1xx_hal_gpio_ex.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_gpio_ex.c
  4. * @author MCD Application Team
  5. * @brief GPIO Extension HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the General Purpose Input/Output (GPIO) extension peripheral.
  8. * + Extended features functions
  9. *
  10. @verbatim
  11. ==============================================================================
  12. ##### GPIO Peripheral extension features #####
  13. ==============================================================================
  14. [..] GPIO module on STM32F1 family, manage also the AFIO register:
  15. (+) Possibility to use the EVENTOUT Cortex feature
  16. ##### How to use this driver #####
  17. ==============================================================================
  18. [..] This driver provides functions to use EVENTOUT Cortex feature
  19. (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout()
  20. (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout()
  21. (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout()
  22. @endverbatim
  23. ******************************************************************************
  24. * @attention
  25. *
  26. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  27. *
  28. * Redistribution and use in source and binary forms, with or without modification,
  29. * are permitted provided that the following conditions are met:
  30. * 1. Redistributions of source code must retain the above copyright notice,
  31. * this list of conditions and the following disclaimer.
  32. * 2. Redistributions in binary form must reproduce the above copyright notice,
  33. * this list of conditions and the following disclaimer in the documentation
  34. * and/or other materials provided with the distribution.
  35. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  36. * may be used to endorse or promote products derived from this software
  37. * without specific prior written permission.
  38. *
  39. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  40. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  41. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  42. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  43. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  44. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  45. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  46. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  47. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  48. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. *
  50. ******************************************************************************
  51. */
  52. /* Includes ------------------------------------------------------------------*/
  53. #include "stm32f1xx_hal.h"
  54. /** @addtogroup STM32F1xx_HAL_Driver
  55. * @{
  56. */
  57. /** @defgroup GPIOEx GPIOEx
  58. * @brief GPIO HAL module driver
  59. * @{
  60. */
  61. #ifdef HAL_GPIO_MODULE_ENABLED
  62. /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions
  63. * @{
  64. */
  65. /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions
  66. * @brief Extended features functions
  67. *
  68. @verbatim
  69. ==============================================================================
  70. ##### Extended features functions #####
  71. ==============================================================================
  72. [..] This section provides functions allowing to:
  73. (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout()
  74. (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout()
  75. (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout()
  76. @endverbatim
  77. * @{
  78. */
  79. /**
  80. * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected.
  81. * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal.
  82. * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT.
  83. * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal.
  84. * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN.
  85. * @retval None
  86. */
  87. void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource)
  88. {
  89. /* Verify the parameters */
  90. assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource));
  91. assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource));
  92. /* Apply the new configuration */
  93. MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (GPIO_PortSource) | (GPIO_PinSource));
  94. }
  95. /**
  96. * @brief Enables the Event Output.
  97. * @retval None
  98. */
  99. void HAL_GPIOEx_EnableEventout(void)
  100. {
  101. SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
  102. }
  103. /**
  104. * @brief Disables the Event Output.
  105. * @retval None
  106. */
  107. void HAL_GPIOEx_DisableEventout(void)
  108. {
  109. CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
  110. }
  111. /**
  112. * @}
  113. */
  114. /**
  115. * @}
  116. */
  117. #endif /* HAL_GPIO_MODULE_ENABLED */
  118. /**
  119. * @}
  120. */
  121. /**
  122. * @}
  123. */
  124. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/