Support High Percision Counter

This commit is contained in:
2023-01-09 22:27:10 +01:00
parent a791f0bffd
commit 0d1e9c3df8
7 changed files with 37 additions and 17 deletions

View File

@@ -32,7 +32,7 @@ namespace JabyEngine {
return Status.read().is_bit_set(irq);
}
static void ack_irg(Bit<uint32_t> irq) {
static void ack_irq(Bit<uint32_t> irq) {
Status.write(Status.read().clear_bit(irq));
}

View File

@@ -12,9 +12,19 @@ namespace JabyEngine {
constexpr TimeStamp(size_t value) : value(value) {}
public:
#ifdef JABYENGINE_USE_HIGH_PERCISION_TIMER
constexpr size_t microseconds_to(const TimeStamp& ts) const {
return (ts.value - this->value)*100;
}
constexpr size_t milliseconds_to(const TimeStamp& ts) const {
return microseconds_to(ts)/1000;
}
#else
constexpr size_t milliseconds_to(const TimeStamp& ts) const {
return (ts.value - this->value)*10;
}
#endif //JABYENGINE_USE_HIGH_PERCISION_TIMER
friend class GlobalTime;
};

View File

@@ -0,0 +1,8 @@
#ifndef __JABYENGINE_CONFIG_HPP__
#define __JABYENGINE_CONFIG_HPP__
#ifdef USE_CUSTOM_CONFIG
#include <jabyengine_custom_config.hpp>
#else
#define JABYENGINE_USE_HIGH_PERCISION_TIMER
#endif //USE_CUSTOM_CONFIG
#endif //!__JABYENGINE_CONFIG_HPP__

View File

@@ -1,5 +1,6 @@
#ifndef __JABYENGINE_DEFINES__H__
#define __JABYENGINE_DEFINES__H__
#include "jabyengine_config.hpp"
#include "../stddef.h"
#define __keep __attribute__((used))