首页应用案例 › 单片机图形控制芯片RA8889系列介绍(四)——软件篇

单片机图形控制芯片RA8889系列介绍(四)——软件篇

2021-02-05

上一节我主要介绍了单片机通过RA8889来点液晶屏的硬件结构,接下来开始讲解软件部份如何设计。

瑞佑(RAIO)的RA8875当前已经拥有相当巨大的用户群,一个最重要的原因是其软件代码特别容易写,而RA8889也一样,功能上比RA8875更强大但是软件代码一样简单,而且还会更容易!

列举:main.c
**
#include

#include

#include

 

#include "delay.h"

 

//Include RAiO files

#include "UserDef.h"

#include "RA8889_MCU_IF.h"

#include "RA8889.h"

#include "RA8889_API.h"

#include "API_Demo.h"

 

int main(void)

{

RA8889_Initial(); //RA8889初始化

BTE_Solid_Fill(0,4800,0,0,0x000000,800,480); //内存清空,填充

while(1)

{

NOR_AVI_Demo(); //执行AVI播放演示

}

}

 

RA8889_Initial() 初始化函数
**
//==============================================================================

void RA8889_Initial(void)

{

#ifdef Parallel_8080 

/* using STM32 FSMC Interface*/ 

#endif

 

#ifdef Parallel_6800

Parallel_6800_ini();

#endif

 

#ifdef Serial_I2C

I2C_Initial();        

#endif

 

#ifdef Serial_4

SPI4_Init();

#endif

 

#ifdef Serial_3

SPI3_Init();

#endif

 

 

//------------------------------------

RA8889_HW_Reset();

Check_IC_ready();

// System_Check_Temp();  

 

 

RA8889_SW_Reset();

Check_IC_ready();

 

 

//------------------------------------

RA8889_PLL(DRAM_FREQ, CORE_FREQ, SCAN_FREQ);

 

//------------------------------------

RA8889_SDRAM_initial();// set the SDRAM parameter.  

//------------------------------------

 

//**[01h]**//

TFT_24bit();

// TFT_18bit();

// TFT_16bit();

// Without_TFT();

 

//**[01h]**//

#if defined (MCU_8bit_ColorDepth_8bpp) || defined (MCU_8bit_ColorDepth_16bpp) || defined (MCU_8bit_ColorDepth_24bpp)

Host_Bus_8bit();

#endif

 

#if defined (MCU_16bit_ColorDepth_16bpp) || defined (MCU_16bit_ColorDepth_24bpp_Mode_1) || defined (MCU_16bit_ColorDepth_24bpp_Mode_2)

Host_Bus_16bit();

#endif

 

 

//------------------------------------

//**[02h]**//

#ifdef MCU_8bit_ColorDepth_8bpp

Data_Format_8b_8bpp();

#endif

#ifdef MCU_8bit_ColorDepth_16bpp

Data_Format_8b_16bpp();

#endif

#ifdef MCU_8bit_ColorDepth_24bpp

Data_Format_8b_24bpp();

#endif

 

#ifdef MCU_16bit_ColorDepth_16bpp

Data_Format_16b_16bpp();

#endif

#ifdef MCU_16bit_ColorDepth_24bpp_Mode_1

Data_Format_16b_24bpp_mode1();

#endif

#ifdef MCU_16bit_ColorDepth_24bpp_Mode_2

Data_Format_16b_24bpp_mode2();

#endif

 

 

MemWrite_Left_Right_Top_Down();//(Default) Memory Write: Left to Right, Top to Down.

 

//------------------------------------

//**[03h]**//

 

Graphic_Mode();

// Text_Mode();

 

Memory_Select_SDRAM();

 

//------------------------------------

//** Set color depth, define in [UserDef.h] **//

 

#ifdef MCU_8bit_ColorDepth_8bpp

Select_Main_Window_8bpp(); //[10h] Set main window color depth

Memory_8bpp_Mode(); //[5Eh] Set active memory color depth

 

Select_PIP1_Window_8bpp(); //[11h] PIP 1 Window Color Depth

Select_PIP2_Window_8bpp(); //[11h] PIP 2 Window Color Depth

 

BTE_S0_Color_8bpp(); //[92h] Source_0 Color Depth

BTE_S1_Color_8bpp(); //[92h] Source_1 Color Depth

BTE_Destination_Color_8bpp(); //[92h] Destination Color Depth

 

IDEC_Destination_Color_8bpp();//

#endif

 

#if defined (MCU_8bit_ColorDepth_16bpp) || defined (MCU_16bit_ColorDepth_16bpp)

Select_Main_Window_16bpp(); //[10h]Set main window color depth

Memory_16bpp_Mode(); //[5Eh]Set active memory color depth

 

Select_PIP1_Window_16bpp(); //[11h] PIP 1 Window Color Depth

Select_PIP2_Window_16bpp(); //[11h] PIP 2 Window Color Depth

 

BTE_S0_Color_16bpp(); //[92h] Source_0 Color Depth

BTE_S1_Color_16bpp(); //[92h] Source_1 Color Depth

BTE_Destination_Color_16bpp(); //[92h] Destination Color Depth

 

IDEC_Destination_Color_16bpp();//

#endif

 

#if defined (MCU_8bit_ColorDepth_24bpp) || defined (MCU_16bit_ColorDepth_24bpp_Mode_1) || defined (MCU_16bit_ColorDepth_24bpp_Mode_2)

Select_Main_Window_24bpp(); //[10h]Set main window color depth

Memory_24bpp_Mode(); //[5Eh]Set active memory color depth

 

Select_PIP1_Window_24bpp(); //[11h] PIP 1 Window Color Depth

Select_PIP2_Window_24bpp(); //[11h] PIP 2 Window Color Depth

 

BTE_S0_Color_24bpp(); //[92h] Source_0 Color Depth

BTE_S1_Color_24bpp(); //[92h] Source_1 Color Depth

BTE_Destination_Color_24bpp(); //[92h] Destination Color Depth    

 

IDEC_Destination_Color_24bpp();//

#endif

 

//------------------------------------

//**[12h]~[1Fh]]**//

Set_LCD_Panel(); // define in [UserDef.h]

 

//------------------------------------

//**[20h][21h][22h][23h]**//

Main_Image_Start_Address(0);

//**[24h][25h]**//

Main_Image_Width(main_image_width);

//**[26h][27h][28h][29h]**//

Main_Window_Start_XY(0,0);

//**[50h][51h][52h][53h]**//

Canvas_Image_Start_address(0);

//**[54h][55h]**//

Canvas_image_width(canvas_image_width);

//**[56h][57h][58h][59h]**//

Active_Window_XY(0,0);

//**[5Ah][5Bh][5Ch][5Dh]**//

Active_Window_WH(LCD_width,LCD_legth);

 

//------------------------------------

//**[5E]**//

Memory_XY_Mode();

// Memory_Linear_Mode();

 

 

//------------------------------------

Set_Serial_Flash_IF();

 

//------------------------------------

//**[5Fh][60h][61h][62h]**//

Goto_Pixel_XY(0,0);    

 

//------------------------------------  

 

//---------------------//

Display_ON();

//---------------------//

//Color_Bar_ON();

//delay_seconds(1);

//Color_Bar_OFF();

}

