forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Deep-Sleep1 when suspending the pok3r
This decreases the power consumption to <1mA when the host suspends the pok3r.
- Loading branch information
lactide
committed
May 26, 2018
1 parent
6d70a03
commit 4436d7d
Showing
4 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
SRC = \ | ||
matrix.c \ | ||
suspend.c \ | ||
eeprom.c \ | ||
backlight.c | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2018 Charlie Waters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "hal.h" | ||
|
||
#define WAKUPCR_EVWUPIEN_Mask 0x80000000uL | ||
#define SCR_DEEPSLEEP_Mask 0x04uL | ||
|
||
extern ioline_t row_list[MATRIX_ROWS]; | ||
extern ioline_t col_list[MATRIX_COLS]; | ||
|
||
void suspend_power_down(void) { | ||
/* enable all rows */ | ||
for (int row = 0; row < MATRIX_ROWS; row++) { | ||
palClearLine(row_list[row]); | ||
} | ||
/* enable EXTI clock */ | ||
CKCU->APBCCR0 |= CKCU_APBCCR0_EXTIEN; | ||
/* enable Event Wakeup Interrupt */ | ||
NVIC_EnableIRQ(EVWUP_IRQn); | ||
/* enable wakeup interrupt */ | ||
EXTI->WAKUPCR = WAKUPCR_EVWUPIEN_Mask; | ||
for (int col = 0; col < MATRIX_COLS; col++) { | ||
/* enable event wakeup for all column pads */ | ||
EXTI->WAKUPCR |= (1 << PAL_PAD(col_list[col])); | ||
/* set wakeup polarity to low */ | ||
EXTI->WAKUPPOLR |= (1 << PAL_PAD(col_list[col])); | ||
} | ||
/* enable deep sleep */ | ||
SCB->SCR |= SCR_DEEPSLEEP_Mask; | ||
/* sleep */ | ||
__WFI(); | ||
/* disable deep sleep */ | ||
SCB->SCR &= SCR_DEEPSLEEP_Mask; | ||
/* disable all rows */ | ||
for (int row = 0; row < MATRIX_ROWS; row++) { | ||
palSetLine(row_list[row]); | ||
} | ||
} | ||
|
||
OSAL_IRQ_HANDLER(Vector58) { | ||
OSAL_IRQ_PROLOGUE(); | ||
/* acknowledge interrupt */ | ||
EXTI->WAKUPFLG |= EXTI->WAKUPFLG; | ||
/* disable interrupt */ | ||
EXTI->WAKUPCR = 0; | ||
OSAL_IRQ_EPILOGUE(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters