mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
Sansa AMS: use the AS3514 ADC driver
Move the ADC defines to as3514.h, and make adc-target.h only include as3514.h Implement the missing API (ascodec_readbytes, ascodec_(un)lock) Revert the changes to the PP-specific arm/ascodec-target.h in r19073, use a AS3525 specific ascodec-target.h while moving the AS3514 specific code in export/as3514.h git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19076 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f7b1d806e6
commit
02dfae031a
7 changed files with 114 additions and 48 deletions
|
|
@ -7,7 +7,7 @@
|
|||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright © 2008 Rafaël Carré
|
||||
* Copyright (C) 2006 by Barry Wardell
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
@ -18,16 +18,10 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _ADC_TARGET_H_
|
||||
#define _ADC_TARGET_H_
|
||||
|
||||
#include "adc.h"
|
||||
/* The ADC sources and channels are common to all targets with AS3514 */
|
||||
#include "as3514.h"
|
||||
|
||||
/* TODO */
|
||||
|
||||
unsigned short adc_read(int channel)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
|
@ -38,6 +38,7 @@
|
|||
*/
|
||||
|
||||
#include "ascodec-target.h"
|
||||
#include "kernel.h"
|
||||
#include "as3525.h"
|
||||
|
||||
#define I2C2_DATA *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x00))
|
||||
|
|
@ -53,6 +54,7 @@
|
|||
#define I2C2_INT_CLR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x40))
|
||||
#define I2C2_SADDR *((volatile unsigned int *)(I2C_AUDIO_BASE + 0x44))
|
||||
|
||||
static struct mutex as_mtx SHAREDBSS_ATTR;
|
||||
|
||||
/* initialises the internal i2c bus and prepares for transfers to the codec */
|
||||
void ascodec_init(void)
|
||||
|
|
@ -84,7 +86,7 @@ static int i2c_busy(void)
|
|||
|
||||
|
||||
/* returns 0 on success, <0 otherwise */
|
||||
int ascodec_write(int index, int value)
|
||||
int ascodec_write(unsigned int index, unsigned int value)
|
||||
{
|
||||
if (index == 0x21) {
|
||||
/* prevent setting of the LREG_CP_not bit */
|
||||
|
|
@ -110,7 +112,7 @@ int ascodec_write(int index, int value)
|
|||
|
||||
|
||||
/* returns value read on success, <0 otherwise */
|
||||
int ascodec_read(int index)
|
||||
int ascodec_read(unsigned int index)
|
||||
{
|
||||
/* check if still busy */
|
||||
if (i2c_busy()) {
|
||||
|
|
@ -128,3 +130,32 @@ int ascodec_read(int index)
|
|||
return I2C2_DATA;
|
||||
}
|
||||
|
||||
int ascodec_readbytes(int index, int len, unsigned char *data)
|
||||
{
|
||||
int i;
|
||||
|
||||
ascodec_lock();
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
{
|
||||
int temp = ascodec_read(index+i);
|
||||
if(temp == -1)
|
||||
break;
|
||||
else
|
||||
data[i] = temp;
|
||||
}
|
||||
|
||||
ascodec_unlock();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void ascodec_lock(void)
|
||||
{
|
||||
mutex_lock(&as_mtx);
|
||||
}
|
||||
|
||||
void ascodec_unlock(void)
|
||||
{
|
||||
mutex_unlock(&as_mtx);
|
||||
}
|
||||
|
|
|
|||
40
firmware/target/arm/as3525/ascodec-target.h
Normal file
40
firmware/target/arm/as3525/ascodec-target.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Driver for AS3514 audio codec
|
||||
*
|
||||
* Copyright (c) 2007 Daniel Ankers
|
||||
* Copyright (c) 2007 Christian Gmeiner
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _ASCODEC_TARGET_H
|
||||
#define _ASCODEC_TARGET_H
|
||||
|
||||
#include "as3514.h"
|
||||
|
||||
int ascodec_write(unsigned int index, unsigned int value);
|
||||
|
||||
int ascodec_read(unsigned int index);
|
||||
|
||||
int ascodec_readbytes(int index, int len, unsigned char *data);
|
||||
|
||||
void ascodec_lock(void);
|
||||
|
||||
void ascodec_unlock(void);
|
||||
|
||||
#endif /* !_ASCODEC_TARGET_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue