Hardware Abstraction Layer for FreeRTOS
os.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: MIT */
2
/*
3
* Author: Andreas Werner <kernel@andy89.org>
4
* Date: 2016
5
*/
6
#ifndef OS_H_
7
#define OS_H_
8
#include <FreeRTOS.h>
9
#include <semphr.h>
10
#include <
system.h
>
11
#include <stdbool.h>
12
#include <
system.h
>
13
#include <portable.h>
24
#ifdef CONFIG_USE_STATIC
25
# define OS_DEFINE_TASK(name, stackSize) StaticTask_t name##_buffer; StackType_t ALIGN(portBYTE_ALIGNMENT) name##_stack[stackSize]; TaskHandle_t name
26
# define OS_DEFINE_QUEUE(name, length, size) StaticQueue_t name##_buffer; uint8_t name##_storage[length * size]; QueueHandle_t name
27
# define OS_DEFINE_TIMER(name) StaticTimer_t name##_buffer; TimerHandle_t name
28
# define OS_DEFINE_EVENT_GROUP(name) StaticEventGroup_t name##_buffer; EventGroupHandle_t name
29
# define OS_DEFINE_SEMARPHORE(name) StaticSemaphore_t name##_buffer; SemaphoreHandle_t name
30
# define OS_DEFINE_SEMARPHORE_BINARAY(name) OS_DEFINE_SEMARPHORE(name)
31
# define OS_DEFINE_MUTEX(name) OS_DEFINE_SEMARPHORE(name)
32
# define OS_DEFINE_MUTEX_RECURSIVE(name) OS_DEFINE_SEMARPHORE(name)
33
34
# define OS_CREATE_TASK(function, name, stackSize, parameter, prio, handleName) (\
35
{\
36
BaseType_t ret; \
37
handleName = xTaskCreateStatic(function, name, stackSize, parameter, prio, handleName##_stack, &handleName##_buffer); \
38
ret = (handleName == NULL) ? errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY : pdPASS; \
39
ret;\
40
}\
41
)
42
# define OS_CREATE_QUEUE(length, size, handleName) xQueueCreateStatic(length, size, handleName##_storage, &handleName##_buffer)
43
# define OS_CREATE_TIMER(name, period, autoReload, timerID, function, handleName) xTimerCreateStatic(name,period, autoReload, timerID, function, &handleName##_buffer)
44
# define OS_CREATE_EVENT_GROUP(handleName) xEventGroupCreateStatic(&handleName##_buffer)
45
# define OS_CREATE_SEMARPHORE(maxCount, initialCount, handleName) xSemaphoreCreateCountingStatic(maxCount, initialCount, &handleName##_buffer)
46
# define OS_CREATE_SEMARPHORE_BINARAY(handleName) xSemaphoreCreateBinaryStatic(&handleName##_buffer)
47
# define OS_CREATE_MUTEX(handleName) xSemaphoreCreateMutexStatic(&handleName##_buffer)
48
# define OS_CREATE_MUTEX_RECURSIVE(handleName) xSemaphoreCreateRecursiveMutexStatic(&handleName##_buffer)
49
50
#else
51
52
# define OS_DEFINE_TASK(name, stackSize) TaskHandle_t name
53
# define OS_DEFINE_QUEUE(name, length, size) QueueHandle_t name
54
# define OS_DEFINE_TIMER(name) TimerHandle_t name
55
# define OS_DEFINE_EVENT_GROUP(name) EventGroupHandle_t name
56
# define OS_DEFINE_SEMARPHORE(name) SemaphoreHandle_t name
57
# define OS_DEFINE_SEMARPHORE_BINARAY(name) OS_DEFINE_SEMARPHORE(name)
58
# define OS_DEFINE_MUTEX(name) OS_DEFINE_SEMARPHORE(name)
59
# define OS_DEFINE_MUTEX_RECURSIVE(name) OS_DEFINE_SEMARPHORE(name)
60
61
# define OS_CREATE_TASK(function, name, stackSize, parameter, prio, handleName) xTaskCreate(function, name, stackSize, parameter, prio, &handleName)
62
# define OS_CREATE_QUEUE(length, size, handleName) xQueueCreate(length, size)
63
# define OS_CREATE_TIMER(name, period, autoReload, timerID, function, handleName) xTimerCreate(name,period, autoReload, timerID, function)
64
# define OS_CREATE_EVENT_GROUP(handleName) xEventGroupCreate()
65
# define OS_CREATE_SEMARPHORE(maxCount, initialCount, handleName) xSemaphoreCreateCounting(maxCount, initialCount)
66
# define OS_CREATE_SEMARPHORE_BINARAY(handleName) xSemaphoreCreateBinary()
67
# define OS_CREATE_MUTEX(handleName) xSemaphoreCreateMutex()
68
# define OS_CREATE_MUTEX_RECURSIVE(handleName) xSemaphoreCreateRecursiveMutex()
69
#endif
70
71
#endif
system.h
driver
include
os.h
Generated on Tue Aug 17 2021 15:19:23 for Hardware Abstraction Layer for FreeRTOS by
1.8.20