|
stm32与图形点阵19264液晶屏的程序,请高手指教一下,谢谢
[复制链接]
#include
#include
#include"19264.h"
#include"delay.h"
#include "sys.h"
void IO_inint()
{
RCC->APB2ENR|=1<<2; //使能PORTA时钟
RCC->APB2ENR|=1<<3; //使能PORTB时钟
JTAG_Set(SWD_ENABLE);
GPIOB->CRL=0X33333333;
GPIOB->ODR|=0XFFFF; //shuju
GPIOA->CRL&=0XFF00000;
GPIOA->CRL|=0X0033333;
GPIOA->ODR|=0X001F;
}
void wr_cmd(u8 cmd)
{
RS = 0;
RW = 0;
DATAOUT(cmd);
E = 1;
delay_us(10);
E = 0;
}
void wr_data(u8 wdata)
{
RS = 1;
RW = 0;
DATAOUT(wdata);
E = 1;
delay_us(10);
E = 0;
}
void Lcm_Rd_Status() //判断busy
{
u8 dat;
RS=0;
RW=1;
delay_us(100);
E=1;
dat=DATAOUT(7);
while(dat&0X80);
E=0;
delay_us(100);
}
void display(u8 fst, u8 snd)
{
u8 i,j;
for(i=0;i<0x08;i++)
{
wr_cmd(0xc0);
wr_cmd(0x40);
wr_cmd(0xB8+i); //set page address
for(j=0;j<0x20;j++)
{
wr_data(fst);
wr_data(snd);
}
}
}
void LCD_CLS()
{
display(0x00, 0x00);
}
void init_lcd (void)
{
wr_cmd(0xC0); //--DISPLAY START LINE
wr_cmd(0x3F);
}
void init_cpu(void )
{
RST=0;
delay_ms(100);
RST=1;
delay_ms(100);
}
void LCD_Test(void)
{
u8 i;
u8 TestData[][2] =
{
{0xFF,0xFF}, // All
{0x00,0x00}, // None
{0x00,0xFF}, // Virtical
{0xAA,0xAA}, // Horizontal
{0xAA,0x55}, // Stars
};
for (i = 0; i < 5; i++)
{
display(TestData[i][0], TestData[i][1]);
delay_ms(100);
LCD_CLS();
}
}
#ifndef __19264_H#define __19264_H
//LED端口定义#define CSA PAout(0)#define CSB PAout(1) #define E PAout(2)#define RW PAout(3) #define RS PAout(4)#define RST PAout(5)
//PB0~7,作为数据线#define DATAOUT(x) GPIOB->ODR=(GPIOB->ODR&0xff00)|(x&0x00FF); //输出
void IO_init(void);//初始化
void LCD_CLS(void);void wr_data(u8 wdata);void wr_cmd(u8 cmd); void init_cpu(void );void init_lcd(void);void LCD_Test(void);void Lcm_Rd_Status(); void display(u8 fst, u8 snd); #endif
|
|