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
451545fc
Commit
451545fc
authored
Jul 10, 2025
by
aohui.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加阈值mg转lsb函数
parent
3836be1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
6 deletions
+30
-6
lis2dw12.c
main/lis2dw12.c
+30
-6
No files found.
main/lis2dw12.c
View file @
451545fc
...
...
@@ -175,19 +175,41 @@ void lis2dw12_init()
// }
}
int
lis2dw12_trans_mg2lsb
(
lis2dw12_fs_t
fs
,
float
mg
)
{
if
(
fs
==
LIS2DW12_2g
)
{
return
mg
/
1000
.
0
/
((
2
*
2
)
/
64
.
0
);
}
else
if
(
fs
==
LIS2DW12_4g
)
{
return
mg
*
4096
/
4
;
}
else
if
(
fs
==
LIS2DW12_8g
)
{
return
mg
*
4096
/
8
;
}
else
{
return
mg
*
4096
/
16
;
}
lis2dw12_full_scale_set
(
&
dev_ctx
,
fs
);
}
static
void
lis2dw12_wake_config
(
void
)
{
lis2dw12_reg_t
int_route
;
lis2dw12_fs_t
fs
;
lis2dw12_fs_t
fs
=
LIS2DW12_2g
,
fs_get
;
int
val
=
0
;
/* Set full scale */
lis2dw12_full_scale_set
(
&
dev_ctx
,
LIS2DW12_16g
);
lis2dw12_full_scale_get
(
&
dev_ctx
,
&
fs
);
ESP_LOGI
(
TAG
,
"LIS2DW12 full scale: %d"
,
fs
);
lis2dw12_full_scale_set
(
&
dev_ctx
,
fs
);
lis2dw12_full_scale_get
(
&
dev_ctx
,
&
fs
_get
);
ESP_LOGI
(
TAG
,
"LIS2DW12 full scale: %d"
,
fs
_get
);
/* Configure power mode */
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_
200Hz
);
lis2dw12_data_rate_set
(
&
dev_ctx
,
LIS2DW12_XL_ODR_
1Hz6_LP_ONLY
);
/* 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
...
...
@@ -199,7 +221,9 @@ static void lis2dw12_wake_config(void)
/* Set wake-up threshold
* Set Wake-Up threshold: 1 LSb corresponds to FS_XL/2^6
*/
lis2dw12_wkup_threshold_set
(
&
dev_ctx
,
1
);
val
=
lis2dw12_trans_mg2lsb
(
fs_get
,
1000
);
ESP_LOGI
(
TAG
,
"LIS2DW12 wakeup threshold: %d LSB"
,
val
);
lis2dw12_wkup_threshold_set
(
&
dev_ctx
,
val
);
/* Enable interrupt generation on Wake-Up INT1 pin */
lis2dw12_pin_int1_route_get
(
&
dev_ctx
,
&
int_route
.
ctrl4_int1_pad_ctrl
);
int_route
.
ctrl4_int1_pad_ctrl
.
int1_wu
=
PROPERTY_ENABLE
;
...
...
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