最近寫一個硬件I2C驅動,程序中調試的錯誤碼是error C237: : function already has a body
/*代碼如下(未完工)*/
/*定義I2C控制寄存器命令*/
#define wait 0x80
#define start 0x81
#define txdc 0x82
#define rack 0x83
#define rxdc 0x84
#define tack 0x85
#define stop 0x86
#define start_txdc_rack 0x89
#define txdc_rack 0x8a
#define rxdc_ack 0x8b
#define rxdc_nak 0x8c
/*定義I2C主機讀寫控制指令*/
#define rd 1
#define wt 0
/*定義I2C主機狀態命令*/
#define ack_t 0x01
#define ack_r 0x02
i2c_init(uc i2c_s_add,uc rw) /*片內I2C硬件驅動器初始化函數*/
{
iuc combuf;
I2CCFG=0xfe; /*啟動I2C,設置本機為主機,波特率為86400*/
combuf=i2c_s_add<<1; /*器件地址左移1位*/
if(rw && combuf%2) /*如果指令為讀,且左移過后地址合法(0-127之間)*/
{
combuf|=0x01; /*將最低位設置為1*/
}
whl(I2CMSST & ack_r) /*等待標志位*/
{
;
}
I2CMSST |= 0x02; /*恢復標志位*/
I2CMSCR=start;
I2CTXD=combuf;
}
/*取消宏定義*/
#undef ack_t
#undef ack_r
#undef rd
#undef wt
#undef wait
#undef start
#undef txdc
#undef rack
#undef rxdc
#undef tack
#undef stop
#undef start_txdc_rack
#undef txdc_rack
#undef rxdc_ack
#undef rxdc_nak
#undef SCL
#undef SDA
|