本帖最后由 袁胜富 于 2023-11-27 22:37 编辑
以下代码驱动不成功,求网友或原厂帮忙一下,十分感谢。
#include <string.h>
#include "SWM341.h"
#include "led.h"
#include "ugui.h"
#include "delay.h"
extern const unsigned char gImage_Synwit128[32768];
/*-------------------------------------------------------- LCD背光引脚 -------------------------------------------------------*/
#define LCD_Backlight_PIN PIN9
#define LCD_Backlight_PORT GPIOD
#define LCD_Backlight_OFF GPIO_AtomicClrBit(LCD_Backlight_PORT, LCD_Backlight_PIN) // 关闭背光
#define LCD_Backlight_ON GPIO_AtomicSetBit(LCD_Backlight_PORT, LCD_Backlight_PIN) // 开启背光
#define LCD_HDOT 800 // 水平点数
#define LCD_VDOT 480 // 垂直点数
#define LCD_SDA_Port GPIOA // SPI-MOSI
#define LCD_SDA_PIN PIN12 //GPIO_PIN_12 LCD_G0
void LCD_SDA_WRITE(uint8_t x)
{
if(x==1)
{
GPIO_SetBit(LCD_SDA_Port,LCD_SDA_PIN );
}
else
{
GPIO_ClrBit(LCD_SDA_Port,LCD_SDA_PIN );
}
}
#define LCD_SCL_Port GPIOC // SPI-SCK
#define LCD_SCL_PIN PIN8 //GPIO_PIN_8 LCD_R2
void LCD_SCL_WRITE(uint8_t x)
{
if(x==1)
{
GPIO_SetBit(LCD_SCL_Port,LCD_SCL_PIN );
}
else
{
GPIO_ClrBit(LCD_SCL_Port,LCD_SCL_PIN );
}
}
#define LCD_CS_Port GPIOC //SPI-CS
#define LCD_CS_PIN PIN4 //GPIO_PIN_4 LCD_R0
void LCD_CS_WRITE(uint8_t x)
{
if(x==1)
{
GPIO_SetBit(LCD_CS_Port,LCD_CS_PIN);
}
else
{
GPIO_ClrBit(LCD_CS_Port,LCD_CS_PIN );
}
}
#define LCD_RST_Port GPIOA // LCD_RST
#define LCD_RST_PIN PIN5 //GPIO_PIN_5 TOUCH_RST
void LCD_RST_WRITE(uint8_t x)
{
if(x==1)
{
GPIO_SetBit(LCD_RST_Port,LCD_RST_PIN );
}
else
{
GPIO_ClrBit(LCD_RST_Port,LCD_RST_PIN );
}
}
#define LCD_BLK_ON GPIO_SetBit(GPIOD,PIN9 ) // PD9
#define LCD_BLK_OFF GPIO_ClrBit(GPIOD,PIN9 ) // PD9
#define LCD_CS_Clr GPIO_ClrBit(LCD_CS_Port,LCD_CS_PIN ) // PC4
#define LCD_CS_Set GPIO_SetBit(LCD_CS_Port,LCD_CS_PIN ) // PC4
//画笔颜色
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40 //棕色
#define BRRED 0XFC07 //棕红色
#define GRAY 0X8430 //灰色
//GUI颜色
#define DARKBLUE 0X01CF //深蓝色
#define LIGHTBLUE 0X7D7C //浅蓝色
#define GRAYBLUE 0X5458 //灰蓝色
//以上三色为PANEL的颜色
#define LIGHTGREEN 0X841F //浅绿色
#define LIGHTGRAY 0XEF5B //浅灰色(PANNEL)
#define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)
#define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)
UG_GUI gui;
//uint16_t *LCD_Buffer1 = (uint16_t *)(SDRAMM_BASE + 0x000000);
//uint16_t *LCD_Buffer2 = (uint16_t *)(SDRAMM_BASE + 800*480*2);
//uint16_t *LCD_Buffer;
uint16_t POINT[5]={WHITE,BLUE,RED,YELLOW,GREEN};
uint16_t BACK[5]={LIGHTGREEN,LIGHTGRAY,LGRAY,LGRAYBLUE,LBBLUE};
uint16_t *ltdc_framebuf[2];
uint16_t *ltdc_lcd_framebuf0 = (uint16_t *)(SDRAMM_BASE + 0x000000);
uint16_t *ltdc_lcd_framebuf1 = (uint16_t *)(SDRAMM_BASE + 800*480*2);
//uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((section(".ARM.__at_0x80000000"))); //图层0
//uint16_t ltdc_lcd_framebuf1[800][480] __attribute__((section(".ARM.__at_0x800BB800"))); //图层1
//uint16_t ltdc_lcd_framebuf0[800][480] __attribute__((section(".SDRAM"))); //图层0
//uint16_t ltdc_lcd_framebuf1[800][480] __attribute__((section(".SDRAM"))); //图层1
//LCD的画笔颜色和背景色
uint16_t POINT_COLOR=0x0000; //画笔颜色
uint16_t BACK_COLOR=0xFFFF; //背景色
void mDelayuS(uint16_t us)
{
while(us--)
{
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
}
}
void Write_3Spi_Byte(uint8_t CMD)
{
uint8_t i;
LCD_SCL_WRITE(0);
// mDelayuS(10);
for (i = 0; i < 8; i++)
{
LCD_SCL_WRITE(0);
if ((CMD & 0x80) != 0)
{
LCD_SDA_WRITE(1);
}
else
{
LCD_SDA_WRITE(0);
}
LCD_SCL_WRITE(0);
mDelayuS(1);
LCD_SCL_WRITE(1);
mDelayuS(1);
CMD <<= 1;
}
}
void Write_3Spi_cmd(uint16_t addr)
{
LCD_CS_WRITE(0);
mDelayuS(5);
Write_3Spi_Byte(0x20);
Write_3Spi_Byte(addr >> 8);
Write_3Spi_Byte(0x00);
Write_3Spi_Byte(addr);
mDelayuS(5);
LCD_CS_WRITE(1);
}
void Write_3Spi_data(uint8_t value)
{
LCD_CS_WRITE(0);
mDelayuS(5);
Write_3Spi_Byte(0x40);
Write_3Spi_Byte(value);
mDelayuS(5);
LCD_CS_WRITE(1);
}
void _HW_DrawPoint(UG_S16 x, UG_S16 y, UG_COLOR c)
{
//LCD_Buffer[y * 480 + x] = c; // 在128X128大小的图层上绘图
//
// *(uint16_t *)((uint32_t)LCD_Buffer + 2 * (480 * (y) + x)) = c;
}
/////画点
void LTDC_Draw_Point(uint8_t layer, uint16_t x, uint16_t y, uint32_t color)
{
*(uint16_t *)((uint32_t)ltdc_framebuf[layer] + 2 * (480 * (y) + x)) = color;
}
//清屏函数
void LCD_Clear(uint8_t layer,uint16_t color)
{
uint32_t index=0;
uint32_t totalpoint=480;
totalpoint*=800; //得到总点数
for(index=0;index<totalpoint;index++)
{
ltdc_framebuf[layer][index] = color;
}
}
void SerialInit(void);
void MemoryInit(void);
void RGBLCDInit(void);
int main(void)
{
uint32_t i, j;
// SystemInit();
SysTick_Init(); // 系统定时器初始化,1ms中断
SerialInit();
// MemoryInit();
LED_Init();
RGBLCDInit();
LCD_Start(LCD);
while(1)
{
for(i=0;i<5;i++)
{
POINT_COLOR=POINT;
BACK_COLOR=BACK;
LCD_Clear(1,BACK);
Delay_ms(800);
LED1_Toggle;
}
}
// UG_Init(&gui,(void(*)(UG_S16,UG_S16,UG_COLOR))_HW_DrawPoint, LCD_HDOT, LCD_VDOT);
//
// LCD_Buffer = LCD_Buffer1;
// UG_FillFrame(0, 0, 800, 480, C_RED);
// UG_DrawLine(0, 0, 127, 127, C_BLUE);
// UG_DrawLine(0, 127, 127, 0, C_BLUE);
//
// LCD_Buffer = LCD_Buffer2;
// for(i = 0; i < 128*128; i++)
// LCD_Buffer = ((const uint16_t *)gImage_Synwit128);
//
// UG_DrawCircle(63, 63, 63, C_GREEN);
// UG_DrawCircle(63, 63, 62, C_GREEN);
// UG_DrawCircle(63, 63, 61, C_GREEN);
// UG_DrawLine(64, 0, 64, 127, C_GREEN);
// UG_DrawLine(0, 64, 127, 64, C_GREEN);
while(1==1)
{
// for(i = 0; i < 9; i++)
// {
// LCD_SetLayerPos(LCD, LCD_LAYER_1, (479 - 127)/8*i, (479 - 127)/8*i + 127, (271 - 127)/8*i, (271 - 127)/8*i + 127);
// LCD_SetLayerPos(LCD, LCD_LAYER_2, (479 - 127)/8*(8 - i), (479 - 127)/8*(8 - i) + 127, (271 - 127)/8*(8 - i), (271 - 127)/8*(8 - i) + 127);
//
// for(j = 0; j < SystemCoreClock/4; j++) __NOP();
// }
}
}
void RGBLCDInit(void)
{
uint32_t i;
LCD_InitStructure LCD_initStruct;
LCD_LayerInitStructure LCD_layerInitStruct;
GPIO_Init(GPIOD, PIN9, 1, 0, 0, 0); //屏幕背光
GPIO_ClrBit(GPIOD, PIN9);
GPIO_Init(GPIOA, PIN5, 1, 0, 0, 0); //屏幕复位
GPIO_ClrBit(GPIOA, PIN5);
Delay_ms(500);
GPIO_SetBit(GPIOA, PIN5);
PORT_Init(PORTB, PIN1, PORTB_PIN1_LCD_B0, 0);
PORT_Init(PORTB, PIN11, PORTB_PIN11_LCD_B1, 0);
PORT_Init(PORTB, PIN13, PORTB_PIN13_LCD_B2, 0);
PORT_Init(PORTB, PIN15, PORTB_PIN15_LCD_B3, 0);
PORT_Init(PORTA, PIN2, PORTA_PIN2_LCD_B4, 0);
PORT_Init(PORTA, PIN9, PORTA_PIN9_LCD_B5, 0);
PORT_Init(PORTA, PIN10, PORTA_PIN10_LCD_B6, 0);
PORT_Init(PORTA, PIN11, PORTA_PIN11_LCD_B7, 0);
PORT_Init(PORTA, PIN12, PORTA_PIN12_LCD_G0, 0);
PORT_Init(PORTA, PIN13, PORTA_PIN13_LCD_G1, 0);
PORT_Init(PORTA, PIN14, PORTA_PIN14_LCD_G2, 0);
PORT_Init(PORTA, PIN15, PORTA_PIN15_LCD_G3, 0);
PORT_Init(PORTC, PIN0, PORTC_PIN0_LCD_G4, 0);
PORT_Init(PORTC, PIN1, PORTC_PIN1_LCD_G5, 0);
PORT_Init(PORTC, PIN2, PORTC_PIN2_LCD_G6, 0);
PORT_Init(PORTC, PIN3, PORTC_PIN3_LCD_G7, 0);
PORT_Init(PORTC, PIN4, PORTC_PIN4_LCD_R0, 0);
PORT_Init(PORTC, PIN5, PORTC_PIN5_LCD_R1, 0);
PORT_Init(PORTC, PIN8, PORTC_PIN8_LCD_R2, 0);
PORT_Init(PORTC, PIN9, PORTC_PIN9_LCD_R3, 0);
PORT_Init(PORTC, PIN10, PORTC_PIN10_LCD_R4, 0);
PORT_Init(PORTC, PIN11, PORTC_PIN11_LCD_R5, 0);
PORT_Init(PORTC, PIN12, PORTC_PIN12_LCD_R6, 0);
PORT_Init(PORTC, PIN13, PORTC_PIN13_LCD_R7, 0);
PORT_Init(PORTB, PIN2, PORTB_PIN2_LCD_VSYNC, 0);
PORT_Init(PORTB, PIN3, PORTB_PIN3_LCD_HSYNC, 0);
PORT_Init(PORTB, PIN4, PORTB_PIN4_LCD_DEN, 0);
PORT_Init(PORTB, PIN5, PORTB_PIN5_LCD_DCLK, 0);
// 初始化背光引脚
LCD_Backlight_OFF; // 先关闭背光引脚,初始化LCDC之后再开启
GPIO_Init(LCD_Backlight_PORT, LCD_Backlight_PIN, 1, 0, 0, 0); // 输出模式、禁止上拉、禁止下拉、推挽
LCD_BLK_OFF;
LCD_SCL_WRITE(1);
LCD_CS_WRITE(1);
LCD_SDA_WRITE(1);
Delay_ms(200);
LCD_RST_WRITE(1);
Delay_ms(10);
LCD_RST_WRITE(0);
Delay_ms(50);
LCD_RST_WRITE(1);
Delay_ms(150);
Write_3Spi_cmd(0xF000);
Write_3Spi_data(0x55);
Write_3Spi_cmd(0xF001);
Write_3Spi_data(0xAA);
Write_3Spi_cmd(0xF002);
Write_3Spi_data(0x52);
Write_3Spi_cmd(0xF003);
Write_3Spi_data(0x08);
Write_3Spi_cmd(0xF004);
Write_3Spi_data(0x01); // Page 1
//*************AVDD Set AVDD 5.2V*************//
Write_3Spi_cmd(0xB000);
Write_3Spi_data(0x0D);
Write_3Spi_cmd(0xB001);
Write_3Spi_data(0x0D);
Write_3Spi_cmd(0xB002);
Write_3Spi_data(0x0D);
//************AVDD ratio****************//
Write_3Spi_cmd(0xB600);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xB601);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xB602);
Write_3Spi_data(0x34);
//************AVEE -5.2V****************//
Write_3Spi_cmd(0xB100);
Write_3Spi_data(0x0D);
Write_3Spi_cmd(0xB101);
Write_3Spi_data(0x0D);
Write_3Spi_cmd(0xB102);
Write_3Spi_data(0x0D);
//***********AVEE ratio*************//
Write_3Spi_cmd(0xB700);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xB701);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xB702);
Write_3Spi_data(0x34);
//***********VCL -2.5V*************//
Write_3Spi_cmd(0xB200);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xB201);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xB202);
Write_3Spi_data(0x00);
//**************VCL ratio*****************//
Write_3Spi_cmd(0xB800);
Write_3Spi_data(0x24);
Write_3Spi_cmd(0xB801);
Write_3Spi_data(0x24);
Write_3Spi_cmd(0xB802);
Write_3Spi_data(0x24);
//*************VGH 15V (Free pump)*********//
Write_3Spi_cmd(0xBF00);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xB300);
Write_3Spi_data(0x0F);
Write_3Spi_cmd(0xB301);
Write_3Spi_data(0x0F);
Write_3Spi_cmd(0xB302);
Write_3Spi_data(0x0F);
//*************VGH ratio*****************//
Write_3Spi_cmd(0xB900);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xB901);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xB902);
Write_3Spi_data(0x34);
//***************VGL_REG -10V**************//
Write_3Spi_cmd(0xB500);
Write_3Spi_data(0x08);
Write_3Spi_cmd(0xB501);
Write_3Spi_data(0x08);
Write_3Spi_cmd(0xB502);
Write_3Spi_data(0x08);
Write_3Spi_cmd(0xC200);
Write_3Spi_data(0x03);
//*****************VGLX ratio***************//
Write_3Spi_cmd(0xBA00);
Write_3Spi_data(0x24);
Write_3Spi_cmd(0xBA01);
Write_3Spi_data(0x24);
Write_3Spi_cmd(0xBA02);
Write_3Spi_data(0x24);
//*************VGMP/VGSP 4.5V/0V*************//
Write_3Spi_cmd(0xBC00);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xBC01);
Write_3Spi_data(0x78);
Write_3Spi_cmd(0xBC02);
Write_3Spi_data(0x00);
//************VGMN/VGSN -4.5V/0V****************//
Write_3Spi_cmd(0xBD00);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xBD01);
Write_3Spi_data(0x78);
Write_3Spi_cmd(0xBD02);
Write_3Spi_data(0x00);
//************VCOM -1.25V****************//
Write_3Spi_cmd(0xBE00);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xBE01);
Write_3Spi_data(0x64); // 67--------------
//************Gamma Setting******************//
Write_3Spi_cmd(0xD100);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD101);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD102);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD103);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD104);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD105);
Write_3Spi_data(0x3a);
Write_3Spi_cmd(0xD106);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD107);
Write_3Spi_data(0x4A);
Write_3Spi_cmd(0xD108);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD109);
Write_3Spi_data(0x5c);
Write_3Spi_cmd(0xD10A);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD10B);
Write_3Spi_data(0x81);
Write_3Spi_cmd(0xD10C);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD10D);
Write_3Spi_data(0xA6);
Write_3Spi_cmd(0xD10E);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD10F);
Write_3Spi_data(0xE5);
Write_3Spi_cmd(0xD110);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD111);
Write_3Spi_data(0x13);
Write_3Spi_cmd(0xD112);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD113);
Write_3Spi_data(0x54);
Write_3Spi_cmd(0xD114);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD115);
Write_3Spi_data(0x82);
Write_3Spi_cmd(0xD116);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD117);
Write_3Spi_data(0xCA);
Write_3Spi_cmd(0xD118);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD119);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD11A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD11B);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD11C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD11D);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD11E);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD11F);
Write_3Spi_data(0x67);
Write_3Spi_cmd(0xD120);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD121);
Write_3Spi_data(0x84);
Write_3Spi_cmd(0xD122);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD123);
Write_3Spi_data(0xA4);
Write_3Spi_cmd(0xD124);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD125);
Write_3Spi_data(0xB7);
Write_3Spi_cmd(0xD126);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD127);
Write_3Spi_data(0xCF);
Write_3Spi_cmd(0xD128);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD129);
Write_3Spi_data(0xDE);
Write_3Spi_cmd(0xD12A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD12B);
Write_3Spi_data(0xF2);
Write_3Spi_cmd(0xD12C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD12D);
Write_3Spi_data(0xFE);
Write_3Spi_cmd(0xD12E);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD12F);
Write_3Spi_data(0x10);
Write_3Spi_cmd(0xD130);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD131);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD132);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD133);
Write_3Spi_data(0x6D);
Write_3Spi_cmd(0xD200);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD201);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD202);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD203);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD204);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD205);
Write_3Spi_data(0x3A);
Write_3Spi_cmd(0xD206);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD207);
Write_3Spi_data(0x4A);
Write_3Spi_cmd(0xD208);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD209);
Write_3Spi_data(0x5C);
Write_3Spi_cmd(0xD20A);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD20B);
Write_3Spi_data(0x81);
Write_3Spi_cmd(0xD20C);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD20D);
Write_3Spi_data(0xA6);
Write_3Spi_cmd(0xD20E);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD20F);
Write_3Spi_data(0xE5);
Write_3Spi_cmd(0xD210);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD211);
Write_3Spi_data(0x13);
Write_3Spi_cmd(0xD212);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD213);
Write_3Spi_data(0x54);
Write_3Spi_cmd(0xD214);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD215);
Write_3Spi_data(0x82);
Write_3Spi_cmd(0xD216);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD217);
Write_3Spi_data(0xCA);
Write_3Spi_cmd(0xD218);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD219);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD21A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD21B);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD21C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD21D);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD21E);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD21F);
Write_3Spi_data(0x67);
Write_3Spi_cmd(0xD220);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD221);
Write_3Spi_data(0x84);
Write_3Spi_cmd(0xD222);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD223);
Write_3Spi_data(0xA4);
Write_3Spi_cmd(0xD224);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD225);
Write_3Spi_data(0xB7);
Write_3Spi_cmd(0xD226);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD227);
Write_3Spi_data(0xCF);
Write_3Spi_cmd(0xD228);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD229);
Write_3Spi_data(0xDE);
Write_3Spi_cmd(0xD22A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD22B);
Write_3Spi_data(0xF2);
Write_3Spi_cmd(0xD22C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD22D);
Write_3Spi_data(0xFE);
Write_3Spi_cmd(0xD22E);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD22F);
Write_3Spi_data(0x10);
Write_3Spi_cmd(0xD230);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD231);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD232);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD233);
Write_3Spi_data(0x6D);
Write_3Spi_cmd(0xD300);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD301);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD302);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD303);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD304);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD305);
Write_3Spi_data(0x3A);
Write_3Spi_cmd(0xD306);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD307);
Write_3Spi_data(0x4A);
Write_3Spi_cmd(0xD308);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD309);
Write_3Spi_data(0x5C);
Write_3Spi_cmd(0xD30A);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD30B);
Write_3Spi_data(0x81);
Write_3Spi_cmd(0xD30C);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD30D);
Write_3Spi_data(0xA6);
Write_3Spi_cmd(0xD30E);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD30F);
Write_3Spi_data(0xE5);
Write_3Spi_cmd(0xD310);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD311);
Write_3Spi_data(0x13);
Write_3Spi_cmd(0xD312);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD313);
Write_3Spi_data(0x54);
Write_3Spi_cmd(0xD314);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD315);
Write_3Spi_data(0x82);
Write_3Spi_cmd(0xD316);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD317);
Write_3Spi_data(0xCA);
Write_3Spi_cmd(0xD318);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD319);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD31A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD31B);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD31C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD31D);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD31E);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD31F);
Write_3Spi_data(0x67);
Write_3Spi_cmd(0xD320);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD321);
Write_3Spi_data(0x84);
Write_3Spi_cmd(0xD322);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD323);
Write_3Spi_data(0xA4);
Write_3Spi_cmd(0xD324);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD325);
Write_3Spi_data(0xB7);
Write_3Spi_cmd(0xD326);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD327);
Write_3Spi_data(0xCF);
Write_3Spi_cmd(0xD328);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD329);
Write_3Spi_data(0xDE);
Write_3Spi_cmd(0xD32A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD32B);
Write_3Spi_data(0xF2);
Write_3Spi_cmd(0xD32C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD32D);
Write_3Spi_data(0xFE);
Write_3Spi_cmd(0xD32E);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD32F);
Write_3Spi_data(0x10);
Write_3Spi_cmd(0xD330);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD331);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD332);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD333);
Write_3Spi_data(0x6D);
Write_3Spi_cmd(0xD400);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD401);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD402);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD403);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD404);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD405);
Write_3Spi_data(0x3A);
Write_3Spi_cmd(0xD406);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD407);
Write_3Spi_data(0x4A);
Write_3Spi_cmd(0xD408);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD409);
Write_3Spi_data(0x5C);
Write_3Spi_cmd(0xD40A);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD40B);
Write_3Spi_data(0x81);
Write_3Spi_cmd(0xD40C);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD40D);
Write_3Spi_data(0xA6);
Write_3Spi_cmd(0xD40E);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD40F);
Write_3Spi_data(0xE5);
Write_3Spi_cmd(0xD410);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD411);
Write_3Spi_data(0x13);
Write_3Spi_cmd(0xD412);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD413);
Write_3Spi_data(0x54);
Write_3Spi_cmd(0xD414);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD415);
Write_3Spi_data(0x82);
Write_3Spi_cmd(0xD416);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD417);
Write_3Spi_data(0xCA);
Write_3Spi_cmd(0xD418);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD419);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD41A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD41B);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD41C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD41D);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD41E);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD41F);
Write_3Spi_data(0x67);
Write_3Spi_cmd(0xD420);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD421);
Write_3Spi_data(0x84);
Write_3Spi_cmd(0xD422);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD423);
Write_3Spi_data(0xA4);
Write_3Spi_cmd(0xD424);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD425);
Write_3Spi_data(0xB7);
Write_3Spi_cmd(0xD426);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD427);
Write_3Spi_data(0xCF);
Write_3Spi_cmd(0xD428);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD429);
Write_3Spi_data(0xDE);
Write_3Spi_cmd(0xD42A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD42B);
Write_3Spi_data(0xF2);
Write_3Spi_cmd(0xD42C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD42D);
Write_3Spi_data(0xFE);
Write_3Spi_cmd(0xD42E);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD42F);
Write_3Spi_data(0x10);
Write_3Spi_cmd(0xD430);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD431);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD432);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD433);
Write_3Spi_data(0x6D);
Write_3Spi_cmd(0xD500);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD501);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD502);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD503);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD504);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD505);
Write_3Spi_data(0x3A);
Write_3Spi_cmd(0xD506);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD507);
Write_3Spi_data(0x4A);
Write_3Spi_cmd(0xD508);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD509);
Write_3Spi_data(0x5C);
Write_3Spi_cmd(0xD50A);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD50B);
Write_3Spi_data(0x81);
Write_3Spi_cmd(0xD50C);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD50D);
Write_3Spi_data(0xA6);
Write_3Spi_cmd(0xD50E);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD50F);
Write_3Spi_data(0xE5);
Write_3Spi_cmd(0xD510);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD511);
Write_3Spi_data(0x13);
Write_3Spi_cmd(0xD512);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD513);
Write_3Spi_data(0x54);
Write_3Spi_cmd(0xD514);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD515);
Write_3Spi_data(0x82);
Write_3Spi_cmd(0xD516);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD517);
Write_3Spi_data(0xCA);
Write_3Spi_cmd(0xD518);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD519);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD51A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD51B);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD51C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD51D);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD51E);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD51F);
Write_3Spi_data(0x67);
Write_3Spi_cmd(0xD520);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD521);
Write_3Spi_data(0x84);
Write_3Spi_cmd(0xD522);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD523);
Write_3Spi_data(0xA4);
Write_3Spi_cmd(0xD524);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD525);
Write_3Spi_data(0xB7);
Write_3Spi_cmd(0xD526);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD527);
Write_3Spi_data(0xCF);
Write_3Spi_cmd(0xD528);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD529);
Write_3Spi_data(0xDE);
Write_3Spi_cmd(0xD52A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD52B);
Write_3Spi_data(0xF2);
Write_3Spi_cmd(0xD52C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD52D);
Write_3Spi_data(0xFE);
Write_3Spi_cmd(0xD52E);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD52F);
Write_3Spi_data(0x10);
Write_3Spi_cmd(0xD530);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD531);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD532);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD533);
Write_3Spi_data(0x6D);
Write_3Spi_cmd(0xD600);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD601);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD602);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD603);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD604);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD605);
Write_3Spi_data(0x3A);
Write_3Spi_cmd(0xD606);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD607);
Write_3Spi_data(0x4A);
Write_3Spi_cmd(0xD608);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD609);
Write_3Spi_data(0x5C);
Write_3Spi_cmd(0xD60A);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD60B);
Write_3Spi_data(0x81);
Write_3Spi_cmd(0xD60C);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD60D);
Write_3Spi_data(0xA6);
Write_3Spi_cmd(0xD60E);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD60F);
Write_3Spi_data(0xE5);
Write_3Spi_cmd(0xD610);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD611);
Write_3Spi_data(0x13);
Write_3Spi_cmd(0xD612);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD613);
Write_3Spi_data(0x54);
Write_3Spi_cmd(0xD614);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD615);
Write_3Spi_data(0x82);
Write_3Spi_cmd(0xD616);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD617);
Write_3Spi_data(0xCA);
Write_3Spi_cmd(0xD618);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD619);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xD61A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD61B);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xD61C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD61D);
Write_3Spi_data(0x34);
Write_3Spi_cmd(0xD61E);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD61F);
Write_3Spi_data(0x67);
Write_3Spi_cmd(0xD620);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD621);
Write_3Spi_data(0x84);
Write_3Spi_cmd(0xD622);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD623);
Write_3Spi_data(0xA4);
Write_3Spi_cmd(0xD624);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD625);
Write_3Spi_data(0xB7);
Write_3Spi_cmd(0xD626);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD627);
Write_3Spi_data(0xCF);
Write_3Spi_cmd(0xD628);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD629);
Write_3Spi_data(0xDE);
Write_3Spi_cmd(0xD62A);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD62B);
Write_3Spi_data(0xF2);
Write_3Spi_cmd(0xD62C);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xD62D);
Write_3Spi_data(0xFE);
Write_3Spi_cmd(0xD62E);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD62F);
Write_3Spi_data(0x10);
Write_3Spi_cmd(0xD630);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD631);
Write_3Spi_data(0x33);
Write_3Spi_cmd(0xD632);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xD633);
Write_3Spi_data(0x6D);
//**************LV2 Page 0 enable*************//
Write_3Spi_cmd(0xF000);
Write_3Spi_data(0x55);
Write_3Spi_cmd(0xF001);
Write_3Spi_data(0xAA);
Write_3Spi_cmd(0xF002);
Write_3Spi_data(0x52);
Write_3Spi_cmd(0xF003);
Write_3Spi_data(0x08);
Write_3Spi_cmd(0xF004);
Write_3Spi_data(0x00); // Page 0
// Write_3Spi_cmd(0xB000); Write_3Spi_data(0x00);//add RGB mode2
// Write_3Spi_cmd(0xB001); Write_3Spi_data(0x10);
// Write_3Spi_cmd(0xB002); Write_3Spi_data(0x10);
// Write_3Spi_cmd(0xB003); Write_3Spi_data(0x10);
// Write_3Spi_cmd(0xB004); Write_3Spi_data(0x10);
Write_3Spi_cmd(0xB300);
Write_3Spi_data(0x00);
//*************480x800*********************//
Write_3Spi_cmd(0xB500);
Write_3Spi_data(0x50);
//***************Display control**************//
Write_3Spi_cmd(0xB100);
Write_3Spi_data(0xCC);
Write_3Spi_cmd(0xB101);
Write_3Spi_data(0x00);
//***************Source hold time*************//
Write_3Spi_cmd(0xB600);
Write_3Spi_data(0x05);
//**************Gate EQ control***************//
Write_3Spi_cmd(0xB700);
Write_3Spi_data(0x70);
Write_3Spi_cmd(0xB701);
Write_3Spi_data(0x70);
//*************Source EQ control (Mode 2)******//
Write_3Spi_cmd(0xB800);
Write_3Spi_data(0x01);
Write_3Spi_cmd(0xB801);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xB802);
Write_3Spi_data(0x03);
Write_3Spi_cmd(0xB803);
Write_3Spi_data(0x03);
//************Inversion mode (2-dot)***********//
Write_3Spi_cmd(0xBC00);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xBC01);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0xBC02);
Write_3Spi_data(0x00);
//***************Frame rate***************//
/*
Write_3Spi_cmd(0xBD00); Write_3Spi_data(0x01);
Write_3Spi_cmd(0xBD01); Write_3Spi_data(0x84);
Write_3Spi_cmd(0xBD02); Write_3Spi_data(0x1C); //0X1C
Write_3Spi_cmd(0xBD03); Write_3Spi_data(0x1C);
Write_3Spi_cmd(0xBD04); Write_3Spi_data(0x00);*/
//********Timing control 4H w/ 4-Delayms *******//
Write_3Spi_cmd(0xC900);
Write_3Spi_data(0xD0);
Write_3Spi_cmd(0xC901);
Write_3Spi_data(0x02);
Write_3Spi_cmd(0xC902);
Write_3Spi_data(0x50);
Write_3Spi_cmd(0xC903);
Write_3Spi_data(0x50);
Write_3Spi_cmd(0xC904);
Write_3Spi_data(0x50);
Write_3Spi_cmd(0x3600);
Write_3Spi_data(0x00); // 00
Write_3Spi_cmd(0x3500);
Write_3Spi_data(0x00);
Write_3Spi_cmd(0x3A00);
Write_3Spi_data(0x55);
Write_3Spi_cmd(0x1100);
Delay_ms(120);
Write_3Spi_cmd(0x2900);
Delay_ms(10);
Write_3Spi_cmd(0x2C00);
// lcdltdc.hbp = 20; //水平后廊
// lcdltdc.hfp = 40; //水平前廊
// lcdltdc.hsw = 10; //水平同步宽度
// lcdltdc.vbp = 10; //垂直后廊
// lcdltdc.vfp = 15; //垂直前廊
// lcdltdc.vsw = 10; //垂直同步宽度
Delay_ms(100);
ltdc_framebuf[0] = (uint16_t *)<dc_lcd_framebuf0;
LCD_initStruct.ClkDiv = 10;
LCD_initStruct.Format = LCD_FMT_RGB565;
LCD_initStruct.HnPixel = LCD_HDOT;
LCD_initStruct.VnPixel = LCD_VDOT;
LCD_initStruct.Hfp = 40; // 其它的参数可参考屏幕的手册进行配置
LCD_initStruct.Hbp = 20;
LCD_initStruct.Vfp = 15;
LCD_initStruct.Vbp = 10;
LCD_initStruct.HsyncWidth = 10;
LCD_initStruct.VsyncWidth = 10;
LCD_initStruct.DataSource = (uint32_t)SDRAMM_BASE;
LCD_initStruct.Background = C_GRAY;
LCD_initStruct.SampleEdge = LCD_SAMPLE_RISE; // ATK-4342 RGBLCD 下降沿采样
LCD_initStruct.IntEOTEn = 0;
LCD_Init(LCD, &LCD_initStruct);
LCD_layerInitStruct.Alpha = 0x00;
LCD_layerInitStruct.HStart = 0;
LCD_layerInitStruct.HStop = 800;
LCD_layerInitStruct.VStart = 0;
LCD_layerInitStruct.VStop = 480;
LCD_layerInitStruct.DataSource = (uint32_t)ltdc_framebuf[0];
LCD_LayerInit(LCD, LCD_LAYER_1, &LCD_layerInitStruct);
ltdc_framebuf[1] = (uint16_t *)<dc_lcd_framebuf1;
LCD_layerInitStruct.Alpha = 0x00;
LCD_layerInitStruct.HStart = 0;
LCD_layerInitStruct.HStop = 800;
LCD_layerInitStruct.VStart = 0;
LCD_layerInitStruct.VStop = 480;
LCD_layerInitStruct.DataSource = (uint32_t)ltdc_framebuf[1];
LCD_LayerInit(LCD, LCD_LAYER_2, &LCD_layerInitStruct);
/* Color Keying */
LCD->L[LCD_LAYER_1].LCR |= (1 << LCD_LCR_CKEN_Pos);
LCD->L[LCD_LAYER_1].CK = C_WHITE;
LCD_BLK_ON;
}
void LCD_Handler(void)
{
LCD_INTClr(LCD);
LCD_Start(LCD);
}
void MemoryInit(void)
{
SDRAM_InitStructure SDRAM_InitStruct;
PORT_Init(PORTM, PIN13, PORTM_PIN13_SDR_CLK, 0);
PORT_Init(PORTM, PIN14, PORTM_PIN14_SDR_CKE, 0);
PORT_Init(PORTB, PIN7, PORTB_PIN7_SDR_WE, 0);
PORT_Init(PORTB, PIN8, PORTB_PIN8_SDR_CAS, 0);
PORT_Init(PORTB, PIN9, PORTB_PIN9_SDR_RAS, 0);
PORT_Init(PORTB, PIN10, PORTB_PIN10_SDR_CS, 0);
PORT_Init(PORTE, PIN15, PORTE_PIN15_SDR_BA0, 0);
PORT_Init(PORTE, PIN14, PORTE_PIN14_SDR_BA1, 0);
PORT_Init(PORTN, PIN14, PORTN_PIN14_SDR_A0, 0);
PORT_Init(PORTN, PIN13, PORTN_PIN13_SDR_A1, 0);
PORT_Init(PORTN, PIN12, PORTN_PIN12_SDR_A2, 0);
PORT_Init(PORTN, PIN11, PORTN_PIN11_SDR_A3, 0);
PORT_Init(PORTN, PIN10, PORTN_PIN10_SDR_A4, 0);
PORT_Init(PORTN, PIN9, PORTN_PIN9_SDR_A5, 0);
PORT_Init(PORTN, PIN8, PORTN_PIN8_SDR_A6, 0);
PORT_Init(PORTN, PIN7, PORTN_PIN7_SDR_A7, 0);
PORT_Init(PORTN, PIN6, PORTN_PIN6_SDR_A8, 0);
PORT_Init(PORTN, PIN3, PORTN_PIN3_SDR_A9, 0);
PORT_Init(PORTN, PIN15, PORTN_PIN15_SDR_A10, 0);
PORT_Init(PORTN, PIN2, PORTN_PIN2_SDR_A11, 0);
PORT_Init(PORTM, PIN15, PORTM_PIN15_SDR_A12, 0);
PORT_Init(PORTE, PIN7, PORTE_PIN7_SDR_D0, 1);
PORT_Init(PORTE, PIN6, PORTE_PIN6_SDR_D1, 1);
PORT_Init(PORTE, PIN5, PORTE_PIN5_SDR_D2, 1);
PORT_Init(PORTE, PIN4, PORTE_PIN4_SDR_D3, 1);
PORT_Init(PORTE, PIN3, PORTE_PIN3_SDR_D4, 1);
PORT_Init(PORTE, PIN2, PORTE_PIN2_SDR_D5, 1);
PORT_Init(PORTE, PIN1, PORTE_PIN1_SDR_D6, 1);
PORT_Init(PORTE, PIN0, PORTE_PIN0_SDR_D7, 1);
PORT_Init(PORTE, PIN8, PORTE_PIN8_SDR_D8, 1);
PORT_Init(PORTE, PIN9, PORTE_PIN9_SDR_D9, 1);
PORT_Init(PORTE, PIN10, PORTE_PIN10_SDR_D10, 1);
PORT_Init(PORTE, PIN11, PORTE_PIN11_SDR_D11, 1);
PORT_Init(PORTE, PIN12, PORTE_PIN12_SDR_D12, 1);
PORT_Init(PORTE, PIN13, PORTE_PIN13_SDR_D13, 1);
PORT_Init(PORTC, PIN14, PORTC_PIN14_SDR_D14, 1);
PORT_Init(PORTC, PIN15, PORTC_PIN15_SDR_D15, 1);
PORT_Init(PORTB, PIN6, PORTB_PIN6_SDR_LDQM, 0);
PORT_Init(PORTM, PIN12, PORTM_PIN12_SDR_UDQM,0);
SDRAM_InitStruct.Size = SDRAM_SIZE_8MB;
SDRAM_InitStruct.ClkDiv = SDRAM_CLKDIV_1;
SDRAM_InitStruct.CASLatency = SDRAM_CASLATENCY_2;
SDRAM_InitStruct.TimeTRP = SDRAM_TRP_3;
SDRAM_InitStruct.TimeTRCD = SDRAM_TRCD_3;
SDRAM_InitStruct.TimeTRFC = SDRAM_TRFC_15;
SDRAM_Init(&SDRAM_InitStruct);
}
void SerialInit(void)
{
UART_InitStructure UART_initStruct;
PORT_Init(PORTM, PIN0, PORTM_PIN0_UART0_RX, 1); //GPIOM.0配置为UART0输入引脚
PORT_Init(PORTM, PIN1, PORTM_PIN1_UART0_TX, 0); //GPIOM.1配置为UART0输出引脚
UART_initStruct.Baudrate = 57600;
UART_initStruct.DataBits = UART_DATA_8BIT;
UART_initStruct.Parity = UART_PARITY_NONE;
UART_initStruct.StopBits = UART_STOP_1BIT;
UART_initStruct.RXThresholdIEn = 0;
UART_initStruct.TXThresholdIEn = 0;
UART_initStruct.TimeoutIEn = 0;
UART_Init(UART0, &UART_initStruct);
UART_Open(UART0);
}
///******************************************************************************************************************************************
//* 函数名称: fputc()
//* 功能说明: printf()使用此函数完成实际的串口打印动作
//* 输 入: int ch 要打印的字符
//* FILE *f 文件句柄
//* 输 出: 无
//* 注意事项: 无
//******************************************************************************************************************************************/
//int fputc(int ch, FILE *f)
//{
// UART_WriteByte(UART0, ch);
//
// while(UART_IsTXBusy(UART0));
//
// return ch;
//}
|