/**** 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 ****/
