diff --git a/avr/att84_bootloader.asm b/avr/att84_bootloader.asm index d33e972..6cf6f44 100644 --- a/avr/att84_bootloader.asm +++ b/avr/att84_bootloader.asm @@ -135,13 +135,14 @@ main: .include "modules/com2/crc.asm" .include "modules/com2/packets.asm" .include "common/crc8.asm" -.include "modules/flash/main.asm" -.include "modules/flash/proto.asm" +.include "modules/flash/bootloader.asm" +.include "modules/flash/flash.asm" .include "modules/flash/recv.asm" .include "modules/flash/send.asm" .include "modules/flash/wait.asm" .include "modules/flash/hdl_flash_start.asm" .include "modules/flash/hdl_flash_data.asm" +.include "modules/flash/hdl_flash_end.asm" .include "modules/flash/flash_rsp.asm" .include "modules/flash/flash_ready.asm" diff --git a/avr/modules/flash/proto.asm b/avr/modules/flash/bootloader.asm similarity index 93% rename from avr/modules/flash/proto.asm rename to avr/modules/flash/bootloader.asm index d4227ae..9133582 100644 --- a/avr/modules/flash/proto.asm +++ b/avr/modules/flash/bootloader.asm @@ -101,14 +101,20 @@ bootLoader: ; try to start firmware bootLoader_startFirmware: - sbi PORTA, PORTA3 ; LED off - - ldi r16, 20 + cbi PORTA, PORTA3 ; LED on + ldi r16, 10 rcall flashWaitForMulti100ms + sbi PORTA, PORTA3 ; LED off + ldi r16, 3 + rcall flashWaitForMulti100ms + cbi PORTA, PORTA3 ; LED on + ldi r16, 10 + rcall flashWaitForMulti100ms + sbi PORTA, PORTA3 ; LED off rjmp firmwareStart bootLoader_waitAndRestartBootLoader: - sbi PORTA, PORTA3 ; LED off + sbi PORTA, PORTA3 ; LED off ldi r16, 20 rcall flashWaitForMulti100ms rjmp bootLoader @@ -170,6 +176,8 @@ bootLoaderFlash_loop1: rcall flashHandleFlashData rjmp bootLoaderFlash_loop1 +bootLoaderFlash_endReceived: + rjmp flashHandleFlashEnd diff --git a/avr/modules/flash/main.asm b/avr/modules/flash/flash.asm similarity index 100% rename from avr/modules/flash/main.asm rename to avr/modules/flash/flash.asm diff --git a/avr/modules/flash/hdl_flash_end.asm b/avr/modules/flash/hdl_flash_end.asm new file mode 100644 index 0000000..dd4f0ab --- /dev/null +++ b/avr/modules/flash/hdl_flash_end.asm @@ -0,0 +1,38 @@ +; *************************************************************************** +; copyright : (C) 2023 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 + + + + +; --------------------------------------------------------------------------- +; Handle FLASH END packet. +; +; IN: +; - X : buffer containing the message +; OUT: +; - CFLAG: set if message is for us, cleared otherwise +; REGS: r16, r18. r19. r20, r21, X (R15, R17, R22) + +flashHandleFlashEnd: + rcall flashWaitFor100ms + clr r16 + rcall flashSendFlashResponse ; (R15, R16, R17, R18, R19, R20, R21, R22, X) + sec + ret + + +