X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Flcd_32122a_avr.c;h=7b18741a4fa35f479d933981888cf123a5c6537c;hb=4cc44c9888a0336b9d01121ec0b7ad95f4a76195;hp=b38ec1a3c33bc9754e39b36c9c369600f7ab6879;hpb=856dd0b8c8d78922fd52f3d7dd34356f5ed602b6;p=bertos.git diff --git a/bertos/cpu/avr/drv/lcd_32122a_avr.c b/bertos/cpu/avr/drv/lcd_32122a_avr.c index b38ec1a3..7b18741a 100644 --- a/bertos/cpu/avr/drv/lcd_32122a_avr.c +++ b/bertos/cpu/avr/drv/lcd_32122a_avr.c @@ -27,7 +27,7 @@ * the GNU General Public License. * * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/) - * Copyright 2001 Bernardo Innocenti + * Copyright 2001 Bernie Innocenti * * --> * @@ -35,14 +35,14 @@ * * \version $Id$ * - * \author Bernardo Innocenti + * \author Bernie Innocenti * \author Stefano Fedrigo * */ #include "lcd_32122a_avr.h" -#include "appconfig.h" +#include "cfg/cfg_lcd.h" #include /* BV() */ #include @@ -59,6 +59,8 @@ #include #include +#warning TODO:Refactor this module. Split code to hw file. + /* Configuration sanity checks */ #if !defined(CONFIG_LCD_SOFTINT_REFRESH) || (CONFIG_LCD_SOFTINT_REFRESH != 0 && CONFIG_LCD_SOFTINT_REFRESH != 1) #error CONFIG_LCD_SOFTINT_REFRESH must be defined to either 0 or 1 @@ -297,7 +299,7 @@ static bool lcd_check(void) */ -static inline void lcd_cmd(uint8_t cmd, uint8_t chip) +static inline void lcd_32122_cmd(uint8_t cmd, uint8_t chip) { WAIT_LCD; @@ -321,7 +323,7 @@ static inline void lcd_cmd(uint8_t cmd, uint8_t chip) } -static inline uint8_t lcd_read(uint8_t chip) +static inline uint8_t lcd_32122_read(uint8_t chip) { uint8_t data; @@ -354,8 +356,7 @@ static inline uint8_t lcd_read(uint8_t chip) return data; } - -static inline void lcd_write(uint8_t c, uint8_t chip) +static inline void lcd_32122_write(uint8_t c, uint8_t chip) { WAIT_LCD; @@ -382,34 +383,21 @@ static inline void lcd_write(uint8_t c, uint8_t chip) //LCD_DB_IN; } - -/** - * Set LCD contrast PWM. - */ -void lcd_setPwm(int duty) -{ - ASSERT(duty >= LCD_MIN_PWM); - ASSERT(duty <= LCD_MAX_PWM); - - OCR3C = duty; -} - - -static void lcd_clear(void) +static void lcd_32122_clear(void) { uint8_t page, j; for (page = 0; page < LCD_PAGES; ++page) { - lcd_cmd(LCD_CMD_COLADDR | 0, LCDF_E1 | LCDF_E2); - lcd_cmd(LCD_CMD_PAGEADDR | page, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_COLADDR | 0, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_PAGEADDR | page, LCDF_E1 | LCDF_E2); for (j = 0; j < LCD_PAGESIZE; j++) - lcd_write(0, LCDF_E1 | LCDF_E2); + lcd_32122_write(0, LCDF_E1 | LCDF_E2); } } -static void lcd_writeRaster(const uint8_t *raster) +static void lcd_32122_writeRaster(const uint8_t *raster) { uint8_t page, rows; const uint8_t *right_raster; @@ -419,35 +407,25 @@ static void lcd_writeRaster(const uint8_t *raster) for (page = 0; page < LCD_PAGES; ++page) { - lcd_cmd(LCD_CMD_PAGEADDR | page, LCDF_E1 | LCDF_E2); - lcd_cmd(LCD_CMD_COLADDR | 0, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_PAGEADDR | page, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_COLADDR | 0, LCDF_E1 | LCDF_E2); /* Super optimized lamer loop */ right_raster = raster + LCD_PAGESIZE; rows = LCD_PAGESIZE; do { - lcd_write(*raster++, LCDF_E1); - lcd_write(*right_raster++, LCDF_E2); + lcd_32122_write(*raster++, LCDF_E1); + lcd_32122_write(*right_raster++, LCDF_E2); } while (--rows); raster = right_raster; } } -/** - * Update the LCD display with data from the provided bitmap. - */ -void lcd_blitBitmap(Bitmap *bm) -{ - MOD_CHECK(lcd); - lcd_writeRaster(bm->raster); -} - - #if CONFIG_LCD_SOFTINT_REFRESH -static void lcd_refreshSoftint(void) +static void lcd_32122_refreshSoftint(void) { lcd_blit_bitmap(&lcd_bitmap); timer_add(lcd_refresh_timer); @@ -455,6 +433,26 @@ static void lcd_refreshSoftint(void) #endif /* CONFIG_LCD_SOFTINT_REFRESH */ +/** + * Set LCD contrast PWM. + */ +void lcd_32122_setPwm(int duty) +{ + ASSERT(duty >= LCD_MIN_PWM); + ASSERT(duty <= LCD_MAX_PWM); + + OCR3C = duty; +} + +/** + * Update the LCD display with data from the provided bitmap. + */ +void lcd_32122_blitBitmap(Bitmap *bm) +{ + MOD_CHECK(lcd); + lcd_32122_writeRaster(bm->raster); +} + /** * Initialize LCD subsystem. @@ -462,7 +460,7 @@ static void lcd_refreshSoftint(void) * \note The PWM used for LCD contrast is initialized in drv/pwm.c * because it is the same PWM used for output attenuation. */ -void lcd_init(void) +void lcd_32122_init(void) { MOD_CHECK(timer); @@ -497,9 +495,9 @@ void lcd_init(void) timer_delay(20); IRQ_SAVE_DISABLE(flags); - lcd_cmd(LCD_CMD_RESET, LCDF_E1 | LCDF_E2); - lcd_cmd(LCD_CMD_DISPLAY_ON, LCDF_E1 | LCDF_E2); - lcd_cmd(LCD_CMD_STARTLINE | 0, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_RESET, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_DISPLAY_ON, LCDF_E1 | LCDF_E2); + lcd_32122_cmd(LCD_CMD_STARTLINE | 0, LCDF_E1 | LCDF_E2); /* Initialize anti-corruption walls for raster */ INIT_WALL(wall_before_raster); @@ -507,8 +505,8 @@ void lcd_init(void) IRQ_RESTORE(flags); - lcd_clear(); - lcd_setpwm(LCD_DEF_PWM); + lcd_32122_clear(); + lcd_32122_setPwm(LCD_DEF_PWM); gfx_bitmapInit(&lcd_bitmap, lcd_raster, LCD_WIDTH, LCD_HEIGHT); gfx_bitmapClear(&lcd_bitmap); @@ -526,3 +524,4 @@ void lcd_init(void) MOD_INIT(lcd); } +