1
0
forked from fsfw/fsfw
Files
action
container
contrib
controller
coordinates
datalinklayer
datapool
devicehandlers
events
fdir
globalfunctions
health
internalError
ipc
memory
modes
monitoring
objectmanager
osal
FreeRTOS
BinSemaphUsingTask.cpp
BinSemaphUsingTask.h
BinarySemaphore.cpp
BinarySemaphore.h
Clock.cpp
CountingSemaphUsingTask.cpp
CountingSemaphUsingTask.h
CountingSemaphore.cpp
CountingSemaphore.h
FixedTimeslotTask.cpp
FixedTimeslotTask.h
FreeRTOSTaskIF.h
MessageQueue.cpp
MessageQueue.h
Mutex.cpp
Mutex.h
MutexFactory.cpp
PeriodicTask.cpp
PeriodicTask.h
QueueFactory.cpp
README.md
SemaphoreFactory.cpp
TaskFactory.cpp
TaskManagement.cpp
TaskManagement.h
Timekeeper.cpp
Timekeeper.h
host
linux
rtems
Endiness.h
InternalErrorCodes.h
parameters
power
pus
returnvalues
rmap
serialize
serviceinterface
storagemanager
subsystem
tasks
tcdistribution
thermal
timemanager
tmstorage
tmtcpacket
tmtcservices
.gitignore
LICENSE
NOTICE
fsfw.mk
fsfw/osal/FreeRTOS/Timekeeper.cpp
2020-08-13 20:53:35 +02:00

42 lines
859 B
C++

#include "Timekeeper.h"
#include "FreeRTOSConfig.h"
Timekeeper * Timekeeper::myinstance = nullptr;
Timekeeper::Timekeeper() : offset( { 0, 0 } ) {}
Timekeeper::~Timekeeper() {}
const timeval& Timekeeper::getOffset() const {
return offset;
}
Timekeeper* Timekeeper::instance() {
if (myinstance == nullptr) {
myinstance = new Timekeeper();
}
return myinstance;
}
void Timekeeper::setOffset(const timeval& offset) {
this->offset = offset;
}
timeval Timekeeper::ticksToTimeval(TickType_t ticks) {
timeval uptime;
uptime.tv_sec = ticks / configTICK_RATE_HZ;
//TODO explain, think about overflow
uint32_t subsecondTicks = ticks % configTICK_RATE_HZ;
uint64_t usecondTicks = subsecondTicks * 1000000;
uptime.tv_usec = usecondTicks / configTICK_RATE_HZ;
return uptime;
}
TickType_t Timekeeper::getTicks() {
return xTaskGetTickCount();
}