stm32h7xx_hal_hsem.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_hsem.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 21-April-2017
  7. * @brief Header file of HSEM HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32H7xx_HAL_HSEM_H
  39. #define __STM32H7xx_HAL_HSEM_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32h7xx_hal_def.h"
  45. /** @addtogroup STM32H7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup HSEM
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup HSEM_Exported_Types HSEM Exported Types
  53. * @{
  54. */
  55. /**
  56. * @}
  57. */
  58. /* Exported constants --------------------------------------------------------*/
  59. /** @defgroup HSEM_Exported_Constants HSEM Exported Constants
  60. * @{
  61. */
  62. /**
  63. * @}
  64. */
  65. /* Exported macro ------------------------------------------------------------*/
  66. /** @defgroup HSEM_Exported_Macros HSEM Exported Macros
  67. * @{
  68. */
  69. /**
  70. * @brief SemID to mask helper Macro.
  71. * @param __SEMID__: semaphore ID from 0 to 31
  72. * @retval Semaphore Mask.
  73. */
  74. #define __HAL_HSEM_SEMID_TO_MASK(__SEMID__) (1 << (__SEMID__))
  75. /**
  76. * @brief Enables the specified HSEM interrupts.
  77. * @param __SEM_MASK__: semaphores Mask
  78. * @retval None.
  79. */
  80. #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) (HSEM->IER0 |= (__SEM_MASK__))
  81. /**
  82. * @brief Disables the specified HSEM interrupts.
  83. * @param __SEM_MASK__: semaphores Mask
  84. * @retval None.
  85. */
  86. #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) (HSEM->IER0 &= ~(__SEM_MASK__))
  87. /**
  88. * @brief Checks whether interrupt has occurred or not for semaphores specified by a mask.
  89. * @param __SEM_MASK__: semaphores Mask
  90. * @retval semaphores Mask : Semaphores where an interrupt occurred.
  91. */
  92. #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((__SEM_MASK__) & HSEM->MISR0)
  93. /**
  94. * @brief Get the semaphores release status flags.
  95. * @param __SEM_MASK__: semaphores Mask
  96. * @retval semaphores Mask : Semaphores where Release flags rise.
  97. */
  98. #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((__SEM_MASK__) & HSEM->ISR0)
  99. /**
  100. * @brief Clears the HSEM Interrupt flags.
  101. * @param __SEM_MASK__: semaphores Mask
  102. * @retval None.
  103. */
  104. #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) (HSEM->ICR0 |= (__SEM_MASK__))
  105. /**
  106. * @}
  107. */
  108. /* Exported functions --------------------------------------------------------*/
  109. /** @defgroup HSEM_Exported_Functions HSEM Exported Functions
  110. * @{
  111. */
  112. /** @addtogroup HSEM_Exported_Functions_Group1 Take and Release functions
  113. * @brief HSEM Take and Release functions
  114. * @{
  115. */
  116. /* HSEM semaphore take (lock) using 2-Step method ****************************/
  117. HAL_StatusTypeDef HAL_HSEM_Take(uint32_t SemID, uint32_t ProcessID);
  118. /* HSEM semaphore fast take (lock) using 1-Step method ***********************/
  119. HAL_StatusTypeDef HAL_HSEM_FastTake(uint32_t SemID);
  120. /* HSEM Check semaphore state Taken or not **********************************/
  121. uint32_t HAL_HSEM_IsSemTaken(uint32_t SemID);
  122. /* HSEM Release **************************************************************/
  123. void HAL_HSEM_Release(uint32_t SemID, uint32_t ProcessID);
  124. /* HSEM Release All************************************************************/
  125. void HAL_HSEM_ReleaseAll(uint32_t Key, uint32_t MasterID);
  126. /**
  127. * @}
  128. */
  129. /** @addtogroup HSEM_Exported_Functions_Group2 HSEM Set and Get Key functions
  130. * @brief HSEM Set and Get Key functions.
  131. * @{
  132. */
  133. /* HSEM Set Clear Key *********************************************************/
  134. void HAL_HSEM_SetClearKey(uint32_t Key);
  135. /* HSEM Get Clear Key *********************************************************/
  136. uint32_t HAL_HSEM_GetClearKey(void);
  137. /**
  138. * @}
  139. */
  140. /** @addtogroup HSEM_Exported_Functions_Group3
  141. * @brief HSEM Notification functions
  142. * @{
  143. */
  144. /* HSEM Activate HSEM Notification (When a semaphore is released) ) *****************/
  145. void HAL_HSEM_ActivateNotification(uint32_t SemMask);
  146. /* HSEM Deactivate HSEM Notification (When a semaphore is released) ****************/
  147. void HAL_HSEM_DeactivateNotification(uint32_t SemMask);
  148. /* HSEM Free Callback (When a semaphore is released) *******************************/
  149. void HAL_HSEM_FreeCallback(uint32_t SemMask);
  150. /* HSEM IRQ Handler **********************************************************/
  151. void HAL_HSEM_IRQHandler(void);
  152. /**
  153. * @}
  154. */
  155. /**
  156. * @}
  157. */
  158. /* Private types -------------------------------------------------------------*/
  159. /** @defgroup HSEM_Private_Types HSEM Private Types
  160. * @{
  161. */
  162. /**
  163. * @}
  164. */
  165. /* Private variables ---------------------------------------------------------*/
  166. /** @defgroup HSEM_Private_Variables HSEM Private Variables
  167. * @{
  168. */
  169. /**
  170. * @}
  171. */
  172. /* Private constants ---------------------------------------------------------*/
  173. /** @defgroup HSEM_Private_Constants HSEM Private Constants
  174. * @{
  175. */
  176. /**
  177. * @}
  178. */
  179. /* Private macros ------------------------------------------------------------*/
  180. /** @defgroup HSEM_Private_Macros HSEM Private Macros
  181. * @{
  182. */
  183. #define IS_HSEM_SEMID(__SEMID__) ((__SEMID__) <= HSEM_SEMID_MAX )
  184. #define IS_HSEM_PROCESSID(__PROCESSID__) ((__PROCESSID__) <= HSEM_PROCESSID_MAX )
  185. #define IS_HSEM_KEY(__KEY__) ((__KEY__) <= HSEM_CLEAR_KEY_MAX )
  186. #define IS_HSEM_MASTERID(__MASTERID__) (((__MASTERID__) == HSEM_CM7_MASTERID))
  187. /**
  188. * @}
  189. */
  190. /**
  191. * @}
  192. */
  193. /**
  194. * @}
  195. */
  196. #ifdef __cplusplus
  197. }
  198. #endif
  199. #endif /* __STM32H7xx_HAL_HSEM_H */
  200. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/