avr: more work on uart_hw module.
This commit is contained in:
@@ -14,33 +14,23 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_Interface_RunWrite @global
|
||||
;
|
||||
; Get messages via @ref UART_HW_GetNextOutgoingMsgNum and fill them into
|
||||
; the outbound ringbuffer of this interface.
|
||||
;
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers r16, r19, X (R17, R18, R20, R21)
|
||||
|
||||
UART_HW_Interface_RunWrite:
|
||||
ldd r19, Y+UART_HW_IFACE_OFFS_WRITEMSG_BUFNUM
|
||||
cpi r19, 0xff
|
||||
brne UART_HW_Interface_RunWrite_haveMsg
|
||||
rcall UART_HW_GetNextOutgoingMsgNum ; (R17, R18, X)
|
||||
rcall UART_HW_FixedBuffers_Locate ; (R16)
|
||||
brcc UART_HW_Interface_RunWrite_end
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_BUFNUM, r19
|
||||
adiw xh:xl, 1
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_PTR, xl
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_PTR+1, xh
|
||||
adiw xh:xl, 1 ; get msg len
|
||||
ld r16, X
|
||||
inc r16
|
||||
inc r16
|
||||
inc r16
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_LEFT, r16
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_USED, r16
|
||||
breq UART_HW_Interface_RunWrite_end ; nothing to do
|
||||
UART_HW_Interface_RunWrite_haveMsg:
|
||||
ldd r20, Y+UART_HW_IFACE_OFFS_WRITEMSG_LEFT
|
||||
rcall uartHwWriteUptoNumBytes ; (r16, r17, r18, r20, r21, X)
|
||||
ldd r16, Y+UART_HW_IFACE_OFFS_WRITEMSG_LEFT
|
||||
tst r16
|
||||
brne UART_HW_Interface_RunWrite_end ; still bytes left to write
|
||||
; message completely sent to interface, release buffer
|
||||
ldd r16, Y+UART_HW_IFACE_OFFS_WRITEMSG_BUFNUM
|
||||
rcall UART_HW_FixedBuffers_ReleaseByNum
|
||||
ldi r16, 0xff ; reset buffer number
|
||||
@@ -51,6 +41,35 @@ UART_HW_Interface_RunWrite_end:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_Interface_WriteSetBuffer
|
||||
;
|
||||
; Set given fixed buffer as source for @ref UART_HW_Interface_RunWrite.
|
||||
;
|
||||
; @param r16 buffer num
|
||||
; @clobbers r16, r19, X
|
||||
|
||||
UART_HW_Interface_WriteSetBuffer:
|
||||
mov r19, r16
|
||||
rcall UART_HW_FixedBuffers_Locate ; (R16)
|
||||
brcc UART_HW_Interface_WriteSetBuffer_end
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_BUFNUM, r19
|
||||
adiw xh:xl, 1
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_PTR, xl
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_PTR+1, xh
|
||||
adiw xh:xl, 1 ; get msg len
|
||||
ld r16, X
|
||||
inc r16 ; adjust for destination addr byte
|
||||
inc r16 ; adjust for msg len byte
|
||||
inc r16 ; adjust for crc byte
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_LEFT, r16
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEMSG_USED, r16
|
||||
UART_HW_Interface_WriteSetBuffer_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine uartHwWriteUptoNumBytes
|
||||
;
|
||||
@@ -84,3 +103,4 @@ uartHwWriteUptoNumBytes_done:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user