/*----------------------------------------------------------------------------
 * Name:    ADC.c
 * Purpose: MCB1700 low level ADC functions
 * Version: V1.00
 * Note(s):
 *----------------------------------------------------------------------------
 * This file is part of the uVision/ARM development tools.
 * This software may only be used under the terms of a valid, current,
 * end user licence from KEIL for a compatible version of KEIL software
 * development tools. Nothing else gives you the right to use this software.
 *
 * This software is supplied "AS IS" without warranties of any kind.
 *
 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
 *----------------------------------------------------------------------------
 * History:
 *          V1.00 Initial Version
 *----------------------------------------------------------------------------*/

#include "LPC17xx.h" 
#include "lpc17xx_adc.h"                            /* LPC17xx definitions */
#include "ADC.h"

#include "lpc17xx_pinsel.h"
#include "lincoln_board.h"

/*----------------------------------------------------------------------------
  initialize ADC Pins
 *----------------------------------------------------------------------------*/
void ADC_init (void) 
{
  PINSEL_CFG_Type PinCfg;
  /*
   * Init ADC pin connect
   * AD0.0
   */
  PinCfg.Funcnum = ADC0_FUNCTION;
  PinCfg.OpenDrain = 0;
  PinCfg.Pinmode = 0;
  PinCfg.Pinnum = ADC0_PIN;
  PinCfg.Portnum = ADC0_PORT;
  PINSEL_ConfigPin(&PinCfg);
   /*
   * Init ADC pin connect
   * AD0.1
   */
  PinCfg.Funcnum = ADC1_FUNCTION;
  PinCfg.OpenDrain = 0;
  PinCfg.Pinmode = 0;
  PinCfg.Pinnum = ADC1_PIN;
  PinCfg.Portnum = ADC1_PORT;
  PINSEL_ConfigPin(&PinCfg);
  
  /* Configuration for ADC :
  *  Select: ADC channel 0 & 1
  *  ADC conversion rate = 200Khz
  */
  ADC_Init(LPC_ADC, 200000);
  ADC_IntConfig(LPC_ADC,ADC_ADINTEN0,DISABLE);
  ADC_IntConfig(LPC_ADC,ADC_ADINTEN1,DISABLE);
}
