PowerBlocks SDK
 
Loading...
Searching...
No Matches
portmacro.h
Go to the documentation of this file.
1
10
11#ifndef PORTMACRO_H
12#define PORTMACRO_H
13
14/*-----------------------------------------------------------
15 * Port specific definitions.
16 *
17 * The settings in this file configure FreeRTOS correctly for the
18 * given hardware and compiler.
19 *
20 * These settings should not be altered.
21 *-----------------------------------------------------------
22 */
23
24#include <stdio.h>
25#include <stddef.h>
26#include <stdbool.h>
27
29
30extern uint32_t freertos_isr_enabled;
31
32/* Type definitions. */
33#define portCHAR char
34#define portFLOAT float
35#define portDOUBLE double
36#define portLONG long
37#define portSHORT short
38#define portSTACK_TYPE uint32_t
39#define portBASE_TYPE uint32_t
40
41#define portSTACK_GROWTH ( -1 )
42#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
43#define portBYTE_ALIGNMENT 4
44#define portPOINTER_SIZE_TYPE size_t
45typedef portSTACK_TYPE StackType_t;
46typedef int32_t BaseType_t;
47typedef uint32_t UBaseType_t;
48
49#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
50 typedef uint16_t TickType_t;
51 #define portMAX_DELAY ( TickType_t ) 0xffffU
52#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
53 typedef uint32_t TickType_t;
54 #define portMAX_DELAY ( TickType_t ) 0xffffffffU
55#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
56 typedef uint64_t TickType_t;
57 #define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffU
58#else
59 #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
60#endif
61
62/* Architecture specific optimisations. */
63#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
64 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
65#endif
66
67#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
68
69/* Check the configuration. */
70 #if ( configMAX_PRIORITIES > 32 )
71 #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
72 #endif
73
74/* Store/clear the ready priorities in a bit map. */
75 #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
76 #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
77
78/*-----------------------------------------------------------*/
79
80 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
81 do { \
82 uxTopPriority = 0; \
83 } while( 0 )
84
85#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
86
87/* Disable the interrupts */
88#define portDISABLE_INTERRUPTS() do {int ee; SYSTEM_DISABLE_ISR(freertos_isr_enabled);} while( 0 )
89
90/* Enable the interrupts */
91#define portENABLE_INTERRUPTS() do {SYSTEM_ENABLE_ISR(freertos_isr_enabled);} while( 0 )
92
93#if ( configNUMBER_OF_CORES == 1 )
94/* preserve current interrupt state and then disable interrupts */
95 #define portENTER_CRITICAL() portDISABLE_INTERRUPTS()
96
97/* restore previously preserved interrupt state */
98 #define portEXIT_CRITICAL() portENABLE_INTERRUPTS()
99#else
100
101/* The port can maintain the critical nesting count in TCB or maintain the critical
102 * nesting count in the port. */
103 #define portCRITICAL_NESTING_IN_TCB 1
104
105/* vTaskEnterCritical and vTaskExitCritical should be used in the implementation
106 * of portENTER/EXIT_CRITICAL if the number of cores is more than 1 in the system. */
107 #define portENTER_CRITICAL vTaskEnterCritical
108 #define portEXIT_CRITICAL vTaskExitCritical
109
110/* vTaskEnterCriticalFromISR and vTaskExitCriticalFromISR should be used in the
111 * implementation of portENTER/EXIT_CRITICAL_FROM_ISR if the number of cores is
112 * more than 1 in the system. */
113 #define portENTER_CRITICAL_FROM_ISR vTaskEnterCriticalFromISR
114 #define portEXIT_CRITICAL_FROM_ISR vTaskExitCriticalFromISR
115
116#endif /* if ( configNUMBER_OF_CORES == 1 ) */
117
118extern void vPortYield( void );
119#define portYIELD() vPortYield()
120
121/* Task function macros as described on the FreeRTOS.org WEB site. */
122#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) )
123#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
124
125#if ( configNUMBER_OF_CORES > 1 )
126 /* Return the core ID on which the code is running. */
127 #define portGET_CORE_ID() 0
128
129/* Set the interrupt mask. */
130 #define portSET_INTERRUPT_MASK() 0
131
132/* Clear the interrupt mask. */
133 #define portCLEAR_INTERRUPT_MASK( x ) ( ( void ) ( x ) )
134
135/* Request the core ID x to yield. */
136 #define portYIELD_CORE( x ) do {} while( 0 )
137
138/* Acquire the TASK lock. TASK lock is a recursive lock.
139 * It should be able to be locked by the same core multiple times. */
140 #define portGET_TASK_LOCK( xCoreID ) do {} while( 0 )
141
142/* Release the TASK lock. If a TASK lock is locked by the same core multiple times,
143 * it should be released as many times as it is locked. */
144 #define portRELEASE_TASK_LOCK( xCoreID ) do {} while( 0 )
145
146/* Acquire the ISR lock. ISR lock is a recursive lock.
147 * It should be able to be locked by the same core multiple times. */
148 #define portGET_ISR_LOCK( xCoreID ) do {} while( 0 )
149
150/* Release the ISR lock. If a ISR lock is locked by the same core multiple times, \
151 * it should be released as many times as it is locked. */
152 #define portRELEASE_ISR_LOCK( xCoreID ) do {} while( 0 )
153
154#endif /* if ( configNUMBER_OF_CORES > 1 ) */
155
156#endif /* PORTMACRO_H */
Access parts of the base system.