Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zephyr Firmware
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kestrel Collaboration
Kestrel Firmware
Zephyr Firmware
Commits
d662e59b
Commit
d662e59b
authored
Apr 26, 2021
by
Raptor Engineering Development Team
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debounce button presses in software
parent
b7b0adb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
kestrel/src/zephyr.c
kestrel/src/zephyr.c
+22
-6
No files found.
kestrel/src/zephyr.c
View file @
d662e59b
...
...
@@ -32,6 +32,8 @@ static struct k_thread kestrel_service_thread_data;
#define KESTREL_IDLE_THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1)
#define BUTTON_PRESS_DEBOUNCE_DELAY_MS 200
static
void
kestrel_init_thread
(
void
)
{
kestrel_init
();
...
...
@@ -60,6 +62,8 @@ static void kestrel_service_thread(void)
void
host_power_button_pressed
(
const
struct
device
*
dev
,
struct
gpio_callback
*
cb
,
uint32_t
pins
)
{
static
uint64_t
last_press
=
0
;
int
want_power_on
=
0
;
int
want_power_off
=
0
;
...
...
@@ -78,16 +82,23 @@ void host_power_button_pressed(const struct device *dev, struct gpio_callback *c
// Re-activate interupts on exiting critical section
irq_unlock
(
key
);
if
(
want_power_on
)
{
power_on_host
();
}
else
if
(
want_power_off
)
{
power_off_chassis
();
if
((
k_uptime_get
()
-
last_press
)
>
BUTTON_PRESS_DEBOUNCE_DELAY_MS
)
{
// The debounce delay has passed since last press, handle request
if
(
want_power_on
)
{
power_on_host
();
}
else
if
(
want_power_off
)
{
power_off_chassis
();
}
}
last_press
=
k_uptime_get
();
}
void
host_reset_button_pressed
(
const
struct
device
*
dev
,
struct
gpio_callback
*
cb
,
uint32_t
pins
)
{
static
uint64_t
last_press
=
0
;
// Deactivate interrupts on entering critical section
int
key
=
irq_lock
();
...
...
@@ -97,7 +108,12 @@ void host_reset_button_pressed(const struct device *dev, struct gpio_callback *c
// Re-activate interupts on exiting critical section
irq_unlock
(
key
);
LOG_WRN
(
"[FIXME] Reset button pressed, but not implemented!"
);
if
((
k_uptime_get
()
-
last_press
)
>
BUTTON_PRESS_DEBOUNCE_DELAY_MS
)
{
// The debounce delay has passed since last press, handle request
LOG_WRN
(
"[FIXME] Reset button pressed, but not implemented!"
);
}
last_press
=
k_uptime_get
();
}
static
int
configure_gpios
(
void
)
...
...
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