fsfw/src/fsfw/osal/freertos/Timekeeper.h

40 lines
876 B
C
Raw Normal View History

2018-07-13 15:56:37 +02:00
#ifndef FRAMEWORK_OSAL_FREERTOS_TIMEKEEPER_H_
#define FRAMEWORK_OSAL_FREERTOS_TIMEKEEPER_H_
2020-08-13 20:53:35 +02:00
#include "../../timemanager/Clock.h"
#include "FreeRTOS.h"
#include "task.h"
2020-04-08 19:33:01 +02:00
2018-07-13 15:56:37 +02:00
/**
* A Class to basically store the time difference between uptime and UTC
* so the "time-agnostic" FreeRTOS can keep an UTC Time
*
* Implemented as Singleton, so the FSFW Clock Implementation (see Clock.cpp)
* can use it without having a member.
*/
class Timekeeper {
2022-02-02 10:29:30 +01:00
private:
Timekeeper();
timeval offset;
2018-07-13 15:56:37 +02:00
2022-02-02 10:29:30 +01:00
static Timekeeper* myinstance;
2018-07-13 15:56:37 +02:00
2022-02-02 10:29:30 +01:00
public:
static Timekeeper* instance();
virtual ~Timekeeper();
2018-07-13 15:56:37 +02:00
2022-02-02 10:29:30 +01:00
static timeval ticksToTimeval(TickType_t ticks);
/**
* Get elapsed time in system ticks.
* @return
*/
static TickType_t getTicks();
2018-07-13 15:56:37 +02:00
2022-02-02 10:29:30 +01:00
const timeval& getOffset() const;
void setOffset(const timeval& offset);
2018-07-13 15:56:37 +02:00
};
#endif /* FRAMEWORK_OSAL_FREERTOS_TIMEKEEPER_H_ */