1 | /* |
---|
2 | * Instantiate the clock driver shell for the Mongoose-V's on-CPU timer. |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2001. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in found in the file LICENSE in this distribution or at |
---|
9 | * http://www.OARcorp.com/rtems/license.html. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems.h> |
---|
15 | #include <libcpu/mongoose-v.h> |
---|
16 | #include <bsp.h> |
---|
17 | |
---|
18 | #if defined(USE_TIMER2_FOR_CLOCK) |
---|
19 | #define CLOCK_BASE MONGOOSEV_TIMER2_BASE |
---|
20 | #define CLOCK_VECTOR MONGOOSEV_IRQ_TIMER2 |
---|
21 | #else |
---|
22 | #define CLOCK_BASE MONGOOSEV_TIMER1_BASE |
---|
23 | #define CLOCK_VECTOR MONGOOSEV_IRQ_TIMER1 |
---|
24 | #endif |
---|
25 | |
---|
26 | /* reset Timeout (TO) bit */ |
---|
27 | #define Clock_driver_support_at_tick() \ |
---|
28 | MONGOOSEV_WRITE_REGISTER( \ |
---|
29 | CLOCK_BASE, \ |
---|
30 | MONGOOSEV_TIMER_CONTROL_REGISTER, \ |
---|
31 | (MONGOOSEV_TIMER_CONTROL_COUNTER_ENABLE | \ |
---|
32 | MONGOOSEV_TIMER_CONTROL_INTERRUPT_ENABLE) \ |
---|
33 | ); |
---|
34 | |
---|
35 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
36 | do { \ |
---|
37 | _old = set_vector( _new, CLOCK_VECTOR, 1 ); \ |
---|
38 | } while(0) |
---|
39 | |
---|
40 | |
---|
41 | extern int ClockRate; |
---|
42 | |
---|
43 | #define CLICKS (unsigned32) &ClockRate |
---|
44 | #define Clock_driver_support_initialize_hardware() \ |
---|
45 | do { \ |
---|
46 | unsigned32 _clicks; \ |
---|
47 | _clicks = CLICKS * rtems_configuration_get_microseconds_per_tick(); \ |
---|
48 | MONGOOSEV_WRITE_REGISTER( \ |
---|
49 | CLOCK_BASE, \ |
---|
50 | MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, \ |
---|
51 | _clicks \ |
---|
52 | ); \ |
---|
53 | Clock_driver_support_at_tick(); \ |
---|
54 | } while(0) |
---|
55 | |
---|
56 | #define Clock_driver_support_shutdown_hardware() \ |
---|
57 | MONGOOSEV_WRITE_REGISTER( CLOCK_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0 ) |
---|
58 | |
---|
59 | #include <clockdrv_shell.c> |
---|