Fix getsecs() to return more proper values:
- use not only second but also minute and hour registers - use bcdtobin() to read mkclock registers
This commit is contained in:
parent
a217648bf2
commit
c959ad2698
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ether_if.c,v 1.3 2008/04/28 20:23:18 martin Exp $ */
|
||||
/* $NetBSD: ether_if.c,v 1.4 2009/01/12 11:00:49 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
@ -140,6 +140,13 @@ _rtt(void)
|
||||
time_t
|
||||
getsecs(void)
|
||||
{
|
||||
volatile uint8_t *mkclock;
|
||||
u_int t;
|
||||
|
||||
return (time_t)*(RTC_MK48T18_ADDR + 4);
|
||||
mkclock = RTC_MK48T18_ADDR;
|
||||
t = bcdtobin(*(mkclock + 4));
|
||||
t += bcdtobin(*(mkclock + 8)) * 60;
|
||||
t += bcdtobin(*(mkclock + 12)) * 60 * 60;
|
||||
|
||||
return (time_t)t;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user