資源簡介
采用atmel168A單片機,采用ssd1306方案,驅動oled的程序,開發環境為AtmelStudio6,語言為C語言。

代碼片段和文件信息
/*
?*?I2C.c
?*
?*?Created:?2013-7-24?8:02:13
?*??Author:?Administrator
?*/?
/*
?*?I2C.c
?*
?*?Created:?2013-7-16?9:09:40
?*??Author:?Administrator
?*/?
#include?
#include?“define.h“
void?stay_on(void)
{
DDRB?|=?(1?< PORTB?|=?(1?< DDRF?|=?(1?< PORTF?|=?(1?<}
void?delay_1us(void)
{
asm(“nop“);
}
void?delay_Nus(unsigned?int?a)
{
unsigned?int?i;
for(i?=?0;i? {
delay_1us();
}
}
void?delay_1ms(void)
{
unsigned?int?i;
for(i?=?1;i?(unsigned?int)(8*143?-?2);i++)
{
;
}
}
void?delay_Nms(unsigned?int?a)
{
unsigned?int?i;
for(i?=?0;i? {
delay_1ms();
}
}
void?SCK_H(void){PORTB?|=?(1?<void?SCK_L(void){PORTB?&=?~(1?<void?SDA_H(void){PORTB?|=?(1?<void?SDA_L(void){PORTB?&=?~(1?<
void?clock(void)
{
delay_Nus(2);
SCK_H();
delay_Nus(2);
SCK_L();
}
void?start(void)
{
SDA_H();
SCK_H();
delay_Nus(8);
SDA_L();
delay_Nus(8);
SCK_L();
delay_Nus(8);
}
void?stop(void)
{
SDA_L();
SCK_H();
delay_Nus(8);
SDA_H();
delay_Nus(8);
}
unsigned?char?response(void)
{
unsigned?char?flag?=?0;
DDRB?&=?~(1?< if(PINB?&?0x04)
{
flag?=?1;
}
else
{
SCK_H();
delay_Nus(2);
SCK_L();
delay_Nus(2);
}
DDRB?|=?(1?< return?flag;
}
void?write(unsigned?char?temp)
{
unsigned?char?i;
unsigned?char?dat;
dat?=?temp;
for(i?=?0;i?8;i++)
{
if(dat?&?0x80)
{
SDA_H();
}
else
{
SDA_L();
}
clock();
delay_1us();
dat?=?dat?<1;
}
SDA_H();
while(response());
}
void?write_command(unsigned?char?temp)
{
start();
write(slave_add);
write(0x00);
write(temp);
stop();
}
void?write_gddram(unsigned?char?dat)
{
start();
write(slave_add);
write(0x40);
write(dat);
stop();
}
void?write_command_data(unsigned?char?commandunsigned?char?dat)
{
start();
write(slave_add);
write(0x00);
write(command);
write(dat);
stop();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2953??2013-08-14?16:15??oled\oled\Debug\I2C.d
?????文件???????6916??2013-08-14?16:15??oled\oled\Debug\I2C.o
?????文件???????3230??2013-08-14?16:15??oled\oled\Debug\main.d
?????文件???????3008??2013-08-14?16:15??oled\oled\Debug\main.o
?????文件????????259??2013-08-14?16:10??oled\oled\Debug\makedep.mk
?????文件???????3419??2013-08-14?16:15??oled\oled\Debug\Makefile
?????文件???????2992??2013-08-14?16:15??oled\oled\Debug\oled.d
?????文件?????????34??2013-08-14?16:15??oled\oled\Debug\oled.eep
?????文件??????18318??2013-08-14?16:15??oled\oled\Debug\oled.elf
?????文件???????7185??2013-08-14?16:15??oled\oled\Debug\oled.hex
?????文件??????50457??2013-08-14?16:15??oled\oled\Debug\oled.lss
?????文件??????19205??2013-08-14?16:15??oled\oled\Debug\oled.map
?????文件??????17020??2013-08-14?16:15??oled\oled\Debug\oled.o
?????文件???????7034??2013-08-14?16:15??oled\oled\Debug\oled.srec
?????文件???????1611??2013-08-14?16:15??oled\oled\define.h
?????文件???????2180??2013-07-26?08:27??oled\oled\font_lib.h
?????文件???????2113??2013-07-26?10:35??oled\oled\I2C.c
?????文件????????780??2013-08-14?16:11??oled\oled\main.c
?????文件???????5933??2013-07-26?14:15??oled\oled\oled.c
?????文件???????5018??2013-07-26?17:23??oled\oled\oled.cproj
?????文件????????883??2013-07-24?08:00??oled\oled.atsln
????..A..H.?????16896??2013-08-14?15:27??oled\oled.atsuo
?????目錄??????????0??2013-08-14?16:15??oled\oled\Debug
?????目錄??????????0??2013-07-26?16:24??oled\oled
?????目錄??????????0??2013-07-24?08:00??oled
-----------?---------??----------?-----??----
???????????????177444????????????????????25
- 上一篇:OpenCv實現兩個圖片的相似度
- 下一篇:基于Matlab的聲紋鎖
評論
共有 條評論