資源簡介
智能學習型紅外遙控器設計,內部包含源代碼和電路圖

代碼片段和文件信息
#include?
#include?
#define?__SRC
???#include?“AT24C02.h“
#undef??__SRC
?
#define?OP_WRITE?0xa0??????????//?器件地址以及寫入操作?
#define?OP_READ??0xa1??????????//?器件地址以及讀取操作?
?
#define?delayNOP();?{_nop_();_nop_();_nop_();_nop_();};?
/**********************************************************/
void?AT24C02_Init()??//?總線初始化
{
SDA=1;
delayNOP();
SCL=1;
delayNOP();
}
/**********************************************************/?
void?start()??//啟動信號?
{?
SDA?=?1;?
SCL?=?1;?
delayNOP();?
SDA?=?0;? //?SCL高電平期間,SDA下降沿啟動信號
delayNOP();
SCL?=?0;?
}?
/**********************************************************/?
void?stop()??//?停止信號?
{?
SDA?=?0;?
delayNOP();?
SCL?=?1;?
delayNOP();?//?SCL高電平期間,SDA上升沿停止信號
SDA?=?1;?
}?
/**********************************************************/?
unsigned?char?shin()?//?從AT24C02移出數(shù)據(jù)到MCU
{?
unsigned?char?iread_data;?
for(i?=?0;?i?8;?i++)?
{?
SCL?=?1;?
read_data?<<=?1;?
read_data?|=?SDA;?
SCL?=?0;?
}?
return(read_data);?
}?
/**********************************************************/?
bit?shout(unsigned?char?write_data)?//?從MCU移出數(shù)據(jù)到AT24C02??
{?
unsigned?char?i;?
bit?ack_bit;?
for(i?=?0;?i?8;?i++)???//?循環(huán)移入8個位?
{?
SDA?=?(bit)(write_data?&?0x80);?
_nop_();?
SCL?=?1;?
delayNOP();?
SCL?=?0;?
write_data?<<=?1;?
}?
SDA?=?1;?????????????????????//?讀取應答?
delayNOP();?
SCL?=?1;?
delayNOP();?
ack_bit?=?SDA;?
SCL?=?0;?
return?ack_bit;????????????//?返回AT24C02應答位?
}?
/**********************************************************/?
void?AT24C02_WriteByte(unsigned?char?addr?unsigned?char?write_data)?//?在指定地址addr處寫入數(shù)據(jù)write_data?
{?
start();?
shout(OP_WRITE);?
shout(addr);?
shout(write_data);?
stop();?
AT24C02_delayms(10);??????????//?寫入周期?
}?
/**********************************************************/?
unsigned?char?read_current()?//?在當前地址讀取
{?
unsigned?char?read_data;?
start();?
shout(OP_READ);?
read_data?=?shin();?
stop();?
return?read_data;?
}?
/**********************************************************/?
unsigned?char?read_random(unsigned?char?random_addr)?//?在指定地址讀取?
{?
start();?
shout(OP_WRITE);?
shout(random_addr);?
return(read_current());?
}?
/**********************************************************/?
void?AT24C02_delayms(unsigned?int?ms)?//?延時子程序?
{?
???unsigned?char?k;?
???while(ms--)?
???{?
??????for(k?=?0;?k?120;?k++);?
???}?
}
////////////////////////////////////////////////////////////////////////
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2674??2011-06-10?09:27??智能學習型紅外遙控器設計\Infrared_Code\AT24C02.c
?????文件????????596??2011-06-09?00:04??智能學習型紅外遙控器設計\Infrared_Code\AT24C02.h
?????文件???????5741??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\AT24C02.LST
?????文件???????7357??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\AT24C02.OBJ
?????文件??????26069??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code
?????文件???????5033??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code.hex
?????文件?????????96??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code.lnp
?????文件??????33175??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code.M51
?????文件???????1736??2012-04-28?11:13??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code.Opt
?????文件????????227??2012-04-28?11:13??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code.plg
?????文件???????2262??2012-04-18?16:09??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code.Uv2
????.......??????1745??2012-04-18?16:09??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code_Opt.Bak
?????文件???????2282??2011-06-09?12:14??智能學習型紅外遙控器設計\Infrared_Code\Infrared_Code_Uv2.Bak
?????文件???????8711??2011-06-25?10:23??智能學習型紅外遙控器設計\Infrared_Code\IR_Main.c
?????文件????????882??2011-06-09?11:19??智能學習型紅外遙控器設計\Infrared_Code\IR_Main.h
?????文件??????19355??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\IR_Main.LST
?????文件??????14183??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\IR_Main.OBJ
?????文件????????694??2011-06-09?12:07??智能學習型紅外遙控器設計\Infrared_Code\Key.c
?????文件????????251??2011-06-09?12:07??智能學習型紅外遙控器設計\Infrared_Code\Key.h
?????文件???????2271??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\Key.LST
?????文件???????2308??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\Key.OBJ
?????文件???????2824??2011-06-08?23:07??智能學習型紅外遙控器設計\Infrared_Code\SO12864.c
?????文件????????629??2011-06-08?22:29??智能學習型紅外遙控器設計\Infrared_Code\SO12864.h
?????文件???????5995??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\SO12864.LST
?????文件???????6485??2011-06-25?10:28??智能學習型紅外遙控器設計\Infrared_Code\SO12864.OBJ
?????文件?????447488??2011-06-28?20:40??智能學習型紅外遙控器設計\智能學習型紅外遙控器PCB.PcbDoc
?????文件??????34766??2011-09-02?17:58??智能學習型紅外遙控器設計\智能學習型紅外遙控器PCB截圖.png
?????文件??????28425??2011-06-28?20:33??智能學習型紅外遙控器設計\智能學習型紅外遙控器原理圖.pdf
?????文件?????344064??2011-06-07?23:27??智能學習型紅外遙控器設計\智能學習型紅外遙控器原理圖.SchDoc
?????目錄??????????0??2012-04-28?11:13??智能學習型紅外遙控器設計\Infrared_Code
............此處省略4個文件信息
- 上一篇:vcf解析工具--安卓通訊錄備份文件解析工具
- 下一篇:卡耐基SSD9選擇題大全
評論
共有 條評論