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

#include "ADC.h"
#include "VREF.h"
#include "DAC.h"
#include "OPAMP.h"
#include "PDB.h"

#define LED1_DD	PTFDD_PTFDD2 = 1
#define LED1	PTFD_PTFD2

void main(void) 
{
  EnableInterrupts;
  vfnMCG_Init();
  vfnSCIInit();
  
  vfnADC_Init ();
  vfnADCHWTrigger (ADC_HWTRG_PDB);
  vfnADConfigChannel(0);
  
  vfnPDBInit();
  vfnPDBConfig(PDB_CONTINUOUS_MODE,0);
  
  vfnVREF_Init (_IntUseOnly);
  
  vfnDACFillBuffer ();
  vfnDACInit(gu8DACConfig1, gu8DACConfig2);
  vfnDACSetPointer (0, 15);
  
  vfnOPAMPInit();
  vfnOPAMPConfig(OPAMP0);
  

  PDB_TRIGGER;
  

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

