mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-16 16:42:33 -05:00
H1x0, H300: Get rid of the adc tick, and use the same concept as the iAudio ADC driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14079 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
09b2e58998
commit
2e2f92c906
4 changed files with 14 additions and 54 deletions
|
|
@ -22,7 +22,6 @@
|
|||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "adc.h"
|
||||
static unsigned char adcdata[NUM_ADC_CHANNELS];
|
||||
|
||||
|
||||
#define CS_LO and_l(~0x80, &GPIO_OUT)
|
||||
|
|
@ -48,6 +47,7 @@ static unsigned char adcdata[NUM_ADC_CHANNELS];
|
|||
|
||||
unsigned short adc_scan(int channel)
|
||||
{
|
||||
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
unsigned char data = 0;
|
||||
int i;
|
||||
|
||||
|
|
@ -97,27 +97,9 @@ unsigned short adc_scan(int channel)
|
|||
|
||||
CS_HI;
|
||||
|
||||
adcdata[channel] = data;
|
||||
|
||||
set_irq_level(level);
|
||||
return data;
|
||||
}
|
||||
unsigned short adc_read(int channel)
|
||||
{
|
||||
return adcdata[channel];
|
||||
}
|
||||
|
||||
static int adc_counter;
|
||||
|
||||
static void adc_tick(void)
|
||||
{
|
||||
if(++adc_counter == HZ)
|
||||
{
|
||||
adc_counter = 0;
|
||||
adc_scan(ADC_BATTERY);
|
||||
adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
|
||||
detection feels stable. */
|
||||
}
|
||||
}
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
|
|
@ -128,8 +110,4 @@ void adc_init(void)
|
|||
or_l(0x00600080, &GPIO_ENABLE);
|
||||
or_l(0x80, &GPIO_OUT); /* CS high */
|
||||
and_l(~0x00400000, &GPIO_OUT); /* CLK low */
|
||||
|
||||
adc_scan(ADC_BATTERY);
|
||||
|
||||
tick_add_task(adc_tick);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,9 @@
|
|||
/* Force a scan now */
|
||||
unsigned short adc_scan(int channel);
|
||||
|
||||
static inline unsigned short adc_read(int channel)
|
||||
{
|
||||
return adc_scan(channel);
|
||||
}
|
||||
|
||||
#endif /* _ADC_TARGET_H_ */
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@
|
|||
#include "adc.h"
|
||||
#include "pcf50606.h"
|
||||
|
||||
static unsigned char adcdata[NUM_ADC_CHANNELS];
|
||||
|
||||
static int adcc2_parms[] =
|
||||
{
|
||||
[ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */
|
||||
|
|
@ -42,34 +40,6 @@ unsigned short adc_scan(int channel)
|
|||
pcf50606_write(0x2f, adcc2_parms[channel]);
|
||||
data = pcf50606_read(0x30);
|
||||
|
||||
adcdata[channel] = data;
|
||||
|
||||
set_irq_level(level);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
unsigned short adc_read(int channel)
|
||||
{
|
||||
return adcdata[channel];
|
||||
}
|
||||
|
||||
static int adc_counter;
|
||||
|
||||
static void adc_tick(void)
|
||||
{
|
||||
if(++adc_counter == HZ)
|
||||
{
|
||||
adc_counter = 0;
|
||||
adc_scan(ADC_BATTERY);
|
||||
adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
|
||||
detection feels stable. */
|
||||
}
|
||||
}
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
adc_scan(ADC_BATTERY);
|
||||
|
||||
tick_add_task(adc_tick);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,11 @@
|
|||
/* Force a scan now */
|
||||
unsigned short adc_scan(int channel);
|
||||
|
||||
static inline unsigned short adc_read(int channel)
|
||||
{
|
||||
return adc_scan(channel);
|
||||
}
|
||||
static inline void adc_init(void)
|
||||
{}
|
||||
|
||||
#endif /* _ADC_TARGET_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue