avr: added guarded ringbuffer routines
This commit is contained in:
@@ -115,3 +115,84 @@ RingBufferY_Reset:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine RingBufferY_ReadByteGuarded
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param r16 byte to write
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
RingBufferY_ReadByteGuarded:
|
||||
push r15
|
||||
in r15, SREG
|
||||
cli
|
||||
rcall RingBufferY_ReadByte ; R17, R18, X
|
||||
brcc RingBufferY_ReadByteGuarded_error
|
||||
out SREG, r15
|
||||
pop r15
|
||||
sec
|
||||
ret
|
||||
RingBufferY_ReadByteGuarded_error:
|
||||
out SREG, r15
|
||||
pop r15
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine RingBufferY_PeekByteGuarded
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param r16 byte to write
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
RingBufferY_PeekByteGuarded:
|
||||
push r15
|
||||
in r15, SREG
|
||||
cli
|
||||
rcall RingBufferY_PeekByte ; R17, R18, X
|
||||
brcc RingBufferY_PeekByteGuarded_error
|
||||
out SREG, r15
|
||||
pop r15
|
||||
sec
|
||||
ret
|
||||
RingBufferY_PeekByteGuarded_error:
|
||||
out SREG, r15
|
||||
pop r15
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine RingBufferY_WriteByteGuarded
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param r16 byte to write
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
RingBufferY_WriteByteGuarded:
|
||||
push r15
|
||||
in r15, SREG
|
||||
cli
|
||||
rcall RingBufferY_WriteByte ; R17, R18, X
|
||||
brcc RingBufferY_WriteByteGuarded_error
|
||||
out SREG, r15
|
||||
pop r15
|
||||
sec
|
||||
ret
|
||||
RingBufferY_WriteByteGuarded_error:
|
||||
out SREG, r15
|
||||
pop r15
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user