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

@@ -134,39 +134,42 @@ LCD_Fini:
LCD_SetCursor:
in r15, SREG
cli
mov r1, r18
mov r2, r19
rcall twiStart ; (R22)
ldi r16, (LCD_TWI_ADDRESS*2)
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
ldi r16, LCD_CMD_MODE
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
mov r16, r2
andi r16, 0x07
ori r16, 0xb0 ; Set Page Start Address for Page Addressing Mode
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
mov r16, r1
andi r16, 0x0f ; Set Lower Column Start Address
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
mov r16, r1
swap r16
andi r16, 0x0f
ori r16, 0x10 ; Set Higher Column Start Address
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
rcall twiStop ; (R22)
push r15
cli
mov r1, r18
mov r2, r19
rcall twiStart ; (R22)
ldi r16, (LCD_TWI_ADDRESS*2)
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
ldi r16, LCD_CMD_MODE
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
mov r16, r2
andi r16, 0x07
ori r16, 0xb0 ; Set Page Start Address for Page Addressing Mode
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
mov r16, r1
andi r16, 0x0f ; Set Lower Column Start Address
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
mov r16, r1
swap r16
andi r16, 0x0f
ori r16, 0x10 ; Set Higher Column Start Address
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_SetCursor_error
rcall twiStop ; (R22)
pop r15
out SREG, r15
sec
ret
LCD_SetCursor_error:
rcall twiStop ; (R22)
rcall twiStop ; (R22)
pop r15
out SREG, r15
clc
ret
@@ -295,23 +298,26 @@ LCD_PrintFromFlash_error:
LCD_PrintChar:
in r15, SREG
cli
rcall twiStart
ldi r16, (LCD_TWI_ADDRESS*2)
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_PrintChar_error
ldi r16, LCD_DATA_MODE
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_PrintChar_error
rcall lcdPrintOneChar
brcc LCD_PrintChar_error
rcall twiStop
push r15
cli
rcall twiStart
ldi r16, (LCD_TWI_ADDRESS*2)
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_PrintChar_error
ldi r16, LCD_DATA_MODE
rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcc LCD_PrintChar_error
rcall lcdPrintOneChar
brcc LCD_PrintChar_error
rcall twiStop
pop r15
out SREG, r15
sec
ret
LCD_PrintChar_error:
rcall twiStop
rcall twiStop
pop r15
out SREG, r15
clc
ret