📄 ctrl.c
字号:
#include <reg2051.h>
#include <absacc.h>
#include <stdio.h>
unsigned char code *systemPasswordCode_1="Hello world !! Take me to your heart !!";
unsigned char code *systemPasswordCode_2="Let me see,this program is very good !!";
unsigned char code *systemPasswordCode_3="Don't you see this program ? I love you !!";
#define PasswordCode CBYTE[0x7ff]
//=================================================
// const unsigned char code PasswordCode=0x7b;
//=================================================
unsigned char stepNum=0;
unsigned char P1_buffer=1;
extern unsigned int getnumber (void);
extern void output (unsigned int);
void func0 (void){;}
void func1(void){;}
void wait (void) { /* wait function */
; /* only to delay for LED flashes */
}
void Set_1 (void) {
unsigned int i; /* Delay var */
unsigned char j; /* LED var */
while (1) { /* Loop forever */
for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
}
}
void Set_2(void) {
/* INITIALIZE SERIAL INTERFACE TO 2400 BAUD @12MHz */
SCON = 0x52; /* SCON */
TMOD = 0x20; /* TMOD */
TCON = 0x69; /* TCON */
TH1 = 0xf3; /* TH1 */
printf("MAIN PROGRAM CALLS A FUNCTION IN BANK 0 \n");
func0();
printf("MAIN PROGRAM CALLS A FUNCTION IN BANK 1 \n");
func1();
while(1);
}
void main(void)
{
P1=0xff;
P1_buffer=P1;
P3=0x00;
while(1)
{
while(P1_buffer==PasswordCode)
{
P3_0=0;
P3_1=1;
// P1_buffer=P1;
}
P1_buffer=P1;
while(P1_buffer!=PasswordCode)
{
P3_0=1;
P3_1=0;
P1_buffer=P1;
}
}
Set_1();
Set_2();
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -