(Tim) Efthimis Kritikos
1966ab78b4
I'm happy to have reached 200 commits and with this, version v0.3.0 is functionally ready. I still need to do a fair bit of cleanup and bug fixing though before the actual release. With this commit I added a CPU I2C driver as well as a basic arbiter to have the hardware lcd controller and the software i2c communication pass through the same I2C driver and I2C bus. I also wrote a bootloader that reads code from an i2c eeprom to make sure the hardware works.
119 lines
1.6 KiB
NASM
119 lines
1.6 KiB
NASM
.org 0xF800
|
|
mov sp,#STACK
|
|
call litedram_init
|
|
|
|
|
|
mov bx,#load_i2c_txt
|
|
call print
|
|
|
|
;########### SET ROM ADDRESS ############
|
|
mov al,#0x50
|
|
outb #0x61
|
|
|
|
mov ax,#0x0000 ; I2C ADDRESS
|
|
outw #0x62
|
|
|
|
mov al,#0x02 ; Write 16bit
|
|
outb #0x63
|
|
|
|
mov al,#0x00
|
|
outb #0x60
|
|
|
|
;wait_send: inw #0x62
|
|
;test al,#0x01
|
|
;jnz wait_send
|
|
|
|
mov ax,#0x1FFE
|
|
aa:
|
|
dec ax
|
|
jnz aa
|
|
|
|
mov bx,#OK_loading_txt
|
|
call print
|
|
|
|
|
|
;############ READ 20% ##################
|
|
|
|
mov bx,#0xD000
|
|
mov di,#0x0000
|
|
rom_read_loop:
|
|
mov al,#0x05 ; Read, 8bit, ignore ack
|
|
outb #0x63
|
|
|
|
mov al,#0x00
|
|
outb #0x60
|
|
|
|
mov ax,#0x1FFE
|
|
aa2:
|
|
dec ax
|
|
jnz aa2
|
|
|
|
inw #0x60
|
|
STOSB
|
|
|
|
cmp di,#0x2999
|
|
jz print_20
|
|
cmp di,#0x5333
|
|
jz print_40
|
|
cmp di,#0x7CCC
|
|
jz print_60
|
|
cmp di,#0xA666
|
|
jz print_80
|
|
|
|
back:dec bx
|
|
jnz rom_read_loop
|
|
|
|
|
|
MOV AX,#0xC000
|
|
JMP AX
|
|
|
|
print_20:
|
|
mov bx,#twenty_prc_txt
|
|
call print
|
|
jmp back
|
|
|
|
print_40:
|
|
mov bx,#forty_prc_txt
|
|
call print
|
|
jmp back
|
|
|
|
print_60:
|
|
mov bx,#sixty_prc_txt
|
|
call print
|
|
jmp back
|
|
|
|
print_80:
|
|
mov bx,#eighty_prc_txt
|
|
call print
|
|
jmp back
|
|
|
|
|
|
include LiteDram_init.asm
|
|
|
|
print:
|
|
mov al,[bx]
|
|
cmp al,#0
|
|
je print_exit
|
|
out byte #0xA5
|
|
inc bx
|
|
jmp print
|
|
print_exit:
|
|
ret
|
|
|
|
.BLKB 18 ; Using the text as stack space for the compiled program
|
|
STACK: ; brainfuck_mandelbrot depends on stack being at the end
|
|
|
|
load_i2c_txt: .ASCII 'Read I2C EEPROM:\0'
|
|
OK_loading_txt: .ASCII 'OK\nLoading rom 0%\r\0'
|
|
twenty_prc_txt: .ASCII 'Loading rom 20%\r\0'
|
|
forty_prc_txt: .ASCII 'Loading rom 40%\r\0'
|
|
sixty_prc_txt: .ASCII 'Loading rom 60%\r\0'
|
|
eighty_prc_txt: .ASCII 'Loading rom 80%\r\0'
|
|
|
|
.ORG 0xFFF0
|
|
MOV AX,#0xF800
|
|
JMP AX
|
|
|
|
.ORG 0xFFFF
|
|
DB 0x00 ;Make sure a full 64KiB image
|