avr: consolidated uart_hw module

This commit is contained in:
Martin Preuss
2025-03-27 00:20:58 +01:00
parent 3555b49219
commit 89542e06c9
9 changed files with 290 additions and 507 deletions

View File

@@ -31,7 +31,7 @@ TtyOnUart1_Init:
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
rcall UART_HW_Interface_Init ; (R16, R17, X)
rcall UART_HW_Uart1_Init ; (R16, R17, X)
rcall ttyOnUart1Init ; (R16, R17, X)
ldi r16, TTYONUART1_IFACENUM
std Y+NET_IFACE_OFFS_IFACENUM, r16
ret
@@ -82,7 +82,7 @@ TtyOnUart1_RxCharIsr:
push yh
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
rcall UART_HW_Uart1_RxCharIsr ; (R16, R17, R18, R24, R25, X)
rcall ttyOnUart1RxCharIsr ; (R16, R17, R18, R24, R25, X)
pop yh
pop yl
pop xh
@@ -115,7 +115,7 @@ TtyOnUart1_TxUdreIsr:
push yh
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
rcall UART_HW_Uart1_TxUdreIsr ; (R16, R17, X)
rcall ttyOnUart1TxUdreIsr ; (R16, R17, X)
pop yh
pop yl
pop xh
@@ -146,7 +146,7 @@ TtyOnUart1_TxCharIsr:
push yh
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
rcall UART_HW_Uart1_TxCharIsr ; (R16, R17, R18, X)
rcall ttyOnUart1TxCharIsr ; (R16, R17, R18, X)
pop yh
pop yl
pop xh
@@ -181,7 +181,7 @@ TtyOnUart1_SendBuffer_setBuffer:
rcall UART_HW_Interface_SetWriteBuffer ; (R17)
ldi r17, UART_HW_WRITEMODE_WRITING
std Y+UART_HW_IFACE_OFFS_WRITEMODE, r17
rcall UART_HW_Uart1_StartTx ; (R16)
rcall ttyOnUart1StartTx ; (R16)
pop r15
out SREG, r15
sec
@@ -284,7 +284,7 @@ ttyOnUart1RunWaitBufferEmpty_checkTimer:
ldd r16, Y+NET_IFACE_OFFS_WRITETIMER
cpi r16, 10
brcs ttyOnUart1RunWaitBufferEmpty_end
rcall UART_HW_Uart1_StopTx ; disable transceiver and interrupts (R16)
rcall ttyOnUart1StopTx ; disable transceiver and interrupts (R16)
ldi r16, NET_IFACE_OFFS_ERR_COLLISIONS_LOW
rcall NET_Interface_IncCounter16 ; (R24, R25)
ttyOnUart1RunWaitBufferEmpty_enterIdle:
@@ -302,7 +302,7 @@ ttyOnUart1RunWaitBufferEmpty_end:
; @clobbers R16, R17, X (R24, R25)
ttyOnUart1RunWriteBufferEmpty:
rcall UART_HW_Uart1_StopTx ; disable transceiver and interrupts (R16)
rcall ttyOnUart1StopTx ; disable transceiver and interrupts (R16)
ldi r16, UART_HW_WRITEMODE_IDLE
std Y+UART_HW_IFACE_OFFS_WRITEMODE, r16
ldi r16, NET_IFACE_OFFS_PACKETSOUT_LOW ; increment packets counter
@@ -342,7 +342,7 @@ ttyOnUart1RunReadIdle:
brcc ttyOnUart1RunReadIdle_noBuf
ldi r16, UART_HW_READMODE_READING
std Y+UART_HW_IFACE_OFFS_READMODE, r16
rcall UART_HW_Uart1_StartRx ; R16
rcall ttyOnUart1StartRx ; R16
ret
ttyOnUart1RunReadIdle_noBuf:
ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW
@@ -400,3 +400,115 @@ ttyOnUart1RunMsgReceived:
; ---------------------------------------------------------------------------
; @routine ttyOnUart1Init @global
;
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_STATE)
; @clobbers R16, R17, X
ttyOnUart1Init:
M_UART_HW_Uart_Init 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1StartRx @global
;
; @clobbers R16
ttyOnUart1StartRx:
M_UART_HW_Uart_StartRx 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1StopRx @global
;
; @clobbers R16
ttyOnUart1StopRx:
M_UART_HW_Uart_StopRx 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1StartTx @global
;
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_STATE)
; @clobbers R16
ttyOnUart1StartTx:
M_UART_HW_Uart_StartTx 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1StopTx @global
;
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_STATE)
; @clobbers R16
ttyOnUart1StopTx:
M_UART_HW_Uart_StopTx 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1RxCharIsr @global
;
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_MODE)
; @clobbers R16 (R17, R18, R24, R25, X)
ttyOnUart1RxCharIsr:
M_UART_HW_Uart_RxCharFullDuplexIsr 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1TxUdreIsr @global
;
; Handler for UDRE1 interrupt called when TX data register is empty.
;
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_MODE)
; @clobbers R16, R17, X
ttyOnUart1TxUdreIsr:
M_UART_HW_Uart_TxUdreIsr 1
ret
; @end
; ---------------------------------------------------------------------------
; @routine ttyOnUart1TxCharIsr @global
;
; Handler for TXC1 interrupt called when a last byte has been completely sent and
; the data register is empty.
;
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_MODE)
; @clobbers R16
ttyOnUart1TxCharIsr:
M_UART_HW_Uart_TxCharIsr 1
ret
; @end