2009-10-09 03:15:54 +08:00
|
|
|
|
#include "stm32f10x.h"
|
|
|
|
|
#include "rtthread.h"
|
2010-02-23 21:19:01 +08:00
|
|
|
|
#include "board.h"
|
2009-10-16 08:06:15 +08:00
|
|
|
|
#include <rtgui/rtgui.h>
|
|
|
|
|
#include <rtgui/driver.h>
|
2009-11-24 07:34:58 +08:00
|
|
|
|
#include <rtgui/rtgui_server.h>
|
|
|
|
|
#include <rtgui/rtgui_system.h>
|
2009-10-09 03:15:54 +08:00
|
|
|
|
|
2010-02-23 21:19:01 +08:00
|
|
|
|
#if (LCD_VERSION == 1)
|
2009-12-15 19:24:33 +08:00
|
|
|
|
#include "fmt0371/FMT0371.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-02-23 21:19:01 +08:00
|
|
|
|
#if (LCD_VERSION == 2)
|
2010-02-24 01:15:03 +08:00
|
|
|
|
#include "ili9325/ili9325.h"
|
2009-12-15 19:24:33 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
rt_err_t rt_hw_lcd_init(void);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
void rt_hw_lcd_update(rtgui_rect_t *rect);
|
|
|
|
|
rt_uint8_t * rt_hw_lcd_get_framebuffer(void);
|
|
|
|
|
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);
|
|
|
|
|
void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y);
|
|
|
|
|
void rt_hw_lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2);
|
2009-11-24 07:34:58 +08:00
|
|
|
|
void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
|
|
|
|
|
struct rtgui_graphic_driver _rtgui_lcd_driver =
|
2009-10-09 03:15:54 +08:00
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
"lcd",
|
|
|
|
|
2,
|
|
|
|
|
240,
|
|
|
|
|
320,
|
|
|
|
|
rt_hw_lcd_update,
|
|
|
|
|
rt_hw_lcd_get_framebuffer,
|
|
|
|
|
rt_hw_lcd_set_pixel,
|
|
|
|
|
rt_hw_lcd_get_pixel,
|
|
|
|
|
rt_hw_lcd_draw_hline,
|
|
|
|
|
rt_hw_lcd_draw_vline,
|
|
|
|
|
rt_hw_lcd_draw_raw_hline
|
2009-10-16 08:06:15 +08:00
|
|
|
|
};
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
extern void info_init(void);
|
|
|
|
|
extern void player_init(void);
|
|
|
|
|
void radio_rtgui_init(void)
|
|
|
|
|
{
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
|
|
|
|
|
rtgui_system_server_init();
|
|
|
|
|
|
|
|
|
|
/* register dock panel */
|
|
|
|
|
rect.x1 = 0;
|
|
|
|
|
rect.y1 = 0;
|
|
|
|
|
rect.x2 = 240;
|
|
|
|
|
rect.y2 = 25;
|
|
|
|
|
rtgui_panel_register("info", &rect);
|
|
|
|
|
|
|
|
|
|
/* register main panel */
|
|
|
|
|
rect.x1 = 0;
|
|
|
|
|
rect.y1 = 25;
|
|
|
|
|
rect.x2 = 320;
|
|
|
|
|
rect.y2 = 320;
|
|
|
|
|
rtgui_panel_register("main", &rect);
|
|
|
|
|
rtgui_panel_set_default_focused("main");
|
|
|
|
|
|
|
|
|
|
rt_hw_lcd_init();
|
|
|
|
|
|
|
|
|
|
info_init();
|
|
|
|
|
player_init();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-23 21:19:01 +08:00
|
|
|
|
#if (LCD_VERSION == 1)
|
2009-10-16 08:06:15 +08:00
|
|
|
|
void rt_hw_lcd_update(rtgui_rect_t *rect)
|
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* nothing for none-DMA mode driver */
|
2009-10-09 03:15:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
rt_uint8_t * rt_hw_lcd_get_framebuffer(void)
|
2009-10-09 03:15:54 +08:00
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
return RT_NULL; /* no framebuffer driver */
|
2009-10-09 03:15:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
2009-10-09 03:15:54 +08:00
|
|
|
|
{
|
2009-10-16 08:06:15 +08:00
|
|
|
|
unsigned short p;
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* get color pixel */
|
|
|
|
|
p = rtgui_color_to_565p(*c);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set X point */
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_ADDR = 0x02;
|
|
|
|
|
LCD_DATA = x;
|
2009-11-06 08:00:39 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set Y point */
|
2009-11-06 08:00:39 +08:00
|
|
|
|
LCD_ADDR = 0x03;
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_DATA16(y);
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* write pixel */
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_ADDR = 0x0E;
|
|
|
|
|
LCD_DATA16(p);
|
2009-10-09 03:15:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
2009-10-09 03:15:54 +08:00
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set X point */
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_ADDR = 0x02;
|
|
|
|
|
LCD_DATA = x;
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set Y point */
|
2009-11-06 08:00:39 +08:00
|
|
|
|
LCD_ADDR = 0x03;
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_DATA16( y );
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* read pixel */
|
|
|
|
|
LCD_ADDR = 0x0F;
|
2010-02-23 21:19:01 +08:00
|
|
|
|
/* dummy read */
|
|
|
|
|
x = LCD_DATA;
|
2009-11-06 08:00:39 +08:00
|
|
|
|
|
2010-02-23 21:19:01 +08:00
|
|
|
|
*c = rtgui_color_from_565p( LCD_DATA16_READ() );
|
2009-10-09 03:15:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
|
2009-10-09 03:15:54 +08:00
|
|
|
|
{
|
2009-10-16 08:06:15 +08:00
|
|
|
|
unsigned short p;
|
2009-10-09 03:15:54 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* get color pixel */
|
|
|
|
|
p = rtgui_color_to_565p(*c);
|
2009-10-09 03:15:54 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set X point */
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_ADDR = 0x02;
|
|
|
|
|
LCD_DATA = x1;
|
2009-10-09 03:15:54 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set Y point */
|
2009-11-06 08:00:39 +08:00
|
|
|
|
LCD_ADDR = 0x03;
|
2009-10-09 03:15:54 +08:00
|
|
|
|
LCD_DATA16( y );
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* write pixel */
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_ADDR = 0x0E;
|
2009-12-15 19:24:33 +08:00
|
|
|
|
while (x1 < x2)
|
|
|
|
|
{
|
|
|
|
|
LCD_DATA16(p);
|
|
|
|
|
x1 ++;
|
|
|
|
|
}
|
2009-10-09 03:15:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
void rt_hw_lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2)
|
|
|
|
|
{
|
|
|
|
|
unsigned short p;
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* get color pixel */
|
|
|
|
|
p = rtgui_color_to_565p(*c);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set X point */
|
2009-10-16 08:06:15 +08:00
|
|
|
|
LCD_ADDR = 0x02;
|
|
|
|
|
LCD_DATA = x;
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
while (y1 < y2)
|
|
|
|
|
{
|
|
|
|
|
/* set Y point */
|
|
|
|
|
LCD_ADDR = 0x03;
|
|
|
|
|
LCD_DATA16( y1 );
|
2009-10-16 08:06:15 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* write pixel */
|
|
|
|
|
LCD_ADDR = 0x0E;
|
|
|
|
|
LCD_DATA16(p);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
y1 ++;
|
|
|
|
|
}
|
2009-10-16 08:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 07:34:58 +08:00
|
|
|
|
void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
|
|
|
|
|
{
|
|
|
|
|
rt_uint16_t *ptr;
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* get pixel */
|
|
|
|
|
ptr = (rt_uint16_t*) pixels;
|
2009-11-24 07:34:58 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set X point */
|
2009-11-24 07:34:58 +08:00
|
|
|
|
LCD_ADDR = 0x02;
|
|
|
|
|
LCD_DATA = x1;
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* set Y point */
|
2009-11-24 07:34:58 +08:00
|
|
|
|
LCD_ADDR = 0x03;
|
|
|
|
|
LCD_DATA16( y );
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* write pixel */
|
2009-11-24 07:34:58 +08:00
|
|
|
|
LCD_ADDR = 0x0E;
|
2009-12-15 19:24:33 +08:00
|
|
|
|
while (x1 < x2)
|
|
|
|
|
{
|
|
|
|
|
LCD_DATA16(*ptr);
|
|
|
|
|
x1 ++;
|
|
|
|
|
ptr ++;
|
|
|
|
|
}
|
2009-11-24 07:34:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
rt_err_t rt_hw_lcd_init(void)
|
2009-10-09 03:15:54 +08:00
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF,ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOF,&GPIO_InitStructure);
|
|
|
|
|
GPIO_SetBits(GPIOF,GPIO_Pin_9);
|
|
|
|
|
|
|
|
|
|
ftm0371_port_init();
|
|
|
|
|
ftm0371_init();
|
|
|
|
|
|
2010-02-23 21:19:01 +08:00
|
|
|
|
//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
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
#ifndef DRIVER_TEST
|
2009-12-15 19:24:33 +08:00
|
|
|
|
/* add lcd driver into graphic driver */
|
|
|
|
|
rtgui_graphic_driver_add(&_rtgui_lcd_driver);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
return RT_EOK;
|
2009-10-16 08:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
#include <finsh.h>
|
|
|
|
|
|
|
|
|
|
void hline(rt_base_t x1, rt_base_t x2, rt_base_t y, rt_uint32_t pixel)
|
2009-11-24 07:34:58 +08:00
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
rt_hw_lcd_draw_hline(&pixel, x1, x2, y);
|
|
|
|
|
}
|
|
|
|
|
FINSH_FUNCTION_EXPORT(hline, draw a hline);
|
2009-11-24 07:34:58 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
void vline(int x, int y1, int y2, rt_uint32_t pixel)
|
|
|
|
|
{
|
|
|
|
|
rt_hw_lcd_draw_vline(&pixel, x, y1, y2);
|
|
|
|
|
}
|
|
|
|
|
FINSH_FUNCTION_EXPORT(vline, draw a vline);
|
2009-11-24 07:34:58 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
void cls()
|
|
|
|
|
{
|
|
|
|
|
rt_size_t index;
|
|
|
|
|
rtgui_color_t white = RTGUI_RGB(0xff, 0xff, 0xff);
|
2009-11-24 07:34:58 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
for (index = 0; index < 320; index ++)
|
|
|
|
|
rt_hw_lcd_draw_hline(&white, 0, 240, index);
|
|
|
|
|
}
|
|
|
|
|
FINSH_FUNCTION_EXPORT(cls, clear screen);
|
|
|
|
|
#endif
|
2009-11-24 07:34:58 +08:00
|
|
|
|
|
2010-02-23 21:19:01 +08:00
|
|
|
|
#if (LCD_VERSION == 2)
|
2009-12-15 19:24:33 +08:00
|
|
|
|
void rt_hw_lcd_update(rtgui_rect_t *rect)
|
|
|
|
|
{
|
|
|
|
|
/* nothing for none-DMA mode driver */
|
|
|
|
|
}
|
2009-11-24 07:34:58 +08:00
|
|
|
|
|
2009-12-15 19:24:33 +08:00
|
|
|
|
rt_uint8_t * rt_hw_lcd_get_framebuffer(void)
|
|
|
|
|
{
|
|
|
|
|
return RT_NULL; /* no framebuffer driver */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD> <20><>ɫ,X,Y */
|
|
|
|
|
void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
|
|
|
|
{
|
|
|
|
|
unsigned short p;
|
|
|
|
|
|
|
|
|
|
/* get color pixel */
|
|
|
|
|
p = rtgui_color_to_565p(*c);
|
2010-02-24 01:15:03 +08:00
|
|
|
|
ili9325_SetCursor(x,y);
|
2009-12-15 19:24:33 +08:00
|
|
|
|
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM_Prepare();
|
|
|
|
|
ili9325_WriteRAM(p);
|
2009-12-15 19:24:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><>ȡ<EFBFBD><C8A1><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>ɫ */
|
|
|
|
|
void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
|
|
|
|
|
{
|
|
|
|
|
unsigned short p;
|
2010-02-24 01:15:03 +08:00
|
|
|
|
p = ili9325_BGR2RGB( ili9325_ReadGRAM(x,y) );
|
2009-12-15 19:24:33 +08:00
|
|
|
|
*c = rtgui_color_from_565p(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><>ˮƽ<CBAE><C6BD> */
|
|
|
|
|
void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
|
|
|
|
|
{
|
|
|
|
|
unsigned short p;
|
|
|
|
|
|
|
|
|
|
/* get color pixel */
|
|
|
|
|
p = rtgui_color_to_565p(*c);
|
|
|
|
|
|
|
|
|
|
/* [5:4]-ID~ID0 [3]-AM-1<><31>ֱ-0ˮƽ */
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteReg(0x0003,(1<<12)|(1<<5)|(1<<4) | (0<<3) );
|
2009-12-15 19:24:33 +08:00
|
|
|
|
|
2010-02-24 01:15:03 +08:00
|
|
|
|
ili9325_SetCursor(x1, y);
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM_Prepare(); /* Prepare to write GRAM */
|
2009-12-15 19:24:33 +08:00
|
|
|
|
while (x1 < x2)
|
|
|
|
|
{
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM(p);
|
2009-12-15 19:24:33 +08:00
|
|
|
|
x1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><>ֱ<EFBFBD><D6B1> */
|
|
|
|
|
void rt_hw_lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2)
|
|
|
|
|
{
|
|
|
|
|
unsigned short p;
|
|
|
|
|
|
|
|
|
|
/* get color pixel */
|
|
|
|
|
p = rtgui_color_to_565p(*c);
|
|
|
|
|
|
|
|
|
|
/* [5:4]-ID~ID0 [3]-AM-1<><31>ֱ-0ˮƽ */
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteReg(0x0003,(1<<12)|(1<<5)|(0<<4) | (1<<3) );
|
2009-12-15 19:24:33 +08:00
|
|
|
|
|
2010-02-24 01:15:03 +08:00
|
|
|
|
ili9325_SetCursor(x, y1);
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM_Prepare(); /* Prepare to write GRAM */
|
2009-12-15 19:24:33 +08:00
|
|
|
|
while (y1 < y2)
|
|
|
|
|
{
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM(p);
|
2009-12-15 19:24:33 +08:00
|
|
|
|
y1++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ?? */
|
|
|
|
|
void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
|
|
|
|
|
{
|
|
|
|
|
rt_uint16_t *ptr;
|
|
|
|
|
|
|
|
|
|
/* get pixel */
|
|
|
|
|
ptr = (rt_uint16_t*) pixels;
|
|
|
|
|
|
|
|
|
|
/* [5:4]-ID~ID0 [3]-AM-1<><31>ֱ-0ˮƽ */
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteReg(0x0003,(1<<12)|(1<<5)|(1<<4) | (0<<3) );
|
2009-12-15 19:24:33 +08:00
|
|
|
|
|
2010-02-24 01:15:03 +08:00
|
|
|
|
ili9325_SetCursor(x1, y);
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM_Prepare(); /* Prepare to write GRAM */
|
2009-12-15 19:24:33 +08:00
|
|
|
|
while (x1 < x2)
|
|
|
|
|
{
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM( *ptr );
|
2009-12-15 19:24:33 +08:00
|
|
|
|
x1 ++;
|
|
|
|
|
ptr ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rt_err_t rt_hw_lcd_init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF,ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(GPIOF,&GPIO_InitStructure);
|
|
|
|
|
GPIO_SetBits(GPIOF,GPIO_Pin_9);
|
|
|
|
|
|
2010-02-24 01:15:03 +08:00
|
|
|
|
ili9325_Initializtion();
|
|
|
|
|
|
|
|
|
|
/* LCD GRAM TEST */
|
|
|
|
|
{
|
|
|
|
|
unsigned short temp;
|
|
|
|
|
unsigned int test_x;
|
|
|
|
|
unsigned int test_y;
|
|
|
|
|
|
|
|
|
|
rt_kprintf("\r\nLCD GRAM test....");
|
|
|
|
|
|
|
|
|
|
/* write */
|
|
|
|
|
temp=0;
|
2010-02-24 13:51:53 +08:00
|
|
|
|
/* [5:4]-ID~ID0 [3]-AM-1<><31>ֱ-0ˮƽ */
|
|
|
|
|
ili9325_WriteReg(0x0003,(1<<12)|(1<<5)|(1<<4) | (0<<3) );
|
|
|
|
|
ili9325_SetCursor(0,0);
|
|
|
|
|
ili9325_WriteRAM_Prepare();
|
|
|
|
|
for(test_y=0; test_y<76800; test_y++)
|
2010-02-24 01:15:03 +08:00
|
|
|
|
{
|
2010-02-24 13:51:53 +08:00
|
|
|
|
ili9325_WriteRAM(temp++);
|
2010-02-24 01:15:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* read */
|
|
|
|
|
temp=0;
|
|
|
|
|
for(test_y=0; test_y<320; test_y++)
|
|
|
|
|
{
|
|
|
|
|
for(test_x=0; test_x<240; test_x++)
|
|
|
|
|
{
|
|
|
|
|
if( ili9325_BGR2RGB( ili9325_ReadGRAM(test_x,test_y) ) != temp++)
|
|
|
|
|
{
|
|
|
|
|
rt_kprintf(" LCD GRAM ERR!!");
|
|
|
|
|
while(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rt_kprintf(" TEST PASS!\r\n");
|
|
|
|
|
}/* LCD GRAM TEST */
|
2009-12-15 19:24:33 +08:00
|
|
|
|
|
|
|
|
|
#ifndef DRIVER_TEST
|
|
|
|
|
/* add lcd driver into graphic driver */
|
|
|
|
|
rtgui_graphic_driver_add(&_rtgui_lcd_driver);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return RT_EOK;
|
2009-11-24 07:34:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 08:06:15 +08:00
|
|
|
|
#include <finsh.h>
|
|
|
|
|
|
|
|
|
|
void hline(rt_base_t x1, rt_base_t x2, rt_base_t y, rt_uint32_t pixel)
|
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
rt_hw_lcd_draw_hline(&pixel, x1, x2, y);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
FINSH_FUNCTION_EXPORT(hline, draw a hline);
|
|
|
|
|
|
|
|
|
|
void vline(int x, int y1, int y2, rt_uint32_t pixel)
|
|
|
|
|
{
|
2009-12-15 19:24:33 +08:00
|
|
|
|
rt_hw_lcd_draw_vline(&pixel, x, y1, y2);
|
2009-10-16 08:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
FINSH_FUNCTION_EXPORT(vline, draw a vline);
|
|
|
|
|
|
|
|
|
|
void cls()
|
|
|
|
|
{
|
2010-02-24 16:20:41 +08:00
|
|
|
|
ili9325_Clear(0x051F);
|
2009-10-09 03:15:54 +08:00
|
|
|
|
}
|
2009-10-16 08:06:15 +08:00
|
|
|
|
FINSH_FUNCTION_EXPORT(cls, clear screen);
|
2009-12-15 19:24:33 +08:00
|
|
|
|
#endif
|