1 | /* |
---|
2 | * Clock Tick Device Driver |
---|
3 | * |
---|
4 | * This routine initializes the Real Time Clock Counter Timer which is |
---|
5 | * part of the MEC on the ERC32 CPU. |
---|
6 | * |
---|
7 | * The tick frequency is directly programmed to the configured number of |
---|
8 | * microseconds per tick. |
---|
9 | * |
---|
10 | * COPYRIGHT (c) 1989-2006. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | * |
---|
17 | * Ported to ERC32 implementation of the SPARC by On-Line Applications |
---|
18 | * Research Corporation (OAR) under contract to the European Space |
---|
19 | * Agency (ESA). |
---|
20 | * |
---|
21 | * ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995. |
---|
22 | * European Space Agency. |
---|
23 | * |
---|
24 | * $Id$ |
---|
25 | */ |
---|
26 | |
---|
27 | #include <bsp.h> |
---|
28 | #include <bspopts.h> |
---|
29 | |
---|
30 | #if SIMSPARC_FAST_IDLE==1 |
---|
31 | #define CLOCK_DRIVER_USE_FAST_IDLE |
---|
32 | #endif |
---|
33 | |
---|
34 | /* |
---|
35 | * The Real Time Clock Counter Timer uses this trap type. |
---|
36 | */ |
---|
37 | |
---|
38 | #define CLOCK_VECTOR ERC32_TRAP_TYPE( ERC32_INTERRUPT_REAL_TIME_CLOCK ) |
---|
39 | |
---|
40 | #define Clock_driver_support_at_tick() |
---|
41 | |
---|
42 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
43 | do { \ |
---|
44 | _old = set_vector( _new, CLOCK_VECTOR, 1 ); \ |
---|
45 | } while(0) |
---|
46 | |
---|
47 | extern int CLOCK_SPEED; |
---|
48 | |
---|
49 | uint32_t bsp_clock_nanoseconds_since_last_tick(void) |
---|
50 | { |
---|
51 | uint32_t clicks; |
---|
52 | |
---|
53 | clicks = ERC32_MEC.Real_Time_Clock_Counter; |
---|
54 | |
---|
55 | return (uint32_t) (rtems_configuration_get_microseconds_per_tick() - clicks) * 1000; |
---|
56 | } |
---|
57 | |
---|
58 | #define Clock_driver_nanoseconds_since_last_tick \ |
---|
59 | bsp_clock_nanoseconds_since_last_tick |
---|
60 | |
---|
61 | #define Clock_driver_support_initialize_hardware() \ |
---|
62 | do { \ |
---|
63 | /* approximately 1 us per countdown */ \ |
---|
64 | ERC32_MEC.Real_Time_Clock_Scalar = CLOCK_SPEED - 1; \ |
---|
65 | ERC32_MEC.Real_Time_Clock_Counter = \ |
---|
66 | rtems_configuration_get_microseconds_per_tick(); \ |
---|
67 | \ |
---|
68 | ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \ |
---|
69 | ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \ |
---|
70 | ERC32_MEC_TIMER_COUNTER_LOAD_SCALER | \ |
---|
71 | ERC32_MEC_TIMER_COUNTER_LOAD_COUNTER \ |
---|
72 | ); \ |
---|
73 | \ |
---|
74 | ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \ |
---|
75 | ERC32_MEC_TIMER_COUNTER_ENABLE_COUNTING | \ |
---|
76 | ERC32_MEC_TIMER_COUNTER_RELOAD_AT_ZERO \ |
---|
77 | ); \ |
---|
78 | } while (0) |
---|
79 | |
---|
80 | #define Clock_driver_support_shutdown_hardware() \ |
---|
81 | do { \ |
---|
82 | ERC32_Mask_interrupt( ERC32_INTERRUPT_REAL_TIME_CLOCK ); \ |
---|
83 | \ |
---|
84 | ERC32_MEC_Set_Real_Time_Clock_Timer_Control( \ |
---|
85 | ERC32_MEC_TIMER_COUNTER_DISABLE_COUNTING \ |
---|
86 | ); \ |
---|
87 | } while (0) |
---|
88 | |
---|
89 | #include "../../../shared/clockdrv_shell.c" |
---|
90 | |
---|