我正在启动一个新项目、希望使用 USI 库进行 I2C 通信。
我这些示例、但在编译时未定义?
我的代码:
#include "stdint.h"
#include "USI_I2CMaster.h"
#include "msp430g2230.h"
//传感器的默认从地址为0x29
int door_state=0、mub=1、iv1=0;
unsigned int ic0=0、ic2=1、iv、Iout、k=0、m=0、in=0、p=500、ivi=20;
unsigned int lDS=0、ACK1=1、slvw=0x28、slvr=0x29;
unsigned char c;
int main (空)
{
WDTCTL = WDTPW + WDTHOLD;//停止看门狗计时器
P1REN=0x1B;//正确终止不可用的 Port1引脚(P1.0/1/3/4)
P1DIR = 0x24;//将 P1设置为输出方向
P1OUT=0x00;
TACCR0=47300;//测量时间为333毫秒。
TACCTL0=CCIE;
TACTL=MC_1_ID_3|tassel_2|TACLR;
MUB=1;
TI_USI_I2C_MasterInit (USIDIV_7+USISSEL_2+USICKPL、StatusCallback);//此处出现错误为"未定义的 StatusCallback "
_enable_interrupt ();
对于(;)
{
_low_power_mode_0 ();
}
}
#pragma vector=TIMERA0_vector
_interrupt void TA0_ISR (void)
{
ic0++;
if (LDS=0 &&(ic0&1)=0)//启动状态
{
IC2++;
Iout=((ic2&1)<<2)|((ic2&2)<<4);
P1OUT=Iout;
if (ic2>12)
{
LDS=1;
IC2=0;
}
}
如果(LDS = 1)则为其他
{
P1OUT=0x24;
}
}
int statusCallback (unsigned char c)
{
返回 TI_USI_EXIT_LPM;
}