大侠帮我看看下面两个函数老是编译错误,找不出原因---------------- Project: IRSwitch_APDS9930 ----------------
compiling delay.c...
compiling iic.c...
iic.h:24:31: error: macro "I2C_SDA_READ" passed 1 arguments, but takes just 0
iic.h:25:31: error: macro "I2C_SCL_READ" passed 1 arguments, but takes just 0
iic.c:20:31: error: macro "I2C_SDA_READ" passed 1 arguments, but takes just 0
iic.c:44:31: error: macro "I2C_SCL_READ" passed 1 arguments, but takes just 0
iic.c:21: syntax error: token -> '{' ; column 1
"IRSwitch_APDS9930" - 5 Error(s), 0 Warning(s).
2021-04-17 00:29:00 Build fail.
源码:
/*
*********************************************************************************************************
* 函 数 名: I2C_SDA_READ
* 功能说明: 读取protB4的值
* 形 参:无
* 返 回 值: sda_val
*********************************************************************************************************
*/
unsigned int I2C_SDA_READ(void)
{
unsigned int sda_val;
TRISB|=(0x01<<4); //PORTB4设置位输入:0=输出;1=输入
PHCON&=~(0x01<<4); //PORTB4设置为上拉输入:0=enable;1=disenable
sda_val=PROTB4;
TRISB&=~(0x01<<4); //PORTB4设置位输出:0=输出;1=输入
PHCON|=(0x01<<4); //屏蔽 PORTB4 输入上拉功能 0=enable;1=disenable
return sda_val;
}
/*
*********************************************************************************************************
* 函 数 名: I2C_SCL_READ
* 功能说明: 读取protB5的值
* 形 参:无
* 返 回 值: sda_val
*********************************************************************************************************
*/
unsigned int I2C_SCL_READ(void)
{
unsigned int scl_val;
TRISB |=(0x01<<5); //ProtB5设置位输入:0=输出;1=输入
PHCON &=~(0x01<<5); //ProtB5设置为上拉输入0=enable;1=disenable
scl_val=PROTB5;
TRISB &=~(0x01<<5); //ProtB5设置位输出:0=输出;1=输入
PHCON |=(0x01<<5); //屏蔽 PORTB5 输入上拉功能 0=enable;1=disenable
return scl_val;
}
|