/**** Includes ****/
#include "utils/utils.h"
#include "board/mcu/mcu_hal.h"
#include "board/ain.h"
#include "board/dio.h"
#include "board/hvdin.h"
#include "board/halfbridge.h"
#include "board/od_com.h"
#include "board/odout.h"

/**** Private definitions ****/
/**** Private constants ****/
/**** Private variables ****/
static board::AnalogIn dccd_i(mcu::ADC0);
static board::AnalogIn dccd_u(mcu::ADC1);
static board::AnalogIn bat_u(mcu::ADC2);
static board::AnalogIn bat_i(mcu::ADC3);

static board::AnalogIn ain1(mcu::ADC5);
static board::AnalogIn ain2(mcu::ADC4);

static board::DigitalIO din1(mcu::GPIO0, board::DIO_HIGH);
static board::DigitalIO din2(mcu::GPIO1, board::DIO_HIGH);
static board::DigitalIO din3(mcu::GPIO2, board::DIO_HIGH);
static board::DigitalIO din4(mcu::GPIO3, board::DIO_HIGH);

static board::HVDigitalIn hvdin1(mcu::GPIO4, board::HVDIN_LOW);
static board::HVDigitalIn hvdin2(mcu::GPIO5, board::HVDIN_LOW);
static board::HVDigitalIn hvdin3(mcu::GPIO6, board::HVDIN_LOW);

/**** Private function declarations ****/
/**** Public function definitions ****/
int main(void)
{
	mcu::startupCfg_t mcu_cfg;
	mcu_cfg.adc_clk = mcu::ADC_DIV2;
	mcu_cfg.pwm_clk = mcu::TIM_DIV1;
	mcu_cfg.pwm_top = 200;
	mcu_cfg.pwm_ch1_en = 1;
	
	mcu::startup(&mcu_cfg);
	
	dccd_i.mul = 1;
	dccd_i.div = 1;
	dccd_i.offset = 0;
	
	dccd_u.mul = 1;
	dccd_u.div = 1;
	dccd_u.offset = 0;
	
	bat_u.mul = 1;
	bat_u.div = 1;
	bat_u.offset = 0;
	
	bat_i.mul = 1;
	bat_i.div = 1;
	bat_i.offset = 0;
	
	// Super loop
	while(1)
	{		
		dccd_i.read();
		dccd_u.read();
		bat_u.read();
		bat_i.read();
		ain1.read();
		ain2.read();
		
		din1.read();
		din2.read();
		din3.read();
		din4.read();
		
		hvdin1.read();
		hvdin2.read();
		hvdin3.read();
		
		continue; // End of super loop
	}
	
	// Escape the matrix
	return 0;
}

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