BTE_Solid_Fill() 颜色填充函数:
**
void BTE_Solid_Fill

(

unsigned long Des_Addr //start address of destination 

,unsigned short Des_W // image width of destination (recommend = canvas image width) 

, unsigned short XDes //coordinate X of destination 

,unsigned short YDes //coordinate Y of destination 

,unsigned long Foreground_color //Solid Fill color

,unsigned short X_W //Width of BTE Window

,unsigned short Y_H //Length of BTE Window 

)

{

 

#ifdef MCU_8bit_ColorDepth_8bpp

  Foreground_color_256(Foreground_color);

#endif

#ifdef MCU_8bit_ColorDepth_16bpp

  Foreground_color_65k(Foreground_color);

#endif

#ifdef MCU_8bit_ColorDepth_24bpp

  Foreground_color_16M(Foreground_color);

#endif

 

#ifdef MCU_16bit_ColorDepth_16bpp

  Foreground_color_65k(Foreground_color);

#endif

#ifdef MCU_16bit_ColorDepth_24bpp_Mode_1

  Foreground_color_16M(Foreground_color);

#endif

#ifdef MCU_16bit_ColorDepth_24bpp_Mode_2

  Foreground_color_16M(Foreground_color);

#endif

  BTE_Destination_Memory_Start_Address(Des_Addr);

  BTE_Destination_Image_Width(Des_W);

  BTE_Destination_Window_Start_XY(XDes,YDes);

  BTE_Window_Size(X_W,Y_H);

  BTE_Operation_Code(0x0c); //BTE Operation: Solid Fill (w/o ROP)

  BTE_Enable();

  Check_BTE_Busy();  

}

 

