Mercurial > flash_v2
comparison packages/devs/wallclock/mips/ref4955/current/src/wallclock_ref4955.cxx @ 134:d2f49caf9e38 ecos-sw-2000-11-03
Merge from eCos master repository on 2000-11-03-09:00:49-GMT
| author | jlarmour |
|---|---|
| date | Fri, 03 Nov 2000 21:17:40 +0000 |
| parents | |
| children | 11b54a94cf58 |
comparison
equal
deleted
inserted
replaced
| 133:98d71f4d8243 | 134:d2f49caf9e38 |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // devs/wallclock/mips/ref4955/ref4955.cxx | |
| 4 // | |
| 5 // Wallclock implementation | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (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://www.redhat.com/ | |
| 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 Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): jskov | |
| 35 // Contributors: jskov | |
| 36 // Date: 2000-05-25 | |
| 37 // Purpose: Wallclock driver for REF4955 | |
| 38 // | |
| 39 //####DESCRIPTIONEND#### | |
| 40 // | |
| 41 //========================================================================== | |
| 42 | |
| 43 #include <pkgconf/kernel.h> // Kernel config | |
| 44 #include <pkgconf/wallclock.h> // Wallclock device config | |
| 45 | |
| 46 #include <cyg/hal/hal_io.h> // IO macros | |
| 47 #include <cyg/infra/cyg_type.h> // Common type definitions and support | |
| 48 | |
| 49 #include <cyg/io/wallclock.hxx> // The WallClock API | |
| 50 #include <cyg/io/wallclock/wallclock.inl> // Helpers | |
| 51 | |
| 52 #include <cyg/infra/diag.h> // For debugging | |
| 53 | |
| 54 // REF4955 has a Dallas 1742W part. | |
| 55 #define DS_BASE 0xb5000000 | |
| 56 #include <cyg/io/wallclock/ds1742.inl> | |
| 57 | |
| 58 //----------------------------------------------------------------------------- | |
| 59 // Functions required for the hardware-driver API. | |
| 60 | |
| 61 // Returns the number of seconds elapsed since 1970-01-01 00:00:00. | |
| 62 cyg_uint32 | |
| 63 Cyg_WallClock::get_hw_seconds(void) | |
| 64 { | |
| 65 cyg_uint32 year, month, mday, hour, minute, second; | |
| 66 | |
| 67 get_ds_hwclock(&year, &month, &mday, &hour, &minute, &second); | |
| 68 | |
| 69 #if 0 | |
| 70 // This will cause the test to eventually fail due to these printouts | |
| 71 // causing timer interrupts to be lost... | |
| 72 diag_printf("year %02d\n", year); | |
| 73 diag_printf("month %02d\n", month); | |
| 74 diag_printf("mday %02d\n", mday); | |
| 75 diag_printf("hour %02d\n", hour); | |
| 76 diag_printf("minute %02d\n", minute); | |
| 77 diag_printf("second %02d\n", second); | |
| 78 #endif | |
| 79 | |
| 80 cyg_uint32 now = _simple_mktime(year, month, mday, hour, minute, second); | |
| 81 return now; | |
| 82 } | |
| 83 | |
| 84 #ifdef CYGSEM_WALLCLOCK_SET_GET_MODE | |
| 85 | |
| 86 // Sets the clock. Argument is seconds elapsed since 1970-01-01 00:00:00. | |
| 87 void | |
| 88 Cyg_WallClock::set_hw_seconds( cyg_uint32 secs ) | |
| 89 { | |
| 90 cyg_uint32 year, month, mday, hour, minute, second; | |
| 91 | |
| 92 _simple_mkdate(secs, &year, &month, &mday, &hour, &minute, &second); | |
| 93 | |
| 94 set_ds_hwclock(year, month, mday, hour, minute, second); | |
| 95 } | |
| 96 | |
| 97 #endif | |
| 98 | |
| 99 void | |
| 100 Cyg_WallClock::init_hw_seconds(void) | |
| 101 { | |
| 102 #ifdef CYGSEM_WALLCLOCK_SET_GET_MODE | |
| 103 init_ds_hwclock(); | |
| 104 #else | |
| 105 // This is our base: 1970-01-01 00:00:00 | |
| 106 // Set the HW clock - if for nothing else, just to be sure it's in a | |
| 107 // legal range. Any arbitrary base could be used. | |
| 108 // After this the hardware clock is only read. | |
| 109 set_ds_hwclock(1970,1,1,0,0,0); | |
| 110 #endif | |
| 111 } | |
| 112 | |
| 113 //----------------------------------------------------------------------------- | |
| 114 // End of devs/wallclock/mips/ref4955/wallclock_ref4955.cxx |
