| Kinetis SDK API Reference Manual 1.0.0-beta Freescale Semiconductor, Inc.

- Introduction
- Related Pages
- API Usage

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Typedefs | Enumerations
Freescale MQX™ RTOS Abstraction Layer
OS Abstraction Layer (OSA)

The Freescale MQX™ RTOS OSA layer provides the OSA services mapped to the MQX software services. More...

## Data Structures
struct | MQX_OSA_QUEUE

## Macros
#define | FSL_RTOS_CURRENT_TASK ((task_handler_t)MQX_NULL_TASK_ID)
| Macro passed to the task_destroy function to destroy the current task. More...

## Typedefs
typedef LWSEM_STRUCT | sync_object_t
| Type for an interrupt synchronization object. More...
typedef MUTEX_STRUCT | lock_object_t
| Type for a resource locking object. More...
typedef LWEVENT_STRUCT | event_object_t
| Type for an event group object. More...
typedef _mqx_uint | event_group_t
| Type for an event flags group. More...
typedef TASK_FPTR | task_t
| Type for a task pointer. More...
typedef _task_id | task_handler_t
| Type for a task handler, returned by the task_create function. More...
typedef uint32_t | task_stack_t
| Type for a task stack. More...
typedef MQX_OSA_QUEUE | msg_queue_t
| Type for a message queue declaration and creation. More...
typedef void * | msg_queue_handler_t
| Type for a message queue declaration and creation. More...
typedef void * | msg_queue_item_t
| Type for a message queue item. More...

## Enumerations
enum | sync_timeouts { kSyncWaitForever = UINT32_MAX }

## Interrupt handler synchronization
Definition of how MQX handles the message queues
#define | sync_object_declare(obj) sync_object_t obj
| Create the synchronization object. More...

## Thread management
#define | FSL_RTOS_TASK_DEFINE(task, stackSize, name, usesFloat)
| Creates a task descriptor that is used to create the task with task_create. More...
#define | task_create(task, priority, param, handler)
| Creates and sets the task to active. More...

## Message queues
#define | SIZE_IN_MMT_UNITS(size) ((size + sizeof(_mqx_max_type) - 1) / sizeof(_mqx_max_type))
#define | MSG_QUEUE_DECLARE(name, number, size)
| This macro statically reserves the memory required for the queue. More...

## Critical Sections
void | rtos_enter_critical (void)
| Ensures the following code will not be preempted. More...
void | rtos_exit_critical (void)
| Allows preemption.

## Data Structure Documentation

struct MQX_OSA_QUEUE

### Data Fields
_mqx_max_type * | one_msg
_mqx_max_type * | msgq

## Macro Definition Documentation

#define FSL_RTOS_CURRENT_TASK ((task_handler_t)MQX_NULL_TASK_ID)

#define sync_object_declare | ( |  | obj | ) | sync_object_t obj

To be used instead of a standard declaration.

Parameters

  obj | The sync object to create.

#define FSL_RTOS_TASK_DEFINE | ( |  | task,
|  |  | stackSize,
|  |  | name,
|  |  | usesFloat
| ) |  |

Value:
const uint16_t fslTaskStackSize_##task = stackSize; \
const uint8_t fslTaskName_##task[] = name; \
const bool fslTaskFloatUse_##task = usesFloat

Parameters

  task | The task function.
  stackSize | Number of elements in the stack for this task.
  name | String to assign to the task.
  usesFloat | Boolean that indicates whether the task uses the floating point unit.

#define task_create | ( |  | task,
|  |  | priority,
|  |  | param,
|  |  | handler
| ) |  |

Value:
__task_create(task, \
(uint8_t *)fslTaskName_##task, \
fslTaskStackSize_##task, \
NULL, \
priority, \
param, \
fslTaskFloatUse_##task, \
handler)
__task_create
fsl_rtos_status __task_create(task_t task, uint8_t *name, uint16_t stackSize, task_stack_t *stackMem, uint16_t priority, void *param, bool usesFloat, task_handler_t *handler)
Create a task.

Parameters

  task | The task function.
  priority | Initial priority of the task.
  param | Pointer to be passed to the task when it is created.
  handler | Returns the identifier to be used afterwards to destroy the task.

Return values

  kSuccess | The task was successfully created.
  kError | Creation of task failed.

#define MSG_QUEUE_DECLARE | ( |  | name,
|  |  | number,
|  |  | size
| ) |  |

Value:
_mqx_max_type mqxq_##name[SIZE_IN_MMT_UNITS(sizeof(LWMSGQ_STRUCT)) + SIZE_IN_MMT_UNITS(size * 4) * number]; \
_mqx_max_type mqxm_##name[SIZE_IN_MMT_UNITS(size * 4)]; \
MQX_OSA_QUEUE name = { \
.one_msg = mqxm_##name, \
.msgq = mqxq_##name, \
}

Note
  The queue will store pointers to the elements, and no the elements themselves. The element must continue to exist in memory for the receiving end to properly get the contents.

Parameters

  name | Identifier for the memory region.
  number | Number of elements in the queue.
  size | Size of element in 4B units.

## Typedef Documentation

typedef LWSEM_STRUCT sync_object_t

typedef MUTEX_STRUCT lock_object_t

typedef LWEVENT_STRUCT event_object_t

typedef _mqx_uint event_group_t

Bit 32 is reserved.

typedef TASK_FPTR task_t

typedef _task_id task_handler_t

typedef uint32_t task_stack_t

typedef MQX_OSA_QUEUE msg_queue_t

typedef void* msg_queue_handler_t

typedef void* msg_queue_item_t

## Enumeration Type Documentation

enum sync_timeouts

Enumerator
kSyncWaitForever | Constant to pass for the sync_wait() timeout in order to wait indefinitely.

## Function Documentation

void rtos_enter_critical | ( | void |  | ) |

Required attention to other system events may be delayed.