From 22a5402141b363ae1cac89290de5f49af71e7939 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 22 Jan 2025 01:10:32 +0100 Subject: [PATCH] avr: receiving flash messages basically works. --- avr/modules/flash/flashprocess.asm | 2 +- avr/modules/flash/io.asm | 2 +- avr/modules/uart_hw/raw_uart1.asm | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/avr/modules/flash/flashprocess.asm b/avr/modules/flash/flashprocess.asm index 79a8843..f09191e 100644 --- a/avr/modules/flash/flashprocess.asm +++ b/avr/modules/flash/flashprocess.asm @@ -41,6 +41,7 @@ flashDataEnd: checkFlash: rcall flashReadUidIntoSdram ; R16, X, Y rcall ioRawInit ; (R16, R17) + ldi xl, LOW(flashSendBuffer) ldi xh, HIGH(flashSendBuffer) rcall flashProcessWriteFlashReady ; (R16, R17, R18, R19, R20, Y, Z) @@ -83,7 +84,6 @@ flashProcess: flashProcess_loop1: ; wait up to 10s for incoming FLASH_DATA message ldi r16, CPRO_CMD_FLASH_DATA - ldi r20, 5 ; wait for 5s (not used!) rcall ioWaitForGivenMsg ; (r16, r17, r18, r19, r20, r22, X) brcc flashProcess_end ; no FLASH_DATA or FLASH_END msg ; either FLASH_DATA or FLASH_END received diff --git a/avr/modules/flash/io.asm b/avr/modules/flash/io.asm index 730c944..ee1073d 100644 --- a/avr/modules/flash/io.asm +++ b/avr/modules/flash/io.asm @@ -22,10 +22,10 @@ ; @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) ioWaitForGivenMsg: + ldi r20, 100 ; number of tries ioWaitForGivenMsg_loop: push r16 rcall ioRawWaitForValidMsg ; (r16, r17, r18, r19, r22, X) diff --git a/avr/modules/uart_hw/raw_uart1.asm b/avr/modules/uart_hw/raw_uart1.asm index 84df837..48da780 100644 --- a/avr/modules/uart_hw/raw_uart1.asm +++ b/avr/modules/uart_hw/raw_uart1.asm @@ -130,6 +130,10 @@ UART_HW_Uart1_DisableRawRecv: ; @clobbers: r16, r17, r18, r19, r22, X UART_HW_Uart1_RawRecvPacket: + lds r19, UCSR1A + cbr r19, (1<