main: added debug code.

This commit is contained in:
Martin Preuss
2023-01-22 00:17:21 +01:00
parent a9ff8d2277
commit 705562d881

View File

@@ -17,7 +17,7 @@
; ---------------------------------------------------------------------------
; COM module
.equ COM_BIT_LENGTH = 104000 ; 104000=9600, 52000=19200, 26000=38400
.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400
.equ COM_RINGBUFFER_SIZE = 32 ; 32 bytes for now
@@ -97,6 +97,7 @@ ledA3Sram: .byte LED_SRAM_SIZE
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
blinkPattern: .db 5, 5, 5, 5, 5, 10, 0xff, 0xff ; 3 short blinks, 1s pause, restart
blinkPattern2: .db 10, 20, 0xff, 0xff ; 1 long blink, 2s pause, restart
@@ -122,9 +123,14 @@ main:
ldi yh, HIGH(ledA3Sram)
rcall Led_SetPattern
ldi r17, 219 ; debug
rcall COM_EnqueuePing ; debug
; ldi r17, 219 ; debug
; rcall COM_EnqueuePing ; debug
; nop
; nop
; nop
; ldi r16, 4
; rcall RingBuffer_DeallocRead
; rjmp PC+0
main_loop:
rcall runModulesUntilIdle
@@ -233,18 +239,53 @@ onEvery100ms:
; USED: depending on called routines
onEverySecond:
; ldi r17, 219
; rcall COM_EnqueuePing
in r15, SREG ; debug
cli
push r15
ldi r18, 0
rcall comSendPacketRaw
ldi yl, LOW(comRingBuffer)
ldi yh, HIGH(comRingBuffer)
ldd r16, y+RINGBUFFER_OFFS_USED
rcall debugSendByte
ldi r17, 219
rcall COM_EnqueuePing
rcall comHandleNextPacketInRingbuffer
; brcc debug1
rjmp debugEnd
rcall comHandleNextPacketInRingbuffer
brcs debug2 ; CF set should not be okay here
ldi r16, 9
rcall debugSendByte
rjmp debugEnd
debug1:
ldi r16, 5
rcall debugSendByte
rjmp debugEnd
debug2:
ldi r16, 17
rcall debugSendByte
debugEnd:
pop r15
out SREG, r15
; in r15, SREG ; debug
; cli
; push r15
; ldi r18, 0
; rcall comSendPacketRaw
; pop r15
; out SREG, r15
; in r15, SREG ; debug
; cli
; push r15
@@ -278,3 +319,36 @@ onPacketReceived:
debugSendByte:
in r15, SREG ; debug
cli
ldi r17, 8
sbi DDRA, PORTA2 ; debug
cbi PORTA, PORTA2 ; debug (on)
Utils_WaitNanoSecs 200000, 0, r22 ; start with 2t low
debugSendByte_loop:
lsr r16
brcs debugSendByte_sendLow
cbi PORTA, PORTA2 ; debug (on)
rjmp debugSendByte_wait
debugSendByte_sendLow:
sbi PORTA, PORTA2 ; debug (off)
debugSendByte_wait:
Utils_WaitNanoSecs 100000, 0, r22
dec r17
brne debugSendByte_loop
cbi PORTA, PORTA2 ; debug (on)
Utils_WaitNanoSecs 200000, 0, r22 ; end with 2t low
sbi PORTA, PORTA2 ; debug (off)
out SREG, r15
ret