osal-headers  0.2.1
osal-headers
Macros | Typedefs | Enumerations | Functions
osal.h File Reference

OS Abstraction Layer API. More...

#include <stdint.h>
#include "osal_portmacro.h"

Go to the source code of this file.

Macros

#define OSAL_INFINITE_TIME   0xFFFFFFFF
 define an infinite time
 

Typedefs

typedef void *(* OSAL_task_entry_point_t) (void *args)
 task function entry point
 
typedef void * OSAL_task_handle_t
 OS task handle.
 
typedef void * OSAL_queue_handle_t
 OS queue handle.
 
typedef void * OSAL_counter_semaphore_handle_t
 OS counter semaphore handle.
 
typedef void * OSAL_binary_semaphore_handle_t
 OS binary semaphore handle.
 
typedef void * OSAL_mutex_handle_t
 OS mutex handle.
 

Enumerations

enum  OSAL_status_t {
  OSAL_OK, OSAL_ERROR, OSAL_NOMEM, OSAL_WRONG_ARGS,
  OSAL_NOT_IMPLEMENTED
}
 return code list
 

Functions

OSAL_status_t OSAL_task_create (OSAL_task_entry_point_t entry_point, uint8_t *name, OSAL_task_stack_t stack, int32_t priority, void *parameters, OSAL_task_handle_t *handle)
 Create an OS task and start it. More...
 
OSAL_status_t OSAL_task_delete (OSAL_task_handle_t *handle)
 Delete an OS task and start it. More...
 
OSAL_status_t OSAL_queue_create (uint8_t *name, uint32_t size, OSAL_queue_handle_t *handle)
 Create an OS queue with a predefined queue size. More...
 
OSAL_status_t OSAL_queue_delete (OSAL_queue_handle_t *handle)
 Delete an OS queue. More...
 
OSAL_status_t OSAL_queue_post (OSAL_queue_handle_t *handle, void *msg)
 Post a message in an OS queue. More...
 
OSAL_status_t OSAL_queue_fetch (OSAL_queue_handle_t *handle, void **msg, uint32_t timeout)
 Fetch a message from an OS queue. Blocks until a message arrived or a timeout occurred. More...
 
OSAL_status_t OSAL_counter_semaphore_create (uint8_t *name, uint32_t initial_count, uint32_t max_count, OSAL_counter_semaphore_handle_t *handle)
 Create an OS counter semaphore with a semaphore count initial value. More...
 
OSAL_status_t OSAL_counter_semaphore_delete (OSAL_counter_semaphore_handle_t *handle)
 Delete an OS counter semaphore. More...
 
OSAL_status_t OSAL_counter_semaphore_take (OSAL_counter_semaphore_handle_t *handle, uint32_t timeout)
 Take operation on OS counter semaphore. Block the current task until counter semaphore become available or timeout occurred. Decrease the counter semaphore count value by 1 and block the current task if count value equals to 0. More...
 
OSAL_status_t OSAL_counter_semaphore_give (OSAL_counter_semaphore_handle_t *handle)
 Give operation on OS counter semaphore. Increase the counter semaphore count value by 1 and unblock the current task if count value. equals to 0. More...
 
OSAL_status_t OSAL_binary_semaphore_create (uint8_t *name, uint32_t initial_count, OSAL_binary_semaphore_handle_t *handle)
 Create an OS binary semaphore with a semaphore count initial value (0 or 1). More...
 
OSAL_status_t OSAL_binary_semaphore_delete (OSAL_binary_semaphore_handle_t *handle)
 Delete an OS binary semaphore. More...
 
OSAL_status_t OSAL_binary_semaphore_take (OSAL_binary_semaphore_handle_t *handle, uint32_t timeout)
 Take operation on OS binary semaphore. Block the current task until binary semaphore become available or timeout occurred. Decrease the binary semaphore count value by 1 and block the current task if count value equals to 0. More...
 
OSAL_status_t OSAL_binary_semaphore_give (OSAL_binary_semaphore_handle_t *handle)
 Give operation on OS binary semaphore. Increase the binary semaphore count value by 1 and unblock the current task if count value. equals to 0. More...
 
