Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
dev_lis2dw12
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
aohui.li
dev_lis2dw12
Commits
2e4cd5d8
Commit
2e4cd5d8
authored
Jul 10, 2025
by
aohui.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加持续时间转为lsb函数
parent
451545fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
+26
-3
lis2dw12.c
main/lis2dw12.c
+26
-3
No files found.
main/lis2dw12.c
View file @
2e4cd5d8
...
...
@@ -196,10 +196,31 @@ int lis2dw12_trans_mg2lsb(lis2dw12_fs_t fs, float mg)
lis2dw12_full_scale_set
(
&
dev_ctx
,
fs
);
}
int
lis2dw12_trans_duration2lsb
(
lis2dw12_odr_t
odr
,
uint16_t
continuous_ms
)
{
uint16_t
val
=
0
;
if
(
continuous_ms
==
0
)
{
return
0
;
}
if
(
odr
==
LIS2DW12_XL_ODR_1Hz6_LP_ONLY
)
{
val
=
(
int
)(
continuous_ms
/
1000
.
0
/
(
1
.
0
/
1
.
6
));
}
else
if
(
odr
==
LIS2DW12_XL_ODR_200Hz
)
{
val
=
(
int
)(
continuous_ms
/
1000
.
0
/
(
1
.
0
/
200
));
}
return
val
;
}
static
void
lis2dw12_wake_config
(
void
)
{
lis2dw12_reg_t
int_route
;
lis2dw12_fs_t
fs
=
LIS2DW12_2g
,
fs_get
;
lis2dw12_odr_t
odr
=
LIS2DW12_XL_ODR_200Hz
;
int
val
=
0
;
/* Set full scale */
lis2dw12_full_scale_set
(
&
dev_ctx
,
fs
);
...
...
@@ -209,7 +230,7 @@ static void lis2dw12_wake_config(void)
lis2dw12_power_mode_set
(
&
dev_ctx
,
LIS2DW12_CONT_LOW_PWR_LOW_NOISE_12bit
);
/* Set Output Data Rate */
lis2dw12_data_rate_set
(
&
dev_ctx
,
LIS2DW12_XL_ODR_1Hz6_LP_ONLY
);
lis2dw12_data_rate_set
(
&
dev_ctx
,
odr
);
/* Apply high-pass digital filter on Wake-Up function */
lis2dw12_filter_path_set
(
&
dev_ctx
,
LIS2DW12_HIGH_PASS_ON_OUT
);
/* Apply high-pass digital filter on Wake-Up function
...
...
@@ -217,11 +238,13 @@ static void lis2dw12_wake_config(void)
* is generated for each X,Y,Z filtered data exceeding the
* configured threshold
*/
lis2dw12_wkup_dur_set
(
&
dev_ctx
,
0
);
val
=
lis2dw12_trans_duration2lsb
(
odr
,
2000
);
ESP_LOGI
(
TAG
,
"LIS2DW12 wakeup duration: %d LSB"
,
val
);
lis2dw12_wkup_dur_set
(
&
dev_ctx
,
val
);
/* Set wake-up threshold
* Set Wake-Up threshold: 1 LSb corresponds to FS_XL/2^6
*/
val
=
lis2dw12_trans_mg2lsb
(
fs_get
,
10
00
);
val
=
lis2dw12_trans_mg2lsb
(
fs_get
,
8
00
);
ESP_LOGI
(
TAG
,
"LIS2DW12 wakeup threshold: %d LSB"
,
val
);
lis2dw12_wkup_threshold_set
(
&
dev_ctx
,
val
);
/* Enable interrupt generation on Wake-Up INT1 pin */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment