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

projects/nrfgo_sdk/adc_examples/adc_continuous_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 //lint -e714
00027 
00028 #include "nrf24le1.h"
00029 #include "hal_adc.h"
00030 
00031 void main()
00032 {
00033   // Set P1 as output
00034   P1DIR = 0;
00035 
00036   // Configure ADC
00037   hal_adc_set_input_channel(HAL_ADC_INP_AIN0);
00038   hal_adc_set_reference(HAL_ADC_REF_VDD);
00039   hal_adc_set_input_mode(HAL_ADC_SINGLE);
00040   hal_adc_set_conversion_mode(HAL_ADC_CONTINOUS);
00041   hal_adc_set_sampling_rate(HAL_ADC_2KSPS);
00042   hal_adc_set_resolution(HAL_ADC_RES_8BIT);
00043   hal_adc_set_data_just(HAL_ADC_JUST_RIGHT);
00044 
00045   // Enable MISC interrupts to enable ADC interrupt
00046   MISC = 1;
00047   // Enable global interrupts
00048   EA = 1;
00049   // Start ADC conversion
00050   hal_adc_start();
00051 
00052   for(;;){}
00053 }
00054 
00055 // ADC (MISC) interrupt
00056 ADC_ISR()
00057 {
00058   // Write sample value to P0
00059   P1 = hal_adc_read_LSB();
00060 }

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