mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-27 06:28:54 +00:00
v1.1.1
This commit is contained in:
@@ -295,18 +295,7 @@ static struct gc03_dev g_gc03_dev = {0};
|
||||
|
||||
static int gc03_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val)
|
||||
{
|
||||
u8 buf[2];
|
||||
struct rt_i2c_msg msgs;
|
||||
|
||||
buf[0] = reg;
|
||||
buf[1] = val;
|
||||
|
||||
msgs.addr = GC03_I2C_SLAVE_ID;
|
||||
msgs.flags = RT_I2C_WR;
|
||||
msgs.buf = buf;
|
||||
msgs.len = 2;
|
||||
|
||||
if (rt_i2c_transfer(i2c, &msgs, 1) != 1) {
|
||||
if (rt_i2c_write_reg(i2c, GC03_I2C_SLAVE_ID, reg, &val, 1) != 1) {
|
||||
LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, val);
|
||||
return -1;
|
||||
}
|
||||
@@ -316,20 +305,7 @@ static int gc03_write_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 val)
|
||||
|
||||
static int gc03_read_reg(struct rt_i2c_bus_device *i2c, u8 reg, u8 *val)
|
||||
{
|
||||
struct rt_i2c_msg msg[2];
|
||||
u8 buf = reg;
|
||||
|
||||
msg[0].addr = GC03_I2C_SLAVE_ID;
|
||||
msg[0].flags = RT_I2C_WR;
|
||||
msg[0].buf = &buf;
|
||||
msg[0].len = 1;
|
||||
|
||||
msg[1].addr = GC03_I2C_SLAVE_ID;
|
||||
msg[1].flags = RT_I2C_RD;
|
||||
msg[1].buf = val;
|
||||
msg[1].len = 1;
|
||||
|
||||
if (rt_i2c_transfer(i2c, msg, 2) != 2) {
|
||||
if (rt_i2c_read_reg(i2c, GC03_I2C_SLAVE_ID, reg, val, 1) != 1) {
|
||||
LOG_E("%s: error: reg = 0x%x, val = 0x%x", __func__, reg, *val);
|
||||
return -1;
|
||||
}
|
||||
@@ -377,9 +353,9 @@ static void gc0308_power_on(struct gc03_dev *sensor)
|
||||
if (sensor->on)
|
||||
return;
|
||||
|
||||
rt_pin_write(sensor->pwdn_pin, PIN_LOW);
|
||||
camera_pin_set_low(sensor->pwdn_pin);
|
||||
aicos_udelay(1);
|
||||
rt_pin_write(sensor->rst_pin, 1);
|
||||
camera_pin_set_high(sensor->rst_pin);
|
||||
|
||||
sensor->on = true;
|
||||
}
|
||||
@@ -390,7 +366,7 @@ static void gc0308_power_off(struct gc03_dev *sensor)
|
||||
if (!sensor->on)
|
||||
return;
|
||||
|
||||
rt_pin_write(sensor->pwdn_pin, PIN_HIGH);
|
||||
camera_pin_set_high(sensor->pwdn_pin);
|
||||
|
||||
sensor->on = false;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user