Skip to content

Commit

Permalink
abstract driver
Browse files Browse the repository at this point in the history
  • Loading branch information
fred13kim committed Dec 4, 2024
1 parent 888e391 commit 4f73812
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/drivers/mpu6050/mpu6050.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void mpu6050_get_raw_gyro(
gyro_raw_val->gyro_raw_zout = (int16_t) (data[4] << 8 | data[5]);
}

void mpu6050_init(void)
void mpu6050_init(i2c_master_dev_handle_t dev_handle)
{
i2c_master_bus_config_t i2c_master_conf = {
.clk_source = I2C_CLK_SRC_DEFAULT,
Expand All @@ -115,7 +115,6 @@ void mpu6050_init(void)
.scl_speed_hz = I2C_MPU6050_DEV_FREQ_HZ,
};

i2c_master_dev_handle_t dev_handle;

ESP_ERROR_CHECK(i2c_master_bus_add_device(
bus_handle, &i2c_dev_conf, &dev_handle));
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/mpu6050/mpu6050.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ typedef struct {
int16_t gyro_raw_zout;
} i2c_mpu6050_raw_gyro_t;

void mpu6050_init(void);
void mpu6050_init(i2c_master_dev_handle_t);

void mpu6050_get_raw_gyro(
i2c_master_dev_handle_t i2c_dev, i2c_mpu6050_raw_gyro_t *gyro_raw_val);
#endif // MPU6050_H

0 comments on commit 4f73812

Please sign in to comment.