Loading...
Searching...
No Matches
portmacro.h
1/*
2 * SPDX-FileCopyrightText: 2019 Gunar Schorcht
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6/*
7 * FreeRTOS to RIOT-OS adaption module for source code compatibility
8 */
9
10#pragma once
11
12#ifndef DOXYGEN
13
14#include "stdbool.h"
15#include "stdint.h"
16
17#ifndef CPU_ESP8266
18#include "esp_heap_caps.h"
19#include "esp_timer.h"
20#include "soc/soc.h"
21#endif
22
23#include "mutex.h"
24#include "irq.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define portBASE_TYPE int
31#define portUBASE_TYPE unsigned portBASE_TYPE
32#define portTICK_TYPE uint32_t
33#define portSTACK_TYPE uint8_t
34
35#define portMAX_DELAY 0xFFFFFFFFUL
36
37#define portMUX_TYPE mutex_t
38#define portMUX_INITIALIZE mutex_init
39#define portMUX_INITIALIZER_UNLOCKED MUTEX_INIT
40
41#define portYIELD thread_yield_higher
42#define portYIELD_FROM_ISR thread_yield_higher
43
44#define portENTER_CRITICAL vTaskEnterCritical
45#define portEXIT_CRITICAL vTaskExitCritical
46#define portENTER_CRITICAL_SAFE vTaskEnterCritical
47#define portEXIT_CRITICAL_SAFE vTaskExitCritical
48#define portENTER_CRITICAL_ISR vTaskEnterCritical
49#define portEXIT_CRITICAL_ISR vTaskExitCritical
50#define portENTER_CRITICAL_NESTED irq_disable
51#define portEXIT_CRITICAL_NESTED irq_restore
52
53#define portSET_INTERRUPT_MASK_FROM_ISR xPortSetInterruptMaskFromISR
54#define portCLEAR_INTERRUPT_MASK_FROM_ISR vPortClearInterruptMaskFromISR
55
56#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
57
58/*
59 * NOTE: RIOT generally uses only one CPU, and the second CPU, if there is one,
60 * is stalled by default. Defining portNUM_PROCESSORS here as 2 can cause
61 * problems. For example, the SYSTIMER counting units are stopped when the
62 * second CPU is disabled, which in turn leads to a memory leak because
63 * SYSTIMER is used for the esp_timer implementation to delete timers in
64 * thread context. Therefore, we define portNUM_PROCESSORS always as 1 even for
65 * ESP32x SOCs with 2 CPUs.
66 */
67#if 0 /* SOC_CPU_CORES_NUM */
68# define portNUM_PROCESSORS SOC_CPU_CORES_NUM
69#else
70# define portNUM_PROCESSORS 1
71#endif
72
73#define xPortGetCoreID() PRO_CPU_NUM
74#define vPortYield portYIELD
75
76extern void vTaskEnterCritical(portMUX_TYPE *mux);
77extern void vTaskExitCritical(portMUX_TYPE *mux);
78
79bool xPortCanYield(void);
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif /* DOXYGEN */
IRQ driver interface.
Mutex for thread synchronization.