; *************************************************************************** ; copyright : (C) 2025 by Martin Preuss ; email : martin@libchipcard.de ; ; *************************************************************************** ; * This file is part of the project "AqHome". * ; * Please see toplevel file COPYING of that project for license details. * ; *************************************************************************** ; *************************************************************************** ; code .cseg ; --------------------------------------------------------------------------- ; @routine flashWaitForGivenMsg ; Wait for incoming msg with given command ; ; @return CFLAG set if okay (packet received), cleared on error ; @return r16 code of received msg ; @param r16 command to wait for ; @param r20 time in seconds to wait for a message ; @clobbers: r16, r17, r20, X (r18, r19, r22) flashWaitForGivenMsg: flashWaitForGivenMsg_loop: push r16 rcall flashRawWaitForValidMsg ; (r16, r17, r18, r19, r22, X) pop r16 brcc flashWaitForGivenMsg_end ldi xl, LOW(flashRecvBuffer) ldi xh, HIGH(flashRecvBuffer) adiw xh:xl, COM2_MSG_OFFS_CMD ld r17, X sbiw xh:xl, COM2_MSG_OFFS_CMD cp r16, r17 breq flashWaitForGivenMsg_gotIt cpi r16, CPRO_CMD_FLASH_END breq flashWaitForGivenMsg_gotIt dec r20 brne flashWaitForGivenMsg_loop clc rjmp flashWaitForGivenMsg_end flashWaitForGivenMsg_gotIt: sec flashWaitForGivenMsg_end: ret ; @end