Skip to content

Commit cdbec85

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

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
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: 20 additions & 12 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) {

drivers/sensor/st/lis2dux12/lis2duxs12_api.c

Lines changed: 20 additions & 12 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) {

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: b2448bd56b6fbb3394b3e2ac243134104b375c67
249249
path: modules/hal/st
250250
groups:
251251
- hal

0 commit comments

Comments
 (0)