我正在尝试使用bit banging为I2c编写ac代码.我修改了维基代码(http://en.wikipedia.org/wiki/I%C2%B2C).但我无法得到结果.根据我的理解,维基中的代码不正确.我做了很多改变,但是我所做的一个重大改变,wiki失败告诉了正确的标记/标记该行与/ TBN /.我的代码如下,//必须定制的特定于硬件的支持功能:
#define I2CSPEED 135
#define SCL P0_0
#define SDA P0_1
void I2C_delay() { volatile int v; int i; for (i=0; i < I2CSPEED/2; i++) v; }
bool read_SCL(void); // Set SCL as input and return current level of line, 0 or 1
bool read_SDA(void); // Set SDA as input and return current level of line, 0 or 1
void clear_SCL(void); // Actively drive SCL signal low
void clear_SDA(void); // Actively drive SDA signal low
void …Run Code Online (Sandbox Code Playgroud)