mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-05 04:50:57 +00:00
feat(core): improve button driver init/deinit
[no changelog]
This commit is contained in:
parent
1330645bc1
commit
67c00b4c9b
@ -49,6 +49,9 @@ typedef enum {
|
||||
// Returns true in case of success, false otherwise
|
||||
bool button_init(void);
|
||||
|
||||
// Deinitializes button driver
|
||||
void button_deinit(void);
|
||||
|
||||
#endif // KERNEL_MODE
|
||||
|
||||
// Get the last button event
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <io/button.h>
|
||||
#include <sys/irq.h>
|
||||
#include <sys/mpu.h>
|
||||
|
||||
#ifdef USE_POWERCTL
|
||||
#include <sys/wakeup_flags.h>
|
||||
@ -103,6 +104,12 @@ bool button_init(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void button_deinit(void) {
|
||||
#ifdef BTN_EXIT_INTERRUPT_HANDLER
|
||||
NVIC_DisableIRQ(BTN_EXTI_INTERRUPT_NUM);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t button_get_event(void) {
|
||||
button_driver_t *drv = &g_button_driver;
|
||||
|
||||
@ -182,6 +189,9 @@ bool button_is_down(button_t button) {
|
||||
|
||||
#ifdef BTN_EXTI_INTERRUPT_HANDLER
|
||||
void BTN_EXTI_INTERRUPT_HANDLER(void) {
|
||||
IRQ_LOG_ENTER();
|
||||
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
|
||||
|
||||
// button_driver_t *drv = &g_button_driver;
|
||||
|
||||
// Clear the EXTI line pending bit
|
||||
@ -191,6 +201,9 @@ void BTN_EXTI_INTERRUPT_HANDLER(void) {
|
||||
// Inform the powerctl module about button press
|
||||
wakeup_flags_set(WAKEUP_FLAG_BUTTON);
|
||||
#endif
|
||||
|
||||
mpu_restore(mpu_mode);
|
||||
IRQ_LOG_EXIT();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -134,7 +134,9 @@ static void drivers_init(secbool *touch_initialized) {
|
||||
|
||||
static void drivers_deinit(void) {
|
||||
#ifdef FIXED_HW_DEINIT
|
||||
// TODO
|
||||
#ifdef USE_BUTTON
|
||||
button_deinit();
|
||||
#endif
|
||||
#endif
|
||||
gfx_bitblt_deinit();
|
||||
display_deinit(DISPLAY_JUMP_BEHAVIOR);
|
||||
|
Loading…
Reference in New Issue
Block a user