ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_rtos_map_ucos_iii.h
1 
47 #ifndef ADI_RTOS_MAP_UCOS_III_H
48 #define ADI_RTOS_MAP_UCOS_III_H
49 
50 /* If building a c file */
51 #if defined(__STDC__)
52 
53 #include <cpu.h>
54 #include <os.h>
55 #include <stdint.h>
56 #include <stddef.h>
57 
61 #define SEM_VAR_DECLR \
62  OS_SEM Semaphore;
63 
69 #define ADI_SEM_SIZE (sizeof(OS_SEM))
70 
72 #define SEM_CREATE(DEV, name, error) \
73  do { \
74  OS_ERR os_error; \
75  OSSemCreate(&((DEV)->Semaphore), name ,0u, &os_error); \
76  if(OS_ERR_NONE != os_error) {return((error));} \
77  } while (0)
78 
80 #define SEM_DELETE(DEV, error) \
81  do { \
82  OS_ERR os_error; \
83  OSSemDel( &((DEV)->Semaphore), OS_OPT_DEL_NO_PEND, &os_error ); \
84  if(OS_ERR_NONE != os_error) {return((error));} \
85  } while (0)
86 
87 
89 #define SEM_PEND(DEV, error) \
90  do { \
91  OS_ERR os_error; \
92  OSSemPend (&((DEV)->Semaphore), 0u, OS_OPT_PEND_BLOCKING , NULL, &os_error); \
93  if(OS_ERR_NONE != os_error) {return((error));} \
94  } while (0)
95 
97 #define SEM_POST(DEV) \
98  do { \
99  OS_ERR os_error; \
100  OSSemPost(&((DEV)->Semaphore), OS_OPT_POST_1, &os_error); \
101  } while (0)
102 
103 
112 #define ADI_INT_STATUS_ALLOC() CPU_SR_ALLOC()
113 
120 #define ADI_ENTER_CRITICAL_REGION() CPU_CRITICAL_ENTER()
121 
128 #define ADI_EXIT_CRITICAL_REGION() CPU_CRITICAL_EXIT()
129 
130 
131 
132 #if defined(ADI_CYCLECOUNT_ENABLED) && (ADI_CYCLECOUNT_ENABLED == 1)
133 #define ADI_RTOS_UCOS_III_CYCLECOUNT_START adi_cyclecount_start();
134 #define ADI_RTOS_UCOS_III_CYCLECOUNT_STOP adi_cyclecount_stop();
135 #else
136 #define ADI_RTOS_UCOS_III_CYCLECOUNT_START
137 #define ADI_RTOS_UCOS_III_CYCLECOUNT_STOP
138 #endif
139 
143 #define ISR_PROLOG() \
144  do { \
145  CPU_SR_ALLOC(); \
146  CPU_CRITICAL_ENTER(); \
147  OSIntEnter(); \
148  CPU_CRITICAL_EXIT(); \
149  ADI_RTOS_UCOS_III_CYCLECOUNT_START \
150  } while (0);
151 
155 #define ISR_EPILOG() \
156  do { \
157  ADI_RTOS_UCOS_III_CYCLECOUNT_STOP \
158  OSIntExit(); \
159  } while (0); \
160 
161 #endif /* __STDC__ */
162 
163 #define PENDSV_HANDLER OS_CPU_PendSVHandler
164 #define SYSTICK_HANDLER OS_CPU_SysTickHandler
165 #define SVC_HANDLER SVC_Handler
166 
167 
168 #endif /* ADI_RTOS_MAP_UCOS_III_H */