]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/init.asm
* I2C Support added
[avrcpm.git] / avr / init.asm
index e0b860a8154d52efa9e9c3ca4dee91318e8672c0..37b5a2209681252b92c8a0104d125abd6260d893 100644 (file)
@@ -1,4 +1,4 @@
-;    Various functions: init, (RAM) disk, mmc, timer
+;    Hardware initialisation, disk, mmc, timer, DRAM test
 ;
 ;    Copyright (C) 2010 Sprite_tm
 ;    Copyright (C) 2010 Leo C.
@@ -85,7 +85,6 @@ clr_l:
        cpc     zh,temp2
        brne    clr_l
 
-
 ; Init clock/timer system
 
 ; Init timer 1 as 1 ms system clock tick.
@@ -120,6 +119,11 @@ clr_l:
 
        sei
 
+#if I2C
+       rcall   i2c_init                        ; Init I2C master
+       rcall   rtc_get
+#endif
+
 
 .if BOOTWAIT
        ldi temp,10
@@ -130,6 +134,7 @@ clr_l:
        rcall   printstr
        .db     13,13,"CPM on an AVR, v"
        db_version VMAJOR, VMINOR
+       printstring " r" SVN_REVSTR
                
 .if MEMTEST
        printnewline
@@ -155,36 +160,61 @@ ramtestwl:
 
 ;re-read RAM
        ldiw    x,0
-       clr     temp3
+       clr     temp3                   ;Error counter
 ramtestr:
        mem_read
+
+;      ori     temp,0x04               ;simulate error
+;      andi    temp,0xF7
+
        mov     temp2,xh
        eor     temp2,xl
        cp      temp,temp2
        breq    ramtestrok
-       push    temp
-       cpi     temp3,0         ;if first error
-       brne    ramtest2
-       inc     temp3
-       ldi     temp,10         ;newline
-       rcall   uartPutc
-ramtest2:
-       ldi     temp,13         ;return
-       rcall   uartPutc
-       pop     temp
-       rcall   printhex
-       ldi     temp,'<'
-       rcall   uartPutc
+       tst     temp3
+       brne    ramtestr1
+       printnewline
+       printstring "Addr xx yy "
+ramtestr1:
+       printnewline
+       mov     temp4,temp
+       movw    temp,x
+       rcall   printhexw
+       rcall   printspace
        mov     temp,xh
        eor     temp,xl
+       mov     temp2,temp
        rcall   printhex
-       ldi     temp,'@'
-       rcall   uartPutc
-       movw    temp,x
-       rcall   printhexw
+       rcall   printspace
+       mov     temp,temp4
+       rcall   printhex
+       rcall   printspace
+       mov     temp,temp2
+       eor     temp,temp4
+       and     temp,temp2
+       rcall   printxbits
+       rcall   printspace
+       mov     temp,temp2
+       eor     temp,temp4
+       com     temp2
+       and     temp,temp2
+       rcall   printxbits
+
+       inc     temp3
+       cpi     temp3,16                ;
+       brsh    ramtestrex
 ramtestrok:
        adiw    xl,1
        brcc    ramtestr
+ramtestrex:
+       tst     temp3                   ;any errors?
+       breq    ramtestend      
+
+       printstring " System halted!"
+halted_loop:
+       rjmp    halted_loop             ;keep AVR in an endless loop
+
+ramtestend:
 
 .endif
 
@@ -245,3 +275,31 @@ boot_ipl2:
        ljmp z80_init
 
 
+printspace:
+       push    temp
+       ldi     temp,' '
+       rcall   uartputc
+       pop     temp
+       ret
+
+printxbits:
+       push    temp2
+       push    temp3
+       mov     temp2,temp
+       ldi     temp3,8
+prntxb0:
+       ldi     temp,'-'
+       lsl     temp2
+       brcc    prntxb1
+       ldi     temp,'X'
+prntxb1:
+       rcall   uartPutc
+       dec     temp3
+       brne    prntxb0
+       pop     temp3
+       pop     temp2
+       ret
+
+
+
+