程序没有整理,呵呵.是另外一个程序变过来的
只供参考下.简单玩下.程序有一些没有用到的变量,不用管它,看主程序就可以了. #include<reg52.h> #include<intrins.h> #include"DS1302.h"
typedef unsigned char uchar; typedef unsigned int uint;
uchar bdata equip_status; uchar bdata receive_dat;
sbit display_clk=P3^3; sbit display_dat=P3^2;
//sbit disalarm_forbid=P1^0;
sbit int_flag=equip_status^0; //sbit alarm_flag=P1^0; sbit alarm_flag=equip_status^1; sbit sound_flag=equip_status^2; sbit lock_flag=equip_status^3; //sbit forbid_flag=equip_status^3;
bit alarm_oldset=0; bit flag_on; bit flag_rest;
uchar code led_code[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x40}; // {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88};
uchar alarm_order; uchar old_area; uint time_insist; uint time_insist1; uchar alarm_area; uchar dip_order; uchar dip_area; uchar dip_current; uchar dis_buf[3]; uchar iic_buf[3]; uchar key_value; uchar flash_save;
void delayms(uint time_ms); void disend(uchar *p); void alarmdatobuf(uchar ord,uchar area); void key_scan(); void iicwbyte(uchar dat_add,uchar dat); uchar iicrbyte(uchar dat_add); bit RW24C02(uchar *DataBuff,uchar ByteQuantity,uint Address,uchar ControlByte); uchar receive165(); void test_channels(); //void test(); void init_status(); void sys_statue(); void pro_decode(uchar decode); void dat_store(); void status_store(); void change_channels(uchar tep_on); void disblank(); uchar alarm_wilesn(uchar a_area); void wire_alarm(); uchar code message[]={0x00,0x4A,0x00,0x42,0x00,0x33,0x00,0x35,0x00,0x47,0x77,0xED,0x4F,0xE1,0x6D,0x4B,0x8B,0xD5}; //JB35G短信测 uchar code mes_cmdon[]={0x43,0x4F,0x4D,0x53,0x4D,0x53,0x38,0x4b}; uchar code mes_cmdoff[]={0x43,0x4F,0x4D,0x53,0x4D,0x53,0x38,0x47}; uchar code mes_cmd[]={0x43,0x4F,0x4D,0x53,0x4D,0x53}; void wait_idle(); void save_battery();
//comsms01 uchar c1; uchar c2; SYSTEMTIME CurrentTime; uchar week_value[2];
void delayms(uint time_ms) { uint i,j; for (j=0;j<time_ms;j++) { i=202; while(i--); } }
void show_time() { DS1302_GetTime(&CurrentTime); TimeToStr(&CurrentTime); DateToStr(&CurrentTime);
}
main() {
Initial_DS1302(); //时钟芯片初始化 dis_buf[0]=led_code[3]; while (1) { show_time(); c2=1; // P1=1; for (c1=0;c1<8;c1++) { // res_164=0; P1=0xff; dis_buf[0]=led_code[(CurrentTime.DateString][c1])];//led_code[c1]; dis_buf[1]=led_code[(CurrentTime.TimeString][c1])]; dis_buf[2]=led_code[c1]; disend(dis_buf); P1=~c2; delayms(1); c2<<=1; }
} }
//sbit pp=P3^4;
void disend(uchar *p) { uchar i,j,*p1,mid; // pp=0; display_clk=0; p1=p; // pp=1; for(j=0;j<3;j++) { mid=*p1; for (i=0;i<8;i++) { mid<<=1; if(CY) display_dat=1; else display_dat=0; display_clk=1; display_clk=0; } p1++; } }
|
|