Enable buttons and the display.
Kind-of-sort-of usable-ish.
This commit is contained in:
@@ -49,6 +49,10 @@ ReturnCode ButtonManager::init()
|
||||
SET(EXTI->FTSR, 1u << btn.m_gpio_idx);
|
||||
}
|
||||
|
||||
CLR(SYSCFG->EXTICR[0],
|
||||
SYSCFG_EXTICR1_EXTI3 | SYSCFG_EXTICR1_EXTI2 |
|
||||
SYSCFG_EXTICR1_EXTI1 | SYSCFG_EXTICR1_EXTI0);
|
||||
|
||||
NVIC_EnableIRQ(EXTI0_1_IRQn);
|
||||
NVIC_EnableIRQ(EXTI2_3_IRQn);
|
||||
NVIC_EnableIRQ(EXTI4_15_IRQn);
|
||||
@@ -82,7 +86,7 @@ NextTime ButtonManager::execute()
|
||||
}
|
||||
|
||||
// TODO: Call less frequently, and let the buttonmanager re-add itself to the task list on interrupts
|
||||
return NextTime::in(Common::Time::millis(1000));
|
||||
return NextTime::asap();
|
||||
}
|
||||
|
||||
void ButtonManager::set_callback(Button btn, ChangeCallback callback)
|
||||
@@ -119,7 +123,7 @@ void ButtonManager::irq()
|
||||
bool is_pressed = !(idr & (1 << btn.m_gpio_idx));
|
||||
|
||||
// Check if the button state has changed, and timestamp it
|
||||
if (is_pressed && (btn.m_state != ButtonState::PRESSED)) {
|
||||
if (is_pressed && (btn.m_state == ButtonState::NOT_PRESSED)) {
|
||||
btn.m_state = ButtonState::PRESSED;
|
||||
btn.m_state_change_ts = systime;
|
||||
} else if (!is_pressed && (btn.m_state == ButtonState::PRESSED)) {
|
||||
@@ -132,16 +136,23 @@ void ButtonManager::irq()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern "C" void EXTI_1_0_IRQHandler() {
|
||||
static uint32_t irq_count = 0;
|
||||
ButtonManager::irq();
|
||||
irq_count++;
|
||||
}
|
||||
|
||||
extern "C" void EXTI_3_2_IRQHandler() {
|
||||
static uint32_t irq_count = 0;
|
||||
ButtonManager::irq();
|
||||
irq_count++;
|
||||
}
|
||||
|
||||
extern "C" void EXTI_15_4_IRQHandler() {
|
||||
static uint32_t irq_count = 0;
|
||||
ButtonManager::irq();
|
||||
irq_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user