15 iprintf("We got to line %d in file %s\r\n", __LINE__, __FILE__); \
18#define DEFAULT_TIMER -1
20#define TIMER_RELEASED 2
23extern unsigned long CPU_CLOCK;
24#define NB_CPU_CLK (CPU_CLOCK / 2)
26#define TIME_PER_CLK (1.0 / NB_CPU_CLK)
30 static HiResTimer timers[TIMER_COUNT];
31 static uint8_t timerCreated[TIMER_COUNT];
34 volatile timerstruct *simTimer_;
35 volatile int prescaler_;
36 volatile uint32_t resetCount_;
39 volatile uint32_t delayCalled_;
42 void (*interruptFunction_)();
46 HiResTimer(
const HiResTimer &from){};
47 HiResTimer &operator=(
const HiResTimer &from);
49 HiResTimer(
int timer);
58 static void fireInterrupt(
int timer);
60 void init(
double InterruptTime = 0);
61 void init_ticks(uint32_t ReferenceTicks,
int prescale = 0);
71 simTimer_->dtmr |= 0x2;
73 simTimer_->tmr |= 0x2;
77 inline uint32_t readHigh() {
return resetCount_; };
78 inline uint32_t readLow()
82 return simTimer_->dtcn;
84 return simTimer_->tcn;
87 inline int getPrescaler() {
return prescaler_; };
93 simTimer_->tmr &= ~(0x6);
96 inline void stopClear()
98 simTimer_->tmr &= ~(0x6);
100 simTimer_->ter = 0x3;
106 void delay_uSec(uint32_t DelayTime);
107 void pollingDelay(
double DelayTime);
108 inline void pollingDelay_uSec(uint32_t delayTime)
110 if (delayTime < (INT_MAX / NB_CPU_CLK)) { pollingDelay_refTicks(delayTime * NB_CPU_CLK / 1000000UL); }
113 pollingDelay_refTicks(delayTime >> 2 * (NB_CPU_CLK / 250000UL));
116 void pollingDelay_refTicks(uint32_t ticks);
118 void clockGenerator(
double Frequency);
120 inline void setInterruptFunction(
void (*interruptFunction)())
122 interruptFunction_ = interruptFunction;
124 inline void clearInterruptFunction() { interruptFunction_ = NULL; };
129 static HiResTimer *getHiResTimer(
int timer = DEFAULT_TIMER);
132 int getTimerNumber() {
return timer_; }
void init()
System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
NetBurner Real-Time Operating System (NBRTOS) API.
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition nbrtos.h:411