ADuCM4x50 Device Drivers API Reference Manual  Release 4.0.0.0
adi_rtos_map_noos.h
1 
14 #ifndef ADI_RTOS_MAP_NOOS_H
15 #define ADI_RTOS_MAP_NOOS_H
16 
17 /* If building a c file */
18 #if defined(__STDC__)
19 
20 #include <stdint.h>
21 #include <stddef.h>
22 #include <drivers/pwr/adi_pwr.h>
23 #include <adi_cyclecount.h>
24 
33 #define ADI_INT_STATUS_ALLOC() uint32_t IntStatus = 0u
34 
41 #define ADI_ENTER_CRITICAL_REGION() \
42 do { \
43  IntStatus = __get_PRIMASK(); \
44  __disable_irq(); \
45 } while (0)
46 
47 
54 #define ADI_EXIT_CRITICAL_REGION() \
55 do { \
56  __set_PRIMASK(IntStatus); \
57 } while (0)
58 
59 
62 #define ADI_SEM_SIZE (sizeof(uint32_t))
63 
67 #if defined(ADI_CYCLECOUNT_ENABLED) && (ADI_CYCLECOUNT_ENABLED == 1u)
68 #define ISR_PROLOG() adi_cyclecount_start();
69 #else
70 #define ISR_PROLOG()
71 #endif
72 
73 
77 #if defined(ADI_CYCLECOUNT_ENABLED) && (ADI_CYCLECOUNT_ENABLED == 1u)
78 #define ISR_EPILOG() adi_cyclecount_stop();
79 #else
80 #define ISR_EPILOG()
81 #endif
82 
83 #if (ADI_CFG_ENTER_LOW_PWR_MODE_SUPPORT == 1)
84 
88 #define SEM_VAR_DECLR volatile uint32_t nLowPowerExitFlag;
89 
91 #define SEM_CREATE(DEV, name, error) \
92  (DEV)->nLowPowerExitFlag = 0u
93 
95 #define SEM_DELETE(DEV, error) do { } while(0)
96 
98 #define SEM_PEND(DEV, error) \
99  do { \
100  ADI_PWR_RESULT eResult; \
101  eResult = adi_pwr_EnterLowPowerMode(ADI_PWR_MODE_FLEXI, &(DEV)->nLowPowerExitFlag, 0u); \
102  if(eResult != ADI_PWR_SUCCESS) { return ((error)); } \
103  } while(0)
104 
105 
107 #define SEM_POST(DEV) \
108  do { \
109  adi_pwr_ExitLowPowerMode(&(DEV)->nLowPowerExitFlag); \
110  } while(0)
111 
112 
113 #else /* ADI_CFG_ENTER_LOW_PWR_MODE_SUPPORT == 0 */
114 
118 #define SEM_VAR_DECLR volatile uint32_t nSemCount;
119 
121 #define SEM_CREATE(DEV, name, error) \
122  (DEV)->nSemCount = 0
123 
125 #define SEM_DELETE(DEV, error) do { } while(0)
126 
128 #define SEM_PEND(DEV, error) \
129  while ((DEV)->nSemCount == 0u) {} \
130  (DEV)->nSemCount--
131 
133 #define SEM_POST(DEV) { \
134  (DEV)->nSemCount++; \
135 }
136 
137 #endif /* ADI_CFG_ENTER_LOW_PWR_MODE_SUPPORT */
138 
139 #endif /* __STDC__ */
140 
141 #define PENDSV_HANDLER PendSV_Handler
142 #define SYSTICK_HANDLER SysTick_Handler
143 #define SVC_HANDLER SVC_Handler
144 
145 
146 #endif /* ADI_RTOS_MAP_NOOS_H */
147