/* Copyright: Hagen Reddmann mailto HaReddmann at T-Online dot de Author: Hagen Reddmann Remarks: this Copyright must be included known Problems: none Version: 2.1. 2004 Description: Graphic Library for Nokia 6100 Display and compatible */ .nolist #include "glcd.inc" #include "regs.inc" .list // grafic library main part .section .data .global glcd_MemCtrl .global glcd_Flags .global glcd_Colors #ifdef USE_CLIPPING .global glcd_Clip #endif glcd_MemCtrl: .byte ORIENTATION_DEFAULT glcd_Flags: .byte FLAGS_DEFAULT #ifdef USE_HIGHCOLOR glcd_Colors: .word SCREEN_COLOR0, SCREEN_COLOR1, SCREEN_COLOR2, SCREEN_COLOR3 #if COLOR_TABLE_SIZE > 8 .space (COLOR_TABLE_SIZE - 8) #endif #else glcd_Colors: .byte SCREEN_COLOR0, SCREEN_COLOR1, SCREEN_COLOR2, SCREEN_COLOR3 #if COLOR_TABLE_SIZE > 4 .space (COLOR_TABLE_SIZE - 4) #endif #endif #ifdef USE_CLIPPING glcd_Clip: .byte SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM #endif // initialization procedure of glcd lib #ifdef USE_AUTOINIT .section .init7 glcdInitializeDisplay: xcall glcdDisplayInit #endif // glcd library .section .text // SPI Interrupt to reset CS of LCD and deactivate SPI #ifdef USE_ISR #if defined (SIG_SPI) .global SIG_SPI SIG_SPI: sbi LCD_PORT, LCD_CS reti #else #error "This chip has no SPI interrupts defined" #endif #endif .global glcdDisplayCommand // used T1 stack 1 glcdDisplayCommand: mov T1, P0 // don't touch D0,D1,T0,__tmp_reg__,__zero_reg__ .global glcdDispCommand glcdDispCommand: set rjmp glcdDispSend .global glcdDisplayData // used T1 stack 1 glcdDisplayData: mov T1, P0 // don't touch D0,D1,T0,__tmp_reg__,__zero_reg__ .global glcdDispData glcdDispData: clt .global glcdDispSend glcdDispSend: // used T1 as SPI transmission data, T flag indicate 9'th MSB #ifdef SPI_NOP_WAIT nop nop nop nop #ifdef SPI_IN_LOWER_IO_REGS nop nop #else // SPI_IN_LOWER_IO_REGS push T0 #endif // SPI_IN_LOWER_IO_REGS #else // SPI_NOP_WAIT #ifndef SPI_IN_LOWER_IO_REGS push T0 // We need T0 to modify/read some SPI I/O-Registers #endif // SPI_IN_LOWER_IO_REGS glcdDispSend0: #ifdef USE_ISR sbis LCD_PORT, LCD_CS // don't touch D0,D1,T0,__tmp_reg__,__zero_reg__ #else // USE_ISR #ifdef SPI_IN_LOWER_IO_REGS sbis LCD_SPSR, SPIF #else // SPI_IN_LOWER_IO_REGS in T0, LCD_SPSR sbrs T0, SPIF #endif // SPI_IN_LOWER_IO_REGS #endif // USE_ISR rjmp glcdDispSend0 #endif // SPI_NOP_WAIT #if !defined(USE_ISR) && defined(TOGGLE_CS) sbi LCD_PORT, LCD_CS // Disable Chip Select to give address logic in display a known state #endif #ifdef SPI_IN_LOWER_IO_REGS // Disable SPI to send 9th bit cbi LCD_SPCR, SPE #else in T0, LCD_SPCR cbr T0, (1 << SPE) out LCD_SPCR, T0 #endif #ifdef TOGGLE_CS cbi LCD_PORT, LCD_CS #endif cbi LCD_PORT, LCD_SCL cbi LCD_PORT, LCD_SDA brts glcdDispSend1 sbi LCD_PORT, LCD_SDA glcdDispSend1: sbi LCD_PORT, LCD_SCL #ifdef SPI_IN_LOWER_IO_REGS sbi LCD_SPCR, SPE #else in T0, LCD_SPCR sbr T0, (1< 0 ldi P0L, lo8(INIT_DELAY) ldi P0H, hi8(INIT_DELAY) rcall glcdWait #endif ldi T1, COLOR_INTERFACE // initialize color format and color mapping rcall glcdDispSend #ifdef USE_HIGHCOLOR ldi T1, COLOR_16_BIT rcall glcdDispData #else ldi T1, COLOR_8_BIT rcall glcdDispData ldi P0L, lo8(COLOR_RED) // red ldi P0H, hi8(COLOR_RED) ldi P1L, lo8(COLOR_RED) // green ldi P1H, hi8(COLOR_RED) ldi P2L, lo8(COLOR_BLUE) // blue ldi P2H, hi8(COLOR_BLUE) rcall glcdDisplaySetColors #endif ldi T1, MEM_CONTROL // initialize display RAM access rcall glcdDispCommand lds T1, glcd_MemCtrl rjmp glcdDispData .global glcdDisplaySetColors glcdDisplaySetColors: #ifndef USE_HIGHCOLOR ldi T1, COLOR_SET rcall glcdDispCommand _movw D0, P2 // P2 = P3, P3 = P2 mov P2, P3 _movw P3, D0 _movw D0, P0 ldi T0, 8 rcall glcdDispBuffer _movw D0, P1 ldi T0, 8 rcall glcdDispBuffer _movw D0, P3 ldi T0, 4 rjmp glcdDispBuffer #else ret #endif .end