STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_hsem.h 00004 * @author MCD Application Team 00005 * @brief Header file of HSEM HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32H7xx_HAL_HSEM_H 00021 #define STM32H7xx_HAL_HSEM_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32h7xx_hal_def.h" 00029 00030 /** @addtogroup STM32H7xx_HAL_Driver 00031 * @{ 00032 */ 00033 00034 /** @addtogroup HSEM 00035 * @{ 00036 */ 00037 00038 /* Exported macro ------------------------------------------------------------*/ 00039 /** @defgroup HSEM_Exported_Macros HSEM Exported Macros 00040 * @{ 00041 */ 00042 00043 /** 00044 * @brief SemID to mask helper Macro. 00045 * @param __SEMID__: semaphore ID from 0 to 31 00046 * @retval Semaphore Mask. 00047 */ 00048 #define __HAL_HSEM_SEMID_TO_MASK(__SEMID__) (1 << (__SEMID__)) 00049 00050 /** 00051 * @brief Enables the specified HSEM interrupts. 00052 * @param __SEM_MASK__: semaphores Mask 00053 * @retval None. 00054 */ 00055 #if defined(DUAL_CORE) 00056 #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 00057 (HSEM->C1IER |= (__SEM_MASK__)) : \ 00058 (HSEM->C2IER |= (__SEM_MASK__))) 00059 #else 00060 #define __HAL_HSEM_ENABLE_IT(__SEM_MASK__) (HSEM->IER |= (__SEM_MASK__)) 00061 #endif /* DUAL_CORE */ 00062 /** 00063 * @brief Disables the specified HSEM interrupts. 00064 * @param __SEM_MASK__: semaphores Mask 00065 * @retval None. 00066 */ 00067 #if defined(DUAL_CORE) 00068 #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 00069 (HSEM->C1IER &= ~(__SEM_MASK__)) : \ 00070 (HSEM->C2IER &= ~(__SEM_MASK__))) 00071 #else 00072 #define __HAL_HSEM_DISABLE_IT(__SEM_MASK__) (HSEM->IER &= ~(__SEM_MASK__)) 00073 #endif /* DUAL_CORE */ 00074 00075 /** 00076 * @brief Checks whether interrupt has occurred or not for semaphores specified by a mask. 00077 * @param __SEM_MASK__: semaphores Mask 00078 * @retval semaphores Mask : Semaphores where an interrupt occurred. 00079 */ 00080 #if defined(DUAL_CORE) 00081 #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 00082 ((__SEM_MASK__) & HSEM->C1MISR) : \ 00083 ((__SEM_MASK__) & HSEM->C2MISR1)) 00084 #else 00085 #define __HAL_HSEM_GET_IT(__SEM_MASK__) ((__SEM_MASK__) & HSEM->MISR) 00086 #endif /* DUAL_CORE */ 00087 00088 /** 00089 * @brief Get the semaphores release status flags. 00090 * @param __SEM_MASK__: semaphores Mask 00091 * @retval semaphores Mask : Semaphores where Release flags rise. 00092 */ 00093 #if defined(DUAL_CORE) 00094 #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 00095 (__SEM_MASK__) & HSEM->C1ISR : \ 00096 (__SEM_MASK__) & HSEM->C2ISR) 00097 #else 00098 #define __HAL_HSEM_GET_FLAG(__SEM_MASK__) ((__SEM_MASK__) & HSEM->ISR) 00099 #endif /* DUAL_CORE */ 00100 00101 /** 00102 * @brief Clears the HSEM Interrupt flags. 00103 * @param __SEM_MASK__: semaphores Mask 00104 * @retval None. 00105 */ 00106 #if defined(DUAL_CORE) 00107 #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) ((((SCB->CPUID & 0x000000F0) >> 4 )== 0x7) ? \ 00108 (HSEM->C1ICR |= (__SEM_MASK__)) : \ 00109 (HSEM->C2ICR |= (__SEM_MASK__))) 00110 #else 00111 #define __HAL_HSEM_CLEAR_FLAG(__SEM_MASK__) (HSEM->ICR |= (__SEM_MASK__)) 00112 #endif /* DUAL_CORE */ 00113 00114 /** 00115 * @} 00116 */ 00117 00118 /* Exported functions --------------------------------------------------------*/ 00119 /** @defgroup HSEM_Exported_Functions HSEM Exported Functions 00120 * @{ 00121 */ 00122 00123 /** @addtogroup HSEM_Exported_Functions_Group1 Take and Release functions 00124 * @brief HSEM Take and Release functions 00125 * @{ 00126 */ 00127 00128 /* HSEM semaphore take (lock) using 2-Step method ****************************/ 00129 HAL_StatusTypeDef HAL_HSEM_Take(uint32_t SemID, uint32_t ProcessID); 00130 /* HSEM semaphore fast take (lock) using 1-Step method ***********************/ 00131 HAL_StatusTypeDef HAL_HSEM_FastTake(uint32_t SemID); 00132 /* HSEM Release **************************************************************/ 00133 void HAL_HSEM_Release(uint32_t SemID, uint32_t ProcessID); 00134 /* HSEM Release All************************************************************/ 00135 void HAL_HSEM_ReleaseAll(uint32_t Key, uint32_t CoreID); 00136 /* HSEM Check semaphore state Taken or not **********************************/ 00137 uint32_t HAL_HSEM_IsSemTaken(uint32_t SemID); 00138 00139 /** 00140 * @} 00141 */ 00142 00143 /** @addtogroup HSEM_Exported_Functions_Group2 HSEM Set and Get Key functions 00144 * @brief HSEM Set and Get Key functions. 00145 * @{ 00146 */ 00147 /* HSEM Set Clear Key *********************************************************/ 00148 void HAL_HSEM_SetClearKey(uint32_t Key); 00149 /* HSEM Get Clear Key *********************************************************/ 00150 uint32_t HAL_HSEM_GetClearKey(void); 00151 /** 00152 * @} 00153 */ 00154 00155 /** @addtogroup HSEM_Exported_Functions_Group3 00156 * @brief HSEM Notification functions 00157 * @{ 00158 */ 00159 /* HSEM Activate HSEM Notification (When a semaphore is released) ) *****************/ 00160 void HAL_HSEM_ActivateNotification(uint32_t SemMask); 00161 /* HSEM Deactivate HSEM Notification (When a semaphore is released) ****************/ 00162 void HAL_HSEM_DeactivateNotification(uint32_t SemMask); 00163 /* HSEM Free Callback (When a semaphore is released) *******************************/ 00164 void HAL_HSEM_FreeCallback(uint32_t SemMask); 00165 /* HSEM IRQ Handler **********************************************************/ 00166 void HAL_HSEM_IRQHandler(void); 00167 00168 /** 00169 * @} 00170 */ 00171 00172 /** 00173 * @} 00174 */ 00175 00176 /* Private macros ------------------------------------------------------------*/ 00177 /** @defgroup HSEM_Private_Macros HSEM Private Macros 00178 * @{ 00179 */ 00180 00181 #define IS_HSEM_SEMID(__SEMID__) ((__SEMID__) <= HSEM_SEMID_MAX ) 00182 00183 #define IS_HSEM_PROCESSID(__PROCESSID__) ((__PROCESSID__) <= HSEM_PROCESSID_MAX ) 00184 00185 #define IS_HSEM_KEY(__KEY__) ((__KEY__) <= HSEM_CLEAR_KEY_MAX ) 00186 00187 #if defined(DUAL_CORE) 00188 #define IS_HSEM_COREID(__COREID__) (((__COREID__) == HSEM_CPU1_COREID) || \ 00189 ((__COREID__) == HSEM_CPU2_COREID)) 00190 #else 00191 #define IS_HSEM_COREID(__COREID__) ((__COREID__) == HSEM_CPU1_COREID) 00192 #endif 00193 00194 00195 /** 00196 * @} 00197 */ 00198 00199 /** 00200 * @} 00201 */ 00202 00203 /** 00204 * @} 00205 */ 00206 00207 #ifdef __cplusplus 00208 } 00209 #endif 00210 00211 #endif /* STM32H7xx_HAL_HSEM_H */