#include "Initial_LCM.h"
#include "display.h"
#include "SY1X8_Lib.h"
#include "GPU_PIC.h"
#define SPI_DELAY 0
//#define SPI3_9Bit 1
#define SPI4_8Bit 1
void SpiDelay(unsigned char time)
{ unsigned char i;
for(i=0;i<time;i++);
}
unsigned char SPI_SendData(unsigned char i)
{
unsigned char n;
unsigned char data;
u16 temp;
data = 0;
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 0)
{
for(n=0; n<8; n++)
{
if(i&0x80) O_SPI_MOSI(1);
else O_SPI_MOSI(0);
i<<= 1;
data <<=1;
O_SPI_CLK(0);SpiDelay(SPI_DELAY);
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7))data++;
O_SPI_CLK(1);SpiDelay(SPI_DELAY);
}
}else {
for(n=0; n<8; n++)
{
data <<= 1;
if(i&0x80) *(vu16*) (LCD_BASE1)= 0xFFFF;
else *(vu16*) (LCD_BASE1)= 0x0;
temp = *(vu16*) (LCD_BASE0);
if(temp&0x1)data++;
i <<= 1;
}
}
return data;
}
unsigned char SPI_ReadData(unsigned char i)
{
unsigned char n;
unsigned char data;
u16 temp;
data = 0;
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 0)
{
for(n=0; n<8; n++)
{
if(i&0x80) O_SPI_MOSI(1);
else O_SPI_MOSI(0);
i<<= 1;
data <<=1;
O_SPI_CLK(0);SpiDelay(SPI_DELAY);
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7))data++;
O_SPI_CLK(1);SpiDelay(SPI_DELAY);
}
}else {
for(n=0; n<8; n++)
{
if(i&0x80) O_MCU_DO(1);
else O_MCU_DO(0);
i<<= 1;
data <<=1;
O_MCU_WR(1);SpiDelay(SPI_DELAY);
if(I_MCU_DI())data++;
O_MCU_WR(0);SpiDelay(SPI_DELAY);
}
}
return data;
}
void WriteComm(unsigned short int data){
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 1)
{
O_MCU_CS(0);
O_MCU_RD(1);
O_MCU_RS(0);
O_MCU_WR(0);
*(vu16*) (LCD_BASE0)= (data);
O_MCU_WR(1);
O_MCU_CS(1);
}else {
#ifdef SPI3_9Bit
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 0){
O_SPI_CS(0);
O_SPI_MOSI(0);
O_SPI_CLK(0);SpiDelay(SPI_DELAY);
O_SPI_CLK(1);SpiDelay(SPI_DELAY);
SPI_SendData(data);
O_SPI_CS(1);
} else {
O_MCU_CS(0);
*(vu16*) (LCD_BASE0)= 0x0;
SPI_SendData(data);
O_MCU_CS(1);
}
#endif
#ifdef SPI4_8Bit
O_MCU_CS(0);
O_MCU_RS(0);
SPI_SendData(data);
// O_MCU_CS(1);
#endif
}
}
void WriteData(unsigned short int data){
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 1)
{
O_MCU_CS(0);
O_MCU_RS(1);
O_MCU_WR(0);
*(vu16*) (LCD_BASE0)= (data);
O_MCU_WR(1);
O_MCU_CS(1);
}else {
#ifdef SPI3_9Bit
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 0){
O_SPI_CS(0);
O_SPI_MOSI(1);
O_SPI_CLK(0);SpiDelay(SPI_DELAY);
O_SPI_CLK(1);SpiDelay(SPI_DELAY);
SPI_SendData(data);
O_SPI_CS(1);
}else {
O_MCU_CS(0);
*(vu16*) (LCD_BASE1)= 0x1;
SPI_SendData(data);
O_MCU_CS(1);
}
#endif
#ifdef SPI4_8Bit
O_MCU_CS(0);
O_MCU_RS(1);
SPI_SendData(data);
O_MCU_CS(1);
#endif
}
}
unsigned int ReadData(void){
unsigned int data;
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 0)
{
O_SPI_MOSI(1);
O_SPI_CLK(0);SpiDelay(SPI_DELAY);
O_SPI_CLK(1);SpiDelay(SPI_DELAY);
data = SPI_SendData(0xff);
}else {
O_MCU_CS(0);
O_MCU_RS(1);
O_MCU_WR(1);
O_MCU_RD(0);
O_MCU_RD(1);
data = *(vu16*) (LCD_BASE0);
O_MCU_CS(1);
}
return data;
}
void WriteDispData(unsigned short int data){
// u8 i;
if(ptr_RGB_TABLE[gRgbTableIndex]->Display_Mode == 1)
{
*(vu16*) (LCD_BASE0)= (data);
O_MCU_WR(0);
O_MCU_WR(1);
}else {
WriteData(data);
}
}
void BlockWrite(unsigned int Xstart,unsigned int Xend,unsigned int Ystart,unsigned int Yend)
{
//2A 2B 2C
WriteComm(0x2a);
WriteData(Xstart>>8);
WriteData(Xstart&0xff);
WriteData(Xend>>8);
WriteData(Xend&0xff);
WriteComm(0x2b);
WriteData(Ystart>>8);
WriteData(Ystart&0xff);
WriteData(Yend>>8);
WriteData(Yend&0xff);
WriteComm(0x2c);
O_MCU_CS(0);
O_MCU_RS(1);
}
//cmd 读取寄存器
//num 读取寄存器个数
//id_num 需要返回哪一个ID
u32 ReadReg(unsigned int cmd,unsigned int num,unsigned int id_num)
{
unsigned int reg_data[32];
u8 i;
if(id_num >= num)id_num=num-1;
WriteComm(cmd);
for(i=0;i< num;i++){
reg_data[i]=ReadData();
}
disp_Char(0,0,"Read ID:",BLUE);
for(i=0;i<num;i++)
{
disp_Char(0,i+1,"0x",BLUE);
disp_Hex(2,i+1,reg_data[i],BLUE);
}
return reg_data[id_num];
}
void SPI9_ReadData(unsigned int i,unsigned char n)
{
unsigned char j,data[16];
O_MCU_CS(0);
*(vu16*) (LCD_BASE1)= 0x0;
SPI_SendData(i);
for(j=0;j<n;j++)
{
*(vu16*) (LCD_BASE1)= 0x1;
data[j]=SPI_SendData(0xff);
}
O_MCU_CS(1);
// SetDispColor(Yellow,BLUE);
// SetDispString(0,216,"ID:0x _ _ _ ");
// SetDispHex(5,216,data[0]);
// SetDispHex(8,216,data[1]);
// SetDispHex(11,216,data[2]);
// SetDispHex(14,216,data[3]);
// SetDispColor(WHITE,BLUE);
disp_Char(0,0,"Read ID:",BLUE);
for(j=0;j<n;j++)
{
disp_Char(0,j+1,"0x",BLUE);
disp_Hex(2,j+1,data[j],BLUE);
}
for(j=0;j<n;j++)
printf("ID[%d] is 0x%x;\r\n",j,data[j]);
}
void SPI8_ReadData(unsigned int i,unsigned char n)
{
unsigned char j,data[16];
O_MCU_RS(0);
O_MCU_CS(0);
SPI_SendData(i);
O_MCU_RS(1);
*(vu16*) (LCD_BASE0)= 0x1;
MCU_GPU_FSMCConfig1();
for(j=0;j<n;j++)
{
data[j]=SPI_ReadData(0xff);
}
O_MCU_CS(1);
MCU_GPU_FSMCConfig();
disp_Char(0,0,"Read ID:",BLUE);
for(j=0;j<n;j++)
{
disp_Char(0,j+1,"0x",BLUE);
disp_Hex(2,j+1,data[j],BLUE);
}
for(j=0;j<n;j++)
printf("ID[%d] is 0x%x;\r\n",j,data[j]);//printf("ID[%d] is 0x%x;\r\n",j,data[j]);
// if (data[0]==0x52)
//
// {
// disp_Chess(240,240,8);
// SetDispString(9,132,"OTP OK!");
// delay_ms(10000);
// }
// else
// {
// disp_Chess(240,120,8);
// SetDispString(9,132,"OTP NG!");
// delay_ms(10000);
// }
}
//---------------------------------------------------------------------------------------
unsigned char GET_SPI8_ReadData(unsigned int i,unsigned char n)
{
unsigned char j,data[16];
O_MCU_RS(0);
O_MCU_CS(0);
SPI_SendData(i);
O_MCU_RS(1);
*(vu16*) (LCD_BASE0)= 0x1;
MCU_GPU_FSMCConfig1();
for(j=0;j<n;j++)
{
data[j]=SPI_ReadData(0xff);
}
O_MCU_CS(1);
MCU_GPU_FSMCConfig();
disp_Char(0,0,"Read ID:",BLUE);
for(j=0;j<n;j++)
{
disp_Char(0,j+1,"0x",BLUE);
disp_Hex(2,j+1,data[j],BLUE);
}
//for(j=0;j<n;j++)
{
printf("***** GET ID[%d] is 0x%x*****;\r\n",(n-1),data[j]);
return data[n-1];
}
// if (data[0]==0x52)
//
// {
// disp_Chess(240,320,8);
// SetDispString(9,132,"OTP OK!");
// delay_ms(10000);
// }
// else
// {
// disp_Chess(240,320,8);
// SetDispString(9,132,"OTP NG!");
// delay_ms(10000);
// }
}
//-------------------------------------------------------------------------------------------
void Initial_LCM(void) {
O_LCD_RESET(1);
delay_ms(5);
O_LCD_RESET(0);
delay_ms(100);
O_LCD_RESET(1);
delay_ms(20);
//------------------------
WriteComm(0xdf);
WriteData(0x5a);
WriteData(0x69);
WriteData(0x02);
WriteData(0x01);
//----------------------------------
// //*********************************************************************************************************
// printf("\r\n *************************************************************\r\n\r\n");
// printf("\r\n ****READ COMMAND DATA before initial LCD DRIVER IC*****\r\n\r\n");
// printf("\r\n begin to read !!0XDA-4 DATA \r\n\r\n");
// SPI8_ReadData(0x04,4);
// printf("\r\n begin to read !!0XB2 DATA \r\n\r\n");
// SPI8_ReadData(0xb2,5);
// printf("\r\n begin to read !!0XB7 DATA \r\n\r\n");
// SPI8_ReadData(0xB7,1);
// printf("\r\n begin to read !!0XBB DATA \r\n\r\n");
// SPI8_ReadData(0xBB,1);
// printf("\r\n begin to read !!0XC0 DATA \r
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
X200_ST7789V_CTC24_SPI4W_图片ok.rar (84个子文件)
X200_ST7789V_CTC24_SPI4W_图片ok
X200_ST7789V_CTC24_SPI4W_图片ok
app_mcu32_prj.uvguix.Administrator 138KB
DebugConfig
ExtMCU32_STM32F103VC.dbgconf 7KB
ExtMCU32_STM32F103VC_1.0.0.dbgconf 7KB
app_mcu32_prj.uvguix.way 167KB
app_mcu32_prj.uvprojx 17KB
app_mcu32_prj.uvguix.asus 73KB
Src
LCD
Initial_LCM.h 633B
Initial_LCM.c 19KB
BasicDataType.h 685B
Module
usart_pc.c 5KB
power_task.c 1KB
usart_pc.h 493B
power_task.h 529B
Function.c 6KB
UserGpioDefine.h 1KB
RTP.c 4KB
app.h 2KB
UserGpioDefine.c 14KB
Function.h 430B
RTP.h 599B
user_config.h 2KB
user_config.c 2KB
app.c 4KB
SYN_LIB
stm32f10x_conf.h 4KB
SY1X8_Lib.h 13KB
core_cm3.h 84KB
display.h 832B
stm32f10x_usart.h 16KB
stm32f10x.h 619KB
SysInit.h 770B
SYN_X2001.lib 12.96MB
w25q128.h 1018B
stm32f10x_gpio.h 20KB
GPU_PIC.h 1KB
MCU_GPU_fsmc.h 544B
stm32f10x_rcc.h 30KB
SYN_X200.lib 13.14MB
stm32f10x_tim.h 51KB
SY1X8.h 23KB
GPU_Cfg.h 577B
stm32f10x_fsmc.h 26KB
misc.h 9KB
timer.h 733B
system_stm32f10x.h 2KB
delay.h 488B
main.h 264B
main.c 223B
app_mcu32_prj.uvoptx 10KB
Outputs
main.d 1KB
user_config.d 925B
power_task.o 308KB
main.o 308KB
function.o 323KB
usart_pc.o 322KB
user_config.o 286KB
usergpiodefine.crf 263KB
M32_Control.htm 215KB
function.crf 326KB
M32_Control.axf 1.28MB
main.crf 325KB
usart_pc.crf 323KB
rtp.crf 315KB
M32_Control.map 482KB
rtp.o 302KB
initial_lcm.o 335KB
STM32_SD_Updata.bin 36KB
app.crf 325KB
app.o 311KB
usart_pc.d 1KB
M32_Control.sct 479B
M32_Control.build_log.htm 2KB
initial_lcm.crf 328KB
M32_Control.hex 103KB
power_task.d 2KB
app_mcu32_prj_ExtMCU32.dep 15KB
function.d 2KB
initial_lcm.d 2KB
usergpiodefine.o 318KB
power_task.crf 321KB
usergpiodefine.d 691B
app.d 1KB
user_config.crf 271KB
rtp.d 942B
M32_Control.lnp 504B
共 84 条
- 1
资源评论
SGO03938
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 一个chm格式的 SQL 函数手册-SQL语言手册文档
- 计算当前月份的天数和剩余天数
- 基于ARM的指令调度和延迟分支
- 基于Vue和TypeScript的极简聊天应用设计源码 - HasChat
- 基于Vue2全家桶和Zcool数据的图片收集网站设计源码 - cool-picture
- 基于C和C++的二维绘制工具设计源码 - DrawPro
- Object.defineProperty 的 IE 补丁object-defineproperty-ie-master.zip
- 整卷预览.mhtml
- MySQL是一种广泛使用的开源关系型数据库管理系统,它提供了丰富的SQL语句用于数据库的创建、查询、更新和管理 以下是一些常见的
- MySQL是一种广泛使用的开源关系型数据库管理系统,它提供了丰富的SQL语句用于数据库的创建、查询、更新和管理 以下是一些常见
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功