osal-headers  1.0.0
osal-headers
osal.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2017-2018 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,
32  OSAL_NOT_SUPPORTED
34 
35 /*
36  * Each OSAL port has a unique osal_portmacro.h header file.
37  *
38  * This file must declare the following macros:
39  * - OSAL_task_stack_declare:
40  * @brief Declare a task stack.
41  * @param[in] _name name of the variable that defines the stack.
42  * @param[in] _size size of the stack in bytes. _size must be compile time constant value.
43  * OSAL_task_stack_declare(_name, _size);
44  * - OSAL_queue_declare:
45  * @brief Declare a queue.
46  * @param[in] _name name of the variable that defines the queue.
47  * @param[in] _size number of items that can be stored in the queue. _size must be compile time constant value.
48  * OSAL_queue_declare(_name, _size);
49  *
50  * This file must declare the following type:
51  * - OSAL_task_stack_t: OS task stack
52  * - OSAL_queue_t: OS queue
53  */
54 #include "osal_portmacro.h"
55 
56 #ifndef OSAL_task_stack_declare
57  #error "osal_portmacro.h doesn't define OSAL_task_stack_declare() macro."
58 #endif
59 
60 #ifndef OSAL_queue_declare
61  #error "osal_portmacro.h doesn't define OSAL_queue_declare() macro."
62 #endif
63 
64 #ifndef OSAL_CUSTOM_TYPEDEF
65 
67 typedef void* (*OSAL_task_entry_point_t)(void *args);
68 
70 typedef void* OSAL_task_handle_t;
71 
73 typedef void* OSAL_queue_handle_t;
74 
77 
80 
82 typedef void* OSAL_mutex_handle_t;
83 
84 #endif
85 
98 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);
99 
108 
117 
127 OSAL_status_t OSAL_queue_create(uint8_t* name, OSAL_queue_handle_t* handle, OSAL_queue_t queue);
128 
137 
147 
157 OSAL_status_t OSAL_queue_fetch(OSAL_queue_handle_t* handle, void** msg, uint32_t timeout);
158 
169 OSAL_status_t OSAL_counter_semaphore_create(uint8_t* name, uint32_t initial_count, uint32_t max_count, OSAL_counter_semaphore_handle_t* handle);
170 
179 
191 
201 
211 OSAL_status_t OSAL_binary_semaphore_create(uint8_t* name, uint32_t initial_count, OSAL_binary_semaphore_handle_t* handle);
212 
221 
233 
243 
252 OSAL_status_t OSAL_mutex_create(uint8_t* name, OSAL_mutex_handle_t* handle);
253 
262 
271 OSAL_status_t OSAL_mutex_take(OSAL_mutex_handle_t* handle, uint32_t timeout);
272 
281 
291 
299 
307 OSAL_status_t OSAL_sleep(uint32_t milliseconds);
308 
309 #endif // OSAL_H
void * OSAL_mutex_handle_t
OS mutex handle.
Definition: osal.h:82
OSAL_status_t OSAL_task_get_current(OSAL_task_handle_t *handle)
Get the handle of the current OS task.
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:79
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:70
void *(* OSAL_task_entry_point_t)(void *args)
task function entry point
Definition: osal.h:67
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:76
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:73
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.
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_queue_create(uint8_t *name, OSAL_queue_handle_t *handle, OSAL_queue_t queue)
Create an OS queue with a predefined queue size.
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.