|
29 | 29 |
|
30 | 30 | #include "bsp_cfg.h"
|
31 | 31 |
|
| 32 | +#include <zephyr/irq.h> |
| 33 | + |
| 34 | + |
32 | 35 | /** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
|
33 | 36 | FSP_HEADER
|
34 | 37 |
|
@@ -143,35 +146,9 @@ FSP_HEADER
|
143 | 146 | #define BSP_CFG_IRQ_MASK_LEVEL_FOR_CRITICAL_SECTION (0U)
|
144 | 147 | #endif
|
145 | 148 |
|
146 |
| -/* This macro defines a variable for saving previous mask value */ |
147 |
| -#ifndef FSP_CRITICAL_SECTION_DEFINE |
148 |
| - |
149 |
| - #define FSP_CRITICAL_SECTION_DEFINE uint32_t old_mask_level = 0U |
150 |
| -#endif |
151 |
| - |
152 |
| -/* These macros abstract methods to save and restore the interrupt state for different architectures. */ |
153 |
| -#if (0 == BSP_CFG_IRQ_MASK_LEVEL_FOR_CRITICAL_SECTION) |
154 |
| - #define FSP_CRITICAL_SECTION_GET_CURRENT_STATE __get_PRIMASK |
155 |
| - #define FSP_CRITICAL_SECTION_SET_STATE __set_PRIMASK |
156 |
| - #define FSP_CRITICAL_SECTION_IRQ_MASK_SET (1U) |
157 |
| -#else |
158 |
| - #define FSP_CRITICAL_SECTION_GET_CURRENT_STATE __get_BASEPRI |
159 |
| - #define FSP_CRITICAL_SECTION_SET_STATE __set_BASEPRI |
160 |
| - #define FSP_CRITICAL_SECTION_IRQ_MASK_SET ((uint8_t) (BSP_CFG_IRQ_MASK_LEVEL_FOR_CRITICAL_SECTION << \ |
161 |
| - (8U - __NVIC_PRIO_BITS))) |
162 |
| -#endif |
163 |
| - |
164 |
| -/** This macro temporarily saves the current interrupt state and disables interrupts. */ |
165 |
| -#ifndef FSP_CRITICAL_SECTION_ENTER |
166 |
| - #define FSP_CRITICAL_SECTION_ENTER \ |
167 |
| - old_mask_level = FSP_CRITICAL_SECTION_GET_CURRENT_STATE(); \ |
168 |
| - FSP_CRITICAL_SECTION_SET_STATE(FSP_CRITICAL_SECTION_IRQ_MASK_SET) |
169 |
| -#endif |
170 |
| - |
171 |
| -/** This macro restores the previously saved interrupt state, reenabling interrupts. */ |
172 |
| -#ifndef FSP_CRITICAL_SECTION_EXIT |
173 |
| - #define FSP_CRITICAL_SECTION_EXIT FSP_CRITICAL_SECTION_SET_STATE(old_mask_level) |
174 |
| -#endif |
| 149 | +#define FSP_CRITICAL_SECTION_DEFINE unsigned int irq_lock_key |
| 150 | +#define FSP_CRITICAL_SECTION_ENTER irq_lock_key = irq_lock(); |
| 151 | +#define FSP_CRITICAL_SECTION_EXIT irq_unlock(irq_lock_key); |
175 | 152 |
|
176 | 153 | /* Number of Cortex processor exceptions, used as an offset from XPSR value for the IRQn_Type macro. */
|
177 | 154 | #define FSP_PRIV_CORTEX_PROCESSOR_EXCEPTIONS (16U)
|
|
0 commit comments