WE310F5  39.00.000
m2mb_os.h
Go to the documentation of this file.
1 /*===============================================================================================*/
2 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
29 #ifndef M2MB_OS_H
30 #define M2MB_OS_H
31 
32 /* Include ======================================================================================*/
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include "m2mb_os_types.h"
38 #include "m2mb_os_ev.h"
39 #include "m2mb_os_mtx.h"
40 #include "m2mb_os_q.h"
41 #include "m2mb_os_sem.h"
42 
53 /*-----------------------------------------------------------------------------------------------*/
54 
59 /*-----------------------------------------------------------------------------------------------*/
60 
61 
62 #ifdef DEBUG_ENABLE
63 #define vspfunc app_vspfunc
64 #define uart_print app_uart_printextern
65 char tmp[100];
66 #else
67 #define vspfunc( ...) (0)
68 #define uart_print( ...)
69 #endif
70 
71 
72 /* Global declarations ==========================================================================*/
73 #define M2MB_OS_TASK_INVALID 0
74 #define M2MB_OS_TASK_INVALID_ATTR 0
75 
76 #define M2MB_OS_TASK_AUTOSTART 1
77 #define M2MB_OS_TASK_NOT_START 0
78 
79 #define M2MB_OS_ISR_ON 1
80 #define M2MB_OS_ISR_OFF 0
81 
82 /* in bytes */
83 #define M2MB_OS_MIN_STACK_SIZE 1024
84 
85 //QBO #define M2MB_OS_MS2TICKS(ms) ( ms ? ( ( (UINT32)ms * OS_TICKS_x_SEC ) /1000 ) + 1 : 0 )
86 
87 /* category for errno */
88 #define M2MB_FS_CAT ( (UINT32)0 )
89 #define M2MB_SMS_CAT ( (UINT32)1 )
90 #define M2MB_GNSS_CAT ( (UINT32)2 )
91 #define M2MB_OS_CAT ( (UINT32)3 )
92 
93 /*-----------------------------------------------------------------------------------------------*/
94 
95 /* Global typedefs ==============================================================================*/
98 
99 /* specified type for entry function of task */
100 typedef void( *ENTRY_FN )( void * );
101 
102 typedef enum
103 {
118  /* ---- */
122 
123 typedef enum
124 {
136 
137  /* ---- */
141 
142 typedef enum
143 {
144  M2MB_OS_MEMINFO_FRAGMENTS, //the total number of memory fragments
145  M2MB_OS_MEMINFO_BYTES_AVAILABLE, //the total number of available bytes
146  M2MB_OS_MEMINFO_SIZE, //the total number of memory size
147 
148  /* ---- */
152 
153 
154 #define M2MB_OS_ENTER_CRITICAL() do { __asm("cpsid i"); } while(0)
155 #define M2MB_OS_EXIT_CRITICAL() do { __asm("cpsie i"); } while(0)
156 
157 /* Global functions =============================================================================*/
158 
160 
161 
162 /*-----------------------------------------------------------------------------------------------*/
202 /*-----------------------------------------------------------------------------------------------*/
203 void *m2mb_os_malloc( UINT32 size );
204 
205 /*-----------------------------------------------------------------------------------------------*/
255 /*-----------------------------------------------------------------------------------------------*/
256 void *m2mb_os_calloc( UINT32 count, UINT32 size );
257  void *m2mb_os_realloc( void *ptr, UINT32 size );
258 /*-----------------------------------------------------------------------------------------------*/
294 /*-----------------------------------------------------------------------------------------------*/
295 M2MB_OS_RESULT_E m2mb_os_free( void *pMem );
296 
297 /*-----------------------------------------------------------------------------------------------*/
321 /*-----------------------------------------------------------------------------------------------*/
323 
324 /*-----------------------------------------------------------------------------------------------*/
420 /*-----------------------------------------------------------------------------------------------*/
422  M2MB_OS_TASK_HANDLE *pTaskHandle,
423  M2MB_OS_TASK_ATTR_HANDLE *pTaskAttr,
424  ENTRY_FN entryFn,
425  void *pArg
426 );
427 
428 /*-----------------------------------------------------------------------------------------------*/
555 /*-----------------------------------------------------------------------------------------------*/
557  M2MB_OS_TASK_HANDLE taskHandle,
558  M2MB_OS_TASK_SEL_CMD_E selCmd,
559  MEM_W *pOut,
560  void *pIn
561 );
562 
563 
564 /*-----------------------------------------------------------------------------------------------*/
608 /*-----------------------------------------------------------------------------------------------*/
610  M2MB_OS_TASK_HANDLE taskHandle,
611  M2MB_OS_TASK_SEL_CMD_E selCmd,
612  void *pIn
613 );
614 
615 /*-----------------------------------------------------------------------------------------------*/
687 /*-----------------------------------------------------------------------------------------------*/
689  M2MB_OS_TASK_ATTR_HANDLE *pTaskAttrHandle,
690  UINT8 nCmds,
691  ...
692 );
693 
694 /*-----------------------------------------------------------------------------------------------*/
723 /*-----------------------------------------------------------------------------------------------*/
725 
726 /*-----------------------------------------------------------------------------------------------*/
765 /*-----------------------------------------------------------------------------------------------*/
767 
768 /*-----------------------------------------------------------------------------------------------*/
803 /*-----------------------------------------------------------------------------------------------*/
805 
806 /*-----------------------------------------------------------------------------------------------*/
843 /*-----------------------------------------------------------------------------------------------*/
845 
846 /*-----------------------------------------------------------------------------------------------*/
883 /*-----------------------------------------------------------------------------------------------*/
885 
886 /*-----------------------------------------------------------------------------------------------*/
928 /*-----------------------------------------------------------------------------------------------*/
930 
931 /*-----------------------------------------------------------------------------------------------*/
978 /*-----------------------------------------------------------------------------------------------*/
980 
981 /*-----------------------------------------------------------------------------------------------*/
1068 /*-----------------------------------------------------------------------------------------------*/
1070 
1071 /*-----------------------------------------------------------------------------------------------*/
1099 /*-----------------------------------------------------------------------------------------------*/
1100 UINT32 m2mb_os_getSysTicks( void );
1101 
1102 /*-----------------------------------------------------------------------------------------------*/
1132 /*-----------------------------------------------------------------------------------------------*/
1134 
1135 /*-----------------------------------------------------------------------------------------------*/
1157 /*-----------------------------------------------------------------------------------------------*/
1159 
1160 /*-----------------------------------------------------------------------------------------------*/
1201 /*-----------------------------------------------------------------------------------------------*/
1202 UINT8 m2mb_os_isrCtrl( UINT8 newIsrState );
1203 
1204 /*-----------------------------------------------------------------------------------------------*/
1205 /*-----------------------------------------------------------------------------------------------*/
1243 /*-----------------------------------------------------------------------------------------------*/
1244 M2MB_OS_RESULT_E m2mb_os_get_errno( UINT32 *pCategory, INT32 *pErrno );
1245 
1246 
1247 /*-----------------------------------------------------------------------------------------------*/
1264 /*-----------------------------------------------------------------------------------------------*/
1265 int m2mb_thread_fp_enable(void);
1269 /*-----------------------------------------------------------------------------------------------*/
1270 
1271 #ifdef __cplusplus
1272 }
1273 #endif
1274 #endif /* M2MB_OS_H */
M2MB_OS_RESULT_E m2mb_os_taskTerminate(M2MB_OS_TASK_HANDLE taskHandle)
Terminates application task.
float FLOAT32
Definition: m2mb_types.h:77
#define ENUM_TO_INT(Prefix)
Definition: m2mb_types.h:207
HANDLE M2MB_OS_TASK_ATTR_HANDLE
Definition: m2mb_os.h:97
M2MB_OS_MEMINFO_E
Definition: m2mb_os.h:142
M2MB_OS_RESULT_E m2mb_os_taskSetAttrItem(M2MB_OS_TASK_ATTR_HANDLE *pTaskAttrHandle, UINT8 nCmds,...)
Set specific attribute for task creation.
unsigned char UINT8
Definition: m2mb_types.h:86
void * m2mb_os_calloc(UINT32 count, UINT32 size)
Allocates bytes of memory and init space with 0.
M2MB_OS_RESULT_E m2mb_os_setSysTicks(UINT32 newTick)
Set start system time in ticks.
M2MB_OS_RESULT_E m2mb_os_taskSetItem(M2MB_OS_TASK_HANDLE taskHandle, M2MB_OS_TASK_SEL_CMD_E selCmd, void *pIn)
Set specific task properties.
M2MB_OS_RESULT_E m2mb_os_taskCooperate(void)
Make task to cooperate by releasing scheduler control.
HANDLE M2MB_OS_TASK_HANDLE
Definition: m2mb_os.h:96
int m2mb_thread_fp_enable(void)
Sets the thread floating point unit flag.
void * m2mb_os_realloc(void *ptr, UINT32 size)
M2MB_OS_RESULT_E m2mb_os_free(void *pMem)
Free allocated memory.
UINT32 m2mb_os_getSysTicks(void)
Get system time in ticks.
M2MB_OS_RESULT_E m2mb_os_init(void)
Initialization of OS.
Types used across OS (semaphore, mutex...)
M2MB_OS_RESULT_E m2mb_os_taskWaitAbort(M2MB_OS_TASK_HANDLE taskHandle)
Abort suspension of a specified task.
enum M2MB_OS_RESULT M2MB_OS_RESULT_E
UINT32 M2MB_OS_MS2TICKS(UINT32 ms)
M2MB_OS_RESULT_E m2mb_os_taskResume(M2MB_OS_TASK_HANDLE taskHandle)
Resume suspended application task.
M2MB_OS_RESULT_E m2mb_os_taskDelete(M2MB_OS_TASK_HANDLE taskHandle)
Task delete.
FLOAT32 m2mb_os_getSysTickDuration_ms(void)
Get the duration of system tick in ms.
OS queue prototypes.
void * m2mb_os_malloc(UINT32 size)
Allocates bytes of memory.
M2MB_OS_RESULT_E m2mb_os_get_errno(UINT32 *pCategory, INT32 *pErrno)
Allow to get Errno saved in a relative task environment.
M2MB_OS_TASK_SEL_CMD_E
Definition: m2mb_os.h:102
unsigned long int UINT32
Definition: m2mb_types.h:88
M2MB_OS_TASK_STATE_E
Definition: m2mb_os.h:123
OS Semaphore prototypes.
UINT32 MEM_W
Definition: m2mb_types.h:94
signed int INT32
Definition: m2mb_types.h:82
M2MB_OS_RESULT_E m2mb_os_taskSuspend(M2MB_OS_TASK_HANDLE taskHandle)
Suspend application task.
void * HANDLE
Definition: m2mb_types.h:98
M2MB_OS_TASK_HANDLE m2mb_os_taskGetId(void)
Retrieves handle to the currently executing task.
M2MB_OS_RESULT_E m2mb_os_taskCreate(M2MB_OS_TASK_HANDLE *pTaskHandle, M2MB_OS_TASK_ATTR_HANDLE *pTaskAttr, ENTRY_FN entryFn, void *pArg)
Create application task.
OS mutex prototypes.
M2MB_OS_RESULT_E m2mb_os_taskRestart(M2MB_OS_TASK_HANDLE taskHandle)
Task restart.
UINT8 m2mb_os_isrCtrl(UINT8 newIsrState)
Enable and disable interrupts (ISRs)
void(* ENTRY_FN)(void *)
Definition: m2mb_os.h:100
OS event prototypes.
M2MB_OS_RESULT_E m2mb_os_taskGetItem(M2MB_OS_TASK_HANDLE taskHandle, M2MB_OS_TASK_SEL_CMD_E selCmd, MEM_W *pOut, void *pIn)
Get specific task properties.