summaryrefslogtreecommitdiff
path: root/firmware/target/arm/adc-as3514.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/adc-as3514.c')
-rw-r--r--firmware/target/arm/adc-as3514.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/firmware/target/arm/adc-as3514.c b/firmware/target/arm/adc-as3514.c
new file mode 100644
index 0000000000..dcf6cba26e
--- /dev/null
+++ b/firmware/target/arm/adc-as3514.c
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "adc.h"
20#include "kernel.h"
21#include "i2c-pp.h"
22#include "as3514.h"
23
24/* Read 10-bit channel data */
25unsigned short adc_read(int channel)
26{
27 unsigned short data = 0;
28
29 if ((unsigned)channel < NUM_ADC_CHANNELS)
30 {
31 i2c_lock();
32
33 /* Select channel */
34 if (pp_i2c_send( AS3514_I2C_ADDR, AS3514_ADC_0, (channel << 4)) >= 0)
35 {
36 unsigned char buf[2];
37
38 /* Read data */
39 if (i2c_readbytes( AS3514_I2C_ADDR, AS3514_ADC_0, 2, buf) >= 0)
40 {
41 data = (((buf[0] & 0x3) << 8) | buf[1]);
42 }
43 }
44
45 i2c_unlock();
46 }
47
48 return data;
49}
50
51void adc_init(void)
52{
53}