|

楼主 |
发表于 2013-6-11 20:54:43
|
显示全部楼层
回 armfly 的帖子
RA8875.C代码:
/* Includes ------------------------------------------------------------------*/
#include "RA8875.h"
/*********************************************************************//**
* @brief Delay
* @param[in] delayCnt Delay value
* @return None
**********************************************************************/
void delay(uint32_t delayCnt)
{
uint32_t i;
for ( i = 0; i < delayCnt; i++ );
return;
}
void LCD_DataWrite(uint16_t reg, uint16_t data)
{
LCD->LCD_REG = reg;
LCD->LCD_RAM = data;
}
uint16_t LCD_DataRead(uint16_t reg)
{
LCD->LCD_REG = reg;
return (LCD->LCD_RAM);
}
void LCD_WriteREG(uint8_t Reg)
{
LCD->LCD_REG =Reg;
}
void LCD_WriteRAM(uint16_t RGB)
{
LCD->LCD_RAM = RGB;
}
uint16_t LCD_ReadRAM(void)
{
uint16_t RGB;
RGB=LCD->LCD_RAM;
RGB=LCD->LCD_RAM;
return (RGB);
}
void LCD_DDRAMWrite(uint32_t count, const uint16_t *data)
{
uint32_t i;
LCD->LCD_REG = 0x02;
for(i = 0; i < count; i++)
LCD->LCD_RAM = data;
}
void LCD_Clear(uint16_t Color)
{
uint32_t index = 0;
LCD->LCD_REG = 0x02;
for(index = 0; index < 130560; index++)
{
LCD->LCD_RAM = Color;
}
}
void LCD_Init(void)
{
LCD_DataWrite(0x88, 0x0B);//PLLDIVM =1 LLDIVN=8
delay(1000);
LCD_DataWrite(0x89, 0x01);//PLLDIVK=2
delay(1000);
// System Clock = 25m x ( PLLDIVN +1 ) / ( ( PLLDIVM+1 ) x ( 2^PLLDIVK ) )=25x11/(2x2^1)=68.75mhz
LCD_DataWrite(0x04, 0x83); //PCLK 频率周期= 8 倍的系统频率周期。
delay(1000);
//Horizontal set
LCD_DataWrite(0x14, 0x3b); //480
LCD_DataWrite(0x15, 0x00);
LCD_DataWrite(0x16, 0x01);
LCD_DataWrite(0x17, 0x00);
LCD_DataWrite(0x18, 0x05);
//Vertical set
LCD_DataWrite(0x19, 0x0F); // 272
LCD_DataWrite(0x1A, 0x01);
LCD_DataWrite(0x1B, 0x02);
LCD_DataWrite(0x1C, 0x00);
LCD_DataWrite(0x1D, 0x07);
LCD_DataWrite(0x1E, 0x00);
LCD_DataWrite(0x1F, 0x09);
LCD_DataWrite(0x8A, 0x88);
LCD_DataWrite(0x8B, 0x00);
LCD_DataWrite(0xC0, 0x00);//关闭键盘扫描
LCD_DataWrite(0xC1, 0x00);//关闭键盘扫描唤醒
// //setting active window X
// LCD_DataWrite(0x30, 0x00); //
// LCD_DataWrite(0x31, 0x00);
// LCD_DataWrite(0x34, 0xDF);
// LCD_DataWrite(0x35, 0x01);
//
// //setting active window Y
// LCD_DataWrite(0x32, 0x00); //
// LCD_DataWrite(0x33, 0x00);
// LCD_DataWrite(0x36, 0x0F);
// LCD_DataWrite(0x37, 0x01);
//中断配置
LCD_DataWrite(0xf0, 0x00); //关闭所有中断
LCD_DataWrite(0x10, 0x0F); // SYSR 16-bit interface, 65k colors
}
void Active_Window(uint16_t XL,uint16_t XR ,uint16_t YT ,uint16_t YB)
{
LCD_DataWrite(0x30, XL);
LCD_DataWrite(0x31, XL >> 8);
LCD_DataWrite(0x34, XR);
LCD_DataWrite(0x35, XR >> 8);
LCD_DataWrite(0x32, YT);
LCD_DataWrite(0x33, YT >> 8);
LCD_DataWrite(0x36, YB);
LCD_DataWrite(0x37, YB >> 8);
}
void Display_ON(void)
{
LCD_DataWrite(0x01, 0x80);
}
void LCD_SetCursor(uint16_t X, uint16_t Y)
{
LCD_DataWrite(0x46, X);
LCD_DataWrite(0x47, X >> 8);
LCD_DataWrite(0x48, Y);
LCD_DataWrite(0x49, Y >> 8);
}
void LCD_SetReadCursor(uint16_t X, uint16_t Y)
{
LCD_DataWrite(0x4A, X);
LCD_DataWrite(0x4B, X >> 8);
LCD_DataWrite(0x4C, Y);
LCD_DataWrite(0x4D, Y >> 8);
}
uint16_t LCD_GetPixel(uint16_t X, uint16_t Y)
{
uint16_t RGB;
LCD_SetReadCursor(X, Y); /* 设置位置 */
LCD_WriteREG(0x02);
RGB = LCD_ReadRAM();
return RGB;
}
void LCD_PutPixel(uint16_t X, uint16_t Y, uint16_t Color)
{
LCD_SetCursor(X, Y); /* 设置位置 */
LCD_WriteREG(0x02);
LCD_WriteRAM(Color);
}
/*******************************************************************************
函数名 LCD_Display_Graph_Prepare
输 入:
输 出:
功能说明:
进入绘图模式
*******************************************************************************/
void LCD_Display_Graph_Prepare(void)
{
LCD_DataWrite(0x40, 0x00);//进入绘图模式
} |
|