C++ conversions (#111)
* Remove version from artifact name * Target C++ 20 and higher * Use cpp string * Better crash implementation * String utils in cpp style * Replace parameter methods with start() method * MutexType to Mutex::Type * Kernel c to cpp style * Cleanup event flag * More cpp conversions * Test fixes * Updated ideas docs
This commit is contained in:
committed by
GitHub
parent
d52fe52d96
commit
42e843b463
@@ -0,0 +1,42 @@
|
||||
#include "Critical.h"
|
||||
#include "CoreDefines.h"
|
||||
#include "RtosCompatTask.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
static portMUX_TYPE critical_mutex;
|
||||
#define TT_ENTER_CRITICAL() taskENTER_CRITICAL(&critical_mutex)
|
||||
#else
|
||||
#define TT_ENTER_CRITICAL() taskENTER_CRITICAL()
|
||||
#endif
|
||||
|
||||
namespace tt::kernel::critical {
|
||||
|
||||
TtCriticalInfo enter() {
|
||||
TtCriticalInfo info = {
|
||||
.isrm = 0,
|
||||
.fromIsr = TT_IS_ISR(),
|
||||
.kernelRunning = (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING)
|
||||
};
|
||||
|
||||
if (info.fromIsr) {
|
||||
info.isrm = taskENTER_CRITICAL_FROM_ISR();
|
||||
} else if (info.kernelRunning) {
|
||||
TT_ENTER_CRITICAL();
|
||||
} else {
|
||||
portDISABLE_INTERRUPTS();
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void exit(TtCriticalInfo info) {
|
||||
if (info.fromIsr) {
|
||||
taskEXIT_CRITICAL_FROM_ISR(info.isrm);
|
||||
} else if (info.kernelRunning) {
|
||||
TT_ENTER_CRITICAL();
|
||||
} else {
|
||||
portENABLE_INTERRUPTS();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifndef TT_CRITICAL_ENTER
|
||||
#define TT_CRITICAL_ENTER() __TtCriticalInfo __tt_critical_info = __tt_critical_enter();
|
||||
#endif
|
||||
|
||||
#ifndef TT_CRITICAL_EXIT
|
||||
#define TT_CRITICAL_EXIT() __tt_critical_exit(__tt_critical_info);
|
||||
#endif
|
||||
|
||||
namespace tt::kernel::critical {
|
||||
|
||||
typedef struct {
|
||||
uint32_t isrm;
|
||||
bool fromIsr;
|
||||
bool kernelRunning;
|
||||
} TtCriticalInfo;
|
||||
|
||||
TtCriticalInfo enter();
|
||||
|
||||
void exit(TtCriticalInfo info);
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user