2023-01-27 18:38:36 +01:00
|
|
|
#include "comCfg.h"
|
|
|
|
|
|
|
|
#include <fsfw/ipc/MutexFactory.h>
|
|
|
|
#include <fsfw/ipc/MutexGuard.h>
|
|
|
|
|
2023-03-31 01:14:59 +02:00
|
|
|
#include <atomic>
|
|
|
|
|
2023-01-27 18:38:36 +01:00
|
|
|
com::Datarate DATARATE_CFG_RAW = com::Datarate::LOW_RATE_MODULATION_BPSK;
|
|
|
|
MutexIF* DATARATE_LOCK = nullptr;
|
|
|
|
|
|
|
|
MutexIF* lazyLock();
|
|
|
|
|
|
|
|
com::Datarate com::getCurrentDatarate() {
|
2023-03-02 15:32:12 +01:00
|
|
|
MutexGuard mg(lazyLock(), MutexIF::TimeoutType::WAITING, 20, "com");
|
2023-01-27 18:38:36 +01:00
|
|
|
return DATARATE_CFG_RAW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void com::setCurrentDatarate(com::Datarate newRate) {
|
2023-03-02 15:32:12 +01:00
|
|
|
MutexGuard mg(lazyLock(), MutexIF::TimeoutType::WAITING, 20, "com");
|
2023-01-27 18:38:36 +01:00
|
|
|
DATARATE_CFG_RAW = newRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
MutexIF* lazyLock() {
|
|
|
|
if (DATARATE_LOCK == nullptr) {
|
|
|
|
return MutexFactory::instance()->createMutex();
|
|
|
|
}
|
|
|
|
return DATARATE_LOCK;
|
|
|
|
}
|