improved uartfd1.

This commit is contained in:
Martin Preuss
2025-08-25 10:24:48 +02:00
parent 127525e3ec
commit 77d3a201f5
3 changed files with 84 additions and 7 deletions

View File

@@ -55,7 +55,8 @@
cbr r16, (1<<TXC@0) ; clear TXCn interrupt
outr UCSR@0A, r16
inr r16, UCSR@0B
sbr r16, (1<<UDRIE@0) | (1<<TXCIE@0) | (1<<TXEN@0) ; enable TX UDRE and TXC interrupt, enable transceive
; sbr r16, (1<<UDRIE@0) | (1<<TXCIE@0) | (1<<TXEN@0) ; enable TX UDRE and TXC interrupt, enable transceive
sbr r16, (1<<UDRIE@0) | (1<<TXEN@0) ; enable TX UDRE interrupt, enable transceive
outr UCSR@0B, r16
.endmacro
@@ -63,12 +64,33 @@
.macro M_UARTFD_STOP_TX
inr r16, UCSR@0B
cbr r16, (1<<UDRIE@0) | (1<<TXCIE@0) | (1<<TXEN@0) ; disable TX UDRE and TXC1 interrupt, enable transceive
cbr r16, (1<<UDRIE@0) | (1<<TXCIE@0) | (1<<TXEN@0) ; disable TX UDRE and TXC interrupt, disable transceive
outr UCSR@0B, r16
.endmacro
.macro M_UARTFD_STOP_TXIRQS
inr r16, UCSR@0B
cbr r16, (1<<UDRIE@0) | (1<<TXCIE@0) ; disable TX UDRE and TXC interrupt
outr UCSR@0B, r16
.endmacro
.macro M_UARTFD_FLUSH_IN
l_loop_%:
inr r16, UCSR@0A
sbrs r16, RXC@0
rjmp l_end_% ; no data
inr r16, UDR@0 ; r16=received char
rjmp l_loop_%
l_end_%:
.endmacro
; @end
; ---------------------------------------------------------------------------
; @macro M_UARTFD_RXCHAR_ISR
;
@@ -77,7 +99,12 @@
.macro M_UARTFD_RXCHAR_ISR
ldd r16, Y+UARTFD_IFACE_OFFS_STATUS
andi r16, (1<<UARTFD_IFACE_STATUS_BIT_SKIPPING)
brne l_resetReadTimer_% ; skipping
breq l_readNext_%
; skipping mode, just skip character
inr r16, UDR@0 ; r16=received char
rjmp l_resetReadTimer_% ; skipping
l_readNext_%:
inr r16, UCSR@0A ; check for errors
andi r16, (1<<FE@0) | (1<<DOR@0) | (1<<UPE@0)
brne l_hwerr_%
@@ -184,7 +211,7 @@ l_end_%:
; @clobbers R16, R17, X
.macro M_UARTFD_TXCHAR_ISR
; disable further TXC1 interrupts
; disable further TXC interrupts
inr r16, UCSR@0B
cbr r16, (1<<TXC@0) ; disable TXC interrupt
outr UCSR@0B, r16