board abstraction

This commit is contained in:
2024-04-08 19:40:48 +03:00
parent dd4ff43515
commit c50b3d90bf
23 changed files with 1705 additions and 686 deletions

View File

@@ -0,0 +1,44 @@
/**** Includes ****/
#include "../utils/utils.h"
#include "mcu/mcu_hal.h"
#include "odout.h"
using namespace board;
/**** Private definitions ****/
/**** Private constants ****/
/**** Private variables ****/
/**** Private function declarations ****/
/**** Public function definitions ****/
board::OpenDrainOut::OpenDrainOut(uint8_t gpio_ch)
{
this->gpio_ch = gpio_ch;
this->write(OD_OFF);
}
board::OpenDrainOut::~OpenDrainOut(void)
{
this->write(OD_OFF);
}
void board::OpenDrainOut::write(uint8_t state)
{
if(state)
{
mcu::gpio_write(this->gpio_ch, mcu::LEVEL_HIGH);
this->last_set = OD_ON;
}
else
{
mcu::gpio_write(this->gpio_ch, mcu::LEVEL_LOW);
this->last_set = OD_OFF;
}
}
uint8_t board::OpenDrainOut::get_set_state(void)
{
return this->last_set;
}
/**** Private function definitions ****/