📄 main.c
字号:
#include "reg52.h"
#include "stdio.h"
#include "string.h"
#include "51LIB.h"
#include "SM59264.h"
#include "NX25P40.h"
typedef void (*BOOT)(void);
unsigned long writer,reader;
void main(void)
{unsigned char temp,buf[64];
unsigned long *p;
unsigned char flag;
BOOT reset;
En_SMMem();
for(temp=0;temp!=32;temp++)
buf[temp]=temp;
buf[1]=0xff;
Init_Uart(0xfa,0xfa);
while(!RI);{RI=0;temp=SBUF;}
begin:
p=Init_Datasheet();
reader=*p; writer=*(p+1);
if(writer==0x40000)
Delet_Datasheet();
printf("Reader is %#lx\r\n",reader);
printf("Writer is %#lx\r\n",writer);
while(1)
{if(RI)
{RI=0;temp=SBUF;putchar(temp);
if(temp=='\r')putchar('\n');
if(temp=='\b'){
putchar(' ');
REN=TI = 0;SBUF ='\b';
while (!TI);TI = 0;
REN=1;
}
if(temp=='B')
{printf("\r\ngoto run BOOTLOADER...\r\n");
printf("Please oprn XMODEM protocal to transmit the code!\r\n");
SCON=0x50;TMOD=0x20;TH1=TL1=0xfd;TR1=1;PCON&=~0x80;
reset=(BOOT)0xf000;
reset();
}
if(temp=='P')
{printf("\r\n");
for(temp=0;temp!=32;temp++)
buf[temp]=temp;
buf[1]=0xff;
if((flag=Write_Datasheet(writer,buf))==0)
{memset(buf,0,64);
Read_Datasheet(writer,buf,64);
writer+=32;
if(writer==0x40000){Delet_Datasheet();
writer=reader=0;
}
for(temp=0;temp!=64;temp++)
printf("buf[%d]-%#x ",(unsigned int)temp,(unsigned int)buf[temp]);
printf("\r\n");
}
else printf("Writer Error\r\n");
}
if(temp=='V')
{printf("\r\nStart Datasheet!\r\n");
goto begin;
}
if(temp=='C')
{printf("\r\nCancel Datasheet!\r\n");
if(writer-reader>=32)
{Cancel_Datasheet(reader);
Read_Datasheet(reader,buf,32);
for(temp=0;temp!=64;temp++)
printf("buf[%d]-%#x ",(unsigned int)temp,(unsigned int)buf[temp]);
printf("\r\n");
if(writer-reader>32)reader+=32;
}
else printf("No data can be canceled!\r\n");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -