12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef _MPU6050_H_
- #define _MPU6050_H_
- #include <stdint.h>
- #include <string.h>
- typedef __packed struct {
- int16_t ax,ay,az;
- int16_t temp;
- int16_t gx,gy,gz;
- }ad0x0_gyrodata_s;
- typedef ad0x0_gyrodata_s ad0x0_gyrodata_t;
- typedef uint8_t u8;
- // note: DMP code memory blocks defined at end of header file
- #define MPU6050_ADDRESS_W (MPU6050_ADDRESS_AD0_LOW <<1)
- #define MPU6050_ADDRESS_R (MPU6050_ADDRESS_AD0_LOW <<1)|0x1
- void mpu6050_init(void);
- void mpu6050_writebyte(u8 _reg,u8 _byte);
- void mpu6050_readbyte(u8 _reg);
- void mpu6050_writebits_mask(u8 _reg, u8 _byte, u8 _andmask);
- void mpu6050_writebit(u8 _reg, u8 _bitNum, u8 _value);
- //void mpu6050_readbytes(u8 _reg,u8 *_pbuf,u8 _count);
- void mpu6050_read14(void);
- void update_gdata(void);
- //void mpu6050_damn_lendian(void);
- //void mpu6050_stop(void);
- uint8_t mpu6050_zavis(void);
- ad0x0_gyrodata_s *mpu6050_get_gyrodata_s(void);
- ad0x0_gyrodata_s *mpu6050_get_gyrodata_s_le(void);
- void mpu6050_pin_irq(void);
- void mpu6050_start(void);
- uint32_t mpu6050_get_last_update_tick(void);
- /*чтобы все заработало, в main.c должны быть
- ...
- #include "ad0x0_i2c1.h" или #include "ad0x0_i2c2.h"
- #include "mpu6050.h"
- ...
- ad0x0_i2c1_init();
- mpu6050_init();
- mpu6050_start();
- ....
- ------------
- stm32f1xx_it.c
- #include "i2c/ad0x0_i2c1.h"
- #include "mpu6050/mpu6050.h"
- .....
- void I2C1_EV_IRQHandler(void)
- extern void ad0x0_i2c1_irq(void);
- ad0x0_i2c1_irq();
- ...
- void I2C1_ER_IRQHandler(void)
- {
- ad0x0_i2c1_irq_err();
- ...
- */
- #endif /* _MPU6050_H_ */
|