* Global variables shared between an interrupt and the main code should be volatile See: https://www.embedded.com/electronics-blogs/beginner-s-corner/4023801/Introduction-to-the-Volatile-Keyword * There is no reason to change the active report if it has not changed * Declare local functions and variables static This both helps the compiler and the programmer
24 lines
406 B
C
24 lines
406 B
C
#ifndef __TIMER_H__
|
|
#define __TIMER_H__
|
|
|
|
// Includes:
|
|
|
|
#include "peripherals/pit.h"
|
|
|
|
// Macros:
|
|
|
|
#define TIMER_INTERVAL_MSEC 1
|
|
|
|
// Variables:
|
|
|
|
extern volatile uint32_t CurrentTime;
|
|
|
|
// Functions:
|
|
|
|
void Timer_Init(void);
|
|
void Timer_SetCurrentTime(uint32_t *time);
|
|
uint32_t Timer_GetElapsedTime(uint32_t *time);
|
|
uint32_t Timer_GetElapsedTimeAndSetCurrent(uint32_t *time);
|
|
|
|
#endif
|