diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2006-10-27 05:31:28 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2006-10-27 05:31:28 +0000 |
commit | 1d4a9c63666541b9e42b5d197d6afec21eb26b4e (patch) | |
tree | 6b33e5a3818e0712147cba869ead61421fedc90f | |
parent | d4dfe957f23bce14116ea9f5bdbaa77435f69908 (diff) |
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
-rw-r--r-- | apps/debug_menu.c | 32 | ||||
-rw-r--r-- | firmware/export/adc.h | 5 | ||||
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/adc-x5.c | 44 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/x5/pcf50606-x5.c | 28 |
4 files changed, 85 insertions, 24 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 42c5776128..712a66cfa0 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -76,6 +76,10 @@ #include "pcm_playback.h" #endif +#ifdef IAUDIO_X5 +#include "lcd-remote-target.h" +#endif + /*---------------------------------------------------*/ /* SPECIAL DEBUG STUFF */ /*---------------------------------------------------*/ @@ -92,7 +96,7 @@ char thread_status_char(int status) case STATE_SLEEPING : return 'S'; case STATE_BLOCKED_W_TMO: return 'T'; } - + return '?'; } #ifndef SIMULATOR @@ -130,12 +134,12 @@ bool dbg_os(void) thread = &cores[core].threads[i]; if (thread->name == NULL) continue; - + usage = thread_stack_usage(thread); status = thread_get_status(thread); - - snprintf(buf, 32, "(%d) %c%c %d %s: %d%%", core, - (status == STATE_RUNNING) ? '*' : ' ', + + snprintf(buf, 32, "(%d) %c%c %d %s: %d%%", core, + (status == STATE_RUNNING) ? '*' : ' ', thread_status_char(status), cores[CURRENT_CORE].threads[i].priority, cores[core].threads[i].name, usage); @@ -149,19 +153,19 @@ bool dbg_os(void) thread = &cores[CURRENT_CORE].threads[i]; if (thread->name == NULL) continue; - + usage = thread_stack_usage(thread); status = thread_get_status(thread); # ifdef HAVE_PRIORITY_SCHEDULING snprintf(buf, 32, "%c%c %d %s: %d%%", - (status == STATE_RUNNING) ? '*' : ' ', + (status == STATE_RUNNING) ? '*' : ' ', thread_status_char(status), cores[CURRENT_CORE].threads[i].priority, cores[CURRENT_CORE].threads[i].name, usage); # else snprintf(buf, 32, "%c%c %s: %d%%", - (status == STATE_RUNNING) ? '*' : ' ', - (status == STATE_BLOCKED) ? 'B' : ' ', + (status == STATE_RUNNING) ? '*' : ' ', + (status == STATE_BLOCKED) ? 'B' : ' ', cores[CURRENT_CORE].threads[i].name, usage); # endif lcd_puts(0, 1+i, buf); @@ -1066,9 +1070,17 @@ bool dbg_ports(void) adc_remotedetect = adc_read(ADC_REMOTEDETECT); #endif +#ifdef IAUDIO_X5 + snprintf(buf, sizeof(buf), "ADC_BUTTONS (%c): %02x", + adc_get_button_scan_enabled() ? '+' : '-', adc_buttons); + lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), "ADC_REMOTE (%c): %02x", + remote_detect() ? '+' : '-', adc_remote); +#else snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_remote); +#endif lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_battery); lcd_puts(0, line++, buf); @@ -1438,7 +1450,7 @@ bool view_battery(void) ext_pwr ? "present" : "absent"); lcd_puts(0, 4, buf); snprintf(buf, 30, "Battery: %s", - charging ? "charging" : (usb_pwr||ext_pwr) ? "charged" : "discharging"); + charging ? "charging" : (usb_pwr||ext_pwr) ? "charged" : "discharging"); lcd_puts(0, 5, buf); snprintf(buf, 30, "Dock mode: %s", dock ? "enabled" : "disabled"); diff --git a/firmware/export/adc.h b/firmware/export/adc.h index 13d2617c00..487873dacc 100644 --- a/firmware/export/adc.h +++ b/firmware/export/adc.h @@ -105,4 +105,9 @@ void adc_init(void); unsigned short adc_scan(int channel); #endif +#if defined(IAUDIO_X5) +void adc_enable_button_scan(bool enable); +bool adc_get_button_scan_enabled(void); +#endif + #endif 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 @@ static unsigned short adcdata[NUM_ADC_CHANNELS]; -static int channelnum[] = +static const int adcc2_parms[] = { - 5, /* ADC_BUTTONS (ADCIN2) */ - 6, /* ADC_REMOTE (ADCIN3) */ - 0, /* ADC_BATTERY (BATVOLT, resistive divider) */ + [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ + [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* ADCIN3 */ + [ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */ }; +/* have buttons scan by default */ +static volatile bool button_scan_on = true; + +void adc_enable_button_scan(bool enable) +{ + button_scan_on = enable; +} + +bool adc_get_button_scan_enabled(void) +{ + return button_scan_on; +} + unsigned short adc_scan(int channel) { - int level = set_irq_level(HIGHEST_IRQ_LEVEL); + int level; unsigned char data; - - pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); + + if (channel == ADC_BUTTONS) + { + /* no button scan if nothing pushed */ + if (!button_scan_on) + return adcdata[channel] = 0xff; + } + else if (channel == ADC_REMOTE) + { + /* no remote scan if not plugged */ + if (GPIO_READ & 0x01000000) + return adcdata[channel] = 0xff; + } + + level = set_irq_level(HIGHEST_IRQ_LEVEL); + + pcf50606_write(0x2f, adcc2_parms[channel]); data = pcf50606_read(0x30); adcdata[channel] = data; @@ -56,7 +84,7 @@ static int adc_counter; static void adc_tick(void) { - if(++adc_counter == HZ) + if (++adc_counter == HZ) { adc_counter = 0; adc_scan(ADC_BATTERY); diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c index 58ff5d5cb0..8b3655c107 100644 --- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c +++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c @@ -20,6 +20,7 @@ #include "system.h" #include "kernel.h" #include "pcf50606.h" +#include "adc.h" #include "powermgmt.h" /* These voltages were determined by measuring the output of the PCF50606 @@ -44,7 +45,7 @@ static void init_pmu_interrupts(void) { ~0x04, /* unmask ONKEY1S */ ~0x00, - ~0x00 + ~0x06, /* unmask ACDREM, ACDINS */ }; /* make sure GPI0 interrupt is off before unmasking anything */ @@ -63,6 +64,9 @@ static void init_pmu_interrupts(void) static inline void enable_pmu_interrupts(void) { + /* clear pending GPI0 interrupts first or it may miss the first + H-L transition */ + or_l(0x00000100, &GPIO_INT_CLEAR); or_l(0x3, &INTPRI5); /* INT32 - Priority 3 */ } @@ -86,6 +90,9 @@ void pcf50606_init(void) pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */ #endif + /* Accessory detect */ + pcf50606_write(0x33, 0x8e); /* ACDAPE=1, THRSHLD=2.40V */ + /* allow GPI0 interrupts from PMU now */ enable_pmu_interrupts(); } @@ -101,12 +108,15 @@ void pcf50606_reset_timeout(void) void GPI0(void) __attribute__ ((interrupt_handler, section(".text"))); void GPI0(void) { - unsigned char read[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ + unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ + + /* Clear pending GPI0 interrupts */ + or_l(0x00000100, &GPIO_INT_CLEAR); /* clear pending interrupts from pcf50606 */ - pcf50606_read_multiple(0x02, read, 3); + pcf50606_read_multiple(0x02, data, 3); - if (read[0] & 0x04) + if (data[0] & 0x04) { /* ONKEY1S */ if (GPIO_READ & 0x02000000) @@ -115,6 +125,12 @@ void GPI0(void) pcf50606_reset_timeout(); /* remote ONKEY */ } - /* Clear pending GPI0 interrupts */ - or_l(0x00000100, &GPIO_INT_CLEAR); + if (data[2] & 0x06) + { + /* ACDINS/ACDREM */ + /* Check if adc_scan should actually scan main buttons or not - + bias towards "yes" out of paranoia. */ + adc_enable_button_scan((data[2] & 0x02) != 0 || + (pcf50606_read(0x33) & 0x01) != 0); + } } |