X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=rpikern;a=blobdiff_plain;f=src%2Ftimer.h;fp=src%2Ftimer.h;h=065fdcfde102c2cb39afd2c18a2405b998fa9701;hp=0000000000000000000000000000000000000000;hb=993155fee2327f1f3cda285c9548bbb09688a3f3;hpb=9a3655a43358c43128f6e62c8d74ff3aa81960c7 diff --git a/src/timer.h b/src/timer.h new file mode 100644 index 0000000..065fdcf --- /dev/null +++ b/src/timer.h @@ -0,0 +1,30 @@ +#ifndef TIMER_H_ +#define TIMER_H_ + +#include "config.h" + +#define TM_BASE (IO_BASE | 0xb000) + +#define TM_REG(x) (*(volatile uint32_t*)(TIMER_BASE | (x))) +#define TM_LOAD TM_REG(0x400) +#define TM_VALUE TM_REG(0x404) +#define TM_CTL TM_REG(0x408) +#define TM_ICLR TM_REG(0x40c) +#define TM_IRAW TM_REG(0x410) +#define TM_IMSK TM_REG(0x414) +#define TM_RELOAD TM_REG(0x418) +#define TM_PREDIV TM_REG(0x41c) +#define TM_COUNT TM_REG(0x420) + +#define TMCTL_23BIT 0x000002 +#define TMCTL_DIV16 0x000004 +#define TMCTL_DIV256 0x000008 +#define TMCTL_DIV1 0x00000c +#define TMCTL_IEN 0x000020 +#define TMCTL_EN 0x000080 +#define TMCTL_DBGHALT 0x000100 +#define TMCTL_CNTEN 0x000200 + +#define TMCTL_PRESCALER(x) (((uint32_t)(x) & 0xff) << 16) + +#endif /* TIMER_H_ */