Renesas PTX1xxR IoT-Reader API Version 7.3.1
Renesas Software Stack for IoT-Reader Applications
ptxOsal.h
Go to the documentation of this file.
1
44#ifndef PTX_OSAL_H
45#define PTX_OSAL_H
46
47
48/*
49 * ####################################################################################################################
50 * INCLUDES
51 * ####################################################################################################################
52 */
53
54#include "ptx_Status.h"
55#include <stdlib.h>
56
57
58#ifdef __cplusplus
59extern "C"
60{
61#endif
62
70/*
71 * ####################################################################################################################
72 * DEFINES / TYPES
73 * ####################################################################################################################
74 */
75
79struct ptxOsal;
80
84struct ptxTimer;
85
89struct ptxThread;
90/* polyspace:begin<MISRA-C3:5.7 : Not a defect : No action planned > Forward declaration. */
91/* polyspace:begin<MISRA-C3:1.3 : Not a defect : No action planned > Don't spread other defs via this header file. */
95typedef struct ptxMutex* ptxMutex_t;
96
100typedef struct ptxSemaphore* ptxSemaphore_t;
101/* polyspace:end<MISRA-C3:1.3:Not a defect:No action planned> Don't spread other defs via this header file. */
102/* polyspace:end<MISRA-C3:5.7:Not a defect:No action planned> Forward declaration. */
103
107typedef uint64_t ptxTimeDiff_t;
108
114typedef void (*pptxOsal_ThreadProc_t)(void *threadParam);
115
121typedef void (*pptxOsal_TimerProc_t)(void *timerParam);
122
123
124/*
125 * ####################################################################################################################
126 * API FUNCTIONS / ADMINISTRATIVE
127 * ####################################################################################################################
128 */
129
141ptxStatus_t ptxOsal_AllocInit(struct ptxOsal **osalCtx, void *sysCtx);
142
151void ptxOsal_DeInit(struct ptxOsal *osalCtx);
152
161void ptxOsal_DeAlloc(struct ptxOsal **osalCtx);
162
163
164/*
165 * ####################################################################################################################
166 * API FUNCTIONS / MEMORY HANDLING
167 * ####################################################################################################################
168 */
169
179void *ptxOsal_Allocate(struct ptxOsal *osalCtx, size_t allocSize);
180
194void *ptxOsal_JustAllocate(size_t allocSize);
195
204void ptxOsal_Free(struct ptxOsal *osalCtx, void *memToFree);
205
216void ptxOsal_FreeNull(struct ptxOsal *osalCtx, void **memToFree);
217
232void *ptxOsal_Allocate_NoTrack(struct ptxOsal *osalCtx, size_t allocSize);
233
245void ptxOsal_Free_NoTrack(struct ptxOsal *osalCtx, void *memToFree);
246
260void ptxOsal_JustFree(void *memToFree, uint32_t *sentryViolationCount);
261
262
263/*
264 * ####################################################################################################################
265 * API FUNCTIONS / SEMAPHORES
266 * ####################################################################################################################
267 */
268
280ptxStatus_t ptxOsal_SemInit(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem, uint32_t initialCount, uint32_t maxCount);
281
291ptxStatus_t ptxOsal_SemClose(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem);
292
302ptxStatus_t ptxOsal_SemPost(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem);
303
313ptxStatus_t ptxOsal_SemWait(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem);
314
325ptxStatus_t ptxOsal_SemTimedWait(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem, uint32_t msTimeout);
326
327
328/*
329 * ####################################################################################################################
330 * API FUNCTIONS / MUTEXES
331 * ####################################################################################################################
332 */
333
343ptxStatus_t ptxOsal_MutexInit(struct ptxOsal *osalCtx, ptxMutex_t *hMutex);
344
354ptxStatus_t ptxOsal_MutexDestroy(struct ptxOsal *osalCtx, ptxMutex_t *hMutex);
355
365ptxStatus_t ptxOsal_MutexLock(struct ptxOsal *osalCtx, ptxMutex_t *hMutex);
366
376ptxStatus_t ptxOsal_MutexUnlock(struct ptxOsal *osalCtx, ptxMutex_t *hMutex);
377
378
379/*
380 * ####################################################################################################################
381 * API FUNCTIONS / THREADS
382 * ####################################################################################################################
383 */
384
393struct ptxThread *ptxOsal_ThreadAllocate(struct ptxOsal *osalCtx);
394
407ptxStatus_t ptxOsal_ThreadCreate(struct ptxOsal *osalCtx, struct ptxThread *hThd, pptxOsal_ThreadProc_t thdFn, void *thdParam);
408
418ptxStatus_t ptxOsal_ThreadJoin(struct ptxOsal *osalCtx, struct ptxThread *hThd);
419
429ptxStatus_t ptxOsal_ThreadClose(struct ptxOsal *osalCtx, struct ptxThread *hThd);
430
438void ptxOsal_ThreadSleep(struct ptxOsal *osalCtx, uint32_t msSleep);
439
440
441/*
442 * ####################################################################################################################
443 * API FUNCTIONS / TIMERS
444 * ####################################################################################################################
445 */
446
455struct ptxTimer *ptxOsal_TimerAllocate(struct ptxOsal *osalCtx);
456
469ptxStatus_t ptxOsal_TimerCreate(struct ptxOsal *osalCtx, struct ptxTimer *hTimer, pptxOsal_TimerProc_t timerProc, void *timerParam);
470
483ptxStatus_t ptxOsal_TimerStart(struct ptxOsal *osalCtx, struct ptxTimer *hTimer, uint32_t msInterval);
484
496ptxStatus_t ptxOsal_TimerCancel(struct ptxOsal *osalCtx, struct ptxTimer *hTimer);
497
507ptxStatus_t ptxOsal_TimerClose(struct ptxOsal *osalCtx, struct ptxTimer *hTimer);
508
518ptxStatus_t ptxOsal_StopwatchStart(struct ptxOsal *osalCtx, ptxTimeDiff_t *startVal);
519
530ptxStatus_t ptxOsal_StopwatchStop(struct ptxOsal *osalCtx, ptxTimeDiff_t *startStopVal);
531
532
533/*
534 * ####################################################################################################################
535 * API FUNCTIONS / SYSTEM CONTEXT
536 * ####################################################################################################################
537 */
538
547void *ptxOsal_GetSysCtx(struct ptxOsal *osalCtx);
548
549#ifdef __cplusplus
550}
551#endif
552
555#endif /* Guard */
556
557
uint16_t ptxStatus_t
Status Type.
Definition ptx_Status.h:82
void * ptxOsal_JustAllocate(size_t allocSize)
Allocate memory. Do not track memory usage. Does not need an instance of OSAL.
struct ptxMutex * ptxMutex_t
Mutex Wrapper Structure - Forward Declaration.
Definition ptxOsal.h:95
ptxStatus_t ptxOsal_MutexInit(struct ptxOsal *osalCtx, ptxMutex_t *hMutex)
Initialize a Mutex.
void ptxOsal_DeInit(struct ptxOsal *osalCtx)
Un-Initialize the OSAL.
uint64_t ptxTimeDiff_t
Time difference type.
Definition ptxOsal.h:107
void ptxOsal_DeAlloc(struct ptxOsal **osalCtx)
De-Allocate the OSAL.
ptxStatus_t ptxOsal_TimerStart(struct ptxOsal *osalCtx, struct ptxTimer *hTimer, uint32_t msInterval)
Start or restart the timer.
void ptxOsal_Free_NoTrack(struct ptxOsal *osalCtx, void *memToFree)
Free memory, allocated by ptxOsal_Allocate_NoTrack.
void(* pptxOsal_ThreadProc_t)(void *threadParam)
Thread procedure function pointer declaration.
Definition ptxOsal.h:114
ptxStatus_t ptxOsal_SemClose(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem)
Close an initialized semaphore object.
ptxStatus_t ptxOsal_SemInit(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem, uint32_t initialCount, uint32_t maxCount)
Initialize an already allocated but non-initialized object.
void * ptxOsal_GetSysCtx(struct ptxOsal *osalCtx)
Get the System Context.
void ptxOsal_JustFree(void *memToFree, uint32_t *sentryViolationCount)
Free memory, allocated by ptxOsal_JustAllocate.
struct ptxThread * ptxOsal_ThreadAllocate(struct ptxOsal *osalCtx)
Allocate a thread structure.
ptxStatus_t ptxOsal_StopwatchStop(struct ptxOsal *osalCtx, ptxTimeDiff_t *startStopVal)
End a time measurement.
ptxStatus_t ptxOsal_ThreadJoin(struct ptxOsal *osalCtx, struct ptxThread *hThd)
Join on a thread, wait until it has exited.
ptxStatus_t ptxOsal_ThreadClose(struct ptxOsal *osalCtx, struct ptxThread *hThd)
Close a thread, once it has exited.
void * ptxOsal_Allocate_NoTrack(struct ptxOsal *osalCtx, size_t allocSize)
Allocate memory. Do not track memory usage.
ptxStatus_t ptxOsal_AllocInit(struct ptxOsal **osalCtx, void *sysCtx)
Initialize the OSAL.
void ptxOsal_FreeNull(struct ptxOsal *osalCtx, void **memToFree)
Free memory, allocated by ptxOsal_Allocate and set the pointer to NULL.
ptxStatus_t ptxOsal_SemPost(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem)
Signal a semaphore, unblock a waiting thread.
void ptxOsal_ThreadSleep(struct ptxOsal *osalCtx, uint32_t msSleep)
Sleep for a number of ms.
void * ptxOsal_Allocate(struct ptxOsal *osalCtx, size_t allocSize)
Allocate memory. Track memory usage.
ptxStatus_t ptxOsal_SemTimedWait(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem, uint32_t msTimeout)
Wait on the semaphore, with timeout.
ptxStatus_t ptxOsal_ThreadCreate(struct ptxOsal *osalCtx, struct ptxThread *hThd, pptxOsal_ThreadProc_t thdFn, void *thdParam)
Create a thread.
void ptxOsal_Free(struct ptxOsal *osalCtx, void *memToFree)
Free memory, allocated by ptxOsal_Allocate.
ptxStatus_t ptxOsal_TimerClose(struct ptxOsal *osalCtx, struct ptxTimer *hTimer)
Close a timer, once it has expired.
ptxStatus_t ptxOsal_TimerCreate(struct ptxOsal *osalCtx, struct ptxTimer *hTimer, pptxOsal_TimerProc_t timerProc, void *timerParam)
Create a timer.
ptxStatus_t ptxOsal_MutexLock(struct ptxOsal *osalCtx, ptxMutex_t *hMutex)
Lock/acquire a Mutex.
struct ptxSemaphore * ptxSemaphore_t
Semaphore Wrapper Structure - Forward Declaration.
Definition ptxOsal.h:100
void(* pptxOsal_TimerProc_t)(void *timerParam)
Timer procedure function pointer declaration.
Definition ptxOsal.h:121
ptxStatus_t ptxOsal_SemWait(struct ptxOsal *osalCtx, ptxSemaphore_t *hSem)
Wait on the semaphore.
ptxStatus_t ptxOsal_TimerCancel(struct ptxOsal *osalCtx, struct ptxTimer *hTimer)
Cancel a timer, if active.
ptxStatus_t ptxOsal_MutexDestroy(struct ptxOsal *osalCtx, ptxMutex_t *hMutex)
Remove a Mutex.
ptxStatus_t ptxOsal_StopwatchStart(struct ptxOsal *osalCtx, ptxTimeDiff_t *startVal)
Start a time measurement or get a time value.
ptxStatus_t ptxOsal_MutexUnlock(struct ptxOsal *osalCtx, ptxMutex_t *hMutex)
Unlock/release a Mutex.
struct ptxTimer * ptxOsal_TimerAllocate(struct ptxOsal *osalCtx)
Allocate a timer structure.