Mercurial > flash_v2
comparison packages/kernel/current/src/common/timer.cxx @ 0:3111d98ba7b3 ecos-v1_1-release
Initial commit of eCos version 1.1
| author | jlarmour |
|---|---|
| date | Tue, 11 May 1999 11:16:07 +0000 |
| parents | |
| children | 443894e2e912 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:3111d98ba7b3 |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // common/timer.cxx | |
| 4 // | |
| 5 // Timer class implementations | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. | |
| 26 // ------------------------------------------- | |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //========================================================================== | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): dsm | |
| 33 // Contributors: dsm | |
| 34 // Date: 1998-06-11 | |
| 35 // Purpose: Clock class implementation | |
| 36 // Description: This file implements the Timer class which is derived from | |
| 37 // the Alarm class to support uITRON type functionality | |
| 38 // | |
| 39 //####DESCRIPTIONEND#### | |
| 40 // | |
| 41 //========================================================================== | |
| 42 | |
| 43 #include <pkgconf/kernel.h> | |
| 44 | |
| 45 #include <cyg/kernel/ktypes.h> // base kernel types | |
| 46 #include <cyg/infra/cyg_trac.h> // tracing macros | |
| 47 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 48 | |
| 49 #include <cyg/kernel/clock.hxx> | |
| 50 #include <cyg/kernel/timer.hxx> | |
| 51 | |
| 52 #include <cyg/kernel/clock.inl> // Clock inlines | |
| 53 | |
| 54 // ------------------------------------------------------------------------- | |
| 55 | |
| 56 Cyg_Timer::Cyg_Timer() | |
| 57 { | |
| 58 } | |
| 59 | |
| 60 Cyg_Timer::~Cyg_Timer() | |
| 61 { | |
| 62 CYG_REPORT_FUNCTION(); | |
| 63 | |
| 64 disable(); | |
| 65 counter = NULL; | |
| 66 } | |
| 67 | |
| 68 // ------------------------------------------------------------------------- | |
| 69 | |
| 70 void | |
| 71 Cyg_Timer::initialize( | |
| 72 Cyg_Counter *c, | |
| 73 cyg_alarm_fn a, | |
| 74 CYG_ADDRWORD d, | |
| 75 cyg_tick_count t, // absolute time | |
| 76 cyg_tick_count i, // 0 => one shot, else repeating | |
| 77 cyg_uint32 action // (DISABLE | ENABLE) | |
| 78 ) | |
| 79 { | |
| 80 CYG_REPORT_FUNCTION(); | |
| 81 | |
| 82 counter = c; | |
| 83 alarm = a; | |
| 84 data = d; | |
| 85 trigger = t; | |
| 86 interval = i; | |
| 87 enabled = false; | |
| 88 | |
| 89 CYG_ASSERT(0 == (action & ~ENABLE), "unknown action"); | |
| 90 | |
| 91 if(action & ENABLE) | |
| 92 enable(); | |
| 93 } | |
| 94 | |
| 95 void | |
| 96 Cyg_Timer::activate(cyg_uint32 action) // (DISABLE | ENABLE) [|RESET] | |
| 97 { | |
| 98 if(!(action & ENABLE)) | |
| 99 disable(); | |
| 100 | |
| 101 if((action & RESET)) | |
| 102 { | |
| 103 cyg_tick_count t; | |
| 104 t = counter->current_value(); | |
| 105 trigger = t + interval; | |
| 106 } | |
| 107 | |
| 108 if((action & ENABLE)) { | |
| 109 enable(); | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 // ------------------------------------------------------------------------- | |
| 114 // EOF common/timer.cxx |
