2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <aros/libcall.h>
11 #include "battclock_intern.h"
13 UBYTE
getreg(volatile UBYTE
*p
, UBYTE regnum
)
15 return p
[regnum
* 4 + 3] & 15;
17 void putreg(volatile UBYTE
*p
, UBYTE regnum
, UBYTE v
)
19 p
[regnum
* 4 + 3] = v
;
21 UBYTE
getbcd(volatile UBYTE
*p
, UBYTE regnum
)
23 return getreg(p
, regnum
+ 1) * 10 + getreg(p
, regnum
);
25 void putbcd(volatile UBYTE
*p
, UBYTE regnum
, UBYTE v
)
27 putreg(p
, regnum
+ 1, v
/ 10);
28 putreg(p
, regnum
, v
% 10);
31 void stopclock(struct BattClockBase
*Battclock
)
33 volatile UBYTE
*p
= Battclock
->clockptr
;
34 if (Battclock
->clocktype
== MSM6242B
) {
35 putreg(p
, 0xf, 4 + 2);
36 } else if (Battclock
->clocktype
== RF5C01A
) {
40 void startclock(struct BattClockBase
*Battclock
)
42 volatile UBYTE
*p
= Battclock
->clockptr
;
43 if (Battclock
->clocktype
== MSM6242B
) {
45 } else if (Battclock
->clocktype
== RF5C01A
) {
50 void resetbattclock(struct BattClockBase
*Battclock
)
52 volatile UBYTE
*p
= Battclock
->clockptr
;
58 if (Battclock
->clocktype
== MSM6242B
) {
62 for (i
= 0; i
< 12; i
++)
64 putreg(p
, 0xf, 7); // reset
65 putreg(p
, 0xf, 4); // leave 24h on
66 } else if (Battclock
->clocktype
== RF5C01A
) {
67 putreg(p
, 0xd, 0); // stop
69 for (j
= 0; j
< 4; j
++) {
71 for (i
= 0; i
< 12; i
++)
75 putreg(p
, 0xf, 3); // reset
76 putreg(p
, 0xf, 0); // reset off
77 putreg(p
, 0xd, 8); // timer en