/* lcdtask.Asm Copyright ©1998, 1999 Larry Barello Author: Larry Barello lbarello@accessone.com You are allowed to use this file for personal use only. You may use, embed, modify or distribute the contents of this file in any way you see fit as long as you include this copyright notice in the resulting file. Any commercial or industrial use including publishing or distributing in any form requires the written authorization of the copyright holder(s). No guarantees are made about fitness, functionality, correctness or performance of this file. The file is supplied on a "AS IS" basis, with no responsibility assumed by the author(s) for bug fixes, support, or damages of any sort arising from the use of this file. Contact the author with problem reports or fixes, feature requests or additions and questions. They are welcomed and will be incorporated as time and energy permits. */ #include "Registers.inc" #include "avrx.inc" #include "MotorControl.inc" #include "lcdio.inc" NAME LCDTASK EXTERN TICKRATE AvrXDelay EXTERN Right_Eye Left_Eye RightMotor LeftMotor EXTERN MOTOR LEFT_DIRa RIGHT_DIRa EXTERN lcd_4_init lcd_wr_command lcd_PutHexByte lcd_PutHexWord lcd_putstr EXTERN lcd_put_char EXTERN SmallContext SmallContextSize PUBLIC LCDTaskTcb RSEG AVRXDATA:DATA(0) LCDTaskPid: DS PidSz lcd0: DS TcbSz RSEG SSEG:DATA(1) ;++++++++++++++++++++++++++++++++++++++++++++++ ; Stack = Standard context (10 bytes) + User context (2) + task usage (4) ; AVR stack points to first save location (post dec, pre inc) ; so need one additional byte at location of lable. ; DS 10 ; Standard Context DS 6 ; Task Usage (two calls) DS 2 ; Additional User Context DS 1 ; Room for one interrupt LCDTaskStack: DS 1 RSEG CODE:CODE LCDTIME = TICKRATE/4 ; Update four times a second ;---------------------------------------------- ; LCDTaskTcb: DW LCDTaskStack ; Stack DW LCDTask>>1 ; Start Address DB LCDTaskPid, SmallContextSize DW SmallContext>>1 DB 3 ; Priority ;************************************************************************** ; ; LCD Task ; ; NOTES: ; "0123456789ABCDEF" message1: DB " P E= " message2: DB " P E= " EVEN LCDTask: rcall lcd_4_init ldi LCD_PARM, LCD_FUNC | LCD_N rcall lcd_wr_command ldi LCD_PARM, LCD_CLEAR rcall lcd_wr_command ldi LCD_PARM, LCD_HOME rcall lcd_wr_command ldi LCD_PARM, LCD_DISPLAY | LCD_D | LCD_C ; Display and Cursor ON rcall lcd_wr_command ldi Zl, low(message1) ldi Zh, high(message1) rcall lcd_putstr ldi LCD_PARM, LCD_Next_Line rcall lcd_wr_command ldi Zl, low(message2) ldi Zh, high(message2) rcall lcd_putstr lcdt_0: ldi LCD_PARM, LCD_SET_DDRAM | 0x00 rcall lcd_wr_command lds Yl, RightMotor+1 lds Yh, RightMotor rcall lcd_PutHexWord lds Yl, RightMotor+3 lds Yh, RightMotor+2 rcall lcd_PutHexWord ldi LCD_PARM, '+' sbic MOTOR, RIGHT_DIRa ldi LCD_PARM, '-' rcall lcd_put_char ldi LCD_PARM, LCD_SET_DDRAM | 0x09 rcall lcd_wr_command in Yl, OCR1AL rcall lcd_PutHexByte ldi LCD_PARM, LCD_SET_DDRAM | 0x0E rcall lcd_wr_command lds Yl, Right_Eye rcall lcd_PutHexByte ldi LCD_PARM, LCD_SET_DDRAM | 0x40 rcall lcd_wr_command lds Yl, LeftMotor+1 lds Yh, LeftMotor rcall lcd_PutHexWord lds Yl, LeftMotor+3 lds Yh, LeftMotor+2 rcall lcd_PutHexWord ldi LCD_PARM, '+' sbic MOTOR, LEFT_DIRa ldi LCD_PARM, '-' rcall lcd_put_char ldi LCD_PARM, LCD_SET_DDRAM | 0x49 rcall lcd_wr_command in Yl, OCR1BL rcall lcd_PutHexByte ldi LCD_PARM, LCD_SET_DDRAM | 0x4E rcall lcd_wr_command lds Yl, Left_Eye rcall lcd_PutHexByte rcall lcdwait rjmp lcdt_0 lcdwait: ldi Xl, low(lcd0) ldi Yl, low(LCDTIME) ldi Yh, high(LCDTIME) rjmp AvrXDelay END