rename chapters
This commit is contained in:
21
Chapter17/cib/hal/gpio/src/gpio.cpp
Normal file
21
Chapter17/cib/hal/gpio/src/gpio.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <gpio.hpp>
|
||||
#include <gpio_interrupt_manager.hpp>
|
||||
|
||||
namespace hal {
|
||||
|
||||
gpio::gpio(const std::function<void()> & on_press) {
|
||||
on_press_ = on_press;
|
||||
gpio_interrupt_manager::register_interrupt_handler(this);
|
||||
}
|
||||
|
||||
void gpio::execute_interrupt_handler () const {
|
||||
if(is_interrupt_generated())
|
||||
{
|
||||
clear_interrupt_flag();
|
||||
if(on_press_) {
|
||||
on_press_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
17
Chapter17/cib/hal/gpio/src/gpio_interrupt_manager.cpp
Normal file
17
Chapter17/cib/hal/gpio/src/gpio_interrupt_manager.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <gpio_interrupt_manager.hpp>
|
||||
|
||||
namespace hal {
|
||||
|
||||
void gpio_interrupt_manager::register_interrupt_handler(gpio * pin) {
|
||||
gpio_handlers.at(w_idx++) = pin;
|
||||
}
|
||||
|
||||
void gpio_interrupt_manager::execute_interrupt_handlers() {
|
||||
for(std::size_t i = 0; i < w_idx; i++) {
|
||||
gpio_handlers[i]->execute_interrupt_handler();
|
||||
}
|
||||
}
|
||||
extern "C" void EXTI4_15_IRQHandler(void) {
|
||||
gpio_interrupt_manager::execute_interrupt_handlers();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user