OSAL_status_t OSAL_mutex_create (uint8_t *name, OSAL_mutex_handle_t *handle)
 Create an OS mutex. More...
 
OSAL_status_t OSAL_mutex_delete (OSAL_mutex_handle_t *handle)
 Delete an OS mutex. More...
 
OSAL_status_t OSAL_mutex_take (OSAL_mutex_handle_t *handle, uint32_t timeout)
 Take operation on OS mutex. More...
 
OSAL_status_t OSAL_mutex_give (OSAL_mutex_handle_t *handle)
 Give operation on OS mutex. More...
 
OSAL_status_t OSAL_disable_context_switching (void)
 Disable the OS scheduler context switching. Prevent the OS from scheduling the current thread calling OSAL_disable_context_switching while the OS scheduling is already disable has an undefined behavior. This method may be called from an interrupt. More...
 
OSAL_status_t OSAL_enable_context_switching (void)
 Reenable the OS scheduling that was disabled by OSAL_disable_context_switching. This method may be called from an interrupt. More...
 
OSAL_status_t OSAL_sleep (uint32_t milliseconds)
 Asleep the current task during specified number of milliseconds. More...
 

Detailed Description

OS Abstraction Layer API.

Author
MicroEJ Developer Team
Version
0.2.1
Date
12 November 2020

Definition in file osal.h.

Function Documentation

§ OSAL_binary_semaphore_create()

OSAL_status_t OSAL_binary_semaphore_create ( uint8_t *  name,
uint32_t  initial_count,
OSAL_binary_semaphore_handle_t handle 
)

Create an OS binary semaphore with a semaphore count initial value (0 or 1).

Parameters
[in]namecounter semaphore name
[in]initial_countcounter semaphore initial count value
[in,out]handlepointer on a binary semaphore handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_binary_semaphore_delete()

OSAL_status_t OSAL_binary_semaphore_delete ( OSAL_binary_semaphore_handle_t handle)

Delete an OS binary semaphore.

Parameters
[in]handlepointer on the binary semaphore handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_binary_semaphore_give()

OSAL_status_t OSAL_binary_semaphore_give ( OSAL_binary_semaphore_handle_t handle)

Give operation on OS binary semaphore. Increase the binary semaphore count value by 1 and unblock the current task if count value. equals to 0.

Parameters
[in]handlepointer on the binary semaphore handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_binary_semaphore_take()

OSAL_status_t OSAL_binary_semaphore_take ( OSAL_binary_semaphore_handle_t handle,
uint32_t  timeout 
)

Take operation on OS binary semaphore. Block the current task until binary semaphore become available or timeout occurred. Decrease the binary semaphore count value by 1 and block the current task if count value equals to 0.

Parameters
[in]handlepointer on the binary semaphore handle
[in]timeoutmaximum time to wait until the binary semaphore become available, OSAL_INFINITE_TIME for infinite timeout
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_counter_semaphore_create()

OSAL_status_t OSAL_counter_semaphore_create ( uint8_t *  name,
uint32_t  initial_count,
uint32_t  max_count,
OSAL_counter_semaphore_handle_t handle 
)

Create an OS counter semaphore with a semaphore count initial value.

Parameters
[in]namecounter semaphore name
[in]initial_countcounter semaphore initial count value
[in]max_countcounter semaphore maximum count value
[in,out]handlepointer on a counter semaphore handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_counter_semaphore_delete()

OSAL_status_t OSAL_counter_semaphore_delete ( OSAL_counter_semaphore_handle_t handle)

Delete an OS counter semaphore.

Parameters
[in]handlepointer on the counter semaphore handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_counter_semaphore_give()

OSAL_status_t OSAL_counter_semaphore_give ( OSAL_counter_semaphore_handle_t handle)

Give operation on OS counter semaphore. Increase the counter semaphore count value by 1 and unblock the current task if count value. equals to 0.

Parameters
[in]handlepointer on the counter semaphore handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_counter_semaphore_take()

OSAL_status_t OSAL_counter_semaphore_take ( OSAL_counter_semaphore_handle_t handle,
uint32_t  timeout 
)

