added XRAM module.

Module for external SRAM with AtMega8515.
This commit is contained in:
Martin Preuss
2025-05-17 14:22:49 +02:00
parent 2897aece2c
commit 75b602811c
5 changed files with 127 additions and 0 deletions

View File

@@ -24,6 +24,10 @@
.include "modules/basetimer/main.asm"
#ifdef MODULES_XRAM
.include "modules/xram/main.asm"
#endif
#ifdef MODULES_NETWORK
.include "common/crc8.asm"
.include "common/m_fixedbuffers.asm"
@@ -169,6 +173,7 @@
.include "apps/network/stats.asm"
.include "modules/network/msg/sendstats-w.asm"
.include "modules/network/msg/recvstats-w.asm"
.include "modules/network/msg/memstats-w.asm"
.include "modules/network/msg/device-w.asm"
#endif

View File

@@ -32,6 +32,10 @@ initModules:
rcall Timer_Init
#endif
#ifdef MODULES_XRAM
rcall XRAM_Init
#endif
#ifdef MODULES_LED
ldi zl, LOW(ledA3Flash)
ldi zh, HIGH(ledA3Flash)

View File

@@ -35,6 +35,7 @@
bootloader
f_keepup
valsched
xram
</subdirs>
</gwbuild>

11
avr/modules/xram/0BUILD Normal file
View File

@@ -0,0 +1,11 @@
<?xml?>
<gwbuild>
<extradist>
main.asm
</extradist>
</gwbuild>

106
avr/modules/xram/main.asm Normal file
View File

@@ -0,0 +1,106 @@
; ***************************************************************************
; copyright : (C) 2025 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. *
; ***************************************************************************
; ***************************************************************************
; defines
; ***************************************************************************
; data
.dseg
xramLastAddress: .byte 2
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine XRAM_Init @global
;
XRAM_Init:
clr r16
sts xramLastAddress, r16
sts xramLastAddress+1, r16
M_IO_READ r16, MCUCR
sbr r16, (1<<SRE)
M_IO_WRITE MCUCR, r16
rcall xramWritePattern
rcall xramVerifyPattern
ret
; @end
; ---------------------------------------------------------------------------
; @routine XRAM_Fini @global
;
XRAM_Fini:
ret
; @end
; ---------------------------------------------------------------------------
; @routine xramWritePattern
;
; Write a pattern to memory (high byte of address)
xramWritePattern:
ldi xl, LOW(RAMEND+1)
ldi xh, LOW(RAMEND+1)
xramWritePattern_loop:
mov r16, xh
st X, r16
adiw xh:xl, 1
brne xramWritePattern_loop
ret
; @end
; ---------------------------------------------------------------------------
; @routine xramVerifyPattern
;
; Write a pattern to memory (high byte of address)
xramVerifyPattern:
ldi xl, LOW(RAMEND+1)
ldi xh, LOW(RAMEND+1)
xramVerifyPattern_loop:
mov r16, xh
ld r17, X
cp r16, r17
brne xramVerifyPattern_end
adiw xh:xl, 1
brne xramVerifyPattern_loop
xramVerifyPattern_end:
sbiw xh:xl, 1
sts xramLastAddress, xl
sts xramLastAddress+1, xh
ret
; @end