📄 1.5rohmstn.c
字号:
/********************************************************/
/* MAIN PROGRAM FOR DEMOTOOL FOR SHARP */
/* 1.5stn rohm REVION A */
/********************************************************/
#include <reg52.H>
#define tft19LCD 1
//#define atn13LCD 1
#define tft19LCDb8ud12
//#define tft19LCDb8ud17
#define baudrate38400
//#define baudrate19200
//#define baudrate9600
sfr FST = 0xb6;
sfr T2MOD = 0xc9;
sfr IP0 = 0xb8;
sfr IP0H = 0xb7;
sfr IP1 = 0xf8;
sfr IP1H = 0xf7;
sfr IEN0 = 0xa8;
sfr IEN1 = 0xe8;
sfr CCAP1H = 0xfb;
sfr CCAP1L = 0xeb;
sfr CCAPM1 = 0xdb;
sfr CCON = 0xd8;
sfr CH = 0xf9;
sfr CL = 0xe9;
sfr CMOD = 0xd9;
sfr AUXR =0x8e;
#define true 1
#define false 0
#define key_mask 0x0f
#define block_mask 0x07
#define key_up 0x0e
#define key_down 0x0d
#define key_shift 0x0b
#define key_playpause 0x07
#define key_poweroff 0x0c
#define setup_sector 0x07
#define BLOCK_ADDR_MASK 0xf8
#define FLASH_START 0x00
char xdata LCDREG _at_ 0xDC00;
char xdata LCDDATA _at_ 0xDD00;
char xdata LCDREG_SUB _at_ 0xDA00; //RS=L
char xdata LCDDATA_SUB _at_ 0xDB00;
char xdata LCDHBYTE _at_ 0xEF00;
char xdata AUXOUT _at_ 0xF700;
char xdata FLASH_5555 _at_ 0x5555;
char xdata FLASH_2AAA _at_ 0x2aaa;
sbit LCDcs=P1^6;
sbit Flashcs=P1^7;
sbit Led=P3^5;
sbit Dtr=P3^3;
sbit Dsr=P3^4;
sbit Bl1=P1^4;
unsigned char xdata *Image_data_addr;
unsigned char idata Auxdata;
unsigned char idata Bl_brightness;
unsigned char idata Block_addr;
unsigned char idata Contrast;
unsigned int idata Download_total;
unsigned int idata Download_counter;
unsigned char idata Download_process;
unsigned char idata Download_x;
unsigned char idata Picno;
bit Shift;
bit Pause;
bit Download_over;
bit Empty;
bit Chip_copy;
bit Chip_copy_over;
bit SUB;
bit Power;
void Cpu_init();
void Init_LCD();
void Init_SUB();
void Poweroff_main();
void Poweroff_sub();
void Key_int();
void System_init();
void Pcam1_init();
void Serial_init();
void Program_flash(unsigned char block_addr,unsigned char xdata *image_data,unsigned char io_data);
void Chip_erase_flash();
void Display_x(unsigned char block_addr);
void Display_x_shutter(unsigned char block_addr);
void Display_y(unsigned char block_addr);
void Display_y_shutter(unsigned char block_addr);
void Display_logo();
void Display_downloading();
void Display_downloaded();
void Display_eraseing();
void Display_erased();
void Display_chipcopy_transfering();
void Display_chipcopy_receiving();
void Display_SUB(unsigned char block_addr);
void Dram_write_start();
void LEDREG(unsigned char rgb);
void Display_on();
void Display_off();
void Display_r();
void Display_g();
void Display_b();
void Hardreset();
void Chip_select_flash();
void Chip_select_LCD();
void Led_light(bit led);
void Led_flash(unsigned char cycle);
void Key_up_server();
void Key_down_server();
void Key_shift_server();
void Key_playpause_server();
void Auxdata_write(unsigned char data_mask,unsigned char auxa_data);
void Delayus(int value);
void Delayms(int value);
unsigned char code Logo9616[192];
unsigned char code Downloading[480];
unsigned char code Transfering[480];
unsigned char code Receiving[384];
unsigned char code Downloaded[192];
unsigned char code Erasing[192];
unsigned char code Erased[192];
void main()
{
FST=0X08; //clock double disable
AUXR=0x02;
Bl_brightness=0; //init bightlight
Shift=0;
//Contrast=0x54;
Contrast=0x3f;
Pause=0;
Chip_copy=0;
Image_data_addr=FLASH_START;
Download_counter=0;
Download_process=0;
Download_total=0xffff;
Download_over=false;
Auxdata=0x08;
IEN0=0;
//rr: while(!Power);
Led_light(false);
Init_LCD();
System_init();
Bl_brightness=255; //init bightlight
CCAP1H=255-Bl_brightness; //set duty
Display_logo();
/*Display_on();
Delayms(1000);
Display_off();
Delayms(1000);
Display_r();
Delayms(1000);
Display_g();
Delayms(1000);
Display_b();
Delayms(1000);
Picno=1;
mloop1: while(Pause==1) goto mloop1; //if pause ,notgo
LEDREG(1);
Display_x(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false)
Delayms(1000);
Picno++;
mloop2: while(Pause==1) goto mloop2; //if pause ,notgo
LEDREG(2);
Display_x_shutter(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop3: while(Pause==1) goto mloop3; //if pause ,notgo
LEDREG(3);
Display_y(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop4: while(Pause==1) goto mloop4; //if pause ,notgo
LEDREG(4);
Display_y_shutter(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop5: while(Pause==1) goto mloop5; //if pause ,notgo
LEDREG(5);
Display_x(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false)
Delayms(1000);
Picno++;
mloop6: while(Pause==1) goto mloop6; //if pause ,notgo
LEDREG(6);
Display_x_shutter(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop7: while(Pause==1) goto mloop7; //if pause ,notgo
LEDREG(7);
Display_y(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop8: while(Pause==1) goto mloop8; //if pause ,notgo
LEDREG(5);
Display_y_shutter(Picno&0x07);
Display_SUB(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
goto mloop1;
loop:
Led_light(true);
Delayms(1000);
Led_light(false);
Delayms(1000);
goto loop;
}
*/
//while(1);
mloop1: while(Pause==1) goto mloop1; //if pause ,notgo
Display_on();
Delayms(1000);
mloop2: while(Pause==1) goto mloop2; //if pause ,notgo
Display_off();
Delayms(1000);
mloop3: while(Pause==1) goto mloop3; //if pause ,notgo
Display_r();
Delayms(1000);
mloop4: while(Pause==1) goto mloop4; //if pause ,notgo
Display_g();
Delayms(1000);
mloop5: while(Pause==1) goto mloop5; //if pause ,notgo
Display_b();
Delayms(1000);
Picno=1;
mloop6: while(Pause==1) goto mloop6; //if pause ,notgo
Display_x(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
goto mloop6;
loop: Led_light(true);
Delayms(100);
Led_light(false);
Delayms(100);
goto loop;
//mloop7: while(Pause==1) goto mloop7; //if pause ,notgo
// Display_x(Picno&0x07);
// if(Empty==false) Delayms(1000);
// Picno++;
//mloop8: while(Pause==1) goto mloop8; //if pause ,notgo
// Display_x(Picno&0x07);
// if(Empty==false) Delayms(1000);
// Picno++;
/*mloop5: while(Pause==1) goto mloop5; //if pause ,notgo
Display_x(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop6: while(Pause==1) goto mloop6; //if pause ,notgo
Display_x(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop7: while(Pause==1) goto mloop7; //if pause ,notgo
Display_x(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
mloop8: while(Pause==1) goto mloop8; //if pause ,notgo
Display_x(Picno&0x07);
if(Empty==false) Delayms(1000);
Picno++;
if(Picno=1)
Picno=4;
goto mloop1;
loop: Led_light(true);
Delayms(100);
Led_light(false);
Delayms(100);
goto loop;*/
}
void System_init()
{
unsigned char key;
unsigned char flash00;
system_init_begin:
P1=P1|key_mask;
key=P1&key_mask;
switch (key)
{
case key_mask: //demonstation
{
Pcam1_init();
IP0=0x01; //proitity setup :external i0
EX0=1; //open the io interrupt
EA=1;
IT0=1;
}
break;
case 0x00: //chip_erase
{
Bl1=true;
Led_light(true);
Delayms(1000);
P1=P1|key_mask;
key=P1&key_mask;
if ((key&key_mask)!=0) goto system_init_begin;
Display_eraseing();
Chip_erase_flash();
Display_erased();
Led_flash(3);
}
break;
case 0x02: //Chip_copy trans
{
Chip_copy=1;
Display_chipcopy_transfering();
Serial_init(); //serial port
ES=true; //UART interrupt enable
Block_addr=0;
Image_data_addr=0;
Auxdata_write(BLOCK_ADDR_MASK,0);
Chip_select_flash();
SBUF=*(Image_data_addr);
Image_data_addr++;
transloop: while(Chip_copy_over==0) goto transloop; //loop
EA=0;
}
break;
case 0x03: //Chip_copy receive
{
Chip_copy=1;
Display_chipcopy_receiving();
Serial_init(); //serial port
ES=true; //UART interrupt enable
Block_addr=0;
Image_data_addr=0;
Auxdata_write(BLOCK_ADDR_MASK,0);
Chip_select_flash();
receiveloop:while(Chip_copy_over==0) goto receiveloop; //loop
EA=0;
}
break;
case 0x01:
{
}
break;
case 0x04:
{
}
break;
case 0x05:
{
}
break;
case 0x06:
{
}
break;
default: //Block data receiver
{
Block_addr=key^key_mask;
Auxdata_write(BLOCK_ADDR_MASK,Block_addr&block_mask);
Chip_select_flash();
Image_data_addr=FLASH_START;
flash00=*(Image_data_addr);
if (flash00!=0xff) goto dover;
Serial_init(); //serial port
ES=true; //UART interrupt enable
Display_downloading();
doverloop: while(Download_over==0) goto doverloop; //loop
EA=0;
Delayms(10);
dover: EA=0;
Display_x(Block_addr);
if (flash00!=0xff) Display_downloaded();
Led_flash(3);
}
}
}
//========================================================
void Display_x(unsigned char block_addr)
{
unsigned char xdata *image_data_addr;
unsigned int data_offset;
unsigned int width;
unsigned int highth;
unsigned char r;
unsigned char g;
unsigned char b;
unsigned int i;
unsigned int j;
image_data_addr=FLASH_START;
Auxdata_write(BLOCK_ADDR_MASK,block_addr&block_mask);
Chip_select_flash();
r=*image_data_addr;
if(r==0xff) Empty=true;
else Empty=false;
data_offset=*(image_data_addr+10); //data offset
width=*(image_data_addr+18); //image width
highth=*(image_data_addr+22); //image highth
if (Empty==true){ highth=0; goto end;}
image_data_addr=image_data_addr+data_offset;
image_data_addr=image_data_addr+((highth)*width*3);
Chip_select_LCD();
LCDREG=0x2a;
LCDDATA=0x00;
LCDDATA=0x02;
LCDDATA=0x00;
LCDDATA=0x81;
LCDREG=0x2b;
LCDDATA=0x00;
LCDDATA=0x00;
LCDDATA=0x00;
LCDDATA=0xa1;
LCDREG=0x2c;
for(i=0;i<162;i++)
{
image_data_addr=image_data_addr-(width*3);
for(j=0;j<width;j++)
{
image_data_addr=image_data_addr+3;
Chip_select_flash();
b= (*(image_data_addr-1));
g = (*(image_data_addr-2));
r = (*(image_data_addr-3));
Chip_select_LCD();
LCDDATA =(b)&(0xfc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -