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
0099c5eb
Commit
0099c5eb
authored
Jul 10, 2025
by
aohui.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
继续修改
parent
1d88e1f1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
23 deletions
+50
-23
blink_example_main.c
main/blink_example_main.c
+2
-1
lis2dw12.c
main/lis2dw12.c
+47
-22
lis2dw12.h
main/lis2dw12.h
+1
-0
No files found.
main/blink_example_main.c
View file @
0099c5eb
...
...
@@ -110,8 +110,9 @@ void app_main(void)
ESP_LOGI
(
TAG
,
"Turning the LED %s!"
,
s_led_state
==
true
?
"ON"
:
"OFF"
);
blink_led
();
blink_led_g
();
lis2dw12_wakeup_judgment
();
/* Toggle the LED state */
s_led_state
=
!
s_led_state
;
vTaskDelay
(
1000
/
portTICK_PERIOD_MS
);
//
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
main/lis2dw12.c
View file @
0099c5eb
...
...
@@ -90,7 +90,6 @@ static void WakeupEnable(void)
void
lis2dw12_init
()
{
static
uint8_t
whoamI
,
rst
;
uint8_t
tx_buffer
[
1000
];
esp_err_t
ret
;
ESP_LOGI
(
TAG
,
"LIS2DW12 Init"
);
...
...
@@ -135,8 +134,6 @@ void lis2dw12_init()
vTaskDelay
(
pdMS_TO_TICKS
(
50
));
}
/* Restore default configuration */
lis2dw12_reset_set
(
&
dev_ctx
,
PROPERTY_ENABLE
);
...
...
@@ -152,30 +149,30 @@ void lis2dw12_init()
ESP_LOGI
(
TAG
,
"LIS2DW12 Start Config Done"
);
while
(
1
)
{
lis2dw12_all_sources_t
all_source
;
/* Check Wake-Up events */
lis2dw12_all_sources_get
(
&
dev_ctx
,
&
all_source
);
//
while (1) {
//
lis2dw12_all_sources_t all_source;
//
/* Check Wake-Up events */
//
lis2dw12_all_sources_get(&dev_ctx, &all_source);
if
(
all_source
.
wake_up_src
.
wu_ia
)
{
snprintf
((
char
*
)
tx_buffer
,
sizeof
(
tx_buffer
),
"Wake-Up event on "
);
//
if (all_source.wake_up_src.wu_ia) {
//
snprintf((char *)tx_buffer, sizeof(tx_buffer), "Wake-Up event on ");
if
(
all_source
.
wake_up_src
.
x_wu
)
{
strcat
((
char
*
)
tx_buffer
,
"X"
);
}
//
if (all_source.wake_up_src.x_wu) {
//
strcat((char *)tx_buffer, "X");
//
}
if
(
all_source
.
wake_up_src
.
y_wu
)
{
strcat
((
char
*
)
tx_buffer
,
"Y"
);
}
//
if (all_source.wake_up_src.y_wu) {
//
strcat((char *)tx_buffer, "Y");
//
}
if
(
all_source
.
wake_up_src
.
z_wu
)
{
strcat
((
char
*
)
tx_buffer
,
"Z"
);
}
//
if (all_source.wake_up_src.z_wu) {
//
strcat((char *)tx_buffer, "Z");
//
}
strcat
((
char
*
)
tx_buffer
,
" direction
\r\n
"
);
ESP_LOGI
(
TAG
,
"%s"
,
tx_buffer
);
}
}
//
strcat((char *)tx_buffer, " direction\r\n");
//
ESP_LOGI(TAG, "%s", tx_buffer);
//
}
//
}
}
static
void
lis2dw12_wake_config
(
void
)
...
...
@@ -208,3 +205,31 @@ static void lis2dw12_wake_config(void)
int_route
.
ctrl4_int1_pad_ctrl
.
int1_wu
=
PROPERTY_ENABLE
;
lis2dw12_pin_int1_route_set
(
&
dev_ctx
,
&
int_route
.
ctrl4_int1_pad_ctrl
);
}
void
lis2dw12_wakeup_judgment
(
void
)
{
uint8_t
tx_buffer
[
1000
];
lis2dw12_all_sources_t
all_source
;
/* Check Wake-Up events */
lis2dw12_all_sources_get
(
&
dev_ctx
,
&
all_source
);
if
(
all_source
.
wake_up_src
.
wu_ia
)
{
snprintf
((
char
*
)
tx_buffer
,
sizeof
(
tx_buffer
),
"Wake-Up event on "
);
if
(
all_source
.
wake_up_src
.
x_wu
)
{
strcat
((
char
*
)
tx_buffer
,
"X"
);
}
if
(
all_source
.
wake_up_src
.
y_wu
)
{
strcat
((
char
*
)
tx_buffer
,
"Y"
);
}
if
(
all_source
.
wake_up_src
.
z_wu
)
{
strcat
((
char
*
)
tx_buffer
,
"Z"
);
}
strcat
((
char
*
)
tx_buffer
,
" direction
\r\n
"
);
ESP_LOGI
(
TAG
,
"%s"
,
tx_buffer
);
}
}
\ No newline at end of file
main/lis2dw12.h
View file @
0099c5eb
...
...
@@ -5,5 +5,6 @@
#include "stdlib.h"
void
lis2dw12_init
();
void
lis2dw12_wakeup_judgment
(
void
);
#endif
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