fome-fw/firmware/util/containers/counter64.h

35 lines
625 B
C
Raw Normal View History

/*
2019-12-23 20:05:40 -08:00
* @file counter64.h
*
* Created on: Mar 31, 2019
2020-01-07 21:02:40 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#ifndef UTIL_CONTAINERS_COUNTER64_H_
#define UTIL_CONTAINERS_COUNTER64_H_
#include "global.h"
typedef struct {
// todo: would probably be better to keep the high bits as 32 bit field to be sure
volatile efitime_t highBits;
volatile uint32_t lowBits;
} State64;
void updateAndSet(State64 *state, uint32_t value);
class Overflow64Counter
{
public:
Overflow64Counter();
efitime_t get();
#if EFI_UNIT_TEST
efitime_t update(uint32_t value);
#endif
State64 state;
};
#endif /* UTIL_CONTAINERS_COUNTER64_H_ */