summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-07-30 19:13:59 +0000
committerJens Arnold <amiconn@rockbox.org>2007-07-30 19:13:59 +0000
commit2e2f92c9066734040525347c8cb6d87f91e55c2c (patch)
treefc2dfbb1b6ec1cae18d13d78bcb857e6e55e6a02
parent09b2e589989a356cefd0437bd391e0032d34a664 (diff)
downloadrockbox-2e2f92c9066734040525347c8cb6d87f91e55c2c.tar.gz
rockbox-2e2f92c9066734040525347c8cb6d87f91e55c2c.zip
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
-rw-r--r--firmware/target/coldfire/iriver/h100/adc-h100.c26
-rw-r--r--firmware/target/coldfire/iriver/h100/adc-target.h5
-rw-r--r--firmware/target/coldfire/iriver/h300/adc-h300.c30
-rw-r--r--firmware/target/coldfire/iriver/h300/adc-target.h7
4 files changed, 14 insertions, 54 deletions
diff --git a/firmware/target/coldfire/iriver/h100/adc-h100.c b/firmware/target/coldfire/iriver/h100/adc-h100.c
index 777ab2ff73..b69204aa02 100644
--- a/firmware/target/coldfire/iriver/h100/adc-h100.c
+++ b/firmware/target/coldfire/iriver/h100/adc-h100.c
@@ -22,7 +22,6 @@
22#include "kernel.h" 22#include "kernel.h"
23#include "thread.h" 23#include "thread.h"
24#include "adc.h" 24#include "adc.h"
25static unsigned char adcdata[NUM_ADC_CHANNELS];
26 25
27 26
28#define CS_LO and_l(~0x80, &GPIO_OUT) 27#define CS_LO and_l(~0x80, &GPIO_OUT)
@@ -48,6 +47,7 @@ static unsigned char adcdata[NUM_ADC_CHANNELS];
48 47
49unsigned short adc_scan(int channel) 48unsigned short adc_scan(int channel)
50{ 49{
50 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
51 unsigned char data = 0; 51 unsigned char data = 0;
52 int i; 52 int i;
53 53
@@ -97,27 +97,9 @@ unsigned short adc_scan(int channel)
97 97
98 CS_HI; 98 CS_HI;
99 99
100 adcdata[channel] = data; 100 set_irq_level(level);
101
102 return data; 101 return data;
103} 102}
104unsigned short adc_read(int channel)
105{
106 return adcdata[channel];
107}
108
109static int adc_counter;
110
111static void adc_tick(void)
112{
113 if(++adc_counter == HZ)
114 {
115 adc_counter = 0;
116 adc_scan(ADC_BATTERY);
117 adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
118 detection feels stable. */
119 }
120}
121 103
122void adc_init(void) 104void adc_init(void)
123{ 105{
@@ -128,8 +110,4 @@ void adc_init(void)
128 or_l(0x00600080, &GPIO_ENABLE); 110 or_l(0x00600080, &GPIO_ENABLE);
129 or_l(0x80, &GPIO_OUT); /* CS high */ 111 or_l(0x80, &GPIO_OUT); /* CS high */
130 and_l(~0x00400000, &GPIO_OUT); /* CLK low */ 112 and_l(~0x00400000, &GPIO_OUT); /* CLK low */
131
132 adc_scan(ADC_BATTERY);
133
134 tick_add_task(adc_tick);
135} 113}
diff --git a/firmware/target/coldfire/iriver/h100/adc-target.h b/firmware/target/coldfire/iriver/h100/adc-target.h
index 54e7bc936a..f5161edd68 100644
--- a/firmware/target/coldfire/iriver/h100/adc-target.h
+++ b/firmware/target/coldfire/iriver/h100/adc-target.h
@@ -38,4 +38,9 @@
38/* Force a scan now */ 38/* Force a scan now */
39unsigned short adc_scan(int channel); 39unsigned short adc_scan(int channel);
40 40
41static inline unsigned short adc_read(int channel)
42{
43 return adc_scan(channel);
44}
45
41#endif /* _ADC_TARGET_H_ */ 46#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/coldfire/iriver/h300/adc-h300.c b/firmware/target/coldfire/iriver/h300/adc-h300.c
index 140eafe0ab..77d7b4689f 100644
--- a/firmware/target/coldfire/iriver/h300/adc-h300.c
+++ b/firmware/target/coldfire/iriver/h300/adc-h300.c
@@ -24,8 +24,6 @@
24#include "adc.h" 24#include "adc.h"
25#include "pcf50606.h" 25#include "pcf50606.h"
26 26
27static unsigned char adcdata[NUM_ADC_CHANNELS];
28
29static int adcc2_parms[] = 27static int adcc2_parms[] =
30{ 28{
31 [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ 29 [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */
@@ -42,34 +40,6 @@ unsigned short adc_scan(int channel)
42 pcf50606_write(0x2f, adcc2_parms[channel]); 40 pcf50606_write(0x2f, adcc2_parms[channel]);
43 data = pcf50606_read(0x30); 41 data = pcf50606_read(0x30);
44 42
45 adcdata[channel] = data;
46
47 set_irq_level(level); 43 set_irq_level(level);
48 return data; 44 return data;
49} 45}
50
51
52unsigned short adc_read(int channel)
53{
54 return adcdata[channel];
55}
56
57static int adc_counter;
58
59static void adc_tick(void)
60{
61 if(++adc_counter == HZ)
62 {
63 adc_counter = 0;
64 adc_scan(ADC_BATTERY);
65 adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
66 detection feels stable. */
67 }
68}
69
70void adc_init(void)
71{
72 adc_scan(ADC_BATTERY);
73
74 tick_add_task(adc_tick);
75}
diff --git a/firmware/target/coldfire/iriver/h300/adc-target.h b/firmware/target/coldfire/iriver/h300/adc-target.h
index 04200904a2..211a527253 100644
--- a/firmware/target/coldfire/iriver/h300/adc-target.h
+++ b/firmware/target/coldfire/iriver/h300/adc-target.h
@@ -38,4 +38,11 @@
38/* Force a scan now */ 38/* Force a scan now */
39unsigned short adc_scan(int channel); 39unsigned short adc_scan(int channel);
40 40
41static inline unsigned short adc_read(int channel)
42{
43 return adc_scan(channel);
44}
45static inline void adc_init(void)
46{}
47
41#endif /* _ADC_TARGET_H_ */ 48#endif /* _ADC_TARGET_H_ */