#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 "PDB.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 */
   vfnADCHWTrigger(ADC_HWTRG_TOD);
   vfnADC_Init ();
   vfnADConfigChannel(2);    
   
   /*ADC_CONVERT_CHANNEL(1);
   ADC_CONVERT_CHANNEL(2);*/

  

  /* vfnPDBInit();
   vfnPDBConfig(1);*/

  
  for(;;) 
  {
	if (ADC_COCO)
	{
		ADC_COCO_CLEAR;
		vfnGraphicWords(&sADC.gu16LatestResult[0]);
	}
	
  __RESET_WATCHDOG();	
  } 
}

