From be8a27ad818c0db4c6687edce159bbbe9df7ff5e Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Mon, 20 Apr 2009 18:28:51 +0000 Subject: [PATCH] Onda VX747: fix touchscreen issues when switching from bootloader to 'normal' Rockbox git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20754 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/ondavx747.c | 3 ++ firmware/export/config-ondavx747.h | 2 + .../onda_vx747/sadc-onda_vx747.c | 44 +++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/bootloader/ondavx747.c b/bootloader/ondavx747.c index 442fc61422..3e232e0f46 100755 --- a/bootloader/ondavx747.c +++ b/bootloader/ondavx747.c @@ -31,6 +31,7 @@ #include "storage.h" #include "disk.h" #include "string.h" +#include "adc.h" static void show_splash(int timeout, const char *msg) { @@ -101,6 +102,7 @@ int main(void) font_init(); lcd_setfont(FONT_SYSFIXED); button_init(); + adc_init(); storage_init(); reset_screen(); @@ -142,6 +144,7 @@ int main(void) if (rc == EOK) { printf("Starting Rockbox..."); + adc_close(); /* Disable SADC */ disable_interrupt(); kernel_entry = (void*) CONFIG_SDRAM_START; kernel_entry(); diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h index a2425dec90..e47a8c1702 100644 --- a/firmware/export/config-ondavx747.h +++ b/firmware/export/config-ondavx747.h @@ -123,6 +123,8 @@ #define CONFIG_I2C I2C_JZ47XX +#define NEED_ADC_CLOSE 1 + /* has no tone controls, so we use the software ones */ //#define HAVE_SW_TONE_CONTROLS diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c index d7ad3eb3e6..ebc2f214a9 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c @@ -123,22 +123,7 @@ unsigned int battery_adc_voltage(void) } void button_init_device(void) -{ - __cpm_start_sadc(); - REG_SADC_ENA = 0; - REG_SADC_STATE &= ~REG_SADC_STATE; - REG_SADC_CTRL = 0x1F; - - REG_SADC_CFG = SADC_CFG_INIT; - - system_enable_irq(IRQ_SADC); - - REG_SADC_SAMETIME = 10; - REG_SADC_WAITTIME = 100; - REG_SADC_STATE &= ~REG_SADC_STATE; - REG_SADC_CTRL = ~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM); - REG_SADC_ENA = SADC_ENA_TSEN; - +{ #ifdef ONDA_VX747 __gpio_as_input(32*3 + 29); __gpio_as_input(32*3 + 27); @@ -152,8 +137,6 @@ void button_init_device(void) __gpio_as_input(32*3 + 19); __gpio_as_input(32*2 + 22); #endif - - mutex_init(&battery_mtx); } bool button_hold(void) @@ -282,4 +265,29 @@ void SADC(void) void adc_init(void) { + __cpm_start_sadc(); + REG_SADC_ENA = 0; + REG_SADC_STATE &= (~REG_SADC_STATE); + REG_SADC_CTRL = 0x1f; + + REG_SADC_CFG = SADC_CFG_INIT; + + system_enable_irq(IRQ_SADC); + + REG_SADC_SAMETIME = 10; + REG_SADC_WAITTIME = 100; + REG_SADC_STATE &= ~REG_SADC_STATE; + REG_SADC_CTRL = ~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM); + REG_SADC_ENA = SADC_ENA_TSEN; + + mutex_init(&battery_mtx); } + +void adc_close(void) +{ + REG_SADC_ENA = 0; + __intc_mask_irq(IRQ_SADC); + sleep(20); + __cpm_stop_sadc(); +} +