065fdcfde102c2cb39afd2c18a2405b998fa9701
[rpikern] / src / timer.h
1 #ifndef TIMER_H_
2 #define TIMER_H_
3
4 #include "config.h"
5
6 #define TM_BASE (IO_BASE | 0xb000)
7
8 #define TM_REG(x)       (*(volatile uint32_t*)(TIMER_BASE | (x)))
9 #define TM_LOAD         TM_REG(0x400)
10 #define TM_VALUE        TM_REG(0x404)
11 #define TM_CTL          TM_REG(0x408)
12 #define TM_ICLR         TM_REG(0x40c)
13 #define TM_IRAW         TM_REG(0x410)
14 #define TM_IMSK         TM_REG(0x414)
15 #define TM_RELOAD       TM_REG(0x418)
16 #define TM_PREDIV       TM_REG(0x41c)
17 #define TM_COUNT        TM_REG(0x420)
18
19 #define TMCTL_23BIT             0x000002
20 #define TMCTL_DIV16             0x000004
21 #define TMCTL_DIV256    0x000008
22 #define TMCTL_DIV1              0x00000c
23 #define TMCTL_IEN               0x000020
24 #define TMCTL_EN                0x000080
25 #define TMCTL_DBGHALT   0x000100
26 #define TMCTL_CNTEN             0x000200
27
28 #define TMCTL_PRESCALER(x)      (((uint32_t)(x) & 0xff) << 16)
29
30 #endif  /* TIMER_H_ */