#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 "OPAMP.h"
#include "Display.h"


void main(void) 
{
  EnableInterrupts;
  vfnMCG_Init();
  vfnSCIInit();
  
  /** VREF */
  vfnVREF_Init (_IntUseOnly);
  
  /** DAC */
  TPM1SC = 0x49;
  vfnDACFillBuffer();
  vfnDACInit(gu8DACConfig1, gu8DACConfig2);
  vfnDACSetPointer (0,15);

  /** OPAMP */
   vfnOPAMPInit();
   vfnOPAMPConfig(0); 
  
  /** ADC */
  vfnADC_Init ();
  vfnADConfigChannel(2);
  ADC_CONVERT_CONTINUOUS_CHANNEL(2);
  
  for(;;) 
  {
	if (ADC_COCO)
	{
		ADC_COCO_CLEAR;
		vfnGraphicWords(&sADC.gu16LatestResult[0]);
	}
	
  __RESET_WATCHDOG();	
  } 
}

