; 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
.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
;---------------------------------------------------------------------
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
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