/**** Includes ****/
#include "../utils/utils.h"
#include "board.h"

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

/**** Public function definitions ****/
void board_init(void)
{
	// MCU setup
	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);
	
	// Board setup
	// Fixed function AIN mV and mA scale
	dccd_i.mul = 215;
	dccd_i.div = 22;
	dccd_i.offset = 0;
	dccd_i.last_read = 0;
	
	dccd_u.mul = 20;
	dccd_u.div = 1;
	dccd_u.offset = 0;
	dccd_u.last_read = 0;
	
	bat_u.mul = 20;
	bat_u.div = 1;
	bat_u.offset = 0;
	bat_u.last_read = 12000;
	
	bat_i.mul = 235;
	bat_i.div = 6;
	bat_i.offset = 0;
	bat_i.last_read = 0;
}

void board_read(void)
{
	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();
}

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