WL865E4-P  36.07.001
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 #define M2MB_OS_ENTER_CRITICAL() do { __asm("cpsid i"); } while(0)
143 #define M2MB_OS_EXIT_CRITICAL() do { __asm("cpsie i"); } while(0)
144 
145 /* Global functions =============================================================================*/
146 
148 
149 
150 /*-----------------------------------------------------------------------------------------------*/
190 /*-----------------------------------------------------------------------------------------------*/
191 void *m2mb_os_malloc( UINT32 size );
192 
193 /*-----------------------------------------------------------------------------------------------*/
243 /*-----------------------------------------------------------------------------------------------*/
244 void *m2mb_os_calloc( UINT32 count, UINT32 size );
245 
246 /*-----------------------------------------------------------------------------------------------*/
282 /*-----------------------------------------------------------------------------------------------*/
283 M2MB_OS_RESULT_E m2mb_os_free( void *pMem );
284 
285 /*-----------------------------------------------------------------------------------------------*/
309 /*-----------------------------------------------------------------------------------------------*/
311 
312 /*-----------------------------------------------------------------------------------------------*/
408 /*-----------------------------------------------------------------------------------------------*/
410  M2MB_OS_TASK_HANDLE *pTaskHandle,
411  M2MB_OS_TASK_ATTR_HANDLE *pTaskAttr,
412  ENTRY_FN entryFn,
413  void *pArg
414 );
415 
416 /*-----------------------------------------------------------------------------------------------*/
543 /*-----------------------------------------------------------------------------------------------*/
545  M2MB_OS_TASK_HANDLE taskHandle,
546  M2MB_OS_TASK_SEL_CMD_E selCmd,
547  MEM_W *pOut,
548  void *pIn
549 );
550 
551 
552 /*-----------------------------------------------------------------------------------------------*/
596 /*-----------------------------------------------------------------------------------------------*/
598  M2MB_OS_TASK_HANDLE taskHandle,
599  M2MB_OS_TASK_SEL_CMD_E selCmd,
600  void *pIn
601 );
602 
603 /*-----------------------------------------------------------------------------------------------*/
675 /*-----------------------------------------------------------------------------------------------*/
677  M2MB_OS_TASK_ATTR_HANDLE *pTaskAttrHandle,
678  UINT8 nCmds,
679  ...
680 );
681 
682 /*-----------------------------------------------------------------------------------------------*/
718 /*-----------------------------------------------------------------------------------------------*/
719 VOID m2mb_os_taskSleep( UINT32 ticks );
720 
721 /*-----------------------------------------------------------------------------------------------*/
750 /*-----------------------------------------------------------------------------------------------*/
752 
753 /*-----------------------------------------------------------------------------------------------*/
792 /*-----------------------------------------------------------------------------------------------*/
794 
795 /*-----------------------------------------------------------------------------------------------*/
830 /*-----------------------------------------------------------------------------------------------*/
832 
833 /*-----------------------------------------------------------------------------------------------*/
870 /*-----------------------------------------------------------------------------------------------*/
872 
873 /*-----------------------------------------------------------------------------------------------*/
910 /*-----------------------------------------------------------------------------------------------*/
912 
913 /*-----------------------------------------------------------------------------------------------*/
955 /*-----------------------------------------------------------------------------------------------*/
957 
958 /*-----------------------------------------------------------------------------------------------*/
1005 /*-----------------------------------------------------------------------------------------------*/
1007 
1008 /*-----------------------------------------------------------------------------------------------*/
1095 /*-----------------------------------------------------------------------------------------------*/
1097 
1098 /*-----------------------------------------------------------------------------------------------*/
1126 /*-----------------------------------------------------------------------------------------------*/
1127 MEM_W m2mb_os_getSysTicks( void );
1128 
1129 /*-----------------------------------------------------------------------------------------------*/
1159 /*-----------------------------------------------------------------------------------------------*/
1161 
1162 /*-----------------------------------------------------------------------------------------------*/
1184 /*-----------------------------------------------------------------------------------------------*/
1186 
1187 /*-----------------------------------------------------------------------------------------------*/
1228 /*-----------------------------------------------------------------------------------------------*/
1229 UINT8 m2mb_os_isrCtrl( UINT8 newIsrState );
1230 
1231 /*-----------------------------------------------------------------------------------------------*/
1232 /*-----------------------------------------------------------------------------------------------*/
1270 /*-----------------------------------------------------------------------------------------------*/
1271 M2MB_OS_RESULT_E m2mb_os_get_errno( UINT32 *pCategory, INT32 *pErrno );
1272 
1273 
1274 /*-----------------------------------------------------------------------------------------------*/
1291 /*-----------------------------------------------------------------------------------------------*/
1292 int m2mb_thread_fp_enable();
1296 /*-----------------------------------------------------------------------------------------------*/
1297 
1298 #ifdef __cplusplus
1299 }
1300 #endif
1301 #endif /* M2MB_OS_H */
void * m2mb_os_malloc(UINT32 size)
Allocates bytes of memory.
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:83
int m2mb_thread_fp_enable()
Sets the thread floating point unit flag.
M2MB_OS_RESULT_E m2mb_os_taskTerminate(M2MB_OS_TASK_HANDLE taskHandle)
Terminates application task.
M2MB_OS_RESULT_E m2mb_os_taskWaitAbort(M2MB_OS_TASK_HANDLE taskHandle)
Abort suspension of a specified task.
M2MB_OS_RESULT_E m2mb_os_taskSuspend(M2MB_OS_TASK_HANDLE taskHandle)
Suspend application task.
UINT8 m2mb_os_isrCtrl(UINT8 newIsrState)
Enable and disable interrupts (ISRs)
OS Semaphore prototypes.
HANDLE M2MB_OS_TASK_HANDLE
Definition: m2mb_os.h:96
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.
OS event prototypes.
Types used across OS (semaphore, mutex...)
M2MB_OS_RESULT_E m2mb_os_get_errno(UINT32 *pCategory, INT32 *pErrno)
Allow to get Errno saved in a relative task environment.
OS mutex prototypes.
M2MB_OS_RESULT_E m2mb_os_setSysTicks(UINT32 newTick)
Set start system time in ticks.
M2MB_OS_RESULT_E m2mb_os_taskRestart(M2MB_OS_TASK_HANDLE taskHandle)
Task restart.
void(* ENTRY_FN)(void *)
Definition: m2mb_os.h:100
unsigned long int UINT32
Definition: m2mb_types.h:85
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.
UINT32 M2MB_OS_MS2TICKS(UINT32 ms)
M2MB_OS_RESULT_E m2mb_os_free(void *pMem)
Free allocated memory.
void VOID
Definition: m2mb_types.h:72
HANDLE M2MB_OS_TASK_ATTR_HANDLE
Definition: m2mb_os.h:97
UINT32 MEM_W
Definition: m2mb_types.h:91
enum M2MB_OS_RESULT M2MB_OS_RESULT_E
void * HANDLE
Definition: m2mb_types.h:95
signed int INT32
Definition: m2mb_types.h:80
M2MB_OS_RESULT_E m2mb_os_taskDelete(M2MB_OS_TASK_HANDLE taskHandle)
Task delete.
M2MB_OS_TASK_SEL_CMD_E
Definition: m2mb_os.h:102
M2MB_OS_RESULT_E m2mb_os_taskResume(M2MB_OS_TASK_HANDLE taskHandle)
Resume suspended application task.
float FLOAT32
Definition: m2mb_types.h:75
void * m2mb_os_calloc(UINT32 count, UINT32 size)
Allocates bytes of memory and init space with 0.
VOID m2mb_os_taskSleep(UINT32 ticks)
Suspend current task for specified time in ticks.
FLOAT32 m2mb_os_getSysTickDuration_ms(void)
Get the duration of system tick in ms.
M2MB_OS_RESULT_E m2mb_os_init(void)
Initialization of OS.
MEM_W m2mb_os_getSysTicks(void)
Get system time in ticks.
#define ENUM_TO_INT(Prefix)
Definition: m2mb_types.h:198
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.
M2MB_OS_TASK_STATE_E
Definition: m2mb_os.h:123
OS queue prototypes.
M2MB_OS_TASK_HANDLE m2mb_os_taskGetId(void)
Retrieves handle to the currently executing task.