#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "MCG.h"
#include "ADC.h"
#include "DAC.h"
#include "VREF.h"
#include "Display.h"


void main(void) 
{
  EnableInterrupts;
  vfnMCG_Init();
  vfnSCIInit();
  
  /** Enabled VREF to source internal peripherals */
  vfnVREF_Init (_IntUseOnly);
  
  /** Configure DAC*/
  TPM1SC = 0x4A;
  vfnDACFillBuffer();
  vfnDACInit(gu8DACConfig1, gu8DACConfig2);
  vfnDACSetPointer (0,15);
  
  /** Configure ADC */
  vfnADC_Init ();
  vfnADConfigChannel(1);
  ADC_CONVERT_CONTINUOUS_CHANNEL(1);
  
  for(;;) 
  {
	if (ADC_COCO)
	{
		ADC_COCO_CLEAR;
		vfnGraphicWords(&sADC.gu16LatestResult[0]);
	}
	
  __RESET_WATCHDOG();	
  } 
}

