update Fujitsu FM3 lcd.c

undefined RT_DEBUG in bsp/fm3/mb9bf500r/rtconfig.h
add Fujitsu MB9BF500R config files for IAR 

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1498 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz 2011-06-13 09:40:05 +00:00
parent 1aa724b5d8
commit 7292d15431
8 changed files with 161 additions and 163 deletions

View File

@ -22,38 +22,35 @@ const unsigned char BIT_MASK[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x0
/* simple font: ' ', '0'~'9','a'~'z','A'~'Z' */
extern const unsigned char FONTTYPE8_8[][8];
rt_uint32_t x;
rt_uint32_t y;
void Power_Delay(void)
void power_delay(void)
{
rt_uint32_t i=0x4ffff;
rt_uint32_t i = 0x4ffff;
while(i--)
;//asm("nop");
;
}
void Delay(void)
void delay(void)
{
rt_uint8_t i=0x8;
rt_uint8_t i = 0x8;
while(i--)
;//asm("nop");
;
}
void Reset_Delay(void)
void reset_delay(void)
{
rt_uint8_t i=0xff;
rt_uint8_t i = 0xff;
while(i--)
;//asm("nop");
;
}
void LCD_WriteCmd(unsigned char command)
void lcd_write_cmd(unsigned char command)
{
rt_uint8_t i;
LCD_PS_LOW();
LCD_CS_LOW();
LCD_CD_LOW();
for(i=0; i<8; i++)
for (i=0; i<8; i++)
{
if (command & (0x80 >> i))
LCD_DATA_HIGH();
@ -61,21 +58,21 @@ void LCD_WriteCmd(unsigned char command)
LCD_DATA_LOW();
LCD_CLK_LOW();
Delay();
delay();
LCD_CLK_HIGH();
Delay();
delay();
}
LCD_CS_HIGH();
}
void LCD_WriteData(unsigned char data)
void lcd_write_data(unsigned char data)
{
rt_uint8_t i;
LCD_PS_LOW();
LCD_CS_LOW();
LCD_CD_HIGH();
for(i=0; i<8; i++)
for (i=0; i<8; i++)
{
if (data & (0x80 >> i))
LCD_DATA_HIGH();
@ -83,9 +80,9 @@ void LCD_WriteData(unsigned char data)
LCD_DATA_LOW();
LCD_CLK_LOW();
Delay();
delay();
LCD_CLK_HIGH();
Delay();
delay();
}
LCD_CS_HIGH();
}
@ -94,21 +91,21 @@ void LCD_WriteData(unsigned char data)
#include <rtgui/driver.h>
#include <rtgui/color.h>
static void rt_hw_lcd_update(rtgui_rect_t *rect)
static void rt_hw_lcd_update(struct rt_device_rect_info *rect_info)
{
rt_uint8_t i,j = GUI_LCM_XMAX;
rt_uint8_t* p = (rt_uint8_t*)gui_disp_buf;
for (i=0; i<GUI_LCM_PAGE; i++)
{
LCD_WriteCmd(Set_Page_Addr_0|i);
LCD_WriteCmd(Set_ColH_Addr_0);
LCD_WriteCmd(Set_ColL_Addr_0);
lcd_write_cmd(SET_PAGE_ADDR_0|i);
lcd_write_cmd(SET_COLH_ADDR_0);
lcd_write_cmd(SET_COLL_ADDR_0);
j = GUI_LCM_XMAX;
while (j--)
{
LCD_WriteData(*p++);
Delay();
lcd_write_data(*p++);
delay();
}
}
}
@ -181,14 +178,14 @@ static void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
gui_disp_buf[page][i] |= 1<<(y%8);
coll = i & 0x0f;
colh = i >> 4;
LCD_WriteCmd(Set_Page_Addr_0 | page);
LCD_WriteCmd(Set_ColH_Addr_0 | colh);
LCD_WriteCmd(Set_ColL_Addr_0 | coll);
LCD_WriteData(gui_disp_buf[page][i]);
lcd_write_cmd(SET_PAGE_ADDR_0 | page);
lcd_write_cmd(SET_COLH_ADDR_0 | colh);
lcd_write_cmd(SET_COLL_ADDR_0 | coll);
lcd_write_data(gui_disp_buf[page][i]);
}
}
const struct rtgui_graphic_driver_ops _lcd_driver =
const struct rtgui_graphic_driver_ops _lcd_ops =
{
rt_hw_lcd_set_pixel,
rt_hw_lcd_get_pixel,
@ -229,57 +226,57 @@ static rt_err_t rt_lcd_init (rt_device_t dev)
{
lcd_io_init();
Power_Delay();
LCD_WriteCmd(Display_Off);
Reset_Delay();
power_delay();
lcd_write_cmd(DISPLAY_OFF);
reset_delay();
// Resetting circuit
LCD_WriteCmd(Reset_LCD);
Reset_Delay();
lcd_write_cmd(RESET_LCD);
reset_delay();
// LCD bias setting
LCD_WriteCmd(Set_LCD_Bias_9);
Reset_Delay();
lcd_write_cmd(SET_LCD_BIAS_9);
reset_delay();
// ADC selection: display from left to right
LCD_WriteCmd(Set_ADC_Normal);
Reset_Delay();
lcd_write_cmd(SET_ADC_NORMAL);
reset_delay();
// Common output state selection: display from up to down
LCD_WriteCmd(COM_Scan_Dir_Reverse);
Reset_Delay();
lcd_write_cmd(COM_SCAN_DIR_REVERSE);
reset_delay();
LCD_WriteCmd(Power_Booster_On);
Power_Delay(); // 50ms requried
LCD_WriteCmd(Power_Regulator_On);
Power_Delay(); // 50ms
LCD_WriteCmd(Power_Follower_On);
Power_Delay(); // 50ms
lcd_write_cmd(POWER_BOOSTER_ON);
power_delay(); // 50ms requried
lcd_write_cmd(POWER_REGULATOR_ON);
power_delay(); // 50ms
lcd_write_cmd(POWER_FOLLOWER_ON);
power_delay(); // 50ms
// Setting the built-in resistance radio for regulation of the V0 voltage
// Electronic volume control
// Power control setting
LCD_WriteCmd(Set_ElecVol_Reg|0x05);
Delay();
LCD_WriteCmd(Set_ElecVol_Mode);
Delay();
LCD_WriteCmd(Set_ElecVol_Reg);
Delay();
lcd_write_cmd(SET_ELECVOL_REG|0x05);
delay();
lcd_write_cmd(SET_ELECVOL_MODE);
delay();
lcd_write_cmd(SET_ELECVOL_REG);
delay();
// LCD_Clear();
Delay();
LCD_WriteCmd(Set_Page_Addr_0);
Delay();
LCD_WriteCmd(Set_ColH_Addr_0);
Delay();
LCD_WriteCmd(Set_ColL_Addr_0);
Delay();
LCD_WriteCmd(Display_On);
Delay();
delay();
lcd_write_cmd(SET_PAGE_ADDR_0);
delay();
lcd_write_cmd(SET_COLH_ADDR_0);
delay();
lcd_write_cmd(SET_COLL_ADDR_0);
delay();
lcd_write_cmd(DISPLAY_ON);
delay();
LCD_WriteCmd(Display_All_On);
Delay();
LCD_WriteCmd(Display_Off);
Delay();
LCD_WriteCmd(Display_On);
Delay();
LCD_WriteCmd(Display_All_Normal);
Delay();
lcd_write_cmd(DISPLAY_ALL_ON);
delay();
lcd_write_cmd(DISPLAY_OFF);
delay();
lcd_write_cmd(DISPLAY_ON);
delay();
lcd_write_cmd(DISPLAY_ALL_NORMAL);
delay();
return RT_EOK;
}
@ -298,14 +295,14 @@ void LCD_FillAll(unsigned char* buffer)
for (i=0; i<GUI_LCM_PAGE; i++)
{
LCD_WriteCmd(Set_Page_Addr_0|i);
LCD_WriteCmd(Set_ColH_Addr_0);
LCD_WriteCmd(Set_ColL_Addr_0);
lcd_write_cmd(SET_PAGE_ADDR_0|i);
lcd_write_cmd(SET_COLH_ADDR_0);
lcd_write_cmd(SET_COLL_ADDR_0);
j = GUI_LCM_XMAX;
while (j--)
{
LCD_WriteData(*p++);
Delay();
lcd_write_data(*p++);
delay();
}
}
}
@ -345,10 +342,10 @@ void LCD_UpdatePoint(unsigned int x, unsigned int y)
coll = x & 0x0f;
colh = x >> 4;
LCD_WriteCmd(Set_Page_Addr_0 | page); // page no.
LCD_WriteCmd(Set_ColH_Addr_0 | colh); // fixed col first addr
LCD_WriteCmd(Set_ColL_Addr_0 | coll);
LCD_WriteData(gui_disp_buf[page][x]);
lcd_write_cmd(SET_PAGE_ADDR_0 | page); // page no.
lcd_write_cmd(SET_COLH_ADDR_0 | colh); // fixed col first addr
lcd_write_cmd(SET_COLL_ADDR_0 | coll);
lcd_write_data(gui_disp_buf[page][x]);
}
/****************************************************************************
@ -459,7 +456,7 @@ void rt_hw_lcd_init(void)
lcd->close = RT_NULL;
lcd->control = rt_lcd_control;
#ifdef RT_USING_RTGUI
lcd->user_data = (void*)&_lcd_driver;
lcd->user_data = (void*)&_lcd_ops;
#endif
/* register lcd device to RT-Thread */
rt_device_register(lcd, "lcd", RT_DEVICE_FLAG_RDWR);

