]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/virt_ports.asm
* New config option: SRAM_FILL
[avrcpm.git] / avr / virt_ports.asm
index 1fa815497808d2955e1d64480f24ec9881c5239f..e832d0881159705c0539d2fde7c4505e615f5ed9 100644 (file)
@@ -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.
 ;
 ;03    3       in      - "UART" status: bit 0 = rx, bit 1 = tx
 ;04    4       in      - "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
 ;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
@@ -76,7 +103,7 @@ vport_tbl:
        .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,12 +111,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
 
 ;---------------------------------------------------------------------
@@ -128,24 +182,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
@@ -186,13 +240,13 @@ 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
@@ -210,14 +264,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
 
@@ -232,16 +286,19 @@ 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