os_port_rtx.c File Reference

RTOS abstraction layer (Keil RTX) More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "os_port.h"
#include "os_port_rtx.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   TRACE_LEVEL_OFF
 

Functions

void osInitKernel (void)
 Kernel initialization. More...
 
void osStartKernel (OsInitTaskCode task)
 Start kernel. More...
 
bool_t osCreateStaticTask (OsTask *task, const char_t *name, OsTaskCode taskCode, void *param, void *stack, size_t stackSize, int_t priority)
 Create a static task. More...
 
OsTaskosCreateTask (const char_t *name, OsTaskCode taskCode, void *param, size_t stackSize, int_t priority)
 Create a new task. More...
 
void osDeleteTask (OsTask *task)
 Delete a task. More...
 
void osDelayTask (systime_t delay)
 Delay routine. More...
 
void osSwitchTask (void)
 Yield control to the next task. More...
 
void osSuspendAllTasks (void)
 Suspend scheduler activity. More...
 
void osResumeAllTasks (void)
 Resume scheduler activity. More...
 
bool_t osCreateEvent (OsEvent *event)
 Create an event object. More...
 
void osDeleteEvent (OsEvent *event)
 Delete an event object. More...
 
void osSetEvent (OsEvent *event)
 Set the specified event object to the signaled state. More...
 
void osResetEvent (OsEvent *event)
 Set the specified event object to the nonsignaled state. More...
 
bool_t osWaitForEvent (OsEvent *event, systime_t timeout)
 Wait until the specified event is in the signaled state. More...
 
bool_t osSetEventFromIsr (OsEvent *event)
 Set an event object to the signaled state from an interrupt service routine. More...
 
bool_t osCreateSemaphore (OsSemaphore *semaphore, uint_t count)
 Create a semaphore object. More...
 
void osDeleteSemaphore (OsSemaphore *semaphore)
 Delete a semaphore object. More...
 
bool_t osWaitForSemaphore (OsSemaphore *semaphore, systime_t timeout)
 Wait for the specified semaphore to be available. More...
 
void osReleaseSemaphore (OsSemaphore *semaphore)
 Release the specified semaphore object. More...
 
bool_t osCreateMutex (OsMutex *mutex)
 Create a mutex object. More...
 
void osDeleteMutex (OsMutex *mutex)
 Delete a mutex object. More...
 
void osAcquireMutex (OsMutex *mutex)
 Acquire ownership of the specified mutex object. More...
 
void osReleaseMutex (OsMutex *mutex)
 Release ownership of the specified mutex object. More...
 
systime_t osGetSystemTime (void)
 Retrieve system time. More...
 
void * osAllocMem (size_t size)
 Allocate a memory block. More...
 
void osFreeMem (void *p)
 Release a previously allocated memory block. More...
 

Detailed Description

RTOS abstraction layer (Keil RTX)

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file os_port_rtx.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   TRACE_LEVEL_OFF

Definition at line 28 of file os_port_rtx.c.

Function Documentation

◆ osAcquireMutex()

void osAcquireMutex ( OsMutex mutex)

Acquire ownership of the specified mutex object.

Parameters
[in]mutexA handle to the mutex object

Definition at line 518 of file os_port_rtx.c.

◆ osAllocMem()

void* osAllocMem ( size_t  size)

Allocate a memory block.

Parameters
[in]sizeBytes to allocate
Returns
A pointer to the allocated memory block or NULL if there is insufficient memory available

Definition at line 561 of file os_port_rtx.c.

◆ osCreateEvent()

bool_t osCreateEvent ( OsEvent event)

Create an event object.

Parameters
[in]eventPointer to the event object
Returns
The function returns TRUE if the event object was successfully created. Otherwise, FALSE is returned

Definition at line 265 of file os_port_rtx.c.

◆ osCreateMutex()

bool_t osCreateMutex ( OsMutex mutex)

Create a mutex object.

Parameters
[in]mutexPointer to the mutex object
Returns
The function returns TRUE if the mutex was successfully created. Otherwise, FALSE is returned

Definition at line 492 of file os_port_rtx.c.

◆ osCreateSemaphore()

bool_t osCreateSemaphore ( OsSemaphore semaphore,
uint_t  count 
)

Create a semaphore object.

Parameters
[in]semaphorePointer to the semaphore object
[in]countThe maximum count for the semaphore object. This value must be greater than zero
Returns
The function returns TRUE if the semaphore was successfully created. Otherwise, FALSE is returned

Definition at line 406 of file os_port_rtx.c.

◆ osCreateStaticTask()

bool_t osCreateStaticTask ( OsTask task,
const char_t name,
OsTaskCode  taskCode,
void *  param,
void *  stack,
size_t  stackSize,
int_t  priority 
)

Create a static task.

Parameters
[out]taskPointer to the task structure
[in]nameA name identifying the task
[in]taskCodePointer to the task entry function
[in]paramA pointer to a variable to be passed to the task
[in]stackPointer to the stack
[in]stackSizeThe initial size of the stack, in words
[in]priorityThe priority at which the task should run
Returns
The function returns TRUE if the task was successfully created. Otherwise, FALSE is returned

