1 /*! *********************************************************************************
2  * Copyright (c) 2013-2014, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * ile
7  *
8  * SPDX-License-Identifier: BSD-3-Clause
9  ********************************************************************************** */
10 #if !defined(__FSL_OS_ABSTRACTION_FREERTOS_H__)
11 #define __FSL_OS_ABSTRACTION_FREERTOS_H__
12 
13 #if defined(__IAR_SYSTEMS_ICC__)
14 /**
15  * Workaround to disable MISRA C message suppress warnings for IAR compiler.
16  */
17 /* http://supp.iar.com/Support/?note=24725 */
18 
19 #define MISRAC_DISABLE \
20     _Pragma(           \
21         "diag_suppress=                       \
22     Pm001,Pm002,Pm003,Pm004,Pm005,Pm006,Pm007,Pm008,Pm009,Pm010,Pm011,\
23     Pm012,Pm013,Pm014,Pm015,Pm016,Pm017,Pm018,Pm019,Pm020,Pm021,Pm022,\
24     Pm023,Pm024,Pm025,Pm026,Pm027,Pm028,Pm029,Pm030,Pm031,Pm032,Pm033,\
25     Pm034,Pm035,Pm036,Pm037,Pm038,Pm039,Pm040,Pm041,Pm042,Pm043,Pm044,\
26     Pm045,Pm046,Pm047,Pm048,Pm049,Pm050,Pm051,Pm052,Pm053,Pm054,Pm055,\
27     Pm056,Pm057,Pm058,Pm059,Pm060,Pm061,Pm062,Pm063,Pm064,Pm065,Pm066,\
28     Pm067,Pm068,Pm069,Pm070,Pm071,Pm072,Pm073,Pm074,Pm075,Pm076,Pm077,\
29     Pm078,Pm079,Pm080,Pm081,Pm082,Pm083,Pm084,Pm085,Pm086,Pm087,Pm088,\
30     Pm089,Pm090,Pm091,Pm092,Pm093,Pm094,Pm095,Pm096,Pm097,Pm098,Pm099,\
31     Pm100,Pm101,Pm102,Pm103,Pm104,Pm105,Pm106,Pm107,Pm108,Pm109,Pm110,\
32     Pm111,Pm112,Pm113,Pm114,Pm115,Pm116,Pm117,Pm118,Pm119,Pm120,Pm121,\
33     Pm122,Pm123,Pm124,Pm125,Pm126,Pm127,Pm128,Pm129,Pm130,Pm131,Pm132,\
34     Pm133,Pm134,Pm135,Pm136,Pm137,Pm138,Pm139,Pm140,Pm141,Pm142,Pm143,\
35     Pm144,Pm145,Pm146,Pm147,Pm148,Pm149,Pm150,Pm151,Pm152,Pm153,Pm154,\
36     Pm155")
37 
38 #define MISRAC_ENABLE \
39     _Pragma(          \
40         "diag_default=                         \
41     Pm001,Pm002,Pm003,Pm004,Pm005,Pm006,Pm007,Pm008,Pm009,Pm010,Pm011,\
42     Pm012,Pm013,Pm014,Pm015,Pm016,Pm017,Pm018,Pm019,Pm020,Pm021,Pm022,\
43     Pm023,Pm024,Pm025,Pm026,Pm027,Pm028,Pm029,Pm030,Pm031,Pm032,Pm033,\
44     Pm034,Pm035,Pm036,Pm037,Pm038,Pm039,Pm040,Pm041,Pm042,Pm043,Pm044,\
45     Pm045,Pm046,Pm047,Pm048,Pm049,Pm050,Pm051,Pm052,Pm053,Pm054,Pm055,\
46     Pm056,Pm057,Pm058,Pm059,Pm060,Pm061,Pm062,Pm063,Pm064,Pm065,Pm066,\
47     Pm067,Pm068,Pm069,Pm070,Pm071,Pm072,Pm073,Pm074,Pm075,Pm076,Pm077,\
48     Pm078,Pm079,Pm080,Pm081,Pm082,Pm083,Pm084,Pm085,Pm086,Pm087,Pm088,\
49     Pm089,Pm090,Pm091,Pm092,Pm093,Pm094,Pm095,Pm096,Pm097,Pm098,Pm099,\
50     Pm100,Pm101,Pm102,Pm103,Pm104,Pm105,Pm106,Pm107,Pm108,Pm109,Pm110,\
51     Pm111,Pm112,Pm113,Pm114,Pm115,Pm116,Pm117,Pm118,Pm119,Pm120,Pm121,\
52     Pm122,Pm123,Pm124,Pm125,Pm126,Pm127,Pm128,Pm129,Pm130,Pm131,Pm132,\
53     Pm133,Pm134,Pm135,Pm136,Pm137,Pm138,Pm139,Pm140,Pm141,Pm142,Pm143,\
54     Pm144,Pm145,Pm146,Pm147,Pm148,Pm149,Pm150,Pm151,Pm152,Pm153,Pm154,\
55     Pm155")
56 #else
57 /* Empty MISRA C macros for other toolchains. */
58 #define MISRAC_DISABLE
59 #define MISRAC_ENABLE
60 #endif
61 
62 MISRAC_DISABLE
63 #include "FreeRTOS.h"
64 #include "semphr.h"
65 #include "event_groups.h"
66 MISRAC_ENABLE
67 
68 /*!
69  * @addtogroup os_abstraction_free_rtos
70  * @{
71  */
72 
73 /*******************************************************************************
74  * Declarations
75  ******************************************************************************/
76 /*! @brief Type for a task handler, returned by the OSA_TaskCreate function. */
77 typedef TaskHandle_t task_handler_t;
78 
79 /*! @brief Type for a task stack.*/
80 typedef portSTACK_TYPE task_stack_t;
81 
82 /*! @brief Type for task parameter */
83 typedef void *task_param_t;
84 
85 /*! @brief Type for an event flags object.*/
86 typedef EventBits_t event_flags_t;
87 
88 /*! @brief Constant to pass as timeout value in order to wait indefinitely. */
89 #define OSA_WAIT_FOREVER 0xFFFFFFFFU
90 
91 /*! @brief OSA's time range in millisecond, OSA time wraps if exceeds this value. */
92 #define FSL_OSA_TIME_RANGE 0xFFFFFFFFU
93 
94 /*! @brief The default interrupt handler installed in vector table. */
95 #define OSA_DEFAULT_INT_HANDLER ((osa_int_handler_t)(&DefaultISR))
96 
97 extern void DefaultISR(void);
98 
99 /*!
100  * @name Thread management
101  * @{
102  */
103 
104 /*!
105  * @brief To provide unified task piority for upper layer, OSA layer makes conversion.
106  */
107 #define PRIORITY_OSA_TO_RTOS(osa_prio) \
108     (((UBaseType_t)configMAX_PRIORITIES - 1U) * (OSA_TASK_PRIORITY_MIN - osa_prio) / OSA_TASK_PRIORITY_MIN)
109 #define PRIORITY_RTOS_TO_OSA(rtos_prio)                                               \
110     (OSA_TASK_PRIORITY_MIN * (((UBaseType_t)configMAX_PRIORITIES - 1U) - rtos_prio) / \
111      ((UBaseType_t)configMAX_PRIORITIES - 1U))
112 
113 /* @}*/
114 
115 /*!
116  * @name Message queues
117  * @{
118  */
119 
120 /*!
121  * @brief This macro statically reserves the memory required for the queue.
122  *
123  * @param name Identifier for the memory region.
124  * @param number Number of elements in the queue.
125  * @param size Size of every elements in words.
126  */
127 #define MSG_QUEUE_DECLARE(name, number, size) msg_queue_t *name = NULL
128 
129 /* @}*/
130 
131 /*! @}*/
132 /*! @}*/
133 /*! @}*/
134 
135 #endif /* __FSL_OS_ABSTRACTION_FREERTOS_H__ */
136