|
28 | 28 |
|
29 | 29 |
|
30 | 30 | #ifndef PORTMACRO_H
|
31 |
| - #define PORTMACRO_H |
| 31 | +#define PORTMACRO_H |
32 | 32 |
|
33 |
| - #ifdef __cplusplus |
34 |
| - extern "C" { |
35 |
| - #endif |
| 33 | +/* *INDENT-OFF* */ |
| 34 | +#ifdef __cplusplus |
| 35 | + extern "C" { |
| 36 | +#endif |
| 37 | +/* *INDENT-ON* */ |
36 | 38 |
|
37 | 39 | /*-----------------------------------------------------------
|
38 | 40 | * Port specific definitions.
|
|
45 | 47 | */
|
46 | 48 |
|
47 | 49 | /* Type definitions. */
|
48 |
| - #define portCHAR char |
49 |
| - #define portFLOAT float |
50 |
| - #define portDOUBLE double |
51 |
| - #define portLONG long |
52 |
| - #define portSHORT short |
53 |
| - #define portSTACK_TYPE uint32_t |
54 |
| - #define portBASE_TYPE long |
55 |
| - |
56 |
| - typedef portSTACK_TYPE StackType_t; |
57 |
| - typedef long BaseType_t; |
58 |
| - typedef unsigned long UBaseType_t; |
59 |
| - |
60 |
| - #if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) |
61 |
| - typedef uint16_t TickType_t; |
62 |
| - #define portMAX_DELAY ( TickType_t ) 0xffff |
63 |
| - #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) |
64 |
| - typedef uint32_t TickType_t; |
65 |
| - #define portMAX_DELAY ( TickType_t ) 0xffffffffUL |
| 50 | +#define portCHAR char |
| 51 | +#define portFLOAT float |
| 52 | +#define portDOUBLE double |
| 53 | +#define portLONG long |
| 54 | +#define portSHORT short |
| 55 | +#define portSTACK_TYPE uint32_t |
| 56 | +#define portBASE_TYPE long |
| 57 | + |
| 58 | +typedef portSTACK_TYPE StackType_t; |
| 59 | +typedef long BaseType_t; |
| 60 | +typedef unsigned long UBaseType_t; |
| 61 | + |
| 62 | +#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) |
| 63 | + typedef uint16_t TickType_t; |
| 64 | + #define portMAX_DELAY ( TickType_t ) 0xffff |
| 65 | +#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) |
| 66 | + typedef uint32_t TickType_t; |
| 67 | + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL |
66 | 68 |
|
67 | 69 | /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
|
68 | 70 | * not need to be guarded with a critical section. */
|
69 |
| - #define portTICK_TYPE_IS_ATOMIC 1 |
70 |
| - #else |
71 |
| - #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. |
72 |
| - #endif |
| 71 | + #define portTICK_TYPE_IS_ATOMIC 1 |
| 72 | +#else |
| 73 | + #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. |
| 74 | +#endif |
73 | 75 | /*-----------------------------------------------------------*/
|
74 | 76 |
|
75 | 77 | /* Architecture specifics. */
|
76 |
| - #define portSTACK_GROWTH ( -1 ) |
77 |
| - #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) |
78 |
| - #define portBYTE_ALIGNMENT 8 |
79 |
| - #define portDONT_DISCARD __attribute__( ( used ) ) |
80 |
| - #define portNORETURN __attribute__( ( noreturn ) ) |
| 78 | +#define portSTACK_GROWTH ( -1 ) |
| 79 | +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) |
| 80 | +#define portBYTE_ALIGNMENT 8 |
| 81 | +#define portDONT_DISCARD __attribute__( ( used ) ) |
| 82 | +#define portNORETURN __attribute__( ( noreturn ) ) |
81 | 83 | /*-----------------------------------------------------------*/
|
82 | 84 |
|
83 | 85 |
|
84 | 86 | /* Scheduler utilities. */
|
85 |
| - extern void vPortYield( void ); |
86 |
| - #define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) ) |
87 |
| - #define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) |
88 |
| - #define portYIELD() vPortYield() |
89 |
| - #define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } while( 0 ) |
90 |
| - #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) |
| 87 | +extern void vPortYield( void ); |
| 88 | +#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) ) |
| 89 | +#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL ) |
| 90 | +#define portYIELD() vPortYield() |
| 91 | +#define portEND_SWITCHING_ISR( xSwitchRequired ) \ |
| 92 | + do { if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } \ |
| 93 | + while( 0 ) |
| 94 | +#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) |
91 | 95 | /*-----------------------------------------------------------*/
|
92 | 96 |
|
93 | 97 |
|
94 | 98 | /* Critical section management. */
|
95 |
| - extern void vPortEnterCritical( void ); |
96 |
| - extern void vPortExitCritical( void ); |
97 |
| - extern uint32_t ulSetInterruptMaskFromISR( void ) __attribute__( ( naked ) ); |
98 |
| - extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( naked ) ); |
99 |
| - |
100 |
| - #define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() |
101 |
| - #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vClearInterruptMaskFromISR( x ) |
102 |
| - #define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) |
103 |
| - #define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) |
104 |
| - #define portENTER_CRITICAL() vPortEnterCritical() |
105 |
| - #define portEXIT_CRITICAL() vPortExitCritical() |
| 99 | +extern void vPortEnterCritical( void ); |
| 100 | +extern void vPortExitCritical( void ); |
| 101 | +extern uint32_t ulSetInterruptMaskFromISR( void ) __attribute__( ( naked ) ); |
| 102 | +extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( naked ) ); |
| 103 | + |
| 104 | +#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR() |
| 105 | +#define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vClearInterruptMaskFromISR( x ) |
| 106 | +#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) |
| 107 | +#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) |
| 108 | +#define portENTER_CRITICAL() vPortEnterCritical() |
| 109 | +#define portEXIT_CRITICAL() vPortExitCritical() |
106 | 110 |
|
107 | 111 | /*-----------------------------------------------------------*/
|
108 | 112 |
|
109 | 113 | /* Tickless idle/low power functionality. */
|
110 |
| - #ifndef portSUPPRESS_TICKS_AND_SLEEP |
111 |
| - extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); |
112 |
| - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime ) |
113 |
| - #endif |
| 114 | +#ifndef portSUPPRESS_TICKS_AND_SLEEP |
| 115 | + extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); |
| 116 | + #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime ) |
| 117 | +#endif |
114 | 118 | /*-----------------------------------------------------------*/
|
115 | 119 |
|
116 | 120 | /* Task function macros as described on the FreeRTOS.org WEB site. */
|
117 |
| - #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) |
118 |
| - #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) |
| 121 | +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) |
| 122 | +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) |
119 | 123 |
|
120 |
| - #define portNOP() |
| 124 | +#define portNOP() |
121 | 125 |
|
122 |
| - #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" ) |
| 126 | +#define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" ) |
123 | 127 |
|
124 |
| - #ifdef __cplusplus |
125 |
| - } |
126 |
| - #endif |
| 128 | + |
| 129 | +#define portINLINE __inline |
| 130 | + |
| 131 | +#ifndef portFORCE_INLINE |
| 132 | + #define portFORCE_INLINE inline __attribute__( ( always_inline ) ) |
| 133 | +#endif |
| 134 | + |
| 135 | +/*-----------------------------------------------------------*/ |
| 136 | + |
| 137 | +portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void ) |
| 138 | +{ |
| 139 | + uint32_t ulCurrentInterrupt; |
| 140 | + BaseType_t xReturn; |
| 141 | + |
| 142 | + /* Obtain the number of the currently executing interrupt. */ |
| 143 | + __asm volatile ( "mrs %0, ipsr" : "=r" ( ulCurrentInterrupt )::"memory" ); |
| 144 | + |
| 145 | + if( ulCurrentInterrupt == 0 ) |
| 146 | + { |
| 147 | + xReturn = pdFALSE; |
| 148 | + } |
| 149 | + else |
| 150 | + { |
| 151 | + xReturn = pdTRUE; |
| 152 | + } |
| 153 | + |
| 154 | + return xReturn; |
| 155 | +} |
| 156 | + |
| 157 | +/*-----------------------------------------------------------*/ |
| 158 | + |
| 159 | + |
| 160 | +/* *INDENT-OFF* */ |
| 161 | +#ifdef __cplusplus |
| 162 | + } |
| 163 | +#endif |
| 164 | +/* *INDENT-ON* */ |
127 | 165 |
|
128 | 166 | #endif /* PORTMACRO_H */
|
0 commit comments