ee919dbf3647b8d387c623b953eaf37571b81a80
[AROS.git] / arch / m68k-amiga / battclock / writebattclock.c
blobee919dbf3647b8d387c623b953eaf37571b81a80
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
4 Desc: WriteBattClock()
5 Lang: english
6 */
7 #include "battclock_intern.h"
9 #include <utility/date.h>
10 #include <proto/utility.h>
12 /*****************************************************************************
14 NAME */
15 #include <proto/battclock.h>
17 AROS_LH1(void, WriteBattClock,
19 /* SYNOPSIS */
20 AROS_LHA(ULONG, time, D0),
22 /* LOCATION */
23 struct BattClockBase*, BattClockBase, 3, Battclock)
25 /* FUNCTION
26 Set the system's battery backed up clock to the time specified. The
27 value should be the number of seconds since 00:00:00 on 1.1.1978.
29 INPUTS
30 time - The number of seconds elapsed since 00:00:00 1.1.1978
32 RESULT
33 The clock will be set.
35 NOTES
36 This may not do anything on some systems where the battery backed
37 up clock either doesn't exist, or may not be writable.
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 ReadBattClock(), ResetBattClock()
46 INTERNALS
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
52 volatile UBYTE *p = BattClockBase->clockptr;
53 struct UtilityBase *UtilityBase = BattClockBase->UtilityBase;
54 struct ClockData cd;
55 UBYTE reg;
57 if (!p)
58 return;
59 Amiga2Date(time, &cd);
60 stopclock(BattClockBase);
61 reg = 0;
62 putbcd(p, reg, cd.sec);
63 putbcd(p, reg + 2, cd.min);
64 putbcd(p, reg + 4, cd.hour);
65 if (BattClockBase->clocktype == MSM6242B)
66 reg = 6;
67 else
68 reg = 7;
69 putbcd(p, reg, cd.mday);
70 putbcd(p, reg + 2, cd.month);
71 putbcd(p, reg + 4, cd.year - 1900);
72 startclock(BattClockBase);
73 return;
75 AROS_LIBFUNC_EXIT
76 } /* WriteBattClock */