/**** Includes ****/
#include "../utils/utils.h"
#include "mcu/mcu_hal.h"
#include "hvdin.h"

using namespace board;

/**** Private definitions ****/
/**** Private constants ****/
/**** Private variables ****/
/**** Private function declarations ****/

/**** Public function definitions ****/
board::HVDigitalIn::HVDigitalIn(uint8_t gpio_ch, uint8_t init_read)
{
	this->gpio_ch = gpio_ch;
	
	if(init_read) this->last_read = HVDIN_HIGH;
	else this->last_read = HVDIN_LOW;
}

board::HVDigitalIn::~HVDigitalIn(void)
{
	return;
}

uint8_t board::HVDigitalIn::read(void)
{
	// Auto inverts level to match board external connectors
	uint8_t lvl = mcu::gpio_read(this->gpio_ch);
	if(lvl>0) this->last_read = HVDIN_LOW;
	else this->last_read = HVDIN_HIGH;
	
	return this->last_read;
}

/**** Private function definitions ****/
