//###########################################################################
//
// FILE:    init_adc.c
//
// TITLE:
//
// NOTES:
//  1)
//###########################################################################
//
//  Ver  | dd mmm yyyy | Who  		| Description of changes
// ======|=============|============|========================================
//  00 	   05 04 2015 	 HPCS
//
//  Texas Instruments, Inc
//  Copyright Texas Instruments 2008. All rights reserved.
//###########################################################################
#include "system_defines.h"
#include "cyclone_device.h"
#include "variables.h"
#include "function_definitions.h"
#include "software_interrupts.h"
#include "cyclone_defines.h"
#include "pmbus_common.h"
#include "pmbus_topology.h"
#include "pmbus_constants.h"


void init_adc(void)
{
	  AdcRegs.ADCCTRL.bit.MAX_CONV = 6;       // A total of 6 conversions
      AdcRegs.ADCCTRL.bit.SINGLE_SWEEP = 0;

	  AdcRegs.ADCSEQSEL0.bit.SEQ0 = 1;        // System voltage
	  AdcRegs.ADCSEQSEL0.bit.SEQ1 = 3;        // battery voltage.
	  AdcRegs.ADCSEQSEL0.bit.SEQ2 = 7;        // Battery current or charge current
	  AdcRegs.ADCSEQSEL0.bit.SEQ3 = 6;        // System current or Discharge current
	  AdcRegs.ADCSEQSEL1.bit.SEQ4 = 5;        // temp_sense

	  AdcRegs.ADCAVGCTRL.bit.AVG0_CONFIG=3;
	  AdcRegs.ADCAVGCTRL.bit.AVG0_EN=1;
	  AdcRegs.ADCAVGCTRL.bit.AVG1_CONFIG=3;
	  AdcRegs.ADCAVGCTRL.bit.AVG1_EN=1;

	  AdcRegs.ADCCTRL.bit.ADC_EN = 1;

	  AdcRegs.ADCCTRL.bit.SW_START = 1; //start things running
	  AdcRegs.ADCCTRL.bit.SW_START=0;

}





