osal-headers  0.2.1
osal-headers
osal.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2017 IS2T. All rights reserved
5  * This library is provided in source code for use, modification and test, subject to license terms
6  * Any modification of the source code will break IS2T warranties on the whole library
7  */
8 
9 #ifndef OSAL_H
10 #define OSAL_H
11 
20 #include <stdint.h>
21 
23 #define OSAL_INFINITE_TIME 0xFFFFFFFF
24 
26 typedef enum {
27  OSAL_OK,
28  OSAL_ERROR,
29  OSAL_NOMEM,
30  OSAL_WRONG_ARGS,
31  OSAL_NOT_IMPLEMENTED
33 
35 typedef void*( *OSAL_task_entry_point_t)( void *args);
36 
38 typedef void* OSAL_task_handle_t;
39 
41 typedef void* OSAL_queue_handle_t;
42 
45 
48 
50 typedef void* OSAL_mutex_handle_t;
51 
52 /*
53  * Each OSAL port has a unique osal_portmacro.h header file.
54  *
55  * This file must declare the following macro:
56  * - OSAL_task_stack_declare:
57  * @brief Declare a task stack.
58  * @param[in] _name name of the variable that defines the stack.
59  * @param[in] _size size of the stack in bytes. _size must be compile time constant value.
60  * OSAL_task_stack_declare(_name, _size);
61  *
62  * This file must declare the following type:
63  * - OSAL_task_stack_t: OS task stack
64  */
65 #include "osal_portmacro.h"
66 
67 #ifndef OSAL_task_stack_declare
68  #error "osal_portmacro.h doesn't define OSAL_task_stack_declare() macro."
69 #endif
70 
83 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);
84 
93 
101 OSAL_status_t OSAL_queue_create(uint8_t* name, uint32_t size, OSAL_queue_handle_t* handle);
102 
111 
121 
131 OSAL_status_t OSAL_queue_fetch(OSAL_queue_handle_t* handle, void** msg, uint32_t timeout);
132 
143 OSAL_status_t OSAL_counter_semaphore_create(uint8_t* name, uint32_t initial_count, uint32_t max_count, OSAL_counter_semaphore_handle_t* handle);
144 
153 
165 
175 
185 OSAL_status_t OSAL_binary_semaphore_create(uint8_t* name, uint32_t initial_count, OSAL_binary_semaphore_handle_t* handle);
186 
195 
207 
217 
226 OSAL_status_t OSAL_mutex_create(uint8_t* name, OSAL_mutex_handle_t* handle);
227 
236 
245 OSAL_status_t OSAL_mutex_take(OSAL_mutex_handle_t* handle, uint32_t timeout);
246 
255 
265 
273 
281 OSAL_status_t OSAL_sleep(uint32_t milliseconds);
282 
283 #endif // OSAL_H
void * OSAL_mutex_handle_t
OS mutex handle.
Definition: osal.h:50
OSAL_status_t
return code list
Definition: osal.h:26
OSAL_status_t OSAL_mutex_delete(OSAL_mutex_handle_t *handle)
Delete an OS mutex.
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...
OSAL_status_t OSAL_mutex_take(OSAL_mutex_handle_t *handle, uint32_t timeout)
Take operation on OS mutex.
OSAL_status_t OSAL_sleep(uint32_t milliseconds)
Asleep the current task during specified number of milliseconds.
void * OSAL_binary_semaphore_handle_t
OS binary semaphore handle.
Definition: osal.h:47
OSAL_status_t OSAL_mutex_create(uint8_t *name, OSAL_mutex_handle_t *handle)
Create an OS mutex.
OSAL_status_t OSAL_task_delete(OSAL_task_handle_t *handle)
Delete an OS task and start it.
void * OSAL_task_handle_t
OS task handle.
Definition: osal.h:38
OSAL_status_t OSAL_counter_semaphore_delete(OSAL_counter_semaphore_handle_t *handle)
Delete an OS counter semaphore.
OSAL_status_t OSAL_queue_post(OSAL_queue_handle_t *handle, void *msg)
Post a message in an OS queue.
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.
void * OSAL_counter_semaphore_handle_t
OS counter semaphore handle.
Definition: osal.h:44
OSAL_status_t OSAL_enable_context_switching(void)
Reenable the OS scheduling that was disabled by OSAL_disable_context_switching. This method may be ca...
OSAL_status_t OSAL_disable_context_switching(void)
Disable the OS scheduler context switching. Prevent the OS from scheduling the current thread calling...
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.
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...
OSAL_status_t OSAL_binary_semaphore_delete(OSAL_binary_semaphore_handle_t *handle)
Delete an OS binary semaphore.
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).
void * OSAL_queue_handle_t
OS queue handle.
Definition: osal.h:41
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.
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.
void *(* OSAL_task_entry_point_t)(void *args)
task function entry point
Definition: osal.h:35
OSAL_status_t OSAL_queue_delete(OSAL_queue_handle_t *handle)
Delete an OS queue.
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 availab...
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 t...
OSAL_status_t OSAL_mutex_give(OSAL_mutex_handle_t *handle)
Give operation on OS mutex.