Skip to content

Commit

Permalink
fix semaphore initialisation in max17048 driver
Browse files Browse the repository at this point in the history
Previously, we were using the semaphore before initialising it; this is now fixed.
  • Loading branch information
zhiayang authored May 16, 2023
1 parent 797b460 commit 16b5016
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/drivers/sensor/max17048/max17048.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,15 @@ static int max17048_init(const struct device *dev) {
return err;
}

// the functions below need the semaphore, so initialise it here
k_sem_init(&drv_data->lock, 1, 1);

// bring the device out of sleep
set_sleep_enabled(dev, false);

// set the default rcomp value -- 0x97, as stated in the datasheet
set_rcomp_value(dev, 0x97);

k_sem_init(&drv_data->lock, 1, 1);
LOG_INF("device initialised at 0x%x (version %d)", config->i2c_bus.addr, ic_version);

return 0;
Expand Down

0 comments on commit 16b5016

Please sign in to comment.