]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/init.asm
* New config option: SRAM_FILL
[avrcpm.git] / avr / init.asm
index e0bb269c044dfc690073fee907d97caee8a4cd87..e2d48f4455b84ddf3340d766f66c9766506d2d13 100644 (file)
@@ -1,7 +1,7 @@
-;    Various functions: init, (RAM) disk, mmc, timer
+;    Hardware initialisation, disk, mmc, timer, DRAM test
 ;
 ;    Copyright (C) 2010 Sprite_tm
-;    Copyright (C) 2010 Leo C.
+;    Copyright (C) 2010-2013 Leo C.
 ;
 ;    This file is part of avrcpm.
 ;
@@ -60,9 +60,9 @@ cp_l: lpm     xh,z+
        
 ; - Setup Ports
 
-       ldi     temp,(1<<PUD)           ;disable pullups
-       outm8   P_PUD,temp
-       out     PORTD,_255              ;all pins high
+;      ldi     temp,(1<<PUD)           ;disable pullups
+;      outm8   P_PUD,temp
+       out     PORTD,_255              ;all pins high (enables pullup on input ports)
        out     PORTB,_255
        out     PORTC,_255
        out     DDRD,_255               ; all outputs
@@ -79,12 +79,21 @@ cp_l:       lpm     xh,z+
 
        ldiw    z,SRAM_START
        ldi     temp2,high(ramtop)
-clr_l:
+clr_loop:
        st      z+,_0
        cpi     zl,low(ramtop)
        cpc     zh,temp2
-       brne    clr_l
+       brne    clr_loop
 
+; - Fill unused RAM (stack)
+
+       ldi     temp2,high(RAMEND+1)
+       ldi     temp,SRAMFILL_VAL
+fill_loop:
+       st      z+,temp
+       cpi     zl,low(RAMEND+1)
+       cpc     zh,temp2
+       brne    fill_loop
 
 ; Init clock/timer system
 
@@ -104,7 +113,7 @@ clr_l:
 
        rcall   uart_init
        
-;Init timer2. Refresh-call should happen every (8ms/512)=312 cycles.
+;Init timer2. Refresh-call should happen every (8ms/512) cycles.
 
        ldi     temp,REFR_CNT*2                 ; 2 cycles per int
        outm8   OCR2A,temp
@@ -120,6 +129,11 @@ clr_l:
 
        sei
 
+#if I2C_SUPPORT
+       rcall   i2c_init                        ; Init I2C master
+       rcall   rtc_get
+#endif
+
 
 .if BOOTWAIT
        ldi temp,10
@@ -130,7 +144,7 @@ clr_l:
        rcall   printstr
        .db     13,13,"CPM on an AVR, v"
        db_version VMAJOR, VMINOR
-       printstring " r" SVN_REVSTR
+       printstring " r" SVN_REVSTR " " TESTSTR
                
 .if MEMTEST
        printnewline
@@ -173,7 +187,7 @@ ramtestr:
        printstring "Addr xx yy "
 ramtestr1:
        printnewline
-       mov     temp4,temp
+       mov     zl,temp
        movw    temp,x
        rcall   printhexw
        rcall   printspace
@@ -182,16 +196,16 @@ ramtestr1:
        mov     temp2,temp
        rcall   printhex
        rcall   printspace
-       mov     temp,temp4
+       mov     temp,zl
        rcall   printhex
        rcall   printspace
        mov     temp,temp2
-       eor     temp,temp4
+       eor     temp,zl
        and     temp,temp2
        rcall   printxbits
        rcall   printspace
        mov     temp,temp2
-       eor     temp,temp4
+       eor     temp,zl
        com     temp2
        and     temp,temp2
        rcall   printxbits
@@ -216,8 +230,8 @@ ramtestend:
 
 .if MEMFILL
        ldiw    x,0
+       ldi     temp,MEMFILL_VAL
 ramfillw:
-       ldi temp,MEMFILL_VAL
        rcall   dram_write_pp
        brcc ramfillw
 .endif
@@ -249,7 +263,9 @@ boot_ipl2:
        printnewline
        printstring "Partinit done."
        
-       lcall   dsk_inval_hostbuf       ;init (de)blocking buffer
+; Init (de)blocking buffer
+
+       lcall   dsk_inval_hostbuf
 
 ; Read first sector of first CP/M partition (ipl)
 
@@ -265,7 +281,8 @@ boot_ipl2:
        ldiw    x,IPLADDR
        stsw    dmaadr,x
        
-       lcall   dsk_read
+       ldi     temp,1<<READ_FUNC
+       lcall   dskDoIt
 
 ;      lift off
        ljmp z80_init