From 73f749b5bb25d66d8f26292fbcf1d5311d7b5f79 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 10 Sep 2024 10:25:29 +0200 Subject: [PATCH] Revert "avr: make lcdOneByteCommand() and lcdTwoByteCommand() more generic." This reverts commit 28882010a98445a534488a7bc6abb23420b474d1. --- avr/modules/lcd/main.asm | 74 ++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/avr/modules/lcd/main.asm b/avr/modules/lcd/main.asm index 120d72a..7b21f79 100644 --- a/avr/modules/lcd/main.asm +++ b/avr/modules/lcd/main.asm @@ -128,59 +128,40 @@ LCD_Fini: ; ; @return nothing ; @param r16 1=sleep, 0=awake -; @clobbers r15, r16, r20 (R17, R18, R22) -; - -LCD_Sleep: - ldi r20, 0xae ; set sleep - tst r16 - brne LCD_Sleep_send - ldi r20, 0xaf ; set wake -LCD_Sleep_send: - ldi r23, LCD_MODE_MULTICMD - rjmp lcdOneByteMsg -; @end - - - -; --------------------------------------------------------------------------- -; @routine LCD_SetContrast @global -; -; @return nothing -; @param r16 contrast value (0-255) ; @clobbers r15, r16, r19 (R17, R18, R22) ; -LCD_SetContrast: - ldi r23, LCD_MODE_MULTICMD - ldi r20, 0x81 - mov r21, r16 - rjmp lcdTwoByteMsg +LCD_Sleep: + ldi r16, 0xae ; set sleep + tst r19 + brne LCD_Sleep_send + ldi r16, 0xaf ; set wake +LCD_Sleep_send: + rjmp lcdOneByteCommand ; @end ; --------------------------------------------------------------------------- -; @routine lcdOneByteMsg +; @routine lcdOneByteCommand ; Send a one byte command ; ; @return nothing -; @param r23 packet type (LCD_MODE_MULTICMD, LCD_MODE_DATA etc) ; @param r20 first byte of command ; @clobbers r15, r16, r19 (R17, R18, R22) ; -lcdOneByteMsg: +lcdOneByteCommand: in r15, SREG push r15 cli - rcall lcdBeginMsg - brcc lcdOneByteMsg_error + rcall lcdBeginMultiCommand + brcc lcdOneByteCommand_error mov r16, r20 rcall twiSendByteExpectAck ; (R16, R17, R18, R22) - brcc lcdOneByteMsg_error + brcc lcdOneByteCommand_error rcall twiStop ; (R22) pop r15 @@ -188,38 +169,37 @@ lcdOneByteMsg: sec ret -lcdOneByteMsg_error: +lcdOneByteCommand_error: rjmp lcdTwiStopPopR15ClcRet ; (R22) ; @end ; --------------------------------------------------------------------------- -; @routine lcdTwoByteMsg +; @routine lcdTwoByteCommand ; Send a two byte command ; ; @return nothing -; @param r23 packet type (LCD_MODE_MULTICMD, LCD_MODE_DATA etc) ; @param r20 first byte of command ; @param r21 second byte of command ; @clobbers r15, r16, r19 (R17, R18, R22) ; -lcdTwoByteMsg: +lcdTwoByteCommand: in r15, SREG push r15 cli - rcall lcdBeginMsg - brcc lcdTwoByteMsg_error + rcall lcdBeginMultiCommand + brcc lcdTwoByteCommand_error mov r16, r20 rcall twiSendByteExpectAck ; (R16, R17, R18, R22) - brcc lcdTwoByteMsg_error + brcc lcdTwoByteCommand_error mov r16, r21 rcall twiSendByteExpectAck ; (R16, R17, R18, R22) - brcc lcdTwoByteMsg_error + brcc lcdTwoByteCommand_error rcall twiStop ; (R22) pop r15 @@ -227,31 +207,30 @@ lcdTwoByteMsg: sec ret -lcdTwoByteMsg_error: +lcdTwoByteCommand_error: rjmp lcdTwiStopPopR15ClcRet ; (R22) ; @end ; --------------------------------------------------------------------------- -; @routine lcdBeginMsg +; @routine lcdBeginMultiCommand ; Send a two byte command ; ; @return nothing -; @param r23 packet type (LCD_MODE_MULTICMD, LCD_MODE_DATA etc) +; @param r20 first byte of command +; @param r21 second byte of command ; @clobbers r16, (R17, R18, R22) ; -lcdBeginMsg: +lcdBeginMultiCommand: rcall twiStart ; (R22) ldi r16, (LCD_TWI_ADDRESS*2) rcall twiSendByteExpectAck ; (R16, R17, R18, R22) - brcc lcdBeginMsg_error + brcc lcdTwoByteCommand_error - mov r16, r23 + ldi r16, LCD_MODE_MULTICMD rjmp twiSendByteExpectAck ; (R16, R17, R18, R22) -lcdBeginMsg_error: - ret ; @end @@ -689,7 +668,6 @@ lcdPrintOneChar_error: ret - ; --------------------------------------------------------------------------- ; lcdGetCharMatrix ;