View File

@ -10,6 +10,7 @@
* Change Logs:
* Date Author Notes
* 2008-03-29 Yi.Qiu
* 2011-06-13 lgnq modified for FM3 easy kit
*/
#ifndef __LCD_H__
#define __LCD_H__
@ -28,80 +29,80 @@ LCD_C86 PORT1.1
LCD_PS PORT1.0
LCD_DATA[0..7] PORT5.[0..7]
***********************************************/
#define LCD_CS (1UL << 7)
#define LCD_CS_DDR (FM3_GPIO->DDR1)
#define LCD_CS_PFR (FM3_GPIO->PFR1)
#define LCD_CS_PDOR (FM3_GPIO->PDOR1)
#define LCD_CS (1UL << 7)
#define LCD_CS_DDR (FM3_GPIO->DDR1)
#define LCD_CS_PFR (FM3_GPIO->PFR1)
#define LCD_CS_PDOR (FM3_GPIO->PDOR1)
#define LCD_CD (1UL << 6)
#define LCD_CD_DDR (FM3_GPIO->DDR1)
#define LCD_CD_PFR (FM3_GPIO->PFR1)
#define LCD_CD_PDOR (FM3_GPIO->PDOR1)
#define LCD_CD (1UL << 6)
#define LCD_CD_DDR (FM3_GPIO->DDR1)
#define LCD_CD_PFR (FM3_GPIO->PFR1)
#define LCD_CD_PDOR (FM3_GPIO->PDOR1)
#define LCD_PS (1UL << 0)
#define LCD_PS_DDR (FM3_GPIO->DDR1)
#define LCD_PS_PFR (FM3_GPIO->PFR1)
#define LCD_PS_PDOR (FM3_GPIO->PDOR1)
#define LCD_PS (1UL << 0)
#define LCD_PS_DDR (FM3_GPIO->DDR1)
#define LCD_PS_PFR (FM3_GPIO->PFR1)
#define LCD_PS_PDOR (FM3_GPIO->PDOR1)
#define LCD_CLK (1UL << 6)
#define LCD_CLK_DDR (FM3_GPIO->DDR5)
#define LCD_CLK_PFR (FM3_GPIO->PFR5)
#define LCD_CLK_PDOR (FM3_GPIO->PDOR5)
#define LCD_CLK (1UL << 6)
#define LCD_CLK_DDR (FM3_GPIO->DDR5)
#define LCD_CLK_PFR (FM3_GPIO->PFR5)
#define LCD_CLK_PDOR (FM3_GPIO->PDOR5)
#define LCD_DATA (1UL << 7)
#define LCD_DATA_DDR (FM3_GPIO->DDR5)
#define LCD_DATA_PFR (FM3_GPIO->PFR5)
#define LCD_DATA_PDOR (FM3_GPIO->PDOR5)
#define LCD_DATA (1UL << 7)
#define LCD_DATA_DDR (FM3_GPIO->DDR5)
#define LCD_DATA_PFR (FM3_GPIO->PFR5)
#define LCD_DATA_PDOR (FM3_GPIO->PDOR5)
/* LCD driver for ZYMG12864C3 */
#define LCD_WIDTH 128
#define LCD_HEIGHT 64
#define LCD_WIDTH 128
#define LCD_HEIGHT 64
// Driver the LCD with Parallel or serial interface and the command/data control pin is gpio
#define LCD_CS_HIGH() LCD_CS_PDOR |= LCD_CS
#define LCD_CS_LOW() LCD_CS_PDOR &= ~LCD_CS
#define LCD_CS_HIGH() LCD_CS_PDOR |= LCD_CS
#define LCD_CS_LOW() LCD_CS_PDOR &= ~LCD_CS
#define LCD_CD_HIGH() LCD_CD_PDOR |= LCD_CD
#define LCD_CD_LOW() LCD_CD_PDOR &= ~LCD_CD
#define LCD_CD_HIGH() LCD_CD_PDOR |= LCD_CD
#define LCD_CD_LOW() LCD_CD_PDOR &= ~LCD_CD
#define LCD_PS_HIGH() LCD_PS_PDOR |= LCD_PS
#define LCD_PS_LOW() LCD_PS_PDOR &= ~LCD_PS
#define LCD_PS_HIGH() LCD_PS_PDOR |= LCD_PS
#define LCD_PS_LOW() LCD_PS_PDOR &= ~LCD_PS
#define LCD_CLK_HIGH() LCD_CLK_PDOR |= LCD_CLK
#define LCD_CLK_LOW() LCD_CLK_PDOR &= ~LCD_CLK
#define LCD_CLK_HIGH() LCD_CLK_PDOR |= LCD_CLK
#define LCD_CLK_LOW() LCD_CLK_PDOR &= ~LCD_CLK
#define LCD_DATA_HIGH() LCD_DATA_PDOR |= LCD_DATA
#define LCD_DATA_LOW() LCD_DATA_PDOR &= ~LCD_DATA
#define LCD_DATA_HIGH() LCD_DATA_PDOR |= LCD_DATA
#define LCD_DATA_LOW() LCD_DATA_PDOR &= ~LCD_DATA
// define the arrtibute of ZYMG12864(LCM)
#define GUI_LCM_XMAX 128 // defined the lcd's line-number is 128
#define GUI_LCM_YMAX 64 // defined the lcd's column-number is 64
#define GUI_LCM_PAGE 8 // defined the lcd's page-number is 8(GUI_LCM_YMAX/8)
#define GUI_LCM_XMAX 128 // defined the lcd's line-number is 128
#define GUI_LCM_YMAX 64 // defined the lcd's column-number is 64
#define GUI_LCM_PAGE 8 // defined the lcd's page-number is 8(GUI_LCM_YMAX/8)
/* set LCD command */
#define Display_On 0xAF // A0,RD,WR:010
#define Display_Off 0xAE // A0,RD,WR:010
#define DISPLAY_ON 0xAF // A0,RD,WR:010
#define DISPLAY_OFF 0xAE // A0,RD,WR:010
#define Set_Start_Line_0 0x40 // A0,RD,WR:010; line0~line63
#define Set_Page_Addr_0 0xB0 // A0,RD,WR:010; addr0~addr8
#define Set_ColH_Addr_0 0x10 // A0,RD,WR:010;
#define Set_ColL_Addr_0 0x00 // A0,RD,WR:010; addr0~addr131
#define SET_START_LINE_0 0x40 // A0,RD,WR:010; line0~line63
#define SET_PAGE_ADDR_0 0xB0 // A0,RD,WR:010; addr0~addr8
#define SET_COLH_ADDR_0 0x10 // A0,RD,WR:010;
#define SET_COLL_ADDR_0 0x00 // A0,RD,WR:010; addr0~addr131
#define Read_Status 0x-0 // A0,RD,WR:001; BUSY | ADC | ON/OFF | RESET | 0 0 0 0
#define Status_Busy 0x80
#define Status_ADC_Reverse 0x40 // column address 131-n : SEG n, else column address n : SEG n
#define Status_Display_Off 0x20
#define Status_Reset 0x80
#define READ_STATUS 0x-0 // A0,RD,WR:001; BUSY | ADC | ON/OFF | RESET | 0 0 0 0
#define STATUS_BUSY 0x80
#define STATUS_ADC_REVERSE 0x40 // column address 131-n : SEG n, else column address n : SEG n
#define STATUS_DISPLAY_OFF 0x20
#define STATUS_RESET 0x80
#define Write_Data 0x-- // A0,RD,WR:110
#define Read_Date 0x-- // A0,RD,WR:101; spi mode is unavailable
#define WRITE_DATA 0x-- // A0,RD,WR:110
#define READ_DATE 0x-- // A0,RD,WR:101; spi mode is unavailable
#define Set_ADC_Normal 0xA0 // A0,RD,WR:010
#define Set_ADC_Reverse 0xA1 // A0,RD,WR:010
#define Display_Normal 0xA6 // A0,RD,WR:010
#define Display_Reverse 0xA7 // A0,RD,WR:010; reverse color
#define Display_All_On 0xA5 // A0,RD,WR:010
#define Display_All_Normal 0xA4 // A0,RD,WR:010
#define SET_ADC_NORMAL 0xA0 // A0,RD,WR:010
#define SET_ADC_REVERSE 0xA1 // A0,RD,WR:010
#define DISPLAY_NORMAL 0xA6 // A0,RD,WR:010
#define DISPLAY_REVERSE 0xA7 // A0,RD,WR:010; reverse color
#define DISPLAY_ALL_ON 0xA5 // A0,RD,WR:010
#define DISPLAY_ALL_NORMAL 0xA4 // A0,RD,WR:010
/*************************************************************
* bias: 1/65duty | 1/49duty | 1/33duty | 1/55duty | 1/53duty *
@ -110,12 +111,12 @@ LCD_DATA[0..7] PORT5.[0..7]
* A3: 1/7 bias | 1/6 bias | 1/5 bias | 1/6 bias | 1/6 bias *
**************************************************************/
#define Set_LCD_Bias_7 0xA3 // A0,RD,WR:010
#define Set_LCD_Bias_9 0xA2 // A0,RD,WR:010
#define SET_LCD_BIAS_7 0xA3 // A0,RD,WR:010
#define SET_LCD_BIAS_9 0xA2 // A0,RD,WR:010
#define RMW_Mode_Enable 0xE0 // A0,RD,WR:010; the column address locked when read command operating
#define RMW_Mode_End 0xEE // A0,RD,WR:010; returns to the column address when RMW was entered.
#define Reset_LCD 0xE2 // A0,RD,WR:010
#define RMW_MODE_ENABLE 0xE0 // A0,RD,WR:010; the column address locked when read command operating
#define RMW_MODE_END 0xEE // A0,RD,WR:010; returns to the column address when RMW was entered.
#define RESET_LCD 0xE2 // A0,RD,WR:010
/**************************************************************************************
@ -125,30 +126,30 @@ LCD_DATA[0..7] PORT5.[0..7]
* C8: Reverse | COM63:COM0 | COM47:COM0 | COM31:COM0 | COM53:COM0 | COM51:COM0 *
***************************************************************************************/
#define COM_Scan_Dir_Normal 0xC0 // A0,RD,WR:010
#define COM_Scan_Dir_Reverse 0xC8 // A0,RD,WR:010
#define COM_SCAN_DIR_NORMAL 0xC0 // A0,RD,WR:010
#define COM_SCAN_DIR_REVERSE 0xC8 // A0,RD,WR:010
// 0 0 1 0 1 | Booster On | Regulator On | Follower On
#define Power_Booster_On 0x2C // A0,RD,WR:010
#define Power_Regulator_On 0x2E // A0,RD,WR:010
#define Power_Follower_On 0x2F // A0,RD,WR:010
#define POWER_BOOSTER_ON 0x2C // A0,RD,WR:010
#define POWER_REGULATOR_ON 0x2E // A0,RD,WR:010
#define POWER_FOLLOWER_ON 0x2F // A0,RD,WR:010
#define Set_Resistor_Ratio 0x20 // A0,RD,WR:010; 20~27:small~large
#define SET_RESISTOR_RATIO 0x20 // A0,RD,WR:010; 20~27:small~large
#define Set_ElecVol_Mode 0x81 // A0,RD,WR:010; double byte command
#define Set_ElecVol_Reg 0x20 // A0,RD,WR:010; the electronic volume(64 voltage levels:00~3F) function is not used.
#define SET_ELECVOL_MODE 0x81 // A0,RD,WR:010; double byte command
#define SET_ELECVOL_REG 0x20 // A0,RD,WR:010; the electronic volume(64 voltage levels:00~3F) function is not used.
#define Sleep_Mode_Enable 0xAC // A0,RD,WR:010; double byte command, preceding command
#define Sleep_Mode_Disable 0xAD // A0,RD,WR:010; preceding command
#define Sleep_Mode_Deliver 0x00 // A0,RD,WR:010; following command
#define SLEEP_MODE_ENABLE 0xAC // A0,RD,WR:010; double byte command, preceding command
#define SLEEP_MODE_DISABLE 0xAD // A0,RD,WR:010; preceding command
#define SLEEP_MODE_DELIVER 0x00 // A0,RD,WR:010; following command
#define Boost_Ratio_Set 0xF8 // A0,RD,WR:010; double byte command, preceding command
#define Boost_Ratio_234 0x00 // A0,RD,WR:010; following command
#define Boost_Ratio_5 0x01 // A0,RD,WR:010; following command
#define Boost_Ratio_6 0x03 // A0,RD,WR:010; following command
#define BOOST_RATIO_SET 0xF8 // A0,RD,WR:010; double byte command, preceding command
#define BOOST_RATIO_234 0x00 // A0,RD,WR:010; following command
#define BOOST_RATIO_5 0x01 // A0,RD,WR:010; following command
#define BOOST_RATIO_6 0x03 // A0,RD,WR:010; following command
#define Command_Nop 0xE3 // A0,RD,WR:010
#define Command_IC_Test 0xFC // A0,RD,WR:010; don't use
#define COMMAND_NOP 0xE3 // A0,RD,WR:010
#define COMMAND_IC_TEST 0xFC // A0,RD,WR:010; don't use
#define RT_DEVICE_CTRL_LCD_GET_WIDTH 0
#define RT_DEVICE_CTRL_LCD_GET_HEIGHT 1
@ -173,11 +174,11 @@ enum
struct lcd_msg
{
rt_uint8_t type;
rt_uint16_t adc_value;
rt_uint8_t key;
rt_uint16_t major;
rt_uint16_t minor;
rt_uint8_t type;
rt_uint16_t adc_value;
rt_uint8_t key;
rt_uint16_t major;
rt_uint16_t minor;
};
extern rt_uint32_t x;

View File

@ -16,7 +16,7 @@
/* SECTION: RT_DEBUG */
/* Thread Debug */
#define RT_DEBUG
/* #define RT_DEBUG */
#define RT_USING_OVERFLOW_CHECK
/* Using Hook */