; SXUI assembler part: ; terminal screen functions ; V1.0 ja june 2002 ;------------------------------------------------------- ; .include "aio8515.s" .include "aio8535.s" .area text ;------------------------------------------------------- ; cCharMinus = 0x2d ; cChar0 = 0x30 ; ; ; cLCDlinelen = 20 ; cLCDlines = 4 ; ; cLCDclear = 0x01 ; cLCDhome = 0x02 ; cLCDemode = 0x06 ; cLCDoff = 0x08 ; cLCDon = 0x0d ; cLCDfunct1 = 0x30 ; init for 8bit i/f cLCDfunct2 = 0x20 ; 4bit i/f, 2lines cLCDsetcga = 0x40 ; cLCDsetdda = 0x80 ; ; ; LCD_rs_ = (PORTC<<8) + 1 LCD_rsd_ = (DDRC<<8) + 1 LCD_e_ = (PORTC<<8) + 3 LCD_ed_ = (DDRC<<8) + 3 LCD_wr_ = (PORTC<<8) + 2 LCD_wrd_ = (DDRC<<8) + 2 ; LCDdout = PORTC LCDdin = PINC LCDddr = DDRC ; ;------------------------------------------------------- ; there are some basic times ; pause40us_ = (40-5) pause2ms_ = (2000-5) pause50ms_ = (50000-5) ; ; to be used for: ; LCDpause4byte: pause40us: st -Y,R25 st -Y,R24 ldi R25,>pause40us_ ldi R24,pause2ms_ ldi R24,pause50ms_ ldi R24,LCD_e_,LCD_ed_,LCD_wr_,LCD_wrd_,LCD_rs_,LCD_rsd_,4.2ms rcall pause2ms rcall pause2ms ldi R16,cLCDfunct1 rcall LCD_put4b rcall pause40us ; wait >100us rcall pause40us rcall pause40us ; ldi R16,cLCDfunct1 ; rcall LCD_put4b ; ldi R16,cLCDfunct1 rcall LCDputcmd ldi R16,cLCDfunct2 rcall LCDputcmd ldi R16,cLCDemode rcall LCDputcmd ldi R16,cLCDon rcall LCDputcmd ldi R16,cLCDclear rcall LCDputcmd rjmp LCDpause4clr ; ;------------------------------------------------------- ; _LCDsetXY:: sbrc R18,1 ; z0/1 oder subi R16,-20 ; Z2/3 sbrc R18,0 ; z0/2 oder subi R16,-0x40 ; Z1/3 ori R16,cLCDsetdda rjmp LCDputcmd ; ; _LCDclear:: ldi R16,cLCDclear rcall LCDputcmd rjmp LCDpause4clr ; ; _LCDhome:: ldi R16,cLCDhome rcall LCDputcmd rjmp LCDpause4home ; ;------------------------------------------------------- ; ; put int as ascii to LCD ; ; void LCDputint (int byte, char min_prec) ; _LCDputint:: mov R2,R16 mov R3,R17 mov R4,R18 ; minimum precision clr R5 ; show zeroes flag sbrs R17,7 rjmp LCDputint1 ; value is positive ldi R16,0xFF com R3 neg R2 sbc R3,R16 ldi R16,cCharMinus rcall _LCDputchar LCDputint1: ldi R19,>10000 ldi R18,<10000 ldi R17,5 rcall LCDputintchar ; ldi R19,>1000 ldi R18,<1000 ldi R17,4 rcall LCDputintchar ; ldi R19,>100 ldi R18,<100 ldi R17,3 rcall LCDputintchar ; ldi R19,>10 ldi R18,<10 ldi R17,2 rcall LCDputintchar ; ldi R16,cChar0 add R16,R2 rjmp _LCDputchar ; ; LCDputintchar: ldi R16,cChar0 LCDputintdiv1: inc R16 sub R2,R18 sbc R3,R19 breq LCDputintdiv2 brsh LCDputintdiv1 add R2,R18 adc R3,R19 dec R16 LCDputintdiv2: cpi R16,cChar0 brne LCDputintdiv3 ; on NE '0' goto put ... cp R4,R17 ; on EQ '0' check prec brlo LCDputintdivx ; if lower skip output ... LCDputintdiv3: rcall _LCDputchar inc R5 ; set "show zereos" LCDputintdivx: ret ; ;------------------------------------------------------- ; ; put text to LCD ; ; void LCDputcstr (const char *str) ; _LCDputcstr:: mov R30,R16 mov R31,R17 LCDputcstr1: st -Y,R0 lpm mov R16,R0 ld R0,Y+ tst R16 breq LCDputcstrx rcall _LCDputchar adiw R30,1 rjmp LCDputcstr1 LCDputcstrx: ret ; ; void LCDputstr (char *str) ; _LCDputstr:: mov R30,R16 mov R31,R17 LCDputstr1: ld R16,Z+ tst R16 breq LCDputstrx rcall _LCDputchar rjmp LCDputstr1 LCDputstrx: ret ; ; void LCDputchar (char chr) ; _LCDputchar:: cpi R16,0x60 ; chr ; brlo LCDputcharx ; brlo LCDputdata ; < '`' breq LCDputarrow1 ; == '`' cpi R16,0x7b ; breq LCDputcharae ; == 'ä' cpi R16,0x7c ; breq LCDputcharoe ; == 'ö' cpi R16,0x7d ; breq LCDputcharue ; == 'ü' cpi R16,0x7e ; breq LCDputcharsz ; == 'ß' LCDputcharx: rjmp LCDputdata ; LCDputarrow1: ldi R16,0x7e ; rjmp LCDputdata LCDputcharae: ldi R16,0xe1 ; rjmp LCDputdata LCDputcharoe: ldi R16,0xef ; rjmp LCDputdata LCDputcharue: ldi R16,0xf5 ; rjmp LCDputdata LCDputcharsz: ldi R16,0xe2 ; rjmp LCDputdata ; ;------------------------------------------------------- ; ; low level put to LCD ; LCDputcmd:: cbi >LCD_rs_,LCD_rs_,LCD_rs_,LCD_wr_,LCD_e_,LCD_e_,LCD_rs_,LCD_rs_,LCD_wr_,LCD_e_,LCD_e_,