IIC.C
#include “I2C.h”
#include “N76E003.h”
#include “SFR_Macro.h”
#include “Function_define.h”
#include “Common.h”
#include “Delay.h”
//端口定义===
#define IIC_SCL_PORT //GPIOF
#define IIC_SCL_PIN P13//GPIO_PIN_6
#define IIC_SDA_PORT //GPIOF
#define IIC_SDA_PIN P14//
#define GPIOX_MODE_IN_UP_DOWN 8
#define GPIOX_MODE_OUT_PP 3
//时钟线操作
#define Set_IIC_SCL IIC_SCL_PIN = 1
#define Clr_IIC_SCL IIC_SCL_PIN = 0
//数据线操作
#define Set_IIC_SDA IIC_SDA_PIN = 1
#define Clr_IIC_SDA IIC_SDA_PIN = 0
#define READ_SDA IIC_SDA_PIN
#define IIC_DELAY_TIME 1 //时序延时
#define WAIT_ACK_TIME 5 //等待ACK超时时间
//=内部接口声明=
static void DelayUS(unsigned int ulNS);
//==================================================================================
//数据线方向定义,STM32 GPIO设为OD输出,可双向操作
void SDA_IN(void) {
/* -2- Configure IOs in output push-pull mode to drive external IIC_SDA_PIN */
} //设置为输入
void SDA_OUT(void) {
/* -2- Configure IOs in output push-pull mode to drive external IIC_SDA_PIN */
} //设置为输出
//=================================================================
//函 数 名:IICInit
//功能描述:初始化模拟IIC
//输 入:无
//输 出:无
//返 回:无
//=================================================================
void IICInit(void)
{
//打开IO时钟
//将数据线和时钟线拉高,IIC处于空闲状态
Set_IIC_SCL;
Set_IIC_SDA;
}
//=================================================================
//函 数 名:IICStart
//功能描述:IIC起始信号
/