add Chapter12

This commit is contained in:
Amar Mahmutbegovic
2024-10-21 05:39:20 +02:00
parent 87087b3bfb
commit a73a8f62f1
209 changed files with 303106 additions and 0 deletions

View 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_();
}
}
}
};

View 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();
}
};