Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jack Humbert
reform
Commits
058a6e06
Commit
058a6e06
authored
2 years ago
by
minute
Browse files
Options
Downloads
Plain Diff
Merge branch 'keyboard-powersave-fix' into 'master'
Keyboard powersave fix See merge request
!26
parents
1a9c21f6
d33ac3ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
reform2-keyboard-fw/keyboard.c
+1
-1
1 addition, 1 deletion
reform2-keyboard-fw/keyboard.c
reform2-keyboard-fw/powersave.c
+13
-2
13 additions, 2 deletions
reform2-keyboard-fw/powersave.c
with
14 additions
and
3 deletions
reform2-keyboard-fw/keyboard.c
+
1
−
1
View file @
058a6e06
...
...
@@ -342,7 +342,7 @@ void setup_hardware(void)
ISR
(
WDT_vect
)
{
// WDT interrupt enable and flag cleared on entry
wdt_disable
();
// Disable watchdog for now
Delay_MS
(
1
);
}
/** Event handler for the library USB Connection event. */
...
...
This diff is collapsed.
Click to expand it.
reform2-keyboard-fw/powersave.c
+
13
−
2
View file @
058a6e06
...
...
@@ -49,9 +49,19 @@ void keyboard_power_off(void)
// We can use the Watchdog timer to do this.
do
{
// Setting WDT parameters must be done within 4 cycles of setting WDCE, so interrupts
// must be disabled.
cli
();
wdt_reset
();
WDTCSR
=
(
1
<<
WDCE
)
|
(
1
<<
WDE
);
// Enable writes to watchdog
WDTCSR
=
(
1
<<
WDIE
)
|
(
1
<<
WDE
)
|
(
0
<<
WDP3
)
|
(
1
<<
WDP2
)
|
(
1
<<
WDP1
)
|
(
0
<<
WDP0
);
// Interrupt mode, 1s timeout
// Enable writes to watchdog, then set interrupt-only mode, 1s timeout.
// (Interrupt-only mode is preferred to interrupt-and-reset mode, because
// the latter has the risk of WDT-induced bootloops if the bootloader doesn't
// correctly handle WDT resets. Whereas we have a physical reset button, if
// a hard reset is actually needed.)
WDTCSR
=
(
1
<<
WDCE
)
|
(
1
<<
WDE
);
WDTCSR
=
(
1
<<
WDIE
)
|
(
0
<<
WDE
)
|
(
0
<<
WDP3
)
|
(
1
<<
WDP2
)
|
(
1
<<
WDP1
)
|
(
0
<<
WDP0
);
// Enter Power-save mode
set_sleep_mode
(
SLEEP_MODE_PWR_DOWN
);
...
...
@@ -60,6 +70,7 @@ void keyboard_power_off(void)
sleep_cpu
();
// Actually go to sleep
// Zzzzzz
sleep_disable
();
// We've woken up
wdt_disable
();
// Disable watchdog for now
sei
();
// Check if circle key has been pressed (active-low)
// If not reset the watchdog and try again
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment