Mercurial > ecos
comparison packages/hal/sparclite/sleb/current/include/hal_clock.h @ 2:443894e2e912 ecos-v1_2_1-release
Block commit of eCos version 1.2.1
| author | jlarmour |
|---|---|
| date | Tue, 11 May 1999 12:24:34 +0000 |
| parents | |
| children | c38311975d4f |
comparison
equal
deleted
inserted
replaced
| 1:72f549f0d891 | 2:443894e2e912 |
|---|---|
| 1 #ifndef CYGONCE_HAL_CLOCK_H | |
| 2 #define CYGONCE_HAL_CLOCK_H | |
| 3 | |
| 4 //============================================================================= | |
| 5 // | |
| 6 // hal_clock.h | |
| 7 // | |
| 8 // HAL clock support | |
| 9 // | |
| 10 //============================================================================= | |
| 11 //####COPYRIGHTBEGIN#### | |
| 12 // | |
| 13 // ------------------------------------------- | |
| 14 // The contents of this file are subject to the Cygnus eCos Public License | |
| 15 // Version 1.0 (the "License"); you may not use this file except in | |
| 16 // compliance with the License. You may obtain a copy of the License at | |
| 17 // http://sourceware.cygnus.com/ecos | |
| 18 // | |
| 19 // Software distributed under the License is distributed on an "AS IS" | |
| 20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 21 // License for the specific language governing rights and limitations under | |
| 22 // the License. | |
| 23 // | |
| 24 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 25 // September 30, 1998. | |
| 26 // | |
| 27 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. | |
| 29 // ------------------------------------------- | |
| 30 // | |
| 31 //####COPYRIGHTEND#### | |
| 32 //============================================================================= | |
| 33 //#####DESCRIPTIONBEGIN#### | |
| 34 // | |
| 35 // Author(s): nickg, gthomas, hmt | |
| 36 // Contributors: nickg, gthomas, hmt | |
| 37 // Date: 1999-01-28 | |
| 38 // Purpose: Define clock support | |
| 39 // Description: The macros defined here provide the HAL APIs for handling | |
| 40 // the clock. | |
| 41 // | |
| 42 // Usage: | |
| 43 // #include <cyg/hal/hal_intr.h> // which includes this file | |
| 44 // ... | |
| 45 // | |
| 46 // | |
| 47 //####DESCRIPTIONEND#### | |
| 48 // | |
| 49 //============================================================================= | |
| 50 | |
| 51 // #include <cyg/hal/hal_io.h> | |
| 52 | |
| 53 #include <cyg/hal/hal_hwio.h> // HAL_SPARC_86940_READ/WRITE | |
| 54 | |
| 55 //----------------------------------------------------------------------------- | |
| 56 // Clock control | |
| 57 | |
| 58 | |
| 59 // The vector used by the Real time clock is defined in hal_xpic.h | |
| 60 | |
| 61 extern cyg_int32 cyg_hal_sparclite_clock_period; | |
| 62 | |
| 63 //----------------------------------------------------------------------------- | |
| 64 | |
| 65 #define HAL_SPARC_86940_REG_TIMER1_PRESCALER ( 0x14 * 4 ) | |
| 66 #define HAL_SPARC_86940_REG_TIMER1_CONTROL ( 0x15 * 4 ) | |
| 67 #define HAL_SPARC_86940_REG_TIMER1_RELOAD ( 0x16 * 4 ) | |
| 68 #define HAL_SPARC_86940_REG_TIMER1_COUNT ( 0x17 * 4 ) | |
| 69 | |
| 70 | |
| 71 | |
| 72 #define HAL_SPARC_86940_TIMER1_PRESCALER_WRITE( v ) \ | |
| 73 HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TIMER1_PRESCALER, v ) | |
| 74 | |
| 75 #define HAL_SPARC_86940_TIMER1_PRESCALER_READ( r ) \ | |
| 76 HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_PRESCALER, r ) | |
| 77 | |
| 78 #define HAL_SPARC_86940_TIMER1_CONTROL_WRITE( v ) \ | |
| 79 HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TIMER1_CONTROL, v ) | |
| 80 | |
| 81 #define HAL_SPARC_86940_TIMER1_CONTROL_READ( r ) \ | |
| 82 HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_CONTROL, r ) | |
| 83 | |
| 84 #define HAL_SPARC_86940_TIMER1_RELOAD_WRITE( v ) \ | |
| 85 HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TIMER1_RELOAD, v ) | |
| 86 | |
| 87 #define HAL_SPARC_86940_TIMER1_RELOAD_READ( r ) \ | |
| 88 HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_RELOAD, r ) | |
| 89 | |
| 90 #define HAL_SPARC_86940_TIMER1_COUNT_READ( r ) \ | |
| 91 HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_COUNT, r ) | |
| 92 | |
| 93 //----------------------------------------------------------------------------- | |
| 94 | |
| 95 // Initialize the clock to 1MHz whatever the system clock speed. This | |
| 96 // requires calculation... | |
| 97 | |
| 98 externC void hal_clock_initialize( cyg_uint32 p ); | |
| 99 #define HAL_CLOCK_INITIALIZE( _period_ ) hal_clock_initialize( _period_ ) | |
| 100 | |
| 101 // This is the easiest way to clear the interrupt. | |
| 102 #define HAL_CLOCK_RESET( _vector_, _period_ ) CYG_MACRO_START \ | |
| 103 cyg_uint32 _scratch_; \ | |
| 104 HAL_SPARC_86940_TIMER1_COUNT_READ( _scratch_ ); \ | |
| 105 CYG_MACRO_END | |
| 106 | |
| 107 #define HAL_CLOCK_READ( _pvalue_ ) CYG_MACRO_START \ | |
| 108 cyg_uint32 _read_; \ | |
| 109 HAL_SPARC_86940_TIMER1_COUNT_READ( _read_ ); \ | |
| 110 *((cyg_uint32 *)(_pvalue_)) = cyg_hal_sparclite_clock_period - _read_; \ | |
| 111 CYG_MACRO_END | |
| 112 | |
| 113 #ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY | |
| 114 #define HAL_CLOCK_LATENCY( _pvalue_ ) HAL_CLOCK_READ( _pvalue_ ) | |
| 115 #endif | |
| 116 | |
| 117 //----------------------------------------------------------------------------- | |
| 118 | |
| 119 #endif // ifndef CYGONCE_HAL_CLOCK_H | |
| 120 // End of hal_clock.h |
