From 4864d1648256999dc63409c2561c78488a7ca795 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 30 Jan 2023 01:02:31 +0100 Subject: [PATCH] twi_master: add routine twiReceiveByteSendAck. --- avr/twimaster.asm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/avr/twimaster.asm b/avr/twimaster.asm index 5b156a3..31a224d 100644 --- a/avr/twimaster.asm +++ b/avr/twimaster.asm @@ -340,6 +340,32 @@ twiReceiveByte_error: +; --------------------------------------------------------------------------- +; twiReceiveByteSendAck +; +; Read a byte from the bus. Sends ACK bit. +; +; IN: +; OUT: +; - CARRY flag set: okay, cleared on error +; - R16: byte received +; USED: R16, R17, R18, R22 + +twiReceiveByteSendAck: + rcall twiReceiveByte + brcc twiReceiveByteSendAck_error + push r16 + clr r16 + rcall twiWriteBit ; send ACK (R16, R22) + pop r16 + sec + ret +twiReceiveByteSendAck_error: + clc + ret + + + TWI_Master_ScanNext: in r15, SREG cli