1 | /* ckinit.c |
---|
2 | * |
---|
3 | * This file provides a template for the clock device driver initialization. |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <stdlib.h> |
---|
16 | |
---|
17 | #include <rtems.h> |
---|
18 | #include <rtems/libio.h> |
---|
19 | #include <bsp.h> |
---|
20 | #include <rtems/tic4x/c4xio.h> |
---|
21 | |
---|
22 | |
---|
23 | #define CLOCK_VECTOR 9 |
---|
24 | |
---|
25 | #define Clock_driver_support_at_tick() |
---|
26 | |
---|
27 | #define Clock_driver_support_install_isr( _new, _old ) \ |
---|
28 | do { _old = 0; } while(0) |
---|
29 | |
---|
30 | void Clock_driver_support_initialize_hardware() |
---|
31 | { |
---|
32 | extern int _ClockFrequency; |
---|
33 | uint32_t Clock_counter_register_value; |
---|
34 | float tmp; |
---|
35 | int tmpi; |
---|
36 | |
---|
37 | tmpi = ((int) &_ClockFrequency) * 1000000; /* ClockFrequency is in Mhz */ |
---|
38 | tmp = (float) tmpi / 2.0; |
---|
39 | tmp = ((float) rtems_configuration_get_microseconds_per_tick() / 1000000.0) * (tmp); |
---|
40 | |
---|
41 | Clock_counter_register_value = (unsigned int) tmp; |
---|
42 | #if 0 |
---|
43 | Clock_counter_register_value = |
---|
44 | (uint32_t) ((float) rtems_configuration_get_microseconds_per_tick() / |
---|
45 | ((float)_ClockFrequency / 2.0))); |
---|
46 | #endif |
---|
47 | c4x_timer_stop( C4X_TIMER_0 ); |
---|
48 | c4x_timer_set_counter( C4X_TIMER_0, 0 ); |
---|
49 | c4x_timer_set_period( C4X_TIMER_0, Clock_counter_register_value ); |
---|
50 | c4x_timer_start( C4X_TIMER_0 ); |
---|
51 | |
---|
52 | #if defined(_C4x) |
---|
53 | c4x_set_iee( c4x_get_iie() | 0x1 ); /* should be ETINT0 */ |
---|
54 | #else |
---|
55 | c3x_set_ie( c3x_get_ie() | 0x100 ); |
---|
56 | #endif |
---|
57 | |
---|
58 | Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); |
---|
59 | } |
---|
60 | |
---|
61 | #define Clock_driver_support_shutdown_hardware() |
---|
62 | |
---|
63 | #include "../../../shared/clockdrv_shell.c" |
---|