From b3d4ac3b66bc2efd52d402c62f2ace95982f9e1a Mon Sep 17 00:00:00 2001 From: wuyangyong Date: Tue, 23 Feb 2010 13:19:01 +0000 Subject: [PATCH] fix lcd get_pixel git-svn-id: https://rt-thread.googlecode.com/svn/trunk@438 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/stm32_radio/fmt0371/fmt0371.c | 2 +- bsp/stm32_radio/fmt0371/fmt0371.h | 25 +++++++--- bsp/stm32_radio/lcd.c | 77 +++++++++++++++++++++++++------ 3 files changed, 82 insertions(+), 22 deletions(-) diff --git a/bsp/stm32_radio/fmt0371/fmt0371.c b/bsp/stm32_radio/fmt0371/fmt0371.c index 4aba41293b..1cbed50e50 100644 --- a/bsp/stm32_radio/fmt0371/fmt0371.c +++ b/bsp/stm32_radio/fmt0371/fmt0371.c @@ -1,4 +1,4 @@ -#include "FMT0371.h" +#include "fmt0371.h" #include "stm32f10x.h" #define FSMC_GPIO_CONFIG diff --git a/bsp/stm32_radio/fmt0371/fmt0371.h b/bsp/stm32_radio/fmt0371/fmt0371.h index 2e4acd9aab..33c6408415 100644 --- a/bsp/stm32_radio/fmt0371/fmt0371.h +++ b/bsp/stm32_radio/fmt0371/fmt0371.h @@ -1,20 +1,31 @@ #ifndef FMT0371_H_INCLUDED #define FMT0371_H_INCLUDED -//---------- LCD_RESET ------------- +/************** LCD_RESET ************/ #define LCD_RST_PORT GPIOF #define LCD_RST_PIN GPIO_Pin_10 #define LCD_RST_RCC RCC_APB2Periph_GPIOF -/**************************************/ #define LCD_RST_0 GPIO_ResetBits(LCD_RST_PORT,LCD_RST_PIN) #define LCD_RST_1 GPIO_SetBits(LCD_RST_PORT,LCD_RST_PIN) -//---------- LCD_RESET ------------- +/************** LCD_RESET ************/ -#define LCD_ADDR (*((volatile unsigned char *) 0x64000000)) // RS = 0 -#define LCD_DATA (*((volatile unsigned char *) 0x64000004)) // RS = 1 +#define LCD_ADDR (*((volatile unsigned char *) 0x64000000)) /* RS = 0 */ +#define LCD_DATA (*((volatile unsigned char *) 0x64000004)) /* RS = 1 */ -#define LCD_DATA16(a) LCD_DATA = (unsigned char)(a>>8);LCD_DATA = (unsigned char)a // RS = 1 & WIDHT = 16 -#define LCD_DATA16_READ(a) do { a = (LCD_DATA << 8) | (LCD_DATA); } while (0) +#include "rtdef.h" +rt_inline void LCD_DATA16(rt_uint16_t data) +{ + LCD_DATA = data>>8; + LCD_DATA = data; +} + +rt_inline rt_uint16_t LCD_DATA16_READ(void) +{ + rt_uint16_t temp; + temp = (LCD_DATA << 8); + temp |= LCD_DATA; + return temp; +} #define LCD_WR_CMD(a,b,c) LCD_ADDR = b;LCD_DATA16(c) #define LCD_WR_REG(a) LCD_ADDR = a #define LCD_WR_DATA8(a) LCD_DATA = a diff --git a/bsp/stm32_radio/lcd.c b/bsp/stm32_radio/lcd.c index 84f825abc8..ea71e0c526 100644 --- a/bsp/stm32_radio/lcd.c +++ b/bsp/stm32_radio/lcd.c @@ -1,21 +1,16 @@ #include "stm32f10x.h" #include "rtthread.h" +#include "board.h" #include #include #include #include -#define lcd_hw_version 1 -/* -1 FMT0371 -2 ILI9325 -*/ - -#if (lcd_hw_version == 1) +#if (LCD_VERSION == 1) #include "fmt0371/FMT0371.h" #endif -#if (lcd_hw_version == 2) +#if (LCD_VERSION == 2) #include "ili9325/ili9320.h" #endif @@ -72,7 +67,7 @@ void radio_rtgui_init(void) player_init(); } -#if (lcd_hw_version == 1) +#if (LCD_VERSION == 1) void rt_hw_lcd_update(rtgui_rect_t *rect) { /* nothing for none-DMA mode driver */ @@ -105,8 +100,6 @@ void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y) void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y) { - unsigned short p; - /* set X point */ LCD_ADDR = 0x02; LCD_DATA = x; @@ -117,9 +110,10 @@ void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y) /* read pixel */ LCD_ADDR = 0x0F; - LCD_DATA16_READ(p); + /* dummy read */ + x = LCD_DATA; - *c = rtgui_color_from_565p(p); + *c = rtgui_color_from_565p( LCD_DATA16_READ() ); } void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y) @@ -210,6 +204,61 @@ rt_err_t rt_hw_lcd_init(void) ftm0371_port_init(); ftm0371_init(); + //LCD GRAM test + { + unsigned int test_x; + unsigned int test_y; + unsigned short temp; + + rt_kprintf("\r\nLCD GRAM test...."); + + //write + temp = 0; + for( test_y=0; test_y<320; test_y++) + { + /* set X point */ + LCD_ADDR = 0x02; + LCD_DATA = 0; + + /* set Y point */ + LCD_ADDR = 0x03; + LCD_DATA16( test_y ); + + /* write pixel */ + LCD_ADDR = 0x0E; + for(test_x=0; test_x<240; test_x++) + { + LCD_DATA16(temp++); + } + } + + temp = 0; + for( test_y=0; test_y<320; test_y++) + { + /* set X point */ + LCD_ADDR = 0x02; + LCD_DATA = 0; + + /* set Y point */ + LCD_ADDR = 0x03; + LCD_DATA16( test_y ); + + /* write pixel */ + LCD_ADDR = 0x0f; + /* dummy read */ + test_x = LCD_DATA; + for(test_x=0; test_x<240; test_x++) + { + if ( LCD_DATA16_READ() != temp++) + { + rt_kprintf(" LCD GRAM ERR!!"); + while(1); + } + } + } + rt_kprintf(" TEST PASS!\r\n"); + }//LCD GRAM TEST + #ifndef DRIVER_TEST /* add lcd driver into graphic driver */ rtgui_graphic_driver_add(&_rtgui_lcd_driver); @@ -243,7 +292,7 @@ void cls() FINSH_FUNCTION_EXPORT(cls, clear screen); #endif -#if (lcd_hw_version == 2) +#if (LCD_VERSION == 2) void rt_hw_lcd_update(rtgui_rect_t *rect) { /* nothing for none-DMA mode driver */ -- GitLab