summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootloader/ondavx747.c3
-rw-r--r--firmware/export/config-ondavx747.h2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c44
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 @@
31#include "storage.h" 31#include "storage.h"
32#include "disk.h" 32#include "disk.h"
33#include "string.h" 33#include "string.h"
34#include "adc.h"
34 35
35static void show_splash(int timeout, const char *msg) 36static void show_splash(int timeout, const char *msg)
36{ 37{
@@ -101,6 +102,7 @@ int main(void)
101 font_init(); 102 font_init();
102 lcd_setfont(FONT_SYSFIXED); 103 lcd_setfont(FONT_SYSFIXED);
103 button_init(); 104 button_init();
105 adc_init();
104 storage_init(); 106 storage_init();
105 107
106 reset_screen(); 108 reset_screen();
@@ -142,6 +144,7 @@ int main(void)
142 if (rc == EOK) 144 if (rc == EOK)
143 { 145 {
144 printf("Starting Rockbox..."); 146 printf("Starting Rockbox...");
147 adc_close(); /* Disable SADC */
145 disable_interrupt(); 148 disable_interrupt();
146 kernel_entry = (void*) CONFIG_SDRAM_START; 149 kernel_entry = (void*) CONFIG_SDRAM_START;
147 kernel_entry(); 150 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 @@
123 123
124#define CONFIG_I2C I2C_JZ47XX 124#define CONFIG_I2C I2C_JZ47XX
125 125
126#define NEED_ADC_CLOSE 1
127
126/* has no tone controls, so we use the software ones */ 128/* has no tone controls, so we use the software ones */
127//#define HAVE_SW_TONE_CONTROLS 129//#define HAVE_SW_TONE_CONTROLS
128 130
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)
123} 123}
124 124
125void button_init_device(void) 125void button_init_device(void)
126{ 126{
127 __cpm_start_sadc();
128 REG_SADC_ENA = 0;
129 REG_SADC_STATE &= ~REG_SADC_STATE;
130 REG_SADC_CTRL = 0x1F;
131
132 REG_SADC_CFG = SADC_CFG_INIT;
133
134 system_enable_irq(IRQ_SADC);
135
136 REG_SADC_SAMETIME = 10;
137 REG_SADC_WAITTIME = 100;
138 REG_SADC_STATE &= ~REG_SADC_STATE;
139 REG_SADC_CTRL = ~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM);
140 REG_SADC_ENA = SADC_ENA_TSEN;
141
142#ifdef ONDA_VX747 127#ifdef ONDA_VX747
143 __gpio_as_input(32*3 + 29); 128 __gpio_as_input(32*3 + 29);
144 __gpio_as_input(32*3 + 27); 129 __gpio_as_input(32*3 + 27);
@@ -152,8 +137,6 @@ void button_init_device(void)
152 __gpio_as_input(32*3 + 19); 137 __gpio_as_input(32*3 + 19);
153 __gpio_as_input(32*2 + 22); 138 __gpio_as_input(32*2 + 22);
154#endif 139#endif
155
156 mutex_init(&battery_mtx);
157} 140}
158 141
159bool button_hold(void) 142bool button_hold(void)
@@ -282,4 +265,29 @@ void SADC(void)
282 265
283void adc_init(void) 266void adc_init(void)
284{ 267{
268 __cpm_start_sadc();
269 REG_SADC_ENA = 0;
270 REG_SADC_STATE &= (~REG_SADC_STATE);
271 REG_SADC_CTRL = 0x1f;
272
273 REG_SADC_CFG = SADC_CFG_INIT;
274
275 system_enable_irq(IRQ_SADC);
276
277 REG_SADC_SAMETIME = 10;
278 REG_SADC_WAITTIME = 100;
279 REG_SADC_STATE &= ~REG_SADC_STATE;
280 REG_SADC_CTRL = ~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM);
281 REG_SADC_ENA = SADC_ENA_TSEN;
282
283 mutex_init(&battery_mtx);
284}
285
286void adc_close(void)
287{
288 REG_SADC_ENA = 0;
289 __intc_mask_irq(IRQ_SADC);
290 sleep(20);
291 __cpm_stop_sadc();
285} 292}
293