Skip to content

Commit 60f30eb

Browse files
committed
Fix issue in wake up settings
1 parent c49026a commit 60f30eb

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=STM32duino ISM6HG256X
2-
version=1.0.1
2+
version=2.0.0
33
author=STMicroelectronics
44
maintainer=stm32duino
55
sentence= Intelligent IMU with simultaneous low-g and high-g acceleration detection.

src/ISM6HG256XSensor.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ ISM6HG256XStatusTypeDef ISM6HG256XSensor::Enable_Wake_Up_Detection(ISM6HG256X_Se
10821082
return ISM6HG256X_ERROR;
10831083
}
10841084
/* Set wake-up threshold */
1085-
if (Set_Wake_Up_Threshold(63) != ISM6HG256X_OK) {
1085+
if (Set_Wake_Up_Threshold(1, 3) != ISM6HG256X_OK) {
10861086
return ISM6HG256X_ERROR;
10871087
}
10881088
/* Set wake-up durantion */
@@ -1153,7 +1153,7 @@ ISM6HG256XStatusTypeDef ISM6HG256XSensor::Disable_Wake_Up_Detection()
11531153
return ISM6HG256X_ERROR;
11541154
}
11551155
/* Reset wake-up threshold */
1156-
if (Set_Wake_Up_Threshold(0) != ISM6HG256X_OK) {
1156+
if (Set_Wake_Up_Threshold(0, 0) != ISM6HG256X_OK) {
11571157
return ISM6HG256X_ERROR;
11581158
}
11591159
/* Reset wake-up durantion */
@@ -1167,12 +1167,13 @@ ISM6HG256XStatusTypeDef ISM6HG256XSensor::Disable_Wake_Up_Detection()
11671167
* @param Threshold wake up detection threshold
11681168
* @retval 0 in case of success, an error code otherwise
11691169
*/
1170-
ISM6HG256XStatusTypeDef ISM6HG256XSensor::Set_Wake_Up_Threshold(uint32_t Threshold)
1170+
ISM6HG256XStatusTypeDef ISM6HG256XSensor::Set_Wake_Up_Threshold(uint32_t Threshold, uint32_t InactivityThreshold)
11711171
{
11721172
ism6hg256x_act_thresholds_t wake_up_ths;
11731173
if (ism6hg256x_act_thresholds_get(&reg_ctx, &wake_up_ths) != ISM6HG256X_OK) {
11741174
return ISM6HG256X_ERROR;
11751175
}
1176+
wake_up_ths.inactivity_cfg.wu_inact_ths_w = (uint8_t)InactivityThreshold;
11761177
wake_up_ths.threshold = (uint8_t)Threshold;
11771178
if (ism6hg256x_act_thresholds_set(&reg_ctx, &wake_up_ths) != ISM6HG256X_OK) {
11781179
return ISM6HG256X_ERROR;
@@ -1186,12 +1187,12 @@ ISM6HG256XStatusTypeDef ISM6HG256XSensor::Set_Wake_Up_Threshold(uint32_t Thresho
11861187
*/
11871188
ISM6HG256XStatusTypeDef ISM6HG256XSensor::Set_Wake_Up_Duration(uint8_t Duration)
11881189
{
1189-
ism6hg256x_act_wkup_time_windows_t dur_t;
1190-
if (ism6hg256x_act_wkup_time_windows_get(&reg_ctx, &dur_t) != ISM6HG256X_OK) {
1190+
ism6hg256x_act_thresholds_t wake_up_ths;
1191+
if (ism6hg256x_act_thresholds_get(&reg_ctx, &wake_up_ths) != ISM6HG256X_OK) {
11911192
return ISM6HG256X_ERROR;
11921193
}
1193-
dur_t.shock = Duration;
1194-
if (ism6hg256x_act_wkup_time_windows_set(&reg_ctx, dur_t) != ISM6HG256X_OK) {
1194+
wake_up_ths.duration = (uint8_t)Duration;
1195+
if (ism6hg256x_act_thresholds_set(&reg_ctx, &wake_up_ths) != ISM6HG256X_OK) {
11951196
return ISM6HG256X_ERROR;
11961197
}
11971198
return ISM6HG256X_OK;

src/ISM6HG256XSensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class ISM6HG256XSensor {
151151
ISM6HG256XStatusTypeDef Set_Free_Fall_Duration(uint8_t Duration);
152152
ISM6HG256XStatusTypeDef Enable_Wake_Up_Detection(ISM6HG256X_SensorIntPin_t IntPin);
153153
ISM6HG256XStatusTypeDef Disable_Wake_Up_Detection();
154-
ISM6HG256XStatusTypeDef Set_Wake_Up_Threshold(uint32_t Threshold);
154+
ISM6HG256XStatusTypeDef Set_Wake_Up_Threshold(uint32_t Threshold, uint32_t InactivityThreshold);
155155
ISM6HG256XStatusTypeDef Set_Wake_Up_Duration(uint8_t Duration);
156156
ISM6HG256XStatusTypeDef Enable_Single_Tap_Detection(ISM6HG256X_SensorIntPin_t IntPin);
157157
ISM6HG256XStatusTypeDef Disable_Single_Tap_Detection();

0 commit comments

Comments
 (0)