forked from len0rd/rockbox
H300: ADC driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7906 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ffe0b23902
commit
91c4873253
3 changed files with 28 additions and 11 deletions
|
|
@ -22,6 +22,7 @@
|
|||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "adc.h"
|
||||
#include "pcf50606.h"
|
||||
|
||||
#if CONFIG_CPU == SH7034
|
||||
/**************************************************************************
|
||||
|
|
@ -107,9 +108,29 @@ void adc_init(void)
|
|||
sleep(2); /* Ensure valid readings when adc_init returns */
|
||||
}
|
||||
#elif CONFIG_CPU == MCF5249
|
||||
|
||||
static unsigned char adcdata[NUM_ADC_CHANNELS];
|
||||
|
||||
#ifdef IRIVER_H300_SERIES
|
||||
static int channelnum[] =
|
||||
{
|
||||
5, /* ADC_BUTTONS */
|
||||
6, /* ADC_REMOTE */
|
||||
0, /* ADC_BATTERY */
|
||||
};
|
||||
|
||||
unsigned char adc_scan(int channel)
|
||||
{
|
||||
unsigned char data;
|
||||
|
||||
pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1);
|
||||
data = pcf50606_read(0x30);
|
||||
|
||||
adcdata[channel] = data;
|
||||
|
||||
return data;
|
||||
}
|
||||
#else
|
||||
|
||||
#define CS_LO and_l(~0x80, &GPIO_OUT)
|
||||
#define CS_HI or_l(0x80, &GPIO_OUT)
|
||||
#define CLK_LO and_l(~0x00400000, &GPIO_OUT)
|
||||
|
|
@ -176,6 +197,7 @@ unsigned char adc_scan(int channel)
|
|||
|
||||
return data;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned short adc_read(int channel)
|
||||
{
|
||||
|
|
@ -195,6 +217,8 @@ static void adc_tick(void)
|
|||
|
||||
void adc_init(void)
|
||||
{
|
||||
#ifdef IRIVER_H300_SERIES
|
||||
#else
|
||||
or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS
|
||||
GPIO21: Data In (to the ADC)
|
||||
GPIO22: CLK
|
||||
|
|
@ -202,6 +226,7 @@ void adc_init(void)
|
|||
or_l(0x00600080, &GPIO_ENABLE);
|
||||
or_l(0x80, &GPIO_OUT); /* CS high */
|
||||
and_l(~0x00400000, &GPIO_OUT); /* CLK low */
|
||||
#endif
|
||||
|
||||
adc_scan(ADC_BATTERY);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef IRIVER_H100_SERIES
|
||||
#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
|
||||
#define NUM_ADC_CHANNELS 4
|
||||
|
||||
#define ADC_BUTTONS 0
|
||||
|
|
@ -30,14 +30,6 @@
|
|||
#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
|
||||
|
||||
#else
|
||||
#ifdef IRIVER_H300
|
||||
/* TODO: we don't have enough info about the ADC for the H3x0 for now, so this
|
||||
stuff is only added here for now to make things compile. */
|
||||
#define ADC_BUTTONS -2
|
||||
#define ADC_REMOTE -3
|
||||
unsigned char adc_scan(int channel);
|
||||
|
||||
#endif
|
||||
|
||||
#define NUM_ADC_CHANNELS 8
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
/* Type of mobile power */
|
||||
#define CONFIG_BATTERY BATT_LIPOL1300
|
||||
|
||||
#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
|
||||
#define BATTERY_SCALE_FACTOR 23437 /* FIX: this value is picked at random */
|
||||
|
||||
/* Define this if the platform can charge batteries */
|
||||
#define HAVE_CHARGING 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue