class MCUInstrumentation
{
public:
MCUInstrumentation():
cc_consumed(0),
cc_in(0)
{
}
virtual void init() = 0;
virtual ~MCUInstrumentation() {}
virtual unsigned int getElapsedUS(unsigned int start, unsigned int now, unsigned int clockfrequency) = 0;
virtual unsigned int getCPUCycles(void) = 0;
virtual void setMCUActive(bool active)
{
if (active)
{
uint32_t cc_temp = getCPUCycles() - cc_in;
cc_consumed += cc_temp;
}
else
{
cc_in = getCPUCycles();
}
}
virtual uint32_t getCCConsumed()
{
return cc_consumed;
}
virtual void setCCConsumed(uint32_t val)
{
cc_consumed = val;
}
protected:
volatile uint32_t cc_consumed;
volatile uint32_t cc_in;
};