diff --git a/avr/twimaster.asm b/avr/twimaster.asm index 6f20562..5b156a3 100644 --- a/avr/twimaster.asm +++ b/avr/twimaster.asm @@ -2,7 +2,7 @@ ; *************************************************************************** ; defines -.equ TWI_BIT_LENGTH = 100000 ; 100000 and 200000 works for display +.equ TWI_BIT_LENGTH = 10000 ; 100000 and 200000 works for display: 10000, 100000, 200000 @@ -285,6 +285,30 @@ twiSendByte_error: +; --------------------------------------------------------------------------- +; twiSendByteExpectAck +; +; Write a byte to the bus and expect ACK response. +; +; IN: +; - R16: byte to send +; OUT: +; - CARRY flag set: okay, cleared on error (including case of non-ACK response) +; USED: R16, R17, R18, R22 + +twiSendByteExpectAck: + rcall twiSendByte + brcc twiSendByteExpectAck_error + tst r16 + brne twiSendByteExpectAck_error + sec + ret +twiSendByteExpectAck_error: + clc + ret + + + ; --------------------------------------------------------------------------- ; twiReceiveByte ;