用keil uvision4編譯錯誤
Build target '時鐘'compiling main.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'
..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling pbdata.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling 24c02.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling key.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling xianshi.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'Target not created
頭文件
#ifndef __24C02_H_
#define __24C02_H_
bit write=0; //寫24C02的標志
sbit sda =P2^0;
sbit scl =P2^1;
void delay0();
void start(); //開始信號
void stop(); //停止
void respons(); //應答
void init_24c02(); //I^2C初始化函數
void write_byte(uchar date); //寫一個字節函數
uchar read_byte(); //讀一個字節函數
void write_add(uchar address,uchar date); //指定地址寫一個字節
void read_add(uchar address); //指定地址讀一個字節
#endif
函數
#include "pbdata.h"
void delay0()
{;;}
void start() //開始信號
{
sda=1;
delay0();
scl=1;
delay0();
sda=0;
delay0();
}
void stop() //停止
{
sda=0;
delay0();
scl=1;
delay0();
sda=1;
delay0();
}
void respons() //應答
{
uchar i;
scl=1;
delay0();
while((sda==1)&&(i<250))
i++;
scl=0;
delay0();
}
void init_24c02() //I^2C初始化函數
{
sda=1;
delay0();
scl=1;
delay0();
}
void write_byte(uchar date) //寫一個字節函數
{
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay0();
sda=CY;
delay0();
scl=1;
delay0();
}
scl=0;
delay0();
sda=1;
delay0();
}
uchar read_byte() //讀一個字節函數
{
uchar i,k;
scl=0;
delay0();
sda=1;
delay0();
for(i=0;i<8;i++)
{
scl=1;
delay0();
k=(k<<1)|sda;
scl=0;
delay0();
}
return k;
}
void write_add(uchar address,uchar date) //指定地址寫一個字節
{
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
write_byte(date);
respons();
stop();
}
void read_add(uchar address) //指定地址讀一個字節
{
uchar date;
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
start();
write_byte(0xa1);
respons();
date=read_byte();
stop();
return date;
}
|