avr: more work on uart_hw.
This commit is contained in:
@@ -8,19 +8,49 @@
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_InitInterface @global
|
||||
; @routine UART_HW_Init @global
|
||||
;
|
||||
; Initializes buffers.
|
||||
;
|
||||
; @clobbers R16, R17, X, Y
|
||||
|
||||
UART_HW_Init:
|
||||
ldi xh, HIGH(uartHwDataBegin)
|
||||
ldi xl, LOW(uartHwDataBegin)
|
||||
clr r16
|
||||
ldi r17, (uartHwDataEnd-uartHwDataBegin)
|
||||
rcall Utils_FillSram
|
||||
|
||||
rcall UART_HW_FixedBuffers_Init
|
||||
|
||||
ldi r16, UART_HW_MSGNUMINBUF_SIZE
|
||||
ldi yl, LOW(uartHw_ringBufferMsgNumIn)
|
||||
ldi yh, HIGH(uartHw_ringBufferMsgNumIn)
|
||||
rcall RingBufferY_Init
|
||||
|
||||
ldi r16, UART_HW_MSGNUMOUTBUF_SIZE
|
||||
ldi yl, LOW(uartHw_ringBufferMsgNumOut)
|
||||
ldi yh, HIGH(uartHw_ringBufferMsgNumOut)
|
||||
rcall RingBufferY_Init
|
||||
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_InterfaceInit @global
|
||||
;
|
||||
; @param Y pointer to interface data in SRAM (see @ref UART_HW_IFACE_OFFS_STATE)
|
||||
; @param Z pointer to IFACE jump table for the given interface
|
||||
; @clobbers R16, R17, X
|
||||
|
||||
UART_HW_InitInterface:
|
||||
UART_HW_InterfaceInit:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r17, UART_HW_IFACE_SIZE
|
||||
@@ -38,14 +68,49 @@ UART_HW_InitInterface:
|
||||
UART_HW_IFACE_OFFS_MSGIDBUF_DATA
|
||||
ldi r16, 0xff
|
||||
std Y+UART_HW_IFACE_OFFS_READBUFFERNUM, r16
|
||||
std Y+UART_HW_IFACE_OFFS_WRITEBUFFERNUM, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_InterfaceAddReadByte
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param r16 byte to write
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
UART_HW_InterfaceAddReadByte:
|
||||
push yl
|
||||
push yh
|
||||
adiw yh:yl, UART_HW_IFACE_OFFS_RINGBUF_MAX
|
||||
rcall RingBufferY_WriteByte ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_InterfaceGetNextReadByte
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @return R16 byte read
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
UART_HW_InterfaceGetNextReadByte:
|
||||
push yl
|
||||
push yh
|
||||
adiw yh:yl, UART_HW_IFACE_OFFS_RINGBUF_MAX
|
||||
rcall RingBufferY_ReadByte ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user