summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/x5/adc-x5.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-10-27 05:31:28 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-10-27 05:31:28 +0000
commit1d4a9c63666541b9e42b5d197d6afec21eb26b4e (patch)
tree6b33e5a3818e0712147cba869ead61421fedc90f /firmware/target/coldfire/iaudio/x5/adc-x5.c
parentd4dfe957f23bce14116ea9f5bdbaa77435f69908 (diff)
downloadrockbox-1d4a9c63666541b9e42b5d197d6afec21eb26b4e.tar.gz
rockbox-1d4a9c63666541b9e42b5d197d6afec21eb26b4e.zip
Stop reading buttons if one is not down. Don't read remote keys if not plugged. Good for another few points of boost and 4fps full-screen unboosted. The button scan enabling seems stable and I've been using it without any difficulties but if the interrupts hiccup it could leave them unresponsive. Clearing the GPI0 interrupts before enabling them seems to prevent any difficulties. If there's problems there I'll just leave the remote reading bypass only and 50% of the benefits will still be realized.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11357 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iaudio/x5/adc-x5.c')
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/adc-x5.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c
index fc45da8624..c923951e31 100755
--- a/firmware/target/coldfire/iaudio/x5/adc-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/adc-x5.c
@@ -26,19 +26,47 @@
26 26
27static unsigned short adcdata[NUM_ADC_CHANNELS]; 27static unsigned short adcdata[NUM_ADC_CHANNELS];
28 28
29static int channelnum[] = 29static const int adcc2_parms[] =
30{ 30{
31 5, /* ADC_BUTTONS (ADCIN2) */ 31 [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */
32 6, /* ADC_REMOTE (ADCIN3) */ 32 [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* ADCIN3 */
33 0, /* ADC_BATTERY (BATVOLT, resistive divider) */ 33 [ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */
34}; 34};
35 35
36/* have buttons scan by default */
37static volatile bool button_scan_on = true;
38
39void adc_enable_button_scan(bool enable)
40{
41 button_scan_on = enable;
42}
43
44bool adc_get_button_scan_enabled(void)
45{
46 return button_scan_on;
47}
48
36unsigned short adc_scan(int channel) 49unsigned short adc_scan(int channel)
37{ 50{
38 int level = set_irq_level(HIGHEST_IRQ_LEVEL); 51 int level;
39 unsigned char data; 52 unsigned char data;
40 53
41 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); 54 if (channel == ADC_BUTTONS)
55 {
56 /* no button scan if nothing pushed */
57 if (!button_scan_on)
58 return adcdata[channel] = 0xff;
59 }
60 else if (channel == ADC_REMOTE)
61 {
62 /* no remote scan if not plugged */
63 if (GPIO_READ & 0x01000000)
64 return adcdata[channel] = 0xff;
65 }
66
67 level = set_irq_level(HIGHEST_IRQ_LEVEL);
68
69 pcf50606_write(0x2f, adcc2_parms[channel]);
42 data = pcf50606_read(0x30); 70 data = pcf50606_read(0x30);
43 71
44 adcdata[channel] = data; 72 adcdata[channel] = data;
@@ -56,7 +84,7 @@ static int adc_counter;
56 84
57static void adc_tick(void) 85static void adc_tick(void)
58{ 86{
59 if(++adc_counter == HZ) 87 if (++adc_counter == HZ)
60 { 88 {
61 adc_counter = 0; 89 adc_counter = 0;
62 adc_scan(ADC_BATTERY); 90 adc_scan(ADC_BATTERY);