diff --git a/app/drivers/sensor/max17048/max17048.c b/app/drivers/sensor/max17048/max17048.c index 33a4202bba6..9f4bbc438d3 100644 --- a/app/drivers/sensor/max17048/max17048.c +++ b/app/drivers/sensor/max17048/max17048.c @@ -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;