]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/virt_ports.asm
* cpm/BIOS.MAC
[avrcpm.git] / avr / virt_ports.asm
index 05cfd933b47ee9d9ba0b5e87b34414c38742a379..660f4e71ac8be948e05759f59f22e7ba62a8401a 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.
 ;
 ;   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
 ;                        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.  
 ;
 ;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
@@ -112,7 +128,7 @@ vport_tbl:
        .dw     dbg_stat
        .dw     dbg_ctrl
 
-#if I2C
+#if I2C_SUPPORT
        .db     I2CCTRL,1
        .dw     vi2c_stat_get
        .dw     vi2c_ctrl
@@ -125,7 +141,15 @@ vport_tbl:
        .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
 
 ;---------------------------------------------------------------------
@@ -164,14 +188,14 @@ 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
@@ -180,8 +204,8 @@ vprw_found:
        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
@@ -222,23 +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
 
@@ -271,13 +297,16 @@ dbgOut:
        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