add Chapter12
This commit is contained in:
21
Chapter12/cpp_hal/hal/gpio/src/gpio.cpp
Normal file
21
Chapter12/cpp_hal/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_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user