summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-04-28 05:07:25 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-04-28 05:07:25 +0000
commit57ca7ccf36728fec7096931a064adc0b0e212ae0 (patch)
treed97c3a9477eac4cf2c7d7a4e0602a0b772d5805f
parent4e747f1c5ccc98d99c24354c6fef0d6abf87d220 (diff)
downloadrockbox-57ca7ccf36728fec7096931a064adc0b0e212ae0.tar.gz
rockbox-57ca7ccf36728fec7096931a064adc0b0e212ae0.zip
M:Robe 500: Rearrage TSC2100 reads to make touchscreen more reliable, add hack to get lcd_sleep working/called again, fix the panic handler so that it waits for the power button to be pressed instead of freezing the player
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20818 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config-mrobe500.h8
-rw-r--r--firmware/export/tsc2100.h15
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c43
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-target.h15
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c7
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c77
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-target.h3
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c52
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h1
-rwxr-xr-xfirmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c32
-rw-r--r--firmware/target/arm/tms320dm320/system-dm320.c6
11 files changed, 104 insertions, 155 deletions
diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h
index 29c2670f9e..78802e3adf 100644
--- a/firmware/export/config-mrobe500.h
+++ b/firmware/export/config-mrobe500.h
@@ -79,14 +79,12 @@
79#define LCD_DEPTH 16 /* 65k colours */ 79#define LCD_DEPTH 16 /* 65k colours */
80#define LCD_PIXELFORMAT RGB565 /* rgb565 */ 80#define LCD_PIXELFORMAT RGB565 /* rgb565 */
81 81
82/* Define this if your LCD can be enabled/disabled */
83#define HAVE_LCD_ENABLE
84
85#define HAVE_LCD_SLEEP_SETTING
86
87/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE 82/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
88 should be defined as well. */ 83 should be defined as well. */
89#define HAVE_LCD_SLEEP 84#define HAVE_LCD_SLEEP
85//#define HAVE_LCD_SLEEP_SETTING
86/* Do this for now till lcd sleeping is working properly */
87#define LCD_SLEEP_TIMEOUT 0
90 88
91/* remote LCD */ 89/* remote LCD */
92#define HAVE_REMOTE_LCD 90#define HAVE_REMOTE_LCD
diff --git a/firmware/export/tsc2100.h b/firmware/export/tsc2100.h
index 8d0ee529ff..06714db862 100644
--- a/firmware/export/tsc2100.h
+++ b/firmware/export/tsc2100.h
@@ -21,8 +21,11 @@
21#ifndef __TSC2100_H_ 21#ifndef __TSC2100_H_
22#define __TSC2100_H_ 22#define __TSC2100_H_
23 23
24/* Read X, Y, Z1, Z2 touchscreen coordinates. */ 24void tsc2100_read_data(void);
25void tsc2100_read_values(short *x, short* y, short *z1, short *z2); 25void tsc2100_read_touch(short *x, short* y, short *z1, short *z2);
26void tsc2100_read_volt(short *bat1, short *bat2, short *aux);
27void tsc2100_set_mode(unsigned char scan_mode);
28void tsc2100_adc_init(void);
26 29
27/* read a register */ 30/* read a register */
28short tsc2100_readreg(int page, int address); 31short tsc2100_readreg(int page, int address);
@@ -69,6 +72,14 @@ void tsc2100_keyclick(void);
69#define TSSTAT_T2STAT (1<<1) 72#define TSSTAT_T2STAT (1<<1)
70// Bit 0 is reserved (1<<0) 73// Bit 0 is reserved (1<<0)
71 74
75/* ts Reference Control */
76#define TSREF_PAGE 1
77#define TSREF_ADDRESS 0x03
78#define TSREF_VREFM (1<<4)
79#define TSREF_RPWUDL_SHIFT 2
80#define TSREF_RPWDN (1<<1)
81#define TSREF_IREFV (1<<0)
82
72/* ts Reset Control */ 83/* ts Reset Control */
73#define TSRESET_PAGE 1 84#define TSRESET_PAGE 1
74#define TSRESET_ADDRESS 0x04 85#define TSRESET_ADDRESS 0x04
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
index 0a1389a226..da3e2e9f44 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
@@ -23,27 +23,38 @@
23#include "adc.h" 23#include "adc.h"
24#include "adc-target.h" 24#include "adc-target.h"
25#include "kernel.h" 25#include "kernel.h"
26#include "tsc2100.h"
27#include "button-target.h"
26 28
27/* prototypes */ 29void read_battery_inputs(void);
28static void adc_tick(void);
29 30
30void adc_init(void) 31void adc_init(void)
31{ 32{
32 /* attach the adc reading to the tick */ 33 /* Initialize the touchscreen and the battery readout */
33 tick_add_task(adc_tick); 34 tsc2100_adc_init();
35
36 /* Enable the tsc2100 interrupt */
37 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
34} 38}
35 39
36/* Called to get the recent ADC reading */ 40/* Touchscreen data available interupt */
37inline unsigned short adc_read(int channel) 41void GIO14(void)
38{ 42{
39 return (short)channel; 43 short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
44 short adscm = (tsadc&TSADC_ADSCM_MASK)>>TSADC_ADSCM_SHIFT;
45
46 /* Always read all registers in one go to clear any missed flags */
47 tsc2100_read_data();
48
49 switch (adscm)
50 {
51 case 1:
52 case 2:
53 touch_read_coord();
54 break;
55 case 0x0B:
56 read_battery_inputs();
57 break;
58 }
59 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
40} 60}
41
42/* add this to the tick so that the ADC converts are done in the background */
43static void adc_tick(void)
44{
45}
46
47
48
49
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h b/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h
index 58aa19afcb..45e646cbb3 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h
@@ -22,19 +22,4 @@
22#ifndef _ADC_TARGET_H_ 22#ifndef _ADC_TARGET_H_
23#define _ADC_TARGET_H_ 23#define _ADC_TARGET_H_
24 24
25/* only two channels used by the Gigabeat */
26#define NUM_ADC_CHANNELS 2
27
28#define ADC_BATTERY 0
29#define ADC_HPREMOTE 1
30#define ADC_UNKNOWN_3 2
31#define ADC_UNKNOWN_4 3
32#define ADC_UNKNOWN_5 4
33#define ADC_UNKNOWN_6 5
34#define ADC_UNKNOWN_7 6
35#define ADC_UNKNOWN_8 7
36
37#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
38#define ADC_READ_ERROR 0xFFFF
39
40#endif 25#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
index bdd91e2e20..ab2289822b 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
@@ -27,6 +27,7 @@
27#include "lcd.h" 27#include "lcd.h"
28#include "power.h" 28#include "power.h"
29#include "spi-target.h" 29#include "spi-target.h"
30#include "lcd-target.h"
30 31
31int _backlight_brightness=DEFAULT_BRIGHTNESS_SETTING; 32int _backlight_brightness=DEFAULT_BRIGHTNESS_SETTING;
32 33
@@ -38,15 +39,15 @@ static void _backlight_write_brightness(int brightness)
38 39
39void _backlight_on(void) 40void _backlight_on(void)
40{ 41{
41#ifdef HAVE_LCD_ENABLE 42 lcd_awake(); /* power on lcd + visible display */
42 lcd_enable(true); /* power on lcd + visible display */ 43
43#endif
44 _backlight_write_brightness(_backlight_brightness); 44 _backlight_write_brightness(_backlight_brightness);
45} 45}
46 46
47void _backlight_off(void) 47void _backlight_off(void)
48{ 48{
49 _backlight_write_brightness(0); 49 _backlight_write_brightness(0);
50 lcd_sleep(); /* HACK to get lcd_sleep called again */
50} 51}
51 52
52/* Assumes that the backlight has been initialized */ 53/* Assumes that the backlight has been initialized */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
index 2daae7e5d5..09ff6cbd78 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -35,7 +35,10 @@
35#include "touchscreen.h" 35#include "touchscreen.h"
36 36
37static bool touch_available = false; 37static bool touch_available = false;
38static bool hold_button = false; 38static bool hold_button = false;
39
40static short touch_x, touch_y, touch_z1, touch_z2;
41static long last_touch = 0;
39 42
40static struct touch_calibration_point topleft, bottomright; 43static struct touch_calibration_point topleft, bottomright;
41 44
@@ -49,16 +52,16 @@ static struct touch_calibration_point topleft, bottomright;
49 * (640,480) = 3880, 3900 52 * (640,480) = 3880, 3900
50*/ 53*/
51 54
52static int touch_to_pixels(short val_x, short val_y) 55static int touch_to_pixels(short *val_x, short *val_y)
53{ 56{
54 short x,y; 57 short x,y;
55 58
56#if CONFIG_ORIENTATION == SCREEN_PORTRAIT 59#if CONFIG_ORIENTATION == SCREEN_PORTRAIT
57 x=val_x; 60 x=*val_x;
58 y=val_y; 61 y=*val_y;
59#else 62#else
60 x=val_y; 63 x=*val_y;
61 y=val_x; 64 y=*val_x;
62#endif 65#endif
63 66
64 x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x; 67 x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x;
@@ -74,6 +77,8 @@ static int touch_to_pixels(short val_x, short val_y)
74 else if (y>=LCD_HEIGHT) 77 else if (y>=LCD_HEIGHT)
75 y=LCD_HEIGHT-1; 78 y=LCD_HEIGHT-1;
76 79
80 *val_x=x;
81 *val_y=y;
77 82
78 return (x<<16)|y; 83 return (x<<16)|y;
79} 84}
@@ -103,18 +108,6 @@ void button_init_device(void)
103 108
104 bottomright.px_x = LCD_WIDTH; 109 bottomright.px_x = LCD_WIDTH;
105 bottomright.px_y = LCD_HEIGHT; 110 bottomright.px_y = LCD_HEIGHT;
106
107 /* Enable the touchscreen interrupt */
108 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
109#if 0
110 tsc2100_writereg(TSADC_PAGE, TSADC_ADDRESS,
111 TSADC_PSTCM|
112 (0x2<<TSADC_ADSCM_SHIFT)| /* scan x,y,z1,z2 */
113 (0x1<<TSADC_RESOL_SHIFT) /* 8 bit resolution */
114 );
115 /* doesnt work for some reason...
116 setting to 8bit would probably be better than the 12bit currently */
117#endif
118} 111}
119 112
120inline bool button_hold(void) 113inline bool button_hold(void)
@@ -122,46 +115,35 @@ inline bool button_hold(void)
122 return hold_button; 115 return hold_button;
123} 116}
124 117
118/* This is called from the tsc2100 interupt handler in adc-mr500.c */
119void touch_read_coord(void)
120{
121 touch_available = true;
122 tsc2100_read_touch(&touch_x, &touch_y, &touch_z1, &touch_z2);
123}
124
125int button_read_device(int *data) 125int button_read_device(int *data)
126{ 126{
127 int button_read = BUTTON_NONE; 127 int button_read = BUTTON_NONE;
128 static int button_old = BUTTON_NONE;
129 static bool hold_button_old = false; 128 static bool hold_button_old = false;
130 static long last_touch = 0;
131 129
132 *data = 0; 130 *data = 0;
133 131
134 /* Handle touchscreen */ 132 /* Handle touchscreen */
135 if (touch_available) 133 if (touch_available)
136 { 134 {
137 short x,y; 135 *data = touch_to_pixels(&touch_x, &touch_y);
138 short last_z1, last_z2; 136 button_read |= touchscreen_to_pixels(touch_x, touch_y, data);
139
140 tsc2100_read_values(&x, &y, &last_z1, &last_z2);
141
142 *data = touch_to_pixels(x, y);
143 button_read |= touchscreen_to_pixels((*data&0xffff0000)>>16,
144 *data&0x0000ffff, data);
145 button_old = button_read;
146 137
147 touch_available = false; 138 touch_available = false;
148 last_touch=current_tick; 139 last_touch=current_tick;
149 } 140 }
150 else
151 {
152 /* Touch hasn't happened in a while, clear the bits */
153 if(last_touch+3>current_tick)
154 button_old&=(0xFF);
155 }
156 141
157 /* Handle power button */ 142 /* Handle power button */
158 if ((IO_GIO_BITSET0&0x01) == 0) 143 if ((IO_GIO_BITSET0&0x01) == 0)
159 { 144 {
160 button_read |= BUTTON_POWER; 145 button_read |= BUTTON_POWER;
161 button_old = button_read;
162 } 146 }
163 else
164 button_old&=~BUTTON_POWER;
165 147
166 /* Read data from the remote */ 148 /* Read data from the remote */
167 button_read |= remote_read_device(); 149 button_read |= remote_read_device();
@@ -180,27 +162,8 @@ int button_read_device(int *data)
180 if (hold_button) 162 if (hold_button)
181 { 163 {
182 button_read = BUTTON_NONE; 164 button_read = BUTTON_NONE;
183 button_old = button_read;
184 } 165 }
185 166
186 return button_read; 167 return button_read;
187} 168}
188 169
189/* Touchscreen data available interupt */
190void read_battery_inputs(void);
191void GIO14(void)
192{
193 short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
194 short adscm = (tsadc&TSADC_ADSCM_MASK)>>TSADC_ADSCM_SHIFT;
195 switch (adscm)
196 {
197 case 1:
198 case 2:
199 touch_available = true;
200 break;
201 case 0xb:
202 read_battery_inputs();
203 break;
204 }
205 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
206}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
index 5b888b3e0a..b3a2960e01 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
@@ -30,6 +30,9 @@ bool button_hold(void);
30void button_init_device(void); 30void button_init_device(void);
31int button_read_device(int *data); 31int button_read_device(int *data);
32 32
33/* This is called from the tsc2100 interupt handler in adc-mr500.c */
34void touch_read_coord(void);
35
33struct touch_calibration_point { 36struct touch_calibration_point {
34 short px_x; /* known pixel value */ 37 short px_x; /* known pixel value */
35 short px_y; 38 short px_y;
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
index e26a88704d..20b830b02d 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
@@ -38,9 +38,8 @@
38extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, 38extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
39 int width, int height); 39 int width, int height);
40 40
41#if defined(HAVE_LCD_SLEEP)
41static bool lcd_on = true; 42static bool lcd_on = true;
42#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
43static bool lcd_powered = true;
44#endif 43#endif
45 44
46/* 45/*
@@ -49,7 +48,7 @@ static bool lcd_powered = true;
49extern unsigned fg_pattern; 48extern unsigned fg_pattern;
50extern unsigned bg_pattern; 49extern unsigned bg_pattern;
51 50
52#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 51#if defined(HAVE_LCD_SLEEP)
53bool lcd_active(void) 52bool lcd_active(void)
54{ 53{
55 return lcd_on; 54 return lcd_on;
@@ -59,12 +58,8 @@ bool lcd_active(void)
59#if defined(HAVE_LCD_SLEEP) 58#if defined(HAVE_LCD_SLEEP)
60void lcd_sleep() 59void lcd_sleep()
61{ 60{
62 if (lcd_powered) 61 if (lcd_on)
63 { 62 {
64 /* "not powered" implies "disabled" */
65 if (lcd_on)
66 lcd_enable(false);
67
68 /* Disabling these saves another ~15mA */ 63 /* Disabling these saves another ~15mA */
69 IO_OSD_OSDWINMD0&=~(0x01); 64 IO_OSD_OSDWINMD0&=~(0x01);
70 IO_VID_ENC_VMOD&=~(0x01); 65 IO_VID_ENC_VMOD&=~(0x01);
@@ -73,42 +68,29 @@ void lcd_sleep()
73 68
74 /* Disabling the LCD saves ~50mA */ 69 /* Disabling the LCD saves ~50mA */
75 IO_GIO_BITCLR2=1<<4; 70 IO_GIO_BITCLR2=1<<4;
76 lcd_powered=false; 71 lcd_on = false;
77 } 72 }
78} 73}
79#endif
80 74
81#if defined(HAVE_LCD_ENABLE) 75void lcd_awake(void)
82void lcd_enable(bool state)
83{ 76{
84 if (state == lcd_on) 77 /* "enabled" implies "powered" */
85 return; 78 if (!lcd_on)
86
87 if(state)
88 { 79 {
89 /* "enabled" implies "powered" */ 80 lcd_on=true;
90 if (!lcd_powered)
91 {
92 lcd_powered=true;
93
94 IO_OSD_OSDWINMD0|=0x01;
95 IO_VID_ENC_VMOD|=0x01;
96 81
97 sleep(2); 82 IO_OSD_OSDWINMD0|=0x01;
98 IO_GIO_BITSET2=1<<4; 83 IO_VID_ENC_VMOD|=0x01;
99 /* Wait long enough for a frame to be written - yes, it 84
100 * takes awhile. */ 85 sleep(2);
101 sleep(HZ/5); 86 IO_GIO_BITSET2=1<<4;
102 } 87 /* Wait long enough for a frame to be written - yes, it
103 88 * takes awhile. */
104 lcd_on = true; 89 sleep(HZ/5);
90
105 lcd_update(); 91 lcd_update();
106 lcd_activation_call_hook(); 92 lcd_activation_call_hook();
107 } 93 }
108 else
109 {
110 lcd_on = false;
111 }
112} 94}
113#endif 95#endif
114 96
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h b/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h
index 5175765bc1..2415fdb928 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h
@@ -20,4 +20,5 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22extern void lcd_enable(bool state); 22extern void lcd_enable(bool state);
23extern void lcd_awake(void);
23 24
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index f3746c8c98..654ec96591 100755
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -25,7 +25,7 @@
25#include "tsc2100.h" 25#include "tsc2100.h"
26#include "kernel.h" 26#include "kernel.h"
27 27
28unsigned short current_voltage = 3910; 28static unsigned short current_voltage = 3910;
29const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = 29const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
30{ 30{
31 0 31 0
@@ -47,38 +47,28 @@ const unsigned short percent_to_volt_charge[11] =
47{ 47{
48 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320, 48 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320,
49}; 49};
50
50void read_battery_inputs(void) 51void read_battery_inputs(void)
51{ 52{
52 short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS); 53 short dummy1, dummy2;
53 short adscm = (tsadc&TSADC_ADSCM_MASK)>>TSADC_ADSCM_SHIFT; 54 tsc2100_read_volt(&current_voltage, &dummy1, &dummy2);
54 if (adscm == 0xb) /* battery is available */ 55
55 { 56 /* Set the TSC2100 back to read touches */
56 current_voltage = tsc2100_readreg(0, 5); /* BAT1 */ 57 tsc2100_set_mode(0x01);
57 tsc2100_readreg(0, 6); /* BAT2 */
58 tsc2100_readreg(0, 7); /* AUX */
59 /* reset the TSC2100 to read touches */
60 tsadc &= ~(TSADC_PSTCM|TSADC_ADST|TSADC_ADSCM_MASK);
61 tsadc |= TSADC_PSTCM|(0x2<<TSADC_ADSCM_SHIFT);
62 tsc2100_writereg(TSADC_PAGE, TSADC_ADDRESS, tsadc);
63 tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS, 2<<TSSTAT_PINTDAV_SHIFT);
64 }
65} 58}
66 59
67/* Returns battery voltage from ADC [millivolts] */ 60/* Returns battery voltage from ADC [millivolts] */
68unsigned int battery_adc_voltage(void) 61unsigned int battery_adc_voltage(void)
69{ 62{
70 static unsigned last_tick = 0; 63 static unsigned last_tick = 0;
71 short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS); 64
72 if (TIME_BEFORE(last_tick+2*HZ, current_tick)) 65 if (TIME_BEFORE(last_tick+2*HZ, current_tick))
73 { 66 {
74 tsadc &= ~(TSADC_PSTCM|TSADC_ADST|TSADC_ADSCM_MASK); 67 /* Set the TSC2100 to read voltages */
75 tsadc |= 0xb<<TSADC_ADSCM_SHIFT; 68 tsc2100_set_mode(0x0B);
76 tsc2100_writereg(TSADC_PAGE, TSADC_ADDRESS, tsadc&(~(1<<15)));
77 tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS, 2<<TSSTAT_PINTDAV_SHIFT);
78 last_tick = current_tick; 69 last_tick = current_tick;
79 } 70 }
80 else 71
81 read_battery_inputs();
82 return current_voltage; 72 return current_voltage;
83} 73}
84 74
diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c
index e8d732351f..638e378159 100644
--- a/firmware/target/arm/tms320dm320/system-dm320.c
+++ b/firmware/target/arm/tms320dm320/system-dm320.c
@@ -188,7 +188,11 @@ void system_reboot(void)
188 188
189void system_exception_wait(void) 189void system_exception_wait(void)
190{ 190{
191 while (1); 191 /* Mask all Interrupts. */
192 IO_INTC_EINT0 = 0;
193 IO_INTC_EINT1 = 0;
194 IO_INTC_EINT2 = 0;
195 while ((IO_GIO_BITSET0&0x01) != 0); /* Wait for power button */
192} 196}
193 197
194void system_init(void) 198void system_init(void)