1 | /* |
---|
2 | * Clock Tick Device Driver |
---|
3 | * |
---|
4 | * This routine initializes LEON timer 1 which used for the clock tick. |
---|
5 | * |
---|
6 | * The tick frequency is directly programmed to the configured number of |
---|
7 | * microseconds per tick. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * Modified for LEON BSP |
---|
13 | * COPYRIGHT (c) 2004. |
---|
14 | * Gaisler Research. |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.com/license/LICENSE. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | #include <bspopts.h> |
---|
25 | |
---|
26 | #if SIMSPARC_FAST_IDLE==1 |
---|
27 | #define CLOCK_DRIVER_USE_FAST_IDLE |
---|
28 | #endif |
---|
29 | |
---|
30 | /* |
---|
31 | * The Real Time Clock Counter Timer uses this trap type. |
---|
32 | */ |
---|
33 | |
---|
34 | #define CLOCK_VECTOR LEON_TRAP_TYPE( LEON_INTERRUPT_TIMER1 ) |
---|
35 | |
---|
36 | #define Clock_driver_support_at_tick() |
---|
37 | |
---|
38 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
39 | do { \ |
---|
40 | _old = set_vector( _new, CLOCK_VECTOR, 1 ); \ |
---|
41 | } while(0) |
---|
42 | |
---|
43 | extern int CLOCK_SPEED; |
---|
44 | |
---|
45 | #define Clock_driver_support_initialize_hardware() \ |
---|
46 | do { \ |
---|
47 | LEON_REG.Timer_Reload_1 = rtems_configuration_get_microseconds_per_tick() - 1; \ |
---|
48 | \ |
---|
49 | LEON_REG.Timer_Control_1 = ( \ |
---|
50 | LEON_REG_TIMER_COUNTER_ENABLE_COUNTING | \ |
---|
51 | LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO | \ |
---|
52 | LEON_REG_TIMER_COUNTER_LOAD_COUNTER \ |
---|
53 | ); \ |
---|
54 | } while (0) |
---|
55 | |
---|
56 | #define Clock_driver_support_shutdown_hardware() \ |
---|
57 | do { \ |
---|
58 | LEON_Mask_interrupt( LEON_INTERRUPT_TIMER1 ); \ |
---|
59 | LEON_REG.Timer_Control_1 = 0; \ |
---|
60 | } while (0) |
---|
61 | |
---|
62 | uint32_t bsp_clock_nanoseconds_since_last_tick(void) |
---|
63 | { |
---|
64 | uint32_t clicks; |
---|
65 | |
---|
66 | clicks = LEON_REG.Timer_Counter_1; |
---|
67 | |
---|
68 | /* Down counter */ |
---|
69 | return (uint32_t) |
---|
70 | (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000; |
---|
71 | } |
---|
72 | |
---|
73 | #define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick |
---|
74 | |
---|
75 | #include "../../../shared/clockdrv_shell.h" |
---|