FreeCalypso > hg > freecalypso-sw
comparison nuc-fw/nucleus/caltimer.h @ 79:947b1f473960
beginning of nuc-fw
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 11 Aug 2013 07:17:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
78:2c266d4339ff | 79:947b1f473960 |
---|---|
1 /* | |
2 * Definitions for Calypso general-purpose timer registers | |
3 * Added to the FreeNucleus Calypso port by Spacefalcon the Outlaw. | |
4 * | |
5 * This header is usable from both .c and .S source files. | |
6 */ | |
7 | |
8 #ifndef _CALYPSO_TIMER_H | |
9 #define _CALYPSO_TIMER_H | |
10 | |
11 #define TIMER1_BASE_ADDR 0xFFFE3800 | |
12 #define TIMER2_BASE_ADDR 0xFFFE6800 | |
13 | |
14 #ifdef __ASSEMBLER__ | |
15 | |
16 /* | |
17 * Assembly source with cpp | |
18 * | |
19 * The most convenient way to access registers like these from ARM | |
20 * assembly is to load the base address of the register block in some | |
21 * ARM register, using only one ldr rN, =xxx instruction and only one | |
22 * literal pool entry, and then access various registers in the block | |
23 * from the same base using the immediate offset addressing mode. | |
24 * | |
25 * Here we define the offsets for the usage scenario above. | |
26 */ | |
27 | |
28 #define CNTL_TIM 0x00 | |
29 #define LOAD_TIM 0x02 | |
30 #define READ_TIM 0x04 | |
31 | |
32 #else | |
33 | |
34 /* | |
35 * C source | |
36 * | |
37 * For access from C, we define the layout of each timer register block | |
38 * as a struct, and then define a pleudo-global-var for easy "volatile" | |
39 * access to each of the 2 timers. | |
40 */ | |
41 | |
42 struct timer_regs { | |
43 unsigned char cntl; | |
44 unsigned char pad; | |
45 unsigned short load; | |
46 unsigned short read; | |
47 }; | |
48 | |
49 #define TIMER1_REGS (*(volatile struct timer_regs *) TIMER1_BASE_ADDR) | |
50 #define TIMER2_REGS (*(volatile struct timer_regs *) TIMER2_BASE_ADDR) | |
51 | |
52 #endif | |
53 | |
54 /* CNTL register bit definitions */ | |
55 #define CNTL_START 0x01 | |
56 #define CNTL_AUTO_RELOAD 0x02 | |
57 #define CNTL_CLOCK_ENABLE 0x20 | |
58 | |
59 #endif /* include guard */ |