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