Skip to content

Commit 47f5f73

Browse files
committed
modules/hal_st: Align to stmemsc HAL i/f v2.11.1
Align all sensor drivers that are using stmemsc (STdC) HAL i/f to new APIs of stmemsc v2.11.1 Requires zephyrproject-rtos/hal_st#27 Signed-off-by: Armando Visconti <[email protected]>
1 parent 3568e1b commit 47f5f73

File tree

5 files changed

+54
-36
lines changed

5 files changed

+54
-36
lines changed

drivers/sensor/st/iis2dlpc/iis2dlpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static int iis2dlpc_init(const struct device *dev)
298298
}
299299

300300
/* reset device */
301-
if (iis2dlpc_reset_set(ctx, PROPERTY_ENABLE) < 0) {
301+
if (iis2dlpc_reset_set(ctx) < 0) {
302302
return -EIO;
303303
}
304304

drivers/sensor/st/lis2dux12/lis2dux12_api.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,17 @@ static void st_lis2dux12_stream_config_fifo(const struct device *dev,
164164
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&config->ctx;
165165
lis2dux12_pin_int_route_t pin_int = { 0 };
166166
lis2dux12_fifo_mode_t fifo_mode = { 0 };
167+
lis2dux12_fifo_batch_t batch = { 0 };
168+
lis2dux12_fifo_event_t fifo_event = { 0 };
169+
uint16_t watermark = 0;
167170

168171
/* disable FIFO as first thing */
169172
fifo_mode.store = LIS2DUX12_FIFO_1X;
170173
fifo_mode.xl_only = 0;
171-
fifo_mode.watermark = 0;
172174
fifo_mode.operation = LIS2DUX12_BYPASS_MODE;
173-
fifo_mode.batch.dec_ts = LIS2DUX12_DEC_TS_OFF;
174-
fifo_mode.batch.bdr_xl = LIS2DUX12_BDR_XL_ODR_OFF;
175+
batch.dec_ts = LIS2DUX12_DEC_TS_OFF;
176+
batch.bdr_xl = LIS2DUX12_BDR_XL_ODR_OFF;
177+
watermark = 0;
175178

176179
pin_int.fifo_th = PROPERTY_DISABLE;
177180
pin_int.fifo_full = PROPERTY_DISABLE;
@@ -181,9 +184,9 @@ static void st_lis2dux12_stream_config_fifo(const struct device *dev,
181184
pin_int.fifo_full = (trig_cfg.int_fifo_full) ? PROPERTY_ENABLE : PROPERTY_DISABLE;
182185

183186
if (pin_int.fifo_th) {
184-
fifo_mode.fifo_event = LIS2DUX12_FIFO_EV_WTM;
187+
fifo_event = LIS2DUX12_FIFO_EV_WTM;
185188
} else if (pin_int.fifo_full) {
186-
fifo_mode.fifo_event = LIS2DUX12_FIFO_EV_FULL;
189+
fifo_event = LIS2DUX12_FIFO_EV_FULL;
187190
}
188191

189192
switch (config->fifo_mode_sel) {
@@ -202,27 +205,32 @@ static void st_lis2dux12_stream_config_fifo(const struct device *dev,
202205
}
203206

204207
fifo_mode.operation = LIS2DUX12_STREAM_MODE;
205-
fifo_mode.batch.dec_ts = config->ts_batch;
206-
fifo_mode.batch.bdr_xl = config->accel_batch;
207-
fifo_mode.watermark = config->fifo_wtm;
208+
batch.dec_ts = config->ts_batch;
209+
batch.bdr_xl = config->accel_batch;
210+
watermark = config->fifo_wtm;
208211

209212
/* In case each FIFO word contains 2x accelerometer samples,
210213
* then watermark can be divided by two to match user expectation.
211214
*/
212215
if (config->fifo_mode_sel == 2) {
213-
fifo_mode.watermark /= 2;
216+
watermark /= 2;
214217
}
215218
}
216219

220+
lis2dux12_fifo_mode_set(ctx, fifo_mode);
221+
217222
/*
218223
* Set FIFO watermark (number of unread sensor data TAG + 6 bytes
219224
* stored in FIFO) to FIFO_WATERMARK samples
220225
*/
221-
lis2dux12_fifo_mode_set(ctx, fifo_mode);
226+
lis2dux12_fifo_watermark_set(ctx, watermark);
227+
228+
lis2dux12_fifo_batch_set(ctx, batch);
229+
lis2dux12_fifo_stop_on_wtm_set(ctx, fifo_event);
222230

223231
/* Set FIFO batch rates */
224-
lis2dux12->accel_batch_odr = fifo_mode.batch.bdr_xl;
225-
lis2dux12->ts_batch_odr = fifo_mode.batch.dec_ts;
232+
lis2dux12->accel_batch_odr = batch.bdr_xl;
233+
lis2dux12->ts_batch_odr = batch.dec_ts;
226234

227235
/* Set pin interrupt (fifo_th could be on or off) */
228236
if (config->drdy_pin == 1) {
@@ -356,17 +364,18 @@ int st_lis2dux12_init(const struct device *dev)
356364
}
357365

358366
/* reset device */
359-
ret = lis2dux12_init_set(ctx, LIS2DUX12_RESET);
367+
ret = lis2dux12_sw_reset(ctx);
360368
if (ret < 0) {
361369
return ret;
362370
}
363371

364-
k_busy_wait(100);
365-
366372
LOG_INF("%s: chip id 0x%x", dev->name, chip_id);
367373

368374
/* Set bdu and if_inc recommended for driver usage */
369-
lis2dux12_init_set(ctx, LIS2DUX12_SENSOR_ONLY_ON);
375+
ret = lis2dux12_init_set(ctx);
376+
if (ret < 0) {
377+
return ret;
378+
}
370379

371380
lis2dux12_timestamp_set(ctx, PROPERTY_ENABLE);
372381

drivers/sensor/st/lis2dux12/lis2duxs12_api.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,17 @@ static void st_lis2duxs12_stream_config_fifo(const struct device *dev,
164164
stmdev_ctx_t *ctx = (stmdev_ctx_t *)&config->ctx;
165165
lis2duxs12_pin_int_route_t pin_int = { 0 };
166166
lis2duxs12_fifo_mode_t fifo_mode = { 0 };
167+
lis2duxs12_fifo_batch_t batch = { 0 };
168+
lis2duxs12_fifo_event_t fifo_event = { 0 };
169+
uint16_t watermark = 0;
167170

168171
/* disable FIFO as first thing */
169172
fifo_mode.store = LIS2DUXS12_FIFO_1X;
170173
fifo_mode.xl_only = 0;
171-
fifo_mode.watermark = 0;
172174
fifo_mode.operation = LIS2DUXS12_BYPASS_MODE;
173-
fifo_mode.batch.dec_ts = LIS2DUXS12_DEC_TS_OFF;
174-
fifo_mode.batch.bdr_xl = LIS2DUXS12_BDR_XL_ODR_OFF;
175+
batch.dec_ts = LIS2DUXS12_DEC_TS_OFF;
176+
batch.bdr_xl = LIS2DUXS12_BDR_XL_ODR_OFF;
177+
watermark = 0;
175178

176179
pin_int.fifo_th = PROPERTY_DISABLE;
177180
pin_int.fifo_full = PROPERTY_DISABLE;
@@ -181,9 +184,9 @@ static void st_lis2duxs12_stream_config_fifo(const struct device *dev,
181184
pin_int.fifo_full = (trig_cfg.int_fifo_full) ? PROPERTY_ENABLE : PROPERTY_DISABLE;
182185

183186
if (pin_int.fifo_th) {
184-
fifo_mode.fifo_event = LIS2DUXS12_FIFO_EV_WTM;
187+
fifo_event = LIS2DUXS12_FIFO_EV_WTM;
185188
} else if (pin_int.fifo_full) {
186-
fifo_mode.fifo_event = LIS2DUXS12_FIFO_EV_FULL;
189+
fifo_event = LIS2DUXS12_FIFO_EV_FULL;
187190
}
188191

189192
switch (config->fifo_mode_sel) {
@@ -202,27 +205,32 @@ static void st_lis2duxs12_stream_config_fifo(const struct device *dev,
202205
}
203206

204207
fifo_mode.operation = LIS2DUXS12_STREAM_MODE;
205-
fifo_mode.batch.dec_ts = config->ts_batch;
206-
fifo_mode.batch.bdr_xl = config->accel_batch;
207-
fifo_mode.watermark = config->fifo_wtm;
208+
batch.dec_ts = config->ts_batch;
209+
batch.bdr_xl = config->accel_batch;
210+
watermark = config->fifo_wtm;
208211

209212
/* In case each FIFO word contains 2x accelerometer samples,
210213
* then watermark can be divided by two to match user expectation.
211214
*/
212215
if (config->fifo_mode_sel == 2) {
213-
fifo_mode.watermark /= 2;
216+
watermark /= 2;
214217
}
215218
}
216219

220+
lis2duxs12_fifo_mode_set(ctx, fifo_mode);
221+
217222
/*
218223
* Set FIFO watermark (number of unread sensor data TAG + 6 bytes
219224
* stored in FIFO) to FIFO_WATERMARK samples
220225
*/
221-
lis2duxs12_fifo_mode_set(ctx, fifo_mode);
226+
lis2duxs12_fifo_watermark_set(ctx, watermark);
227+
228+
lis2duxs12_fifo_batch_set(ctx, batch);
229+
lis2duxs12_fifo_stop_on_wtm_set(ctx, fifo_event);
222230

223231
/* Set FIFO batch rates */
224-
lis2dux12->accel_batch_odr = fifo_mode.batch.bdr_xl;
225-
lis2dux12->ts_batch_odr = fifo_mode.batch.dec_ts;
232+
lis2dux12->accel_batch_odr = batch.bdr_xl;
233+
lis2dux12->ts_batch_odr = batch.dec_ts;
226234

227235
/* Set pin interrupt (fifo_th could be on or off) */
228236
if (config->drdy_pin == 1) {
@@ -356,17 +364,18 @@ int st_lis2duxs12_init(const struct device *dev)
356364
}
357365

358366
/* reset device */
359-
ret = lis2duxs12_init_set(ctx, LIS2DUXS12_RESET);
367+
ret = lis2duxs12_sw_reset(ctx);
360368
if (ret < 0) {
361369
return ret;
362370
}
363371

364-
k_busy_wait(100);
365-
366372
LOG_INF("%s: chip id 0x%x", dev->name, chip_id);
367373

368374
/* Set bdu and if_inc recommended for driver usage */
369-
lis2duxs12_init_set(ctx, LIS2DUXS12_SENSOR_ONLY_ON);
375+
ret = lis2duxs12_init_set(ctx);
376+
if (ret < 0) {
377+
return ret;
378+
}
370379

371380
lis2duxs12_timestamp_set(ctx, PROPERTY_ENABLE);
372381

drivers/sensor/st/lsm6dsv16x/lsm6dsv16x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,13 +1106,13 @@ static int lsm6dsv16x_init_chip(const struct device *dev)
11061106
*/
11071107
if (ON_I3C_BUS(cfg)) {
11081108
/* Restore default configuration */
1109-
lsm6dsv16x_reset_set(ctx, LSM6DSV16X_RESTORE_CAL_PARAM);
1109+
lsm6dsv16x_reboot(ctx);
11101110

11111111
/* wait 150us as reported in AN5763 */
11121112
k_sleep(K_USEC(150));
11131113
} else {
11141114
/* reset device (sw_por) */
1115-
if (lsm6dsv16x_reset_set(ctx, LSM6DSV16X_GLOBAL_RST) < 0) {
1115+
if (lsm6dsv16x_sw_por(ctx) < 0) {
11161116
return -EIO;
11171117
}
11181118

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ manifest:
245245
groups:
246246
- hal
247247
- name: hal_st
248-
revision: 9f81b4427e955885398805b7bca0da3a8cd9109c
248+
revision: 6d03b42859c2f8cedd6872da20b1dbdbef5c2392
249249
path: modules/hal/st
250250
groups:
251251
- hal

0 commit comments

Comments
 (0)