Improved ADC driver for AS3514 (used in PP5024 - ie. Sansa e200) based off datasheet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12745 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b051f101d9
commit
7f4f9aead7
5 changed files with 70 additions and 15 deletions
|
@ -1190,6 +1190,34 @@ bool dbg_ports(void)
|
||||||
lcd_puts(0, line++, buf);
|
lcd_puts(0, line++, buf);
|
||||||
snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD));
|
snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD));
|
||||||
lcd_puts(0, line++, buf);
|
lcd_puts(0, line++, buf);
|
||||||
|
#elif defined(SANSA_E200)
|
||||||
|
line++;
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_BVDD: %02x", adc_read(ADC_BVDD));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_RTCSUP: %02x", adc_read(ADC_RTCSUP));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_UVDD: %02x", adc_read(ADC_UVDD));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_CHG_IN: %02x", adc_read(ADC_CHG_IN));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_CVDD: %02x", adc_read(ADC_CVDD));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_BATTEMP: %02x", adc_read(ADC_BATTEMP));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_MICSUP1: %02x", adc_read(ADC_MICSUP1));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_MICSUP2: %02x", adc_read(ADC_MICSUP2));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_VBE1: %02x", adc_read(ADC_VBE1));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_VBE2: %02x", adc_read(ADC_VBE2));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_I_MICSUP1: %02x", adc_read(ADC_I_MICSUP1));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_I_MICSUP2: %02x", adc_read(ADC_I_MICSUP2));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
|
snprintf(buf, sizeof(buf), "ADC_VBAT: %02x", adc_read(ADC_VBAT));
|
||||||
|
lcd_puts(0, line++, buf);
|
||||||
#endif
|
#endif
|
||||||
lcd_update();
|
lcd_update();
|
||||||
if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
|
if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef _AS3514_H
|
#ifndef _AS3514_H
|
||||||
#define _AS3514_H
|
#define _AS3514_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern int tenthdb2master(int db);
|
extern int tenthdb2master(int db);
|
||||||
extern int tenthdb2mixer(int db);
|
extern int tenthdb2mixer(int db);
|
||||||
|
|
||||||
|
@ -67,6 +69,13 @@ extern void audiohw_set_equalizer_band(int band, int freq, int bw, int gain);
|
||||||
#define AUDIOSET3 0x16
|
#define AUDIOSET3 0x16
|
||||||
#define PLLMODE 0x1d
|
#define PLLMODE 0x1d
|
||||||
|
|
||||||
|
#define IRQ_ENRD0 0x25
|
||||||
|
#define IRQ_ENRD1 0x26
|
||||||
|
#define IRQ_ENRD2 0x27
|
||||||
|
|
||||||
|
#define ADC_0 0x2e
|
||||||
|
#define ADC_1 0x2f
|
||||||
|
|
||||||
/* Headphone volume goes from -45.43 - 1.07dB */
|
/* Headphone volume goes from -45.43 - 1.07dB */
|
||||||
#define VOLUME_MIN -454
|
#define VOLUME_MIN -454
|
||||||
#define VOLUME_MAX 10
|
#define VOLUME_MAX 10
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
#define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */
|
#define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */
|
||||||
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
|
#define BATTERY_CAPACITY_INC 0 /* capacity increment */
|
||||||
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
||||||
#define BATTERY_SCALE_FACTOR 5054
|
#define BATTERY_SCALE_FACTOR 5005 /* ADC should read 0x3ff=5.12V */
|
||||||
|
|
||||||
/* Hardware controlled charging? FIXME */
|
/* Hardware controlled charging? FIXME */
|
||||||
#define CONFIG_CHARGING CHARGING_SIMPLE
|
#define CONFIG_CHARGING CHARGING_SIMPLE
|
||||||
|
|
|
@ -18,23 +18,25 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
#include "i2c-pp.h"
|
#include "i2c-pp.h"
|
||||||
#include "logf.h"
|
#include "as3514.h"
|
||||||
|
|
||||||
/* Read 10-bit channel data */
|
/* Read 10-bit channel data */
|
||||||
unsigned short adc_read(int channel)
|
unsigned short adc_read(int channel)
|
||||||
{
|
{
|
||||||
unsigned char bat[2];
|
unsigned char buf[2];
|
||||||
unsigned short data = 0;
|
unsigned short data = 0;
|
||||||
|
|
||||||
switch( channel)
|
/* Select channel */
|
||||||
{
|
pp_i2c_send( AS3514_I2C_ADDR, ADC_0, (channel << 4));
|
||||||
case ADC_UNREG_POWER:
|
|
||||||
pp_i2c_send( 0x46, 0x2e, 0x0);
|
/* Wait for conversion to be complete */
|
||||||
pp_i2c_send( 0x46, 0x27, 0x1);
|
pp_i2c_send( AS3514_I2C_ADDR, IRQ_ENRD2, 0x1);
|
||||||
i2c_readbytes( 0x46, 0x2e, 2, bat);
|
while( (i2c_readbyte( AS3514_I2C_ADDR, IRQ_ENRD2) & 0x1) == 0);
|
||||||
data = ((bat[0]<<8) | bat[1]);
|
|
||||||
break;
|
/* Read data */
|
||||||
}
|
i2c_readbytes( AS3514_I2C_ADDR, ADC_0, 2, buf);
|
||||||
|
data = (((buf[0] & 0x3) << 8) | buf[1]);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,25 @@
|
||||||
#ifndef _ADC_TARGET_H_
|
#ifndef _ADC_TARGET_H_
|
||||||
#define _ADC_TARGET_H_
|
#define _ADC_TARGET_H_
|
||||||
|
|
||||||
#define NUM_ADC_CHANNELS 1
|
/* ADC channels */
|
||||||
|
#define NUM_ADC_CHANNELS 13
|
||||||
|
|
||||||
#define ADC_BATTERY 0
|
#define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */
|
||||||
#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
|
#define ADC_RTCSUP 1 /* RTC backup battery voltage */
|
||||||
|
#define ADC_UVDD 2 /* USB host voltage */
|
||||||
|
#define ADC_CHG_IN 3 /* Charger input voltage */
|
||||||
|
#define ADC_CVDD 4 /* Charger pump output voltage */
|
||||||
|
#define ADC_BATTEMP 5 /* Battery charging temperature */
|
||||||
|
#define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control
|
||||||
|
or external voltage measurement */
|
||||||
|
#define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control
|
||||||
|
or external voltage measurement */
|
||||||
|
#define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */
|
||||||
|
#define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */
|
||||||
|
#define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */
|
||||||
|
#define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */
|
||||||
|
#define ADC_VBAT 12 /* Single cell battery voltage */
|
||||||
|
|
||||||
|
#define ADC_UNREG_POWER ADC_BVDD /* For compatibility */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue