portmacro.h
1 /*
2  * Copyright (C) 2019 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  *
8  * FreeRTOS to RIOT-OS adaption module for source code compatibility
9  */
10 
11 #ifndef FREERTOS_PORTMACRO_H
12 #define FREERTOS_PORTMACRO_H
13 
14 #ifndef DOXYGEN
15 
16 #include "stdbool.h"
17 #include "stdint.h"
18 
19 #ifndef CPU_ESP8266
20 #include "esp_heap_caps.h"
21 #include "esp_timer.h"
22 #endif
23 
24 #include "mutex.h"
25 #include "irq.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define portBASE_TYPE int
32 #define portUBASE_TYPE unsigned portBASE_TYPE
33 #define portTICK_TYPE uint32_t
34 #define portSTACK_TYPE uint8_t
35 
36 #define portMAX_DELAY 0xFFFFFFFFUL
37 
38 #define portMUX_TYPE mutex_t
39 #define portMUX_INITIALIZE mutex_init
40 #define portMUX_INITIALIZER_UNLOCKED MUTEX_INIT
41 
42 #define portYIELD thread_yield_higher
43 #define portYIELD_FROM_ISR thread_yield_higher
44 
45 #define portENTER_CRITICAL vTaskEnterCritical
46 #define portEXIT_CRITICAL vTaskExitCritical
47 #define portENTER_CRITICAL_SAFE vTaskEnterCritical
48 #define portEXIT_CRITICAL_SAFE vTaskExitCritical
49 #define portENTER_CRITICAL_ISR vTaskEnterCritical
50 #define portEXIT_CRITICAL_ISR vTaskExitCritical
51 #define portENTER_CRITICAL_NESTED irq_disable
52 #define portEXIT_CRITICAL_NESTED irq_restore
53 
54 #define portSET_INTERRUPT_MASK_FROM_ISR xPortSetInterruptMaskFromISR
55 #define portCLEAR_INTERRUPT_MASK_FROM_ISR vPortClearInterruptMaskFromISR
56 
57 #define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
58 
59 #if defined(CPU_FAM_ESP32) || defined(CPU_FAM_ESP32S3)
60 
61 #define portNUM_PROCESSORS 2
62 #define xPortGetCoreID() PRO_CPU_NUM
63 #define vPortYield portYIELD
64 
65 #else /* defined(CPU_FAM_ESP32) || defined(CPU_FAM_ESP32S3) */
66 
67 #define portNUM_PROCESSORS 1
68 #define xPortGetCoreID() PRO_CPU_NUM
69 #define vPortYield portYIELD
70 
71 #endif /* defined(CPU_FAM_ESP32) || defined(CPU_FAM_ESP32S3) */
72 
73 extern void vTaskEnterCritical(portMUX_TYPE *mux);
74 extern void vTaskExitCritical(portMUX_TYPE *mux);
75 
76 bool xPortCanYield(void);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* DOXYGEN */
83 #endif /* FREERTOS_PORTMACRO_H */
IRQ driver interface.
Mutex for thread synchronization.