From b008620171c3a21eeb10a2ca18e03000a681ce87 Mon Sep 17 00:00:00 2001 From: Tectu Date: Sun, 10 Jun 2012 22:28:02 +0200 Subject: [PATCH] added ssd1289_lld --- drivers/ssd1289_lld.c | 58 +++++++++++++++++++++++++++++++++++++++++++ drivers/ssd1289_lld.h | 15 +++++++++++ glcd.c | 45 +++++++-------------------------- glcd.h | 5 ++-- lcd.mk | 12 +++++---- 5 files changed, 92 insertions(+), 43 deletions(-) diff --git a/drivers/ssd1289_lld.c b/drivers/ssd1289_lld.c index e69de29b..e6ec0485 100644 --- a/drivers/ssd1289_lld.c +++ b/drivers/ssd1289_lld.c @@ -0,0 +1,58 @@ +#include "ssd1289_lld.h" + +#ifdef LCD_USE_SSD1289 + +extern uint16_t lcd_width, lcd_height; + +void lld_lcdWriteIndex(uint16_t index) { + Clr_RS; + Set_RD; + + palWritePort(LCD_DATA_PORT, index); + + Clr_WR; + Set_WR; +} + +void lld_lcdWriteData(uint16_t data) { + Set_RS; + + palWritePort(LCD_DATA_PORT, data); + + Clr_WR; + Set_WR; +} + +uint16_t lld_lcdReadData(void) { + uint16_t value; + + Set_RS; + Set_WR; + Clr_RD; + + // change pin mode to digital input + LCD_DATA_PORT->CRH = 0x44444444; + LCD_DATA_PORT->CRL = 0x44444444; + + value = palReadPort(LCD_DATA_PORT); // dummy + value = palReadPort(LCD_DATA_PORT); + + // change pin mode back to digital output + LCD_DATA_PORT->CRH = 0x33333333; + LCD_DATA_PORT->CRL = 0x33333333; + + Set_RD; + + return value; +} + +uint16_t lld_lcdGetHeight(void) { + return lcd_height; +} + +uint16_t lld_lcdGetWidth(void) { + return lcd_width; +} + +#endif + diff --git a/drivers/ssd1289_lld.h b/drivers/ssd1289_lld.h index e69de29b..837d0496 100644 --- a/drivers/ssd1289_lld.h +++ b/drivers/ssd1289_lld.h @@ -0,0 +1,15 @@ +#ifndef SSD1289_H +#define SSD1289_H + +#include "glcd.h" + +#ifndef LCD_USE_SSD1289 + +void lld_lcdWriteIndex(uint16_t index); +void lld_lcdWriteData(uint16_t data); +void lld_lcdWriteData(uint16_t data); +uint16_t lld_lcdGetHeight(void); +uint16_t lld_lcdGetWidth(void); + +#endif +#endif diff --git a/glcd.c b/glcd.c index f1f8e977..ba4fa8ba 100644 --- a/glcd.c +++ b/glcd.c @@ -8,46 +8,15 @@ static uint8_t font_width = 8, font_height = 16; uint16_t lcd_width, lcd_height; static __inline void lcdWriteIndex(uint16_t index) { - Clr_RS; - Set_RD; - - palWritePort(LCD_DATA_PORT, index); - - Clr_WR; - Set_WR; + lld_lcdWriteIndex(index); } static __inline void lcdWriteData(uint16_t data) { - Set_RS; - - palWritePort(LCD_DATA_PORT, data); - - Clr_WR; - Set_WR; + lld_lcdWriteData(data); } static __inline uint16_t lcdReadData(void) { - uint16_t value; - - Set_RS; - Set_WR; - Clr_RD; - - // change pin mode to digital input - LCD_DATA_PORT->CRH = 0x44444444; - LCD_DATA_PORT->CRL = 0x44444444; - - - value = palReadPort(LCD_DATA_PORT); // dummy - value = palReadPort(LCD_DATA_PORT); - - // change pin mode back to digital output - LCD_DATA_PORT->CRH = 0x33333333; - LCD_DATA_PORT->CRL = 0x33333333; - - Set_RD; - - return value; + return lld_lcdReadData(); } static __inline void lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { @@ -70,11 +39,11 @@ static __inline uint16_t lcdReadReg(uint16_t lcdReg) { } uint16_t lcdGetHeight(void) { - return lcd_height; + return lld_lcdGetHeight(); } uint16_t lcdGetWidth(void) { - return lcd_width; + return lld_lcdGetWidth(); } static void lcdSetCursor(uint16_t x, uint16_t y) { @@ -744,5 +713,9 @@ void lcdInit() { lcdWriteReg(0x004e,0); } lcdDelay(5); + + lcd_height = SCREEN_HEIGHT; + lcd_width = SCREEN_WIDTH; + } diff --git a/glcd.h b/glcd.h index 4ad21e42..0f4c7f8c 100644 --- a/glcd.h +++ b/glcd.h @@ -1,8 +1,9 @@ #ifndef GLCD_H #define GLCD_H -#include -#include +#include "ch.h" +#include "hal.h" +#include "drivers/ssd1289_lld.h" #define SCREEN_WIDTH 240 #define SCREEN_HEIGHT 320 diff --git a/lcd.mk b/lcd.mk index e842f05c..8439fe38 100644 --- a/lcd.mk +++ b/lcd.mk @@ -1,8 +1,10 @@ # LCD files. LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \ - ${CHIBIOS}/ext/fonts.c \ - ${CHIBIOS}/ext/touchpad.c \ - ${CHIBIOS}/ext/graph.c \ - ${CHIBIOS}/ext/gui.c + ${CHIBIOS}/ext/lcd/fonts.c \ + ${CHIBIOS}/ext/lcd/touchpad.c \ + ${CHIBIOS}/ext/lcd/graph.c \ + ${CHIBIOS}/ext/lcd/gui.c \ + ${CHIBIOS}/ext/lcd/drivers/ssd1289_lld.c -LCDINC = ${CHIBIOS}/ext/lcd +LCDINC = ${CHIBIOS}/ext/lcd \ + ${CHIBIOS}/etc/lcd/drivers