#ifndef _GY_273_H
#define _GY_273_H
#define I2C_SCL_PIN 5
#define I2C_SDA_PIN 1
#define I2CPORT PORTC
#define I2CDDR DDRC
#define I2CPIN PINC
#define I2C_SCL_SET I2CPORT|=BIT(I2C_SCL_PIN);
#define I2C_SCL_CLR I2CPORT&=~BIT(I2C_SCL_PIN);
#define I2C_SDA_SET I2CPORT|=BIT(I2C_SDA_PIN);
#define I2C_SDA_CLR I2CPORT&=~BIT(I2C_SDA_PIN);
#define I2C_SDA_DAT I2CPIN&BIT(I2C_SDA_PIN)
#define I2C_SDA_OUT I2CDDR|=BIT(I2C_SDA_PIN);
#define I2C_SDA_IN I2CDDR&=~BIT(I2C_SDA_PIN);
#define I2C_Drop {I2C_SDA_SET I2C_SCL_SET}
#define I2C_PIN_INIT I2CDDR|=BIT(I2C_SDA_PIN)|BIT(I2C_SCL_PIN);
#define START 0x08
#define RE_START 0x10
#define MT_SLA_ACK 0x18
#define MT_SLA_NOACK 0x20
#define MT_DATA_ACK 0x28
#define MT_DATA_NOACK 0x30
#define MR_SLA_ACK 0x40
#define MR_SLA_NOACK 0x48
#define MR_DATA_ACK 0x50
#define MR_DATA_NOACK 0x58
#define DEVICE_ADDR 0x1e
#define FilterSize 30 //滤波系数
void GY273_Init(void);
void GY273_Read(uint *Data);
void GY273_Filter(uint *Data,uint *Out);
void GY273_GetXYZ(uint *Data);
#endif
<pre class="cpp" name="code">#include <Include.h>
void Delay(uint16 us)
{
while(us--);
}
/*------------------------------------------------------------------------