X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/blobdiff_plain/5482d75ffeb537629e1fe0a82c3eb22986dcbbc5..e8384f88b1a073f47591b9ca13b73da12a7c59a8:/avr/virt_ports.asm diff --git a/avr/virt_ports.asm b/avr/virt_ports.asm index 022d5d4..660f4e7 100644 --- a/avr/virt_ports.asm +++ b/avr/virt_ports.asm @@ -1,6 +1,6 @@ ; Virtual Ports for the BIOS Interaction ; -; Copyright (C) 2010 Leo C. +; Copyright (C) 2010-2013 Leo C. ; ; This file is part of avrcpm. ; @@ -25,13 +25,23 @@ ; Port Direction Function ;hex dez ;------------------------------------------------------------------------- -;00 0 in - Con status. +;00 0 in - Con status. (deprecated) ; Returns 0xFF if the UART has a byte, 0 otherwise. ;01 1 in/out - Console input, aka UDR. / Console Output ;02 2 out - Console Output (deprecated) -;03 3 in - "UART" status: bit 0 = rx, bit 1 = tx -;04 4 in - "UART" data register, no wait +;03 3 in - "UART" status: bit 0 = rx (UARTRXRDY) +; bit 1 = tx (UARTTXRDY) +;03 3 out - "UART" control (tbd) +;04 4 in/out - "UART" data register, no wait ; +;------------------------ Virtual I2C interface -------------------------- +;05 5 out - Control Port: 1 = Start read operation +; 2 = Start write operation +;05 5 in - Status of last Transfer: 0 = ok, else fail +;06 6 in/out - Number of bytes to transfer, including Slave address +;07,08 7,8 in/out - Read/Write address low/high +; +;------------------------ Disk I/O --------------------------------------- ;0D,0E 13,14 in/out - Set address of Bios Controll Block ;0F 15 in/out - Disk select ;10,11 16,17 in/out - Track select @@ -53,30 +63,53 @@ ;16 22 in - Result of last read/write operation. ; 0x00 = ok, 0xff = error (--> Bad Sector) ; +; +;------------------------ ADC Interface ---------------------------------- +;17-19 23,25 in - ADC Channels 6,7 and 8 (Temp-Sensor) +; ADC 6,7 only Devices in 32 pin Case (TQFP/MLF) +; 8 Bit only +; Fixed ADC clock (FCPU/128, 156KHz at 20MHz CPU) +; Vref = VCC +;20,21 in - ADC: Measure VCC +; +;------------------------ Wall Clock and Timers -------------------------- ;40 64-71 in/out - Timer/Clock control. -;46 +;41-46 +; +;47-4D clock - BCD format: ss, mm, hh, DD, MM, YYl, YYh +; +;4F debug - start/stop trace, print stack, ... +; +;------------------------ Ports ------------------------------------------ +;80-87 in/out - Port-Expander PCF8574 (max. 8 Chips) +;88-8F in/out - Port-Expander PCF8574A (not implemented yet!) ; ---------------------------------------------- Start of Code Segment + .cseg vport_tbl: - .db 00,1 ;Port 0, length 1 + .db 00,1 ;Port 0, length, 1 deprecated .dw conStatus ; in .dw dbgOut ; out - .db 01,1 - .dw uartgetc - .dw uartputc - .db 02,1 ;Port 2 (old console output) - .dw uartgetc ; filler - .dw uartputc ; deprecated - .db 03,1 + + .db UARTDR,1 ;Port UARTDR, length 1 + .dw uartgetc ; in + .dw uartputc ; out + +; .db 02,1 ;Port 2 (old console output) +; .dw uartgetc ; filler +; .dw uartputc ; deprecated + + .db UARTCSR,1 .dw uartstat .dw vport_out_dummy + .db 04,1 .dw uartin .dw uartout - .db 13,9 ; Port 13-21, (lenth 9) + .db 13,9 ; Port 13-21, (length 9) .dw dsk_param_get .dw dsk_param_set .db 22,1 @@ -84,8 +117,39 @@ vport_tbl: .dw dskDoIt .db TIMERPORT,7 + .dw utimeget + .dw utimeput + + .db CLOCKPORT,7 ;Clock format (bcd): ss, mm, hh, DD, MM, YYl, YYh .dw clockget .dw clockput + + .db DEBUGPORT,1 + .dw dbg_stat + .dw dbg_ctrl + +#if I2C_SUPPORT + .db I2CCTRL,1 + .dw vi2c_stat_get + .dw vi2c_ctrl + + .db I2CBLEN,3 ; + .dw vi2c_param_get + .dw vi2c_param_set + + .db PORT,8 + .dw pcf8574_in + .dw pcf8574_out +#endif +#if ADC_SUPPORT + .db ADC80,3 ;2 Channels ADC80 ADC81 + Temp Sensor + .dw adc_read8 + .dw vport_out_dummy + + .db 0x20,2 ; + .dw adc_readvcc + .dw vport_out_dummy +#endif .db 0,0 ; Stop mark ;--------------------------------------------------------------------- @@ -100,6 +164,8 @@ portRead: clt vprw_start: + push yh + push yl .if PORT_DEBUG > 1 tst temp2 brne dvp_1 ;don't debug console status @@ -122,24 +188,24 @@ dvp_12: vprw_loop: lpm _tmp0,z+ - lpm temp4,z+ ;length - cpi temp4,0 + lpm _tmp1,z+ ;length + cp _tmp1,_0 breq vprw_exit ;no more ports mov temp3,temp2 sub temp3,_tmp0 ;base port brcs vprw_next ;port # too high - cp temp3,temp4 ;may be in range + cp temp3,_tmp1 ;may be in range brcs vprw_found ; vprw_next: ;port # not in range, test next block. adiw z,4 rjmp vprw_loop vprw_found: - brtc PC+2 - adiw z,2 + brtc PC+2 ;read or write? + adiw z,2 ;skip read function pointer lpm _tmp0,z+ - lpm _tmp1,z+ - movw z,_tmp0 + lpm zh,z + mov zl,_tmp0 .if PORT_DEBUG > 1 push temp2 @@ -157,13 +223,22 @@ vprw_found: icall rcall printhex printstring " " + pop yl + pop yh ret dvp_2: rcall printhex printstring " " - ijmp ; relative port # in temp3 + ; relative port # in temp3 + icall + pop yl + pop yh + ret .else - ijmp + icall + pop yl + pop yh + ret .endif vprw_exit: @@ -171,21 +246,25 @@ vprw_exit: .if PORT_DEBUG > 1 printstring ", not found!" .endif -vport_in_dummy: ldi temp,0xff -vport_out_dummy: + pop yl + pop yh ret - + +vport_out_dummy: + ret + +;--------------------------------------------------------------------- uartstat: clr temp lds temp2,rxcount cpse temp2,_0 - sbr temp,0x01 + sbr temp,UARTRXRDY lds temp2,txcount cpi temp2,TXBUFSIZE breq uartst_1 - sbr temp,0x02 + sbr temp,UARTTXRDY uartst_1: ret @@ -193,14 +272,14 @@ uartin: clr temp lds temp2,rxcount cpse temp2,_0 - rjmp uartgetc + ljmp uartgetc ret uartout: lds temp2,txcount cpi temp2,TXBUFSIZE breq uartout_1 - rjmp uartputc + ljmp uartputc uartout_1: ret @@ -215,9 +294,22 @@ conStatus: dbgOut: printnewline printstring "Debug: " - rcall printhex + lcall printhex + ret + +dbg_stat: + ldi temp,0 ret +dbg_ctrl: + bmov intstat,i_trace, temp,0 +.if SRAM_FILL + sbrc temp,1 + lcall stackusage_print +.endif + ret + + ;--------------------------------------------------------------------- ; vim:set ts=8 noet nowrap