Take operation on OS counter semaphore. Block the current task until counter semaphore become available or timeout occurred. Decrease the counter semaphore count value by 1 and block the current task if count value equals to 0.

Parameters
[in]handlepointer on the counter semaphore handle
[in]timeoutmaximum time to wait until the counter semaphore become available, OSAL_INFINITE_TIME for infinite timeout
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_disable_context_switching()

OSAL_status_t OSAL_disable_context_switching ( void  )

Disable the OS scheduler context switching. Prevent the OS from scheduling the current thread calling OSAL_disable_context_switching while the OS scheduling is already disable has an undefined behavior. This method may be called from an interrupt.

Returns
operation status (
See also
OSAL_status_t)

§ OSAL_enable_context_switching()

OSAL_status_t OSAL_enable_context_switching ( void  )

Reenable the OS scheduling that was disabled by OSAL_disable_context_switching. This method may be called from an interrupt.

Returns
operation status (
See also
OSAL_status_t)

§ OSAL_mutex_create()

OSAL_status_t OSAL_mutex_create ( uint8_t *  name,
OSAL_mutex_handle_t handle 
)

Create an OS mutex.

Parameters
[in]namemutex name
[in,out]handlepointer on a mutex handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_mutex_delete()

OSAL_status_t OSAL_mutex_delete ( OSAL_mutex_handle_t handle)

Delete an OS mutex.

Parameters
[in]handlepointer on the mutex handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_mutex_give()

OSAL_status_t OSAL_mutex_give ( OSAL_mutex_handle_t handle)

Give operation on OS mutex.

Parameters
[in]handlepointer on the mutex handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_mutex_take()

OSAL_status_t OSAL_mutex_take ( OSAL_mutex_handle_t handle,
uint32_t  timeout 
)

Take operation on OS mutex.

Parameters
[in]handlepointer on the mutex handle
[in]timeoutmaximum time to wait until the mutex become available, OSAL_INFINITE_TIME for infinite timeout
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_queue_create()

OSAL_status_t OSAL_queue_create ( uint8_t *  name,
uint32_t  size,
OSAL_queue_handle_t handle 
)

Create an OS queue with a predefined queue size.

Parameters
[in,out]handlepointer on a queue handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_queue_delete()

OSAL_status_t OSAL_queue_delete ( OSAL_queue_handle_t handle)

Delete an OS queue.

Parameters
[in]handlepointer on the queue handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_queue_fetch()

OSAL_status_t OSAL_queue_fetch ( OSAL_queue_handle_t handle,
void **  msg,
uint32_t  timeout 
)

Fetch a message from an OS queue. Blocks until a message arrived or a timeout occurred.

Parameters
[in]handlepointer on the queue handle
[in,out]msgmessage fetched in the OS queue
[in]timeoutmaximum time to wait for message arrival, OSAL_INFINITE_TIME for infinite timeout
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_queue_post()

OSAL_status_t OSAL_queue_post ( OSAL_queue_handle_t handle,
void *  msg 
)

Post a message in an OS queue.

Parameters
[in]handlepointer on the queue handle
[in]msgmessage to post in the message queue
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_sleep()

OSAL_status_t OSAL_sleep ( uint32_t  milliseconds)

Asleep the current task during specified number of milliseconds.

Parameters
[in]millisecondsnumber of milliseconds
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_task_create()

OSAL_status_t OSAL_task_create ( OSAL_task_entry_point_t  entry_point,
uint8_t *  name,
OSAL_task_stack_t  stack,
int32_t  priority,
void *  parameters,
OSAL_task_handle_t handle 
)

Create an OS task and start it.

Parameters
[in]entry_pointfunction called at task startup
[in]namethe task name
[in]stacktask stack declared using OSAL_task_stack_declare() macro
[in]prioritytask priority
[in]parameterstask entry parameters. NULL if no entry parameters
[in,out]handlepointer on a task handle
Returns
operation status (
See also
OSAL_status_t)

§ OSAL_task_delete()

OSAL_status_t OSAL_task_delete ( OSAL_task_handle_t handle)

Delete an OS task and start it.

Parameters
[in]handlepointer on the task handle
Returns
operation status (
See also
OSAL_status_t)