Skip to content

Commit

Permalink
sensor: set correct page for superpix detection
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorxda committed Dec 16, 2023
1 parent cc16f22 commit 923fe2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hal/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ int universal_i2c_write_register(int fd, unsigned char i2c_addr,
unsigned int reg_addr, unsigned int reg_width,
unsigned int data, unsigned int data_width) {
(void)i2c_addr;
(void)data;
char buf[2];
char buf[3];

if (reg_width == 2) {
buf[0] = (reg_addr >> 8) & 0xff;
buf[1] = reg_addr & 0xff;
buf[2] = data;
} else {
buf[0] = reg_addr & 0xff;
buf[1] = data;
}

if (write(fd, buf, data_width) != (int)data_width) {
Expand Down
5 changes: 5 additions & 0 deletions src/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@ static int detect_superpix_sensor(sensor_ctx_t *ctx, int fd,
if (i2c_change_addr(fd, i2c_addr) < 0)
return false;

// Set page 0
int page = i2c_read_register(fd, i2c_addr, 0xFD, 1, 1);
if (page != 0)
i2c_write_register(fd, i2c_addr, 0xFD, 1, 0x00, 2);

int prod_msb = i2c_read_register(fd, i2c_addr, 0x02, 1, 1);
if (prod_msb == -1)
return false;
Expand Down

0 comments on commit 923fe2c

Please sign in to comment.