• Main Page
  • Modules
  • Index
  • File List
  • Globals

projects/nrfgo_sdk/adc_examples/adc_single_step_mode/main.c

Go to the documentation of this file.
00001 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is confidential property of Nordic
00004  * Semiconductor ASA.Terms and conditions of usage are described in detail
00005  * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  * $LastChangedRevision: 133 $
00012  */
00013 
00025 //lint -e716
00026 
00027 #include "nrf24le1.h"
00028 #include "hal_adc.h"
00029 
00030 void main()
00031 {
00032   // Set P1 as output
00033   P1DIR = 0;
00034 
00035   // Configure ADC
00036   hal_adc_set_input_channel(HAL_ADC_INP_AIN0);
00037   hal_adc_set_reference(HAL_ADC_REF_VDD);
00038   hal_adc_set_input_mode(HAL_ADC_SINGLE);
00039   hal_adc_set_conversion_mode(HAL_ADC_SINGLE_STEP);
00040   hal_adc_set_resolution(HAL_ADC_RES_8BIT);
00041   hal_adc_set_data_just(HAL_ADC_JUST_RIGHT);
00042 
00043   while(true)
00044   {
00045     hal_adc_start();                                // Start the ADC
00046     while( hal_adc_busy() )                         // Wait for the ADC to finish a conversion
00047     {
00048         }
00049     P1 = hal_adc_read_LSB();                        // Write the ADC result to P1
00050   }
00051 }

Generated on Fri Apr 20 2012 14:11:45 for nRFGo SDK by  doxygen 1.7.2