Definition at line 83 of file os_port_rtx.c.

◆ osCreateTask()

OsTask* osCreateTask ( const char_t name,
OsTaskCode  taskCode,
void *  param,
size_t  stackSize,
int_t  priority 
)

Create a new task.

Parameters
[in]nameA name identifying the task
[in]taskCodePointer to the task entry function
[in]paramA pointer to a variable to be passed to the task
[in]stackSizeThe initial size of the stack, in words
[in]priorityThe priority at which the task should run
Returns
If the function succeeds, the return value is a pointer to the new task. If the function fails, the return value is NULL

Definition at line 109 of file os_port_rtx.c.

◆ osDelayTask()

void osDelayTask ( systime_t  delay)

Delay routine.

Parameters
[in]delayAmount of time for which the calling task should block

Definition at line 197 of file os_port_rtx.c.

◆ osDeleteEvent()

void osDeleteEvent ( OsEvent event)

Delete an event object.

Parameters
[in]eventPointer to the event object

Definition at line 280 of file os_port_rtx.c.

◆ osDeleteMutex()

void osDeleteMutex ( OsMutex mutex)

Delete a mutex object.

Parameters
[in]mutexPointer to the mutex object

Definition at line 507 of file os_port_rtx.c.

◆ osDeleteSemaphore()

void osDeleteSemaphore ( OsSemaphore semaphore)

Delete a semaphore object.

Parameters
[in]semaphorePointer to the semaphore object

Definition at line 421 of file os_port_rtx.c.

◆ osDeleteTask()

void osDeleteTask ( OsTask task)

Delete a task.

Parameters
[in]taskPointer to the task to be deleted

Definition at line 150 of file os_port_rtx.c.

◆ osFreeMem()

void osFreeMem ( void *  p)

Release a previously allocated memory block.

Parameters
[in]pPreviously allocated memory block to be freed

Definition at line 585 of file os_port_rtx.c.

◆ osGetSystemTime()

systime_t osGetSystemTime ( void  )

Retrieve system time.

Returns
Number of milliseconds elapsed since the system was last started

Definition at line 542 of file os_port_rtx.c.

◆ osInitKernel()

void osInitKernel ( void  )

Kernel initialization.

Definition at line 47 of file os_port_rtx.c.

◆ osReleaseMutex()

void osReleaseMutex ( OsMutex mutex)

Release ownership of the specified mutex object.

Parameters
[in]mutexA handle to the mutex object

Definition at line 530 of file os_port_rtx.c.

◆ osReleaseSemaphore()

void osReleaseSemaphore ( OsSemaphore semaphore)

Release the specified semaphore object.

Parameters
[in]semaphorePointer to the semaphore object

Definition at line 478 of file os_port_rtx.c.

◆ osResetEvent()

void osResetEvent ( OsEvent event)

Set the specified event object to the nonsignaled state.

Parameters
[in]eventPointer to the event object

Definition at line 303 of file os_port_rtx.c.

◆ osResumeAllTasks()

void osResumeAllTasks ( void  )

Resume scheduler activity.

Definition at line 247 of file os_port_rtx.c.

◆ osSetEvent()

void osSetEvent ( OsEvent event)

Set the specified event object to the signaled state.

Parameters
[in]eventPointer to the event object

Definition at line 291 of file os_port_rtx.c.

◆ osSetEventFromIsr()

bool_t osSetEventFromIsr ( OsEvent event)

Set an event object to the signaled state from an interrupt service routine.

Parameters
[in]eventPointer to the event object
Returns
TRUE if setting the event to signaled state caused a task to unblock and the unblocked task has a priority higher than the currently running task

Definition at line 387 of file os_port_rtx.c.

◆ osStartKernel()

void osStartKernel ( OsInitTaskCode  task)

Start kernel.

Parameters
[in]taskPointer to the task function to start after the kernel is initialized

Definition at line 61 of file os_port_rtx.c.

◆ osSuspendAllTasks()

void osSuspendAllTasks ( void  )

Suspend scheduler activity.

Definition at line 232 of file os_port_rtx.c.

◆ osSwitchTask()

void osSwitchTask ( void  )

Yield control to the next task.

Definition at line 221 of file os_port_rtx.c.

◆ osWaitForEvent()

bool_t osWaitForEvent ( OsEvent event,
systime_t  timeout 
)

Wait until the specified event is in the signaled state.

Parameters
[in]eventPointer to the event object
[in]timeoutTimeout interval
Returns
The function returns TRUE if the state of the specified object is signaled. FALSE is returned if the timeout interval elapsed

Definition at line 326 of file os_port_rtx.c.

◆ osWaitForSemaphore()

bool_t osWaitForSemaphore ( OsSemaphore semaphore,
systime_t  timeout 
)

Wait for the specified semaphore to be available.

Parameters
[in]semaphorePointer to the semaphore object
[in]timeoutTimeout interval
Returns
The function returns TRUE if the semaphore is available. FALSE is returned if the timeout interval elapsed

Definition at line 435 of file os_port_rtx.c.