1 /****************************************************************************
4 * Copyright 2012 Nathael Pajani <nathael.pajani@ed3l.fr>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *************************************************************************** */
27 /***************************************************************************** */
28 /* Analog to Digital Converter (ADC) */
29 /***************************************************************************** */
33 ADC_CONV_ON_CT32B0_CAP0_RISING,
34 ADC_CONV_ON_CT32B0_CAP0_FALLING,
35 ADC_CONV_ON_CT32B0_MAT0_RISING,
36 ADC_CONV_ON_CT32B0_MAT0_FALLING,
37 ADC_CONV_ON_CT32B0_MAT1_RISING,
38 ADC_CONV_ON_CT32B0_MAT1_FALLING,
40 ADC_CONV_ON_CT16B0_CAP0_RISING,
41 ADC_CONV_ON_CT16B0_CAP0_FALLING,
42 ADC_CONV_ON_CT16B0_MAT0_RISING,
43 ADC_CONV_ON_CT16B0_MAT0_FALLING,
44 ADC_CONV_ON_CT16B0_MAT1_RISING,
45 ADC_CONV_ON_CT16B0_MAT1_FALLING,
49 /* Read the conversion from the given channel (0 to 7)
50 * This function reads the conversion value directly in the data register and
51 * always returns a value.
52 * Return 1 if the value is a new one, else return 0.
53 * Return -1 if channel does not exist
55 int adc_get_value(uint16_t * val, int channel);
57 /* Start a conversion on the given channel (0 to 7)
58 * Unsupported yet : Set use_int to 1 to have your interrupt callback called upon conversion done.
60 void adc_start_convertion_once(unsigned int channel, int use_int);
62 /* Start burst conversions.
63 * channels is a bit mask of requested channels.
64 * Use LPC_ADC_CHANNEL(x) (x = 0 .. 7) for channels selection.
66 void adc_start_burst_conversion(uint8_t channels);
68 /* This should be used to configure conversion start on falling or rising edges of
69 * some signals, or on timer for burst conversions.
71 void adc_prepare_conversion_on_event(uint8_t channels, uint8_t event, int use_int);
73 /* Change The ADC resolution.
74 * Use defines from lpc_regs_11xx.h to specify the bit width for the convertion.
75 * Ranges from LPC_ADC_3BITS to LPC_ADC_10BITS.
77 int adc_set_resolution(int bits);
80 /***************************************************************************** */
81 /* ADC Setup : private part : Clocks, Pins, Power and Mode */
82 void adc_clk_update(void);
86 #endif /* DRIVERS_ADC_H */