avr: bootloader partially works now but stops after 3 messages...
This commit is contained in:
@@ -16,28 +16,52 @@
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine flashWaitForAttnState
|
||||
; @routine ioWaitForAttnState100ms
|
||||
;
|
||||
; @param r16 expected state (0x00 or 0xff)
|
||||
; @param r17 time to wait for expected state (in milliseconds)
|
||||
; @clobbers
|
||||
; @param r17 time to wait for expected state (in 100 ms units)
|
||||
; @clobbers R17 (R22, R24)
|
||||
|
||||
flashWaitForAttnState:
|
||||
flashWaitForAttnState_loop:
|
||||
rcall flashWaitForAttnState1ms ; (R22, R24)
|
||||
brcs flashWaitForAttnState_stateReached
|
||||
ioWaitForAttnState100ms:
|
||||
ioWaitForAttnState100ms_loop:
|
||||
push r17
|
||||
ldi r17, 100
|
||||
rcall ioWaitForAttnStateMilliSeconds ; (R22, R24)
|
||||
pop r17
|
||||
brcs ioWaitForAttnState100ms_stateReached
|
||||
dec r17
|
||||
brne flashWaitForAttnState_loop
|
||||
brne ioWaitForAttnState100ms_loop
|
||||
clc
|
||||
ret
|
||||
flashWaitForAttnState_stateReached:
|
||||
ioWaitForAttnState100ms_stateReached:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine flashWaitForAttnState1ms
|
||||
; @routine ioWaitForAttnStateMilliSeconds
|
||||
;
|
||||
; @param r16 expected state (0x00 or 0xff)
|
||||
; @param r17 time to wait for expected state (in milliseconds)
|
||||
; @clobbers R17 (R22, R24)
|
||||
|
||||
ioWaitForAttnStateMilliSeconds:
|
||||
ioWaitForAttnStateMilliSeconds_loop:
|
||||
rcall ioWaitForAttnState1ms ; (R22, R24)
|
||||
brcs ioWaitForAttnStateMilliSeconds_stateReached
|
||||
dec r17
|
||||
brne ioWaitForAttnStateMilliSeconds_loop
|
||||
clc
|
||||
ret
|
||||
ioWaitForAttnStateMilliSeconds_stateReached:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ioWaitForAttnState1ms
|
||||
;
|
||||
; Wait for up to 1ms for ATTN line to reach the given state
|
||||
;
|
||||
@@ -45,22 +69,23 @@ flashWaitForAttnState_stateReached:
|
||||
; @param R16 expected state (0xff for high, 0 for low)
|
||||
; @clobbers R24 (R22)
|
||||
|
||||
flashWaitForAttnState1ms:
|
||||
ioWaitForAttnState1ms:
|
||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
||||
ldi r24, 100
|
||||
flashWaitForAttnState1ms_loop:
|
||||
ioWaitForAttnState1ms_loop:
|
||||
push r17
|
||||
in r17, COM_ATTN_INPUT
|
||||
eor r17, r16
|
||||
andi r17, (1<<COM_ATTN_PIN)
|
||||
pop r17
|
||||
breq flashWaitForAttnState1ms_stateReached
|
||||
breq ioWaitForAttnState1ms_stateReached
|
||||
rcall Utils_WaitFor10MicroSecs ; wait for 10us (R22)
|
||||
dec r24
|
||||
brne flashWaitForAttnState1ms_loop
|
||||
rjmp flash_recv_clc_ret
|
||||
flashWaitForAttnState1ms_stateReached:
|
||||
brne ioWaitForAttnState1ms_loop
|
||||
clc
|
||||
ret
|
||||
ioWaitForAttnState1ms_stateReached:
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
Reference in New Issue
Block a user