📄 main.c
字号:
#include "mcu.h"
#include "2408Driver.h"
unsigned char g_Comm_Rcv,g_IsRcv=0;
/* AT24XX驱动程序,AT2402,AT2404,AT2408,AT2416通用
总线方式:I2C
地址分配
sbit SCL= P3^4;
sbit SDA= P3^5;
详细子驱动在2408Driver.h
writed by KreateHe ◎2006/4/18
*/
/*-----------------------------------------------*/
/* */
/* 主程序 */
/* */
/*-----------------------------------------------*/
void main(void)
{
uchar *pw,pwpw[10];
init_mcu();
send_string_comm("OK!");
delay(1000);
pw="1234567890";
send_string_comm("+~+");
savestring_24xx(0xa110,pw);//save string to at24xx
send_string_comm("++");
delay(10000);
send_string_comm("+1+");
getstring_24xx(0xa110,pwpw,10);//read 10byes from at24xx with start addr 0xa110
//pw=pwpw;
//pwpw[10]='\0';
send_string_comm(pwpw);
send_string_comm("++");
delay(10000);
send_string_comm("+2+");
getstring_24xx(0xa110,pwpw,3);
//pw=pwpw;
//pwpw[3]='\0';
send_string_comm(pwpw);
send_string_comm("++");
//while(1);
while(1)
{
if (g_IsRcv==1)
{
g_IsRcv=0;
send_char_comm(g_Comm_Rcv);
}
}
}
/*-----------------------------------------------*/
/*串口中断接收*/
void serial_isr(void) interrupt 4 using 0
{
unsigned char data input_char;
EA=0;
if(RI==1)
{
RI=0;
input_char= SBUF;
g_IsRcv=1;
g_Comm_Rcv=input_char;
}
EA=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -