#ifndef _IIC_H
#define _IIC_H
#include "user.h"
typedef unsigned char BYTE;
typedef unsigned short WORD;
#define   uchar unsigned char
#define   uint unsigned int	

/*模拟I2C端口输出输入定义*/
#define I2C_GPIO		        GPIOC
#define I2C_SCL_PIN			GPIO_Pin_1
#define I2C_SDA_PIN			GPIO_Pin_0

#define SCL_H         (I2C_GPIO->ODR |= I2C_SCL_PIN)
#define SCL_L         (I2C_GPIO->ODR &= (uint8_t)( ~I2C_SCL_PIN ))

#define SDA_H         (I2C_GPIO->ODR |= I2C_SDA_PIN)
#define SDA_L         (I2C_GPIO->ODR &= (uint8_t)( ~I2C_SDA_PIN ))

#define SDA_OUT       ((I2C_GPIO->DDR)|=(uint8_t)(I2C_SDA_PIN))
#define SDA_IN        ((I2C_GPIO->DDR)&=(uint8_t)(~I2C_SDA_PIN))
#define SDA_read      (I2C_GPIO->IDR  & (uint8_t)(I2C_SDA_PIN))
     

extern uint32_t T;
enum{yes=1,no=0};
void Delay5us(void);
void HMC5883_InitPin(void);
bool HMC5883_Start(void);
void HMC5883_Stop(void);
bool HMC5883_WaitACK(void);
void HMC5883_SendACK(bool ack);
void HMC5883_SendByte(BYTE dat);
BYTE HMC5883_RecvByte();
void Single_Write_HMC5883(uchar SlaveAddress,uchar REG_Address,uchar REG_data);
uchar Single_Read_HMC5883(uchar SlaveAddress,uchar REG_Address);
void Multiple_Read_HMC5883(uchar SlaveAddress,uchar *BUFF);
void Init_HMC5883();
#endif
