diff --git a/avr/modules/0BUILD b/avr/modules/0BUILD index 4cfef6f..8fe82d9 100644 --- a/avr/modules/0BUILD +++ b/avr/modules/0BUILD @@ -42,6 +42,7 @@ xram heap brightness + rtc diff --git a/avr/modules/rtc/0BUILD b/avr/modules/rtc/0BUILD new file mode 100644 index 0000000..8a211af --- /dev/null +++ b/avr/modules/rtc/0BUILD @@ -0,0 +1,10 @@ + + + + + + ds3231 + + + + diff --git a/avr/modules/rtc/ds3231/0BUILD b/avr/modules/rtc/ds3231/0BUILD new file mode 100644 index 0000000..c7ca6fd --- /dev/null +++ b/avr/modules/rtc/ds3231/0BUILD @@ -0,0 +1,13 @@ + + + + + + main.asm + recv.asm + send.asm + + + + + diff --git a/avr/modules/rtc/ds3231/main.asm b/avr/modules/rtc/ds3231/main.asm new file mode 100644 index 0000000..9400bfe --- /dev/null +++ b/avr/modules/rtc/ds3231/main.asm @@ -0,0 +1,226 @@ +; *************************************************************************** +; copyright : (C) 2026 by Martin Preuss +; email : martin@libchipcard.de +; +; *************************************************************************** +; * This file is part of the project "AqHome". * +; * Please see toplevel file COPYING of that project for license details. * +; *************************************************************************** + + + +; *************************************************************************** +; defs + +.equ DS3231_FLAGS_PRESENT_BIT = 7 +.equ DS3231_FLAGS_VALID_BIT = 6 + + + + + +; *************************************************************************** +; data + +.dseg + +ds3231DataBegin: + ds3231Flags: .byte 1 + ds3231RecvBuffer: .byte 7 +ds3231DataEnd: + + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine Ds3231_Init @global +; +; @return CFLAG set if okay, cleared on error +; @clobbers + +Ds3231_Init: + ldi xh, HIGH(ds3231DataBegin) + ldi xl, LOW(ds3231DataBegin) + clr r16 + ldi r17, (ds3231DataEnd-ds3231DataBegin) + rcall Utils_FillSram + + rcall ds3231CheckPresence + brcc Ds3231_Init_ret + ldi r16, (1<