2006-10-16 17:21:36 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Barry Wardell
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-10-16 17:21:36 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "adc.h"
|
2007-07-12 04:19:21 +00:00
|
|
|
#include "kernel.h"
|
2008-10-31 00:16:42 +00:00
|
|
|
#include "ascodec.h"
|
2007-03-13 01:50:13 +00:00
|
|
|
#include "as3514.h"
|
2006-10-16 17:21:36 +00:00
|
|
|
|
|
|
|
/* Read 10-bit channel data */
|
|
|
|
unsigned short adc_read(int channel)
|
|
|
|
{
|
2016-02-20 03:36:26 +00:00
|
|
|
unsigned char buf[2];
|
2007-07-12 04:19:21 +00:00
|
|
|
|
2010-05-15 19:44:54 +00:00
|
|
|
ascodec_lock();
|
2007-07-12 04:19:21 +00:00
|
|
|
|
2010-05-15 19:44:54 +00:00
|
|
|
/* Select channel */
|
2016-02-20 03:36:26 +00:00
|
|
|
ascodec_write(AS3514_ADC_0, (channel << 4));
|
2010-03-23 05:02:37 +00:00
|
|
|
|
2016-02-20 03:36:26 +00:00
|
|
|
ascodec_readbytes(AS3514_ADC_0, 2, buf);
|
2010-05-15 19:44:54 +00:00
|
|
|
|
|
|
|
ascodec_unlock();
|
2016-02-20 03:36:26 +00:00
|
|
|
|
|
|
|
return (((buf[0] & 0x3) << 8) | buf[1]);
|
2006-10-16 17:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void adc_init(void)
|
|
|
|
{
|
|
|
|
}
|