예제 #1
0
/*
 * @brief:  enable/disable the ADC and DAC peripheral
 * @param:  ENEABLE_AI, DISABLE_AI, ENEABLE_AO, DISABLE_AO
 * @return: none
*/
void analogConfig( uint8_t config ){

   switch(config){

      case ENABLE_ANALOG_INPUTS: {

         /* Config ADC0 sample mode */
         /*
         ADC_CLOCK_SETUP_T ADCSetup = {
            400000,   // ADC rate
            10,       // ADC bit accuracy
            0         // ADC Burt Mode (true or false)
         };
         */
         ADC_CLOCK_SETUP_T ADCSetup;

         /* Initialized to default values:
		   *   - Sample rate:ADC_MAX_SAMPLE_RATE=400KHz
		   *   - resolution: ADC_10BITS
		   *   - burst mode: DISABLE */
         Chip_ADC_Init( LPC_ADC0, &ADCSetup );
         /* Disable burst mode */
         Chip_ADC_SetBurstCmd( LPC_ADC0, DISABLE );
         /* Set sample rate to 200KHz */
         Chip_ADC_SetSampleRate( LPC_ADC0, &ADCSetup, ADC_MAX_SAMPLE_RATE/2 );
         /* Disable all channels */
         Chip_ADC_EnableChannel( LPC_ADC0,ADC_CH1, DISABLE );
         Chip_ADC_Int_SetChannelCmd( LPC_ADC0, ADC_CH1, DISABLE );

         Chip_ADC_EnableChannel( LPC_ADC0, ADC_CH2, DISABLE );
         Chip_ADC_Int_SetChannelCmd( LPC_ADC0, ADC_CH2, DISABLE );

         Chip_ADC_EnableChannel( LPC_ADC0, ADC_CH3, DISABLE );
         Chip_ADC_Int_SetChannelCmd( LPC_ADC0, ADC_CH3, DISABLE );

         Chip_ADC_EnableChannel( LPC_ADC0, ADC_CH4, DISABLE );
         Chip_ADC_Int_SetChannelCmd( LPC_ADC0, ADC_CH4, DISABLE );
      }
      break;

      case DISABLE_ANALOG_INPUTS:
         /* Disable ADC peripheral */
         Chip_ADC_DeInit( LPC_ADC0 );
      break;

      case ENABLE_ANALOG_OUTPUTS:
         /* Initialize the DAC peripheral */
         Chip_DAC_Init(LPC_DAC);

         /* Enables the DMA operation and controls DMA timer */
         Chip_DAC_ConfigDAConverterControl(LPC_DAC, DAC_DMA_ENA);
                                                 /* DCAR DMA access */
         /* Update value to DAC buffer*/
         Chip_DAC_UpdateValue(LPC_DAC, 0);
      break;

      case DISABLE_ANALOG_OUTPUTS:
         /* Disable DAC peripheral */
         Chip_DAC_DeInit( LPC_DAC );
      break;
   }

}
예제 #2
0
void deinitDAC(){
	Chip_DAC_DeInit(LPC_DAC);
}