consoleByteArrived uses std::atomic

This commit is contained in:
Matthew Kennedy 2024-06-27 11:51:33 -07:00
parent b89afc170a
commit 94a5c52186
5 changed files with 11 additions and 12 deletions

View File

@ -496,9 +496,7 @@ void TunerstudioThread::ThreadTask() {
// Until the end of time, process incoming messages.
while (true) {
if (tsProcessOne(channel) == 0) {
onDataArrived(true);
} else {
onDataArrived(false);
onDataArrived();
}
}
}

View File

@ -44,12 +44,6 @@
#include "rusEfiFunctionalTest.h"
#endif /*EFI_SIMULATOR */
bool consoleByteArrived = false;
void onDataArrived(bool valid) {
consoleByteArrived = valid;
}
CommandHandler console_line_callback;
void startConsole(CommandHandler console_line_callback_p) {

View File

@ -21,4 +21,4 @@ typedef void (*CommandHandler)(char *);
void consoleOutputBuffer(const uint8_t *buf, int size);
void startConsole(CommandHandler console_line_callback_p);
void onDataArrived(bool valid);
void onDataArrived();

View File

@ -257,7 +257,11 @@ static bool isTriggerErrorNow() {
#endif /* EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT */
}
extern bool consoleByteArrived;
static std::atomic<bool> consoleByteArrived = false;
void onDataArrived() {
consoleByteArrived.store(true);
}
class CommunicationBlinkingTask : public PeriodicTimerController {
@ -299,7 +303,8 @@ class CommunicationBlinkingTask : public PeriodicTimerController {
// differentiates software firmware error from critical interrupt error with CPU halt.
offTimeMs = 50;
onTimeMs = 450;
} else if (consoleByteArrived) {
} else if (consoleByteArrived.exchange(false)) {
consoleByteArrived = false;
offTimeMs = 100;
onTimeMs = 33;
#if EFI_INTERNAL_FLASH

View File

@ -47,3 +47,5 @@
#else
#include "chprintf.h"
#endif
#include <atomic>