]> begriffs open source - freertos/blob - portable/ThirdParty/GCC/RP2040/include/portmacro.h
[AUTO][RELEASE]: Bump file header version to "10.5.1"
[freertos] / portable / ThirdParty / GCC / RP2040 / include / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.5.1\r
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.\r
5  *\r
6  * SPDX-License-Identifier: MIT AND BSD-3-Clause\r
7  *\r
8  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
9  * this software and associated documentation files (the "Software"), to deal in\r
10  * the Software without restriction, including without limitation the rights to\r
11  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
12  * the Software, and to permit persons to whom the Software is furnished to do so,\r
13  * subject to the following conditions:\r
14  *\r
15  * The above copyright notice and this permission notice shall be included in all\r
16  * copies or substantial portions of the Software.\r
17  *\r
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
20  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
21  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
22  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
24  *\r
25  * https://www.FreeRTOS.org\r
26  * https://github.com/FreeRTOS\r
27  *\r
28  */\r
29 \r
30 #ifndef PORTMACRO_H\r
31     #define PORTMACRO_H\r
32 \r
33     #ifdef __cplusplus\r
34         extern "C" {\r
35     #endif\r
36 \r
37     #include "pico.h"\r
38 /*-----------------------------------------------------------\r
39  * Port specific definitions.\r
40  *\r
41  * The settings in this file configure FreeRTOS correctly for the\r
42  * given hardware and compiler.\r
43  *\r
44  * These settings should not be altered.\r
45  *-----------------------------------------------------------\r
46  */\r
47 \r
48 /* Type definitions. */\r
49     #define portCHAR          char\r
50     #define portFLOAT         float\r
51     #define portDOUBLE        double\r
52     #define portLONG          long\r
53     #define portSHORT         short\r
54     #define portSTACK_TYPE    uint32_t\r
55     #define portBASE_TYPE     long\r
56 \r
57     typedef portSTACK_TYPE    StackType_t;\r
58     typedef int32_t           BaseType_t;\r
59     typedef uint32_t          UBaseType_t;\r
60 \r
61     #if ( configUSE_16_BIT_TICKS == 1 )\r
62         typedef uint16_t     TickType_t;\r
63         #define portMAX_DELAY              ( TickType_t ) 0xffff\r
64     #else\r
65         typedef uint32_t     TickType_t;\r
66         #define portMAX_DELAY              ( TickType_t ) 0xffffffffUL\r
67 \r
68 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
69  * not need to be guarded with a critical section. */\r
70         #define portTICK_TYPE_IS_ATOMIC    1\r
71     #endif\r
72 /*-----------------------------------------------------------*/\r
73 \r
74 /* Architecture specifics. */\r
75     #define portSTACK_GROWTH      ( -1 )\r
76     #define portTICK_PERIOD_MS    ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
77     #define portBYTE_ALIGNMENT    8\r
78     #define portDONT_DISCARD      __attribute__( ( used ) )\r
79     /* We have to use PICO_DIVIDER_DISABLE_INTERRUPTS as the source of truth rathern than our config,\r
80      * as our FreeRTOSConfig.h header cannot be included by ASM code - which is what this affects in the SDK */\r
81     #define portUSE_DIVIDER_SAVE_RESTORE !PICO_DIVIDER_DISABLE_INTERRUPTS\r
82     #if portUSE_DIVIDER_SAVE_RESTORE\r
83     #define portSTACK_LIMIT_PADDING 4\r
84     #endif\r
85 \r
86 /*-----------------------------------------------------------*/\r
87 \r
88 \r
89 /* Scheduler utilities. */\r
90     extern void vPortYield( void );\r
91     #define portNVIC_INT_CTRL_REG     ( *( ( volatile uint32_t * ) 0xe000ed04 ) )\r
92     #define portNVIC_PENDSVSET_BIT    ( 1UL << 28UL )\r
93     #define portYIELD()                                 vPortYield()\r
94     #define portEND_SWITCHING_ISR( xSwitchRequired )    if( xSwitchRequired ) portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT\r
95     #define portYIELD_FROM_ISR( x )                     portEND_SWITCHING_ISR( x )\r
96 \r
97 /*-----------------------------------------------------------*/\r
98 \r
99 /* Exception handlers */\r
100     #if (configUSE_DYNAMIC_EXCEPTION_HANDLERS == 0)\r
101         /* We only need to override the SDK's weak functions if we want to replace them at compile time */\r
102         #define vPortSVCHandler isr_svcall\r
103         #define xPortPendSVHandler isr_pendsv\r
104         #define xPortSysTickHandler isr_systick\r
105     #endif\r
106 \r
107     #define portCHECK_IF_IN_ISR() ({ \\r
108         uint32_t ulIPSR;                                                  \\r
109        __asm volatile ("mrs %0, IPSR" : "=r" (ulIPSR)::);             \\r
110        ((uint8_t)ulIPSR)>0;})\r
111 \r
112 /*-----------------------------------------------------------*/\r
113 \r
114 /* Critical section management. */\r
115     extern uint32_t ulSetInterruptMaskFromISR( void ) __attribute__( ( naked ) );\r
116     extern void vClearInterruptMaskFromISR( uint32_t ulMask )  __attribute__( ( naked ) );\r
117     #define portSET_INTERRUPT_MASK_FROM_ISR()         ulSetInterruptMaskFromISR()\r
118     #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x )    vClearInterruptMaskFromISR( x )\r
119 \r
120     #define portDISABLE_INTERRUPTS()                  __asm volatile ( " cpsid i " ::: "memory" )\r
121 \r
122     extern void vPortEnableInterrupts();\r
123     #define portENABLE_INTERRUPTS()                   vPortEnableInterrupts()\r
124 \r
125     extern void vPortEnterCritical( void );\r
126     extern void vPortExitCritical( void );\r
127     #define portENTER_CRITICAL()                      vPortEnterCritical()\r
128     #define portEXIT_CRITICAL()                       vPortExitCritical()\r
129 \r
130 /*-----------------------------------------------------------*/\r
131 \r
132 /* Tickless idle/low power functionality. */\r
133     #ifndef portSUPPRESS_TICKS_AND_SLEEP\r
134         extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );\r
135         #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )    vPortSuppressTicksAndSleep( xExpectedIdleTime )\r
136     #endif\r
137 /*-----------------------------------------------------------*/\r
138 \r
139 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
140     #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )\r
141     #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )\r
142 \r
143     #define portNOP()\r
144 \r
145     #define portMEMORY_BARRIER()    __asm volatile ( "" ::: "memory" )\r
146 \r
147     #ifdef __cplusplus\r
148         }\r
149     #endif\r
150 \r
151 #endif /* PORTMACRO_H */\r