NOR_AVI_Demo() 播放AVI影片函数:
**
void NOR_AVI_Demo(void)

{

unsigned char temp;

SPI_NOR_initial_JPG_AVI (1,0,1,2,1);

AVI_NOR(1296674,13327214,shadow_buff,shadow_buff+2400,0,0,322,548,canvas_image_width);

AVI_window(1);

 

do{

temp = Read_Media_Decode_Busy(); //read busy flag to know media decode busy or idle

}while(temp&0x40);

AVI_window(0);

}

瑞佑(RAIO)的工程师们已经化繁为简,所有功能都打包成API函数了,简单明了,用户不需要去查阅繁琐的寄存器功能,相信这一点足以减少巨大的UI开发时间。
瑞佑(RAIO)的API包含描点、几何绘图、文字显示、图形运算(BTE逻辑运算)、DMA调图显示以及AVI影片播放等等各种功能,可以满足人机交互的所有界面设计需求。

许多单片机自带TFT液晶控制器,那种方案正常要结合GUI来设计界面,是直接描点显示,界面图形都是通过软件来完成,在许多情况下显示速度就会慢一些了,而这点在RA8889上就可以得到克服,哪怕您使用的只是一颗51单片机,显示速度一样十分迅速,因为这颗芯片内部是通过硬件来完成图形驱动控制的。

看到这里,相信许多工程师已对这颗芯片的软件设计理解了一大半了。可能大家还有个疑问,液晶屏型号那么多,初始化肯定各有所异,如何设置呢?头大!这个也要告诉大家放心吧!瑞佑(RAIO)已经将常用的型号都建库了,您不需要担心直接拿来用再慢慢细调,若有问题也可以向原厂询求技术支持,难度很小!

液晶屏参数定义举例:AT070TN92
**
#ifdef AT070TN92

 

//**[10h]**//

Select_LCD_Sync_Mode(); // Enable XVSYNC, XHSYNC, XDE.

// Select_LCD_DE_Mode(); // XVSYNC & XHSYNC in idle state.

 

PCLK_Falling();

//PCLK_Rising();

 

VSCAN_T_to_B();

PDATA_Set_RGB();

 

HSYNC_Low_Active();

VSYNC_Low_Active();

DE_High_Active();

//DE_Low_Active();

 

LCD_HorizontalWidth_VerticalHeight(800,480);//INNOLUX 800x480?

 

/* [16h][17h] : Figure 19-3 [HND] Non Display or Back porch (pixels) = (HNDR + 1) * 8 + HNDFTR  

[18h] :  Figure 19-3 [HST] Start Position or Front porch (pixels) = (HSTR + 1)x8

[19h] :  Figure 19-3 [HPW] Pulse Width(pixels) = (HPW + 1)x8

*/

LCD_Horizontal_Non_Display(38);//INNOLUX800x600,46?

LCD_HSYNC_Start_Position(210);//INNOLUX800x600,16~354?

LCD_HSYNC_Pulse_Width(8);//INNOLUX800x600,1~40C

 

/* [1Ch][1Dh] : Figure 19-3 [VND] Non-Display Period(Line) = (VNDR + 1)

[1Eh] :  Figure 19-3 [VST] Start Position(Line) = (VSTR + 1)

[1Fh] :  Figure 19-3 [VPW] Pulse Width(Line) = (VPWR + 1)

*/

LCD_Vertical_Non_Display(13);//INNOLUX800x600,23?

LCD_VSYNC_Start_Position(22);//INNOLUX800x600,1~147?

LCD_VSYNC_Pulse_Width(10);//INNOLUX800x600,1~20C

 

#endif

到这里,基本就将软件设计说明完了,除此而外,瑞佑(RAIO)还新增加了一个上位机辅助界面设计工具,研发在做UI时,可以借助这个工具来开发,可以做到所见即所得的效果,开发效率极高,这些就留到下一节再做介绍吧!

				分享到:

Downloads