#ifndef __SW_I2C_H
#define __SW_I2C_H
#include "sys.h"	    
#include "stm32f10x.h"

#define IIC_TURE	1
#define IIC_FALSE	0

#define	IIC_CLK_DELAY	1			//IIC clock define

#define SDA_IN()  {GPIOB->CRL&=0XF0FFFFFF;GPIOB->CRL|=0X08000000;}	//set SDA as input
#define SDA_OUT() {GPIOB->CRL&=0XF0FFFFFF;GPIOB->CRL|=0X03000000;}	//set SDA as output

//液晶屏SCL--接STM32_PB5引脚
//液晶屏SDA--接STM32_PB6引脚

#define IIC_SCL    PBout(5) 	//SCL output high or low
#define IIC_SDA    PBout(6) 	//SDA output high or low
#define READ_SDA   PBin(6)  	//Get SDA input value


void IIC_Gpio_Init(void);
void IIC_Init(void);
void IIC_Start(void);
void IIC_Stop(void);
void IIC_Send_Byte(u8 txd);
u8 IIC_Read_Byte(unsigned char ack);
u8 IIC_Wait_Ack(void);
void IIC_Ack(void);
void IIC_NAck(void);
void IIC_WriteREG(u8 byte);
void IIC_WriteDAT(u8 byte);
void iic_send_test(u8 txd);
#endif
















