You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

211 lines
6.7 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_hal_hsem.h
  4. * @author MCD Application Team
  5. * @brief Header file of HSEM HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32WBxx_HAL_HSEM_H
  21. #define STM32WBxx_HAL_HSEM_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx_hal_def.h"
  27. /** @addtogroup STM32WBxx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup HSEM
  31. * @{
  32. */
  33. /* Exported macro ------------------------------------------------------------*/
  34. /** @defgroup HSEM_Exported_Macros HSEM Exported Macros
  35. * @{
  36. */
  37. /**
  38. * @brief SemID to mask helper Macro.
  39. * @param __SEMID__: semaphore ID from 0 to 31
  40. * @retval Semaphore Mask.
  41. */
  42. #define __HAL_HSEM_SEMID_TO_MASK(__SEMID__) (1 << (__SEMID__))
  43. /**
  44. * @brief Enables the specified HSEM interrupts.
  45. * @param __SEM_MASK__: semaphores Mask
  46. * @retval None.
  47. */
  48. #if defined(DUAL_CORE)
  49. #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \
  50. (HSEM->C1IER |= (__SEM_MASK__)) : \
  51. (HSEM->C2IER |= (__SEM_MASK__)))
  52. #else
  53. #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) (HSEM->IER |= (__SEM_MASK__))
  54. #endif /* DUAL_CORE */
  55. /**
  56. * @brief Disables the specified HSEM interrupts.
  57. * @param __SEM_MASK__: semaphores Mask
  58. * @retval None.
  59. */
  60. #if defined(DUAL_CORE)
  61. #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \
  62. (HSEM->C1IER &= ~(__SEM_MASK__)) : \
  63. (HSEM->C2IER &= ~(__SEM_MASK__)))
  64. #else
  65. #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) (HSEM->IER &= ~(__SEM_MASK__))
  66. #endif /* DUAL_CORE */
  67. /**
  68. * @brief Checks whether interrupt has occurred or not for semaphores specified by a mask.
  69. * @param __SEM_MASK__: semaphores Mask
  70. * @retval semaphores Mask : Semaphores where an interrupt occurred.
  71. */
  72. #if defined(DUAL_CORE)
  73. #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \
  74. ((__SEM_MASK__) & HSEM->C1MISR) : \
  75. ((__SEM_MASK__) & HSEM->C2MISR1))
  76. #else
  77. #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((__SEM_MASK__) & HSEM->MISR)
  78. #endif /* DUAL_CORE */
  79. /**
  80. * @brief Get the semaphores release status flags.
  81. * @param __SEM_MASK__: semaphores Mask
  82. * @retval semaphores Mask : Semaphores where Release flags rise.
  83. */
  84. #if defined(DUAL_CORE)
  85. #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \
  86. (__SEM_MASK__) & HSEM->C1ISR : \
  87. (__SEM_MASK__) & HSEM->C2ISR)
  88. #else
  89. #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((__SEM_MASK__) & HSEM->ISR)
  90. #endif /* DUAL_CORE */
  91. /**
  92. * @brief Clears the HSEM Interrupt flags.
  93. * @param __SEM_MASK__: semaphores Mask
  94. * @retval None.
  95. */
  96. #if defined(DUAL_CORE)
  97. #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \
  98. (HSEM->C1ICR |= (__SEM_MASK__)) : \
  99. (HSEM->C2ICR |= (__SEM_MASK__)))
  100. #else
  101. #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) (HSEM->ICR |= (__SEM_MASK__))
  102. #endif /* DUAL_CORE */
  103. /**
  104. * @}
  105. */
  106. /* Exported functions --------------------------------------------------------*/
  107. /** @defgroup HSEM_Exported_Functions HSEM Exported Functions
  108. * @{
  109. */
  110. /** @addtogroup HSEM_Exported_Functions_Group1 Take and Release functions
  111. * @brief HSEM Take and Release functions
  112. * @{
  113. */
  114. /* HSEM semaphore take (lock) using 2-Step method ****************************/
  115. HAL_StatusTypeDef HAL_HSEM_Take(uint32_t SemID, uint32_t ProcessID);
  116. /* HSEM semaphore fast take (lock) using 1-Step method ***********************/
  117. HAL_StatusTypeDef HAL_HSEM_FastTake(uint32_t SemID);
  118. /* HSEM Check semaphore state Taken or not **********************************/
  119. uint32_t HAL_HSEM_IsSemTaken(uint32_t SemID);
  120. /* HSEM Release **************************************************************/
  121. void HAL_HSEM_Release(uint32_t SemID, uint32_t ProcessID);
  122. /* HSEM Release All************************************************************/
  123. void HAL_HSEM_ReleaseAll(uint32_t Key, uint32_t CoreID);
  124. /**
  125. * @}
  126. */
  127. /** @addtogroup HSEM_Exported_Functions_Group2 HSEM Set and Get Key functions
  128. * @brief HSEM Set and Get Key functions.
  129. * @{
  130. */
  131. /* HSEM Set Clear Key *********************************************************/
  132. void HAL_HSEM_SetClearKey(uint32_t Key);
  133. /* HSEM Get Clear Key *********************************************************/
  134. uint32_t HAL_HSEM_GetClearKey(void);
  135. /**
  136. * @}
  137. */
  138. /** @addtogroup HSEM_Exported_Functions_Group3
  139. * @brief HSEM Notification functions
  140. * @{
  141. */
  142. /* HSEM Activate HSEM Notification (When a semaphore is released) ) *****************/
  143. void HAL_HSEM_ActivateNotification(uint32_t SemMask);
  144. /* HSEM Deactivate HSEM Notification (When a semaphore is released) ****************/
  145. void HAL_HSEM_DeactivateNotification(uint32_t SemMask);
  146. /* HSEM Free Callback (When a semaphore is released) *******************************/
  147. void HAL_HSEM_FreeCallback(uint32_t SemMask);
  148. /* HSEM IRQ Handler **********************************************************/
  149. void HAL_HSEM_IRQHandler(void);
  150. /**
  151. * @}
  152. */
  153. /**
  154. * @}
  155. */
  156. /* Private macros ------------------------------------------------------------*/
  157. /** @defgroup HSEM_Private_Macros HSEM Private Macros
  158. * @{
  159. */
  160. #define IS_HSEM_SEMID(__SEMID__) ((__SEMID__) <= HSEM_SEMID_MAX )
  161. #define IS_HSEM_PROCESSID(__PROCESSID__) ((__PROCESSID__) <= HSEM_PROCESSID_MAX )
  162. #define IS_HSEM_KEY(__KEY__) ((__KEY__) <= HSEM_CLEAR_KEY_MAX )
  163. #define IS_HSEM_COREID(__COREID__) (((__COREID__) == HSEM_CPU1_COREID) || \
  164. ((__COREID__) == HSEM_CPU2_COREID))
  165. /**
  166. * @}
  167. */
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @}
  173. */
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* STM32WBxx_HAL_HSEM_H */
  178. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/