OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [wallclock/] [powerpc/] [moab/] [current/] [include/] [devices_wallclock_moab.inl] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      devs/wallclock/powerpc/moab/include/devs_wallclock_moab.inl
4
//
5
//      TAMS MOAB RTC IO definitions
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):   rajt
43
// Contributors:rajt
44
// Date:        2001-07-19
45
// Purpose:     MOAB RTC definitions for using DS1307
46
//####DESCRIPTIONEND####
47
//==========================================================================
48
 
49
#include CYGDAT_DEVS_WALLCLOCK_MOAB_CFG
50
 
51
static __inline__ void
52
DS_GET(cyg_uint8 *regs)
53
{
54
    cyg_uint8 addr, page;
55
 
56
    // Read RTC
57
    addr = 0x00;
58
    page = 0xD1;
59
    if (!hal_ppc405_i2c_put_bytes(page, &addr, 1)) {
60
        diag_printf("%s - Can't select page %x\n", __FUNCTION__, page);
61
        return;
62
    }
63
    if (!hal_ppc405_i2c_get_bytes(page, regs, DS_REGS_SIZE)) {
64
        diag_printf("%s - Can't read RTC\n", __FUNCTION__);
65
        return;
66
    }
67
#if 0
68
    diag_printf("RTC data - read\n");
69
    diag_dump_buf(regs, DS_REGS_SIZE);
70
#endif
71
 
72
#ifdef RTC_TEST
73
    addr = 0x10;
74
    page = 0xD1;
75
    if (!hal_ppc405_i2c_put_bytes(page, &addr, 1)) {
76
        diag_printf("%s - Can't select page %x\n", __FUNCTION__, page);
77
        return;
78
    }
79
    if (!hal_ppc405_i2c_get_bytes(page, regs, DS_REGS_SIZE)) {
80
        diag_printf("%s - Can't read RTC\n", __FUNCTION__);
81
        return;
82
    }
83
    diag_printf("RTC data - test\n");
84
    diag_dump_buf(regs, DS_REGS_SIZE);
85
#endif
86
}
87
 
88
static __inline__ void
89
DS_PUT(cyg_uint8 *regs)
90
{
91
    cyg_uint8 addr_data[DS_REGS_SIZE+1], page;
92
    int i;
93
 
94
#if 0
95
    diag_printf("RTC data - write\n");
96
    diag_dump_buf(regs, DS_REGS_SIZE);
97
#endif
98
    // Update RTC in one swoop
99
    addr_data[0] = 0x00;  // Starting register address
100
    for (i = 0;  i < DS_REGS_SIZE;  i++) {
101
        addr_data[i+1] = regs[i];
102
    }
103
    page = 0xD0;
104
    if (!hal_ppc405_i2c_put_bytes(page, addr_data, DS_REGS_SIZE+1)) {
105
        diag_printf("%s - Can't write registers\n", __FUNCTION__);
106
        return;
107
    }
108
#ifdef RTC_TEST
109
    // Test RTC by copying the registers to some of the RAM
110
    addr_data[0] = 0x10;  // Starting register address
111
    for (i = 0;  i < DS_REGS_SIZE;  i++) {
112
        addr_data[i+1] = regs[i];
113
    }
114
    page = 0xD0;
115
    if (!hal_ppc405_i2c_put_bytes(page, addr_data, DS_REGS_SIZE+1)) {
116
        diag_printf("%s - Can't write registers\n", __FUNCTION__);
117
        return;
118
    }
119
#endif
120
}
121
 
122
// EOF devs_wallclock_moab.inl

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.