资源简介
门禁系统代码(C语言版).门禁系统代码(C语言版).门禁系统代码(C语言版).
代码片段和文件信息
#include
#include
#include
#include
#include “TimecardRecord.h“
#include “AVR_TWI.h“
void set_eeprom_as(volatile unsigned char *uc_data)
{
if( (*uc_data != 0xA0) && (*uc_data != 0xA4) && (*uc_data != 0xA6) ) goto error;
unsigned int ui_data_addr;
unsigned char uc_device_addr;
unsigned int uc_cycle;
uc_device_addr = *uc_data;
set_buff_as(*(uc_data+1) 128 uc_pc_buff);
for(ui_data_addr=0; ui_data_addr<0xFF80;)
{
uc_cycle = 0;
re_write:
if( uc_cycle++ >= CYCLE_TRY ) goto error;
if( I2C_eeprom_write(uc_device_addr ui_data_addr 128 uc_pc_buff) == RW_SUC )
{
ui_data_addr+=128;
}
else
{
goto re_write;
}
}
trans_suc_msg(_SET_EEPROM_AS);
return;
error:
trans_err_msg(_SET_EEPROM_AS);
}
void set_system_time(unsigned char uc_len volatile unsigned char *uc_data)
{
unsigned char uc_cycle;
uc_cycle=0;
re_write:
if( uc_cycle++ >= CYCLE_TRY ) goto error;
if( RTC_Write(0xA2 0x02 uc_len uc_data) )
{
goto re_write;
}
trans_suc_msg(_SET_TIME);
return;
error:
trans_err_msg(_SET_TIME);
}
void read_system_time(unsigned char uc_be_send_to_master)
{
unsigned char uc_temp;
unsigned char uc_cycle;
unsigned char uc_cycle_r;
uc_cycle=0;
begin:
if( uc_cycle++ >= CYCLE_TRY ) goto error;
if( RTC_Read(0xA2 0x02) == RW_SUC )
{
for(uc_temp=0; uc_temp<7;)
{
uc_cycle_r=0;
re_read:
if( uc_cycle_r++ >= CYCLE_TRY ) goto error;
if( TWI_SLA_R() == 0x50 )
{
uc_systime[uc_temp++] = TWDR;
}
else
{
goto re_read;
}
}
TWI_Stop();
uc_systime[0] = uc_systime[0]&0x7F;
uc_systime[1] = uc_systime[1]&0x7F;
uc_systime[2] = uc_systime[2]&0x3F;
uc_systime[3] = uc_systime[3]&0x3F;
uc_systime[4] = uc_systime[4]&0x07;
uc_systime[5] = uc_systime[5]&0x1F;
uc_systime[6] = uc_systime[6]&0xFF;
if( uc_be_send_to_master == _READ_TIME )
{
trans_msg(_READ_TIME 7 uc_systime);
}
return;
}
else
{
goto begin;
}
error:
TWI_Stop();
trans_err_msg(_READ_TIME);
}
void set_single_info(unsigned int ui_addr unsigned int ui_addr_offset unsigned char uc_be_warrant)
{
unsigned char uc_cycle;
unsigned char uc_cycle_r;
unsigned char uc_read_buff;
uc_cycle=0;
start_step1:
if( uc_cycle++ > CYCLE_TRY ) goto error;
if( I2C_eeprom_read(0xA0 (ui_addr_offset+(ui_addr/8))) == RW_SUC )
{
uc_cycle_r=0;
re_read_step1:
if( uc_cycle_r++ > CYCLE_TRY ) goto error;
if( TWI_SLA_R() == 0x50 )
{
uc_read_buff = TWDR;
TWI_Stop();
}
else
{
goto re_read_step1;
}
}
else
{
goto start_step1;
}
uc_cycle=0;
if( uc_be_warrant == 0x01 )
{
if( bit_is_clear(uc_read_buff (ui_addr_offset+(ui_addr%8))) )
{
sbi(uc_read_buff (ui_addr_offset+(ui_addr%8)));
goto start_step2;
}
}
else if( uc_be_warrant == 0x00 )
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4666 2007-01-29 14:03 门禁系统代码(C语言版)\门禁系统代码下载\TimecardRecord\AVR_TWI.h
文件 3142 2007-01-31 00:47 门禁系统代码(C语言版)\门禁系统代码下载\TimecardRecord\TimecardRecord.aps
文件 17346 2007-01-31 08:24 门禁系统代码(C语言版)\门禁系统代码下载\TimecardRecord\TimecardRecord.c
文件 8264 2007-01-31 13:12 门禁系统代码(C语言版)\门禁系统代码下载\TimecardRecord\TimecardRecord.h
目录 0 2011-07-09 08:43 门禁系统代码(C语言版)\门禁系统代码下载\TimecardRecord
目录 0 2011-07-09 08:43 门禁系统代码(C语言版)\门禁系统代码下载
目录 0 2011-07-09 08:43 门禁系统代码(C语言版)
----------- --------- ---------- ----- ----
33418 7
- 上一篇:实现最近点对问题源的代码(C语言)
- 下一篇:VegaPrime_MFC
评论
共有 条评论