]> begriffs open source - freertos/blob - portable/GCC/RX600v2/portmacro.h
RP2040: Fix compiler warning and comment (#509)
[freertos] / portable / GCC / RX600v2 / portmacro.h
1 /*
2  * FreeRTOS SMP Kernel V202110.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  * 1 tab == 4 spaces!
26  */
27
28
29 #ifndef PORTMACRO_H
30 #define PORTMACRO_H
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*-----------------------------------------------------------
37  * Port specific definitions.
38  *
39  * The settings in this file configure FreeRTOS correctly for the
40  * given hardware and compiler.
41  *
42  * These settings should not be altered.
43  *-----------------------------------------------------------
44  */
45
46 /* When the FIT configurator or the Smart Configurator is used, platform.h has to be
47  * used. */
48 #ifndef configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H
49     #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H 0
50 #endif
51
52 /* Type definitions - these are a bit legacy and not really used now, other than
53 portSTACK_TYPE and portBASE_TYPE. */
54 #define portCHAR                char
55 #define portFLOAT               float
56 #define portDOUBLE              double
57 #define portLONG                long
58 #define portSHORT               short
59 #define portSTACK_TYPE  uint32_t
60 #define portBASE_TYPE   long
61
62 typedef portSTACK_TYPE StackType_t;
63 typedef long BaseType_t;
64 typedef unsigned long UBaseType_t;
65
66 #if( configUSE_16_BIT_TICKS == 1 )
67         typedef uint16_t TickType_t;
68         #define portMAX_DELAY ( TickType_t ) 0xffff
69 #else
70         typedef uint32_t TickType_t;
71         #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
72
73         /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
74         not need to be guarded with a critical section. */
75         #define portTICK_TYPE_IS_ATOMIC 1
76 #endif
77 /*-----------------------------------------------------------*/
78
79 /* Hardware specifics. */
80 #define portBYTE_ALIGNMENT                      8       /* Could make four, according to manual. */
81 #define portSTACK_GROWTH                        -1
82 #define portTICK_PERIOD_MS                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
83 #define portNOP()                                       __asm volatile( "NOP" )
84
85 /* Yield equivalent to "*portITU_SWINTR = 0x01; ( void ) *portITU_SWINTR;"
86 where portITU_SWINTR is the location of the software interrupt register
87 (0x000872E0).  Don't rely on the assembler to select a register, so instead
88 save and restore clobbered registers manually. */
89 #define portYIELD()                                                     \
90         __asm volatile                                                  \
91         (                                                                               \
92                 "PUSH.L R10                                     \n"             \
93                 "MOV.L  #0x872E0, R10           \n"             \
94                 "MOV.B  #0x1, [R10]                     \n"             \
95                 "MOV.L  [R10], R10                      \n"             \
96                 "POP    R10                                     \n"             \
97         )
98
99 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) portYIELD()
100
101 /* These macros should not be called directly, but through the
102 taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros.  An extra check is
103 performed if configASSERT() is defined to ensure an assertion handler does not
104 inadvertently attempt to lower the IPL when the call to assert was triggered
105 because the IPL value was found to be above     configMAX_SYSCALL_INTERRUPT_PRIORITY
106 when an ISR safe FreeRTOS API function was executed.  ISR safe FreeRTOS API
107 functions are those that end in FromISR.  FreeRTOS maintains a separate
108 interrupt API to ensure API function and interrupt entry is as fast and as
109 simple as possible. */
110 #define portENABLE_INTERRUPTS()         __asm volatile ( "MVTIPL        #0" )
111 #ifdef configASSERT
112         #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( ulPortGetIPL() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) )
113         #define portDISABLE_INTERRUPTS()        if( ulPortGetIPL() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __asm volatile ( "MVTIPL    %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) )
114 #else
115         #define portDISABLE_INTERRUPTS()        __asm volatile ( "MVTIPL        %0" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY) )
116 #endif
117
118 /* Critical nesting counts are stored in the TCB. */
119 #define portCRITICAL_NESTING_IN_TCB ( 1 )
120
121 /* The critical nesting functions defined within tasks.c. */
122 extern void vTaskEnterCritical( void );
123 extern void vTaskExitCritical( void );
124 #define portENTER_CRITICAL()    vTaskEnterCritical()
125 #define portEXIT_CRITICAL()             vTaskExitCritical()
126
127 /* As this port allows interrupt nesting... */
128 uint32_t ulPortGetIPL( void ) __attribute__((naked));
129 void vPortSetIPL( uint32_t ulNewIPL ) __attribute__((naked));
130 #define portSET_INTERRUPT_MASK_FROM_ISR() ulPortGetIPL(); portDISABLE_INTERRUPTS()
131 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) vPortSetIPL( uxSavedInterruptStatus )
132
133 /*-----------------------------------------------------------*/
134
135 /* Task function macros as described on the FreeRTOS.org WEB site. */
136 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
137 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif /* PORTMACRO_H */
144