avr: more work on hardware based uart module.
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
uartHwDataBegin:
|
||||
; fixed buffers for incoming and outgoing messages
|
||||
uartHw_buffers: .byte UART_HW_FIXEDBUFFERS_NUM*UART_HW_FIXEDBUFFERS_SIZE
|
||||
uartHw_ringBufferMsgNumIn: .byte UART_HW_MSGNUMINBUF_SIZE
|
||||
uartHw_ringBufferMsgNumOut: .byte UART_HW_MSGNUMOUTBUF_SIZE
|
||||
uartHwDataEnd:
|
||||
|
||||
|
||||
@@ -53,18 +55,34 @@ UART_HW_FixedBuffers_Alloc:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_FixedBuffers_Release @global
|
||||
; @routine UART_HW_FixedBuffers_ReleaseByAddr @global
|
||||
;
|
||||
; @param X pointer to start of buffers
|
||||
; @clobbers R16
|
||||
|
||||
UART_HW_FixedBuffers_Release:
|
||||
UART_HW_FixedBuffers_ReleaseByAddr:
|
||||
m_fixedbuf_release
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_FixedBuffers_ReleaseByNum @global
|
||||
;
|
||||
; @param r16 buffer number
|
||||
; @clobbers X (R16)
|
||||
|
||||
UART_HW_FixedBuffers_ReleaseByNum:
|
||||
rcall UART_HW_FixedBuffers_Locate ; (R16)
|
||||
brcc UART_HW_FixedBuffers_ReleaseByNum_end
|
||||
rcall UART_HW_FixedBuffers_ReleaseByAddr ; (R16)
|
||||
UART_HW_FixedBuffers_ReleaseByNum_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_FixedBuffers_Locate
|
||||
;
|
||||
@@ -99,3 +117,88 @@ UART_HW_FixedBuffers_Locate_end:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_AddIncomingMsg @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param R16 buffer number of the next incoming message
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
UART_HW_AddIncomingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
ldi yl, LOW(uartHw_ringBufferMsgNumIn)
|
||||
ldi yh, HIGH(uartHw_ringBufferMsgNumIn)
|
||||
rcall RingBufferY_WriteByte ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_GetNextIncomingMsgNum @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @return R16 buffer number of the next incoming message
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
UART_HW_GetNextIncomingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
ldi yl, LOW(uartHw_ringBufferMsgNumIn)
|
||||
ldi yh, HIGH(uartHw_ringBufferMsgNumIn)
|
||||
rcall RingBufferY_ReadByte ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_AddOutgoingMsg @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param R16 buffer number of the next incoming message
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
UART_HW_AddOutgoingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
ldi yl, LOW(uartHw_ringBufferMsgNumOut)
|
||||
ldi yh, HIGH(uartHw_ringBufferMsgNumOut)
|
||||
rcall RingBufferY_WriteByte ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine UART_HW_GetNextOutgoingMsgNum @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @return R16 buffer number of the next incoming message
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
UART_HW_GetNextOutgoingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
ldi yl, LOW(uartHw_ringBufferMsgNumOut)
|
||||
ldi yh, HIGH(uartHw_ringBufferMsgNumOut)
|
||||
rcall RingBufferY_ReadByte ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user