37 lines
744 B
C
37 lines
744 B
C
/*
|
|
* mpu6500.h
|
|
*
|
|
* Created on: Mar 4, 2024
|
|
* Author: gxms0
|
|
*/
|
|
|
|
#ifndef BSP_MPU6500_H_
|
|
#define BSP_MPU6500_H_
|
|
|
|
#include "ch32v20x.h"
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include "drv_i2c.h"
|
|
|
|
typedef struct sMPU {
|
|
|
|
I2C_ptr i2c;
|
|
uint16_t address;
|
|
|
|
uint16_t (*read)(I2C_ptr ptr, uint16_t address, uint16_t reg,uint8_t *data, uint16_t len);
|
|
uint16_t (*write)(I2C_ptr ptr, uint16_t address, uint16_t reg,uint8_t *data, uint16_t len);
|
|
|
|
}MPU_t;
|
|
|
|
typedef MPU_t* MPU_ptr;
|
|
|
|
void mpu6xxx_init(MPU_ptr ptr,I2C_ptr i2c,uint16_t address);
|
|
|
|
uint16_t mpu6xxx_read(MPU_ptr ptr, uint8_t reg,uint8_t *data, uint16_t len);
|
|
|
|
uint16_t mpu6xxx_write(MPU_ptr ptr, uint8_t reg,uint8_t *data, uint16_t len);
|
|
|
|
|
|
|
|
#endif /* BSP_MPU6500_H_ */
|