avr: started reworking COM module.

- sending and receiving now basically works again, but too often the
  read buffer is in use when trying to receive a message.
This commit is contained in:
Martin Preuss
2023-04-12 15:30:38 +02:00
parent 0feceeb96e
commit 024d40fc95
21 changed files with 1816 additions and 1926 deletions

View File

@@ -66,7 +66,7 @@ main:
main_loop:
rcall runModulesUntilIdle
; sbi DDRA, PORTA2 ; debug
sbi DDRA, PORTA2 ; debug
; sbi PINA, PORTA2 ; debug (toggle)
; cbi PORTA, PORTA2 ; debug (on)
; sbi PORTA, PORTA2 ; debug (off)
@@ -111,8 +111,8 @@ initModules:
#endif
#ifdef MODULES_COM
rcall Com_Init ; init COM module
rcall CPRO_Init ; init COM protocol module
rcall Com2_Init ; init COM module
rcall CPRO_Init ; init COM protocol module
#endif
#ifdef MODULES_TWI_MASTER
rcall TWI_Master_Init
@@ -152,16 +152,17 @@ runModulesUntilIdle:
#endif
#ifdef MODULES_COM
; COM module (call until carry flag cleared but at most 10 times to not starve other modules)
; COM module (call until carry flag cleared but at most 10 times to not starve other modules)
ldi r16, 10
runModulesUntilIdle_Com:
push r16
rcall Com_Run
rcall Com2_Run
pop r16
brcc runModulesUntilIdle_ComEnd
dec r16
brne runModulesUntilIdle_Com
runModulesUntilIdle_ComEnd:
runModulesUntilIdle_ComEnd:
#endif
; add more modules here
@@ -206,9 +207,94 @@ initialWait_l2: ; wait for 10ms
#ifdef MODULES_LCD
printSendStats:
printStartSendPackage:
in r15, SREG ; debug
push r15
cli
ldi r18, 1
ldi r19, 3
rcall LCD_SetCursor
ldi r16, 'S'
rcall LCD_PrintChar
ldi r16, ' '
rcall LCD_PrintChar
pop r15
out SREG, r15
ret
printEndSendPackage:
in r15, SREG ; debug
push r15
cli
ldi r18, 2
ldi r19, 3
rcall LCD_SetCursor
ldi r16, 'E'
rcall LCD_PrintChar
pop r15
out SREG, r15
ret
printTimerMark:
in r15, SREG ; debug
push r15
cli
ldi r18, 1
ldi r19, 1
rcall LCD_SetCursor
lds r16, timerModuleCounterSecs
rcall LCD_PrintHexByte
pop r15
out SREG, r15
ret
printSendStats:
in r15, SREG ; debug
push r15
cli
ldi r18, 1
ldi r19, 5
rcall LCD_SetCursor
ldi zl, LOW(textStatsPacketsIn)
ldi zh, HIGH(textStatsPacketsIn)
rcall LCD_PrintFromFlash
lds r18, com2StatsPacketsIn
lds r19, com2StatsPacketsIn+1
rcall LCD_PrintHexWord
ldi r18, 1
ldi r19, 6
rcall LCD_SetCursor
ldi zl, LOW(textStatsPacketsOut)
ldi zh, HIGH(textStatsPacketsOut)
rcall LCD_PrintFromFlash
lds r18, com2StatsPacketsOut
lds r19, com2StatsPacketsOut+1
rcall LCD_PrintHexWord
ldi r18, 1
ldi r19, 7
rcall LCD_SetCursor
ldi zl, LOW(textStatsPacketsRecvErr)
ldi zh, HIGH(textStatsPacketsRecvErr)
rcall LCD_PrintFromFlash
lds r18, com2StatsBusyError
lds r19, com2StatsBusyError+1
rcall LCD_PrintHexWord
pop r15
out SREG, r15
ret
#if 0
printSendStats:
in r15, SREG ; debug
push r15
in r15, SREG ; debug
cli
ldi r18, 0
@@ -290,6 +376,7 @@ printSendStats:
pop r15
out SREG, r15
ret
#endif ; if 0
#endif
@@ -297,11 +384,12 @@ printSendStats:
#ifdef MODULES_SI7021
#ifdef MODULES_COM
#if 0
Main_SendValueMsg:
in r15, SREG
push r15
cli
lds r16, comAddress ; do we have an address assigned?
lds r16, com2Address ; do we have an address assigned?
tst r16
breq sendValueMsg_done ; no, do nothing
; send message for current temp
@@ -337,6 +425,7 @@ sendValueMsg_done:
pop r15
out SREG, r15
ret
#endif
#ifdef MODULES_LCD