summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-05-02 23:25:55 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-05-02 23:25:55 +0000
commitfe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed (patch)
tree0b8c5e2543615640981b14a14de7bd651665b629
parentd5f7dab2308859d98837f76f3b2374645130e082 (diff)
downloadrockbox-fe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed.tar.gz
rockbox-fe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed.zip
M:Robe 500 - Fix some of the Keymaps, touchscreen improvements to decrease inacurate reads, add support for dynamic frequency (was running at 87.5 MHz, now it runs at 175 MHz when boosted), disable clock to unneded modules (decreased power by 20 mA), LCD turnoff now works without graphic glitches, battery ADC read now returns scaled voltage, define backlight fading
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20846 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/keymaps/keymap-mr500.c57
-rw-r--r--firmware/drivers/rtc/rtc_rx5x348ab.c4
-rw-r--r--firmware/drivers/tsc2100.c78
-rw-r--r--firmware/export/config-mrobe500.h19
-rw-r--r--firmware/export/tsc2100.h6
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c21
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c3
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c28
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c24
-rwxr-xr-xfirmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c32
-rw-r--r--firmware/target/arm/tms320dm320/spi-dm320.c8
-rw-r--r--firmware/target/arm/tms320dm320/spi-target.h1
-rw-r--r--firmware/target/arm/tms320dm320/system-dm320.c48
-rwxr-xr-xfirmware/target/arm/tms320dm320/system-target.h8
14 files changed, 220 insertions, 117 deletions
diff --git a/apps/keymaps/keymap-mr500.c b/apps/keymaps/keymap-mr500.c
index b044cb5e93..cd3e30dae1 100644
--- a/apps/keymaps/keymap-mr500.c
+++ b/apps/keymaps/keymap-mr500.c
@@ -73,17 +73,17 @@ static const struct button_mapping button_context_wps[] = {
73 73
74 { ACTION_WPS_SEEKBACK, BUTTON_RC_REW|BUTTON_REPEAT,BUTTON_NONE }, 74 { ACTION_WPS_SEEKBACK, BUTTON_RC_REW|BUTTON_REPEAT,BUTTON_NONE },
75 { ACTION_WPS_SEEKFWD, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE }, 75 { ACTION_WPS_SEEKFWD, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
76 { ACTION_WPS_STOPSEEK, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW|BUTTON_REPEAT }, 76 { ACTION_WPS_STOPSEEK,BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW|BUTTON_REPEAT},
77 { ACTION_WPS_STOPSEEK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_REPEAT }, 77 { ACTION_WPS_STOPSEEK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_REPEAT},
78 78
79 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, 79 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
80 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, 80 { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
81 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, 81 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
82 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE }, 82 { ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
83 83
84 { ACTION_WPS_QUICKSCREEN, BUTTON_RC_MODE|BUTTON_REPEAT, BUTTON_RC_MODE }, 84 { ACTION_WPS_QUICKSCREEN, BUTTON_RC_MODE|BUTTON_REPEAT, BUTTON_RC_MODE },
85 { ACTION_WPS_MENU, BUTTON_RC_MODE|BUTTON_REL, BUTTON_RC_MODE }, 85 { ACTION_WPS_MENU, BUTTON_RC_MODE|BUTTON_REL, BUTTON_RC_MODE },
86 { ACTION_WPS_CONTEXT, BUTTON_RC_HEART|BUTTON_REPEAT, BUTTON_RC_HEART }, 86 { ACTION_WPS_CONTEXT, BUTTON_RC_HEART|BUTTON_REPEAT, BUTTON_RC_HEART },
87 87
88 { ACTION_WPS_BROWSE, BUTTON_RC_HEART|BUTTON_REL, BUTTON_RC_HEART }, 88 { ACTION_WPS_BROWSE, BUTTON_RC_HEART|BUTTON_REL, BUTTON_RC_HEART },
89 89
@@ -91,6 +91,12 @@ static const struct button_mapping button_context_wps[] = {
91}; /* button_context_wps */ 91}; /* button_context_wps */
92 92
93static const struct button_mapping button_context_list[] = { 93static const struct button_mapping button_context_list[] = {
94#ifdef HAVE_VOLUME_IN_LIST
95 { ACTION_LIST_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
96 { ACTION_LIST_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
97 { ACTION_LIST_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
98 { ACTION_LIST_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
99#endif
94 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) 100 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
95}; /* button_context_list */ 101}; /* button_context_list */
96 102
@@ -107,22 +113,36 @@ static const struct button_mapping button_context_listtree_scroll_without_combo[
107}; 113};
108 114
109static const struct button_mapping button_context_settings[] = { 115static const struct button_mapping button_context_settings[] = {
110 { ACTION_SETTINGS_INC, BUTTON_RC_VOL_UP, BUTTON_NONE }, 116
111 { ACTION_SETTINGS_INCREPEAT, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, 117 { ACTION_SETTINGS_INC, BUTTON_RC_PLAY, BUTTON_NONE },
112 { ACTION_SETTINGS_DEC, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, 118 { ACTION_SETTINGS_INCREPEAT, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
113 { ACTION_SETTINGS_DECREPEAT, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, 119 { ACTION_SETTINGS_DEC, BUTTON_RC_DOWN, BUTTON_NONE },
114 { ACTION_STD_OK, BUTTON_RC_HEART, BUTTON_NONE }, 120 { ACTION_SETTINGS_DECREPEAT, BUTTON_RC_DOWN|BUTTON_REPEAT, BUTTON_NONE },
115 { ACTION_STD_CANCEL, BUTTON_RC_MODE, BUTTON_NONE }, 121 { ACTION_STD_PREV, BUTTON_RC_REW, BUTTON_NONE },
122 { ACTION_STD_PREVREPEAT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE },
123 { ACTION_STD_NEXT, BUTTON_RC_FF, BUTTON_NONE },
124 { ACTION_STD_NEXTREPEAT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
125 { ACTION_SETTINGS_RESET, BUTTON_RC_MODE, BUTTON_NONE },
116 126
117 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) 127 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
118}; /* button_context_settings */ 128}; /* button_context_settings */
119 129
120static const struct button_mapping button_context_settings_right_is_inc[] = { 130static const struct button_mapping button_context_settings_right_is_inc[] = {
131 { ACTION_SETTINGS_INC, BUTTON_RC_FF, BUTTON_NONE },
132 { ACTION_SETTINGS_INCREPEAT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
133 { ACTION_SETTINGS_DEC, BUTTON_RC_REW, BUTTON_NONE },
134 { ACTION_SETTINGS_DECREPEAT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE },
135 { ACTION_STD_PREV, BUTTON_RC_PLAY, BUTTON_NONE },
136 { ACTION_STD_PREVREPEAT, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
137 { ACTION_STD_NEXT, BUTTON_RC_DOWN, BUTTON_NONE },
138 { ACTION_STD_NEXTREPEAT, BUTTON_RC_DOWN|BUTTON_REPEAT, BUTTON_NONE },
139 { ACTION_SETTINGS_RESET, BUTTON_RC_MODE, BUTTON_NONE },
121 140
122 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) 141 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
123}; /* button_context_settingsgraphical */ 142}; /* button_context_settingsgraphical */
124 143
125static const struct button_mapping button_context_yesno[] = { 144static const struct button_mapping button_context_yesno[] = {
145 { ACTION_YESNO_ACCEPT, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_NONE },
126 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) 146 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
127}; /* button_context_settings_yesno */ 147}; /* button_context_settings_yesno */
128 148
@@ -140,6 +160,8 @@ static const struct button_mapping button_context_bmark[] = {
140}; /* button_context_bmark */ 160}; /* button_context_bmark */
141 161
142static const struct button_mapping button_context_time[] = { 162static const struct button_mapping button_context_time[] = {
163 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
164 { ACTION_STD_OK, BUTTON_RC_HEART, BUTTON_NONE },
143 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS), 165 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS),
144}; /* button_context_time */ 166}; /* button_context_time */
145 167
@@ -154,6 +176,19 @@ static const struct button_mapping button_context_pitchscreen[] = {
154}; /* button_context_pitchcreen */ 176}; /* button_context_pitchcreen */
155 177
156static const struct button_mapping button_context_keyboard[] = { 178static const struct button_mapping button_context_keyboard[] = {
179 { ACTION_KBD_LEFT, BUTTON_RC_REW, BUTTON_NONE },
180 { ACTION_KBD_LEFT, BUTTON_RC_REW|BUTTON_REPEAT, BUTTON_NONE },
181 { ACTION_KBD_RIGHT, BUTTON_RC_FF, BUTTON_NONE },
182 { ACTION_KBD_RIGHT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
183 { ACTION_KBD_SELECT, BUTTON_RC_HEART, BUTTON_NONE },
184 { ACTION_KBD_DONE, BUTTON_RC_MODE|BUTTON_REL, BUTTON_NONE },
185 { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
186 { ACTION_KBD_BACKSPACE, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
187 { ACTION_KBD_BACKSPACE, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
188 { ACTION_KBD_UP, BUTTON_RC_PLAY, BUTTON_NONE },
189 { ACTION_KBD_UP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE },
190 { ACTION_KBD_DOWN, BUTTON_RC_DOWN, BUTTON_NONE },
191 { ACTION_KBD_DOWN, BUTTON_RC_DOWN|BUTTON_REPEAT, BUTTON_NONE },
157 192
158 LAST_ITEM_IN_LIST 193 LAST_ITEM_IN_LIST
159}; /* button_context_keyboard */ 194}; /* button_context_keyboard */
diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c
index 286cd774e3..2b4e17c81d 100644
--- a/firmware/drivers/rtc/rtc_rx5x348ab.c
+++ b/firmware/drivers/rtc/rtc_rx5x348ab.c
@@ -36,7 +36,7 @@ void rtc_init(void)
36int rtc_read_datetime(unsigned char* buf) 36int rtc_read_datetime(unsigned char* buf)
37{ 37{
38 char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */ 38 char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */
39 spi_block_transfer(SPI_target_RX5X348AB, 39 spi_block_transfer(SPI_target_RX5X348AB, true,
40 &command, 1, buf, 7); 40 &command, 1, buf, 7);
41 return 1; 41 return 1;
42} 42}
@@ -48,7 +48,7 @@ int rtc_write_datetime(unsigned char* buf)
48 data[0] = command; 48 data[0] = command;
49 for (i=1;i<8;i++) 49 for (i=1;i<8;i++)
50 data[i] = buf[i-1]; 50 data[i] = buf[i-1];
51 spi_block_transfer(SPI_target_RX5X348AB, 51 spi_block_transfer(SPI_target_RX5X348AB, true,
52 data, 8, NULL, 0); 52 data, 8, NULL, 0);
53 return 1; 53 return 1;
54} 54}
diff --git a/firmware/drivers/tsc2100.c b/firmware/drivers/tsc2100.c
index 14b56b76c9..271a557822 100644
--- a/firmware/drivers/tsc2100.c
+++ b/firmware/drivers/tsc2100.c
@@ -27,6 +27,10 @@
27 27
28/* adc_data contains the last readings from the tsc2100 */ 28/* adc_data contains the last readings from the tsc2100 */
29static short adc_data[10]; 29static short adc_data[10];
30static short adc_status;
31static long adc_last_read=0;
32static long adc_last_touch_read=0;
33static long adc_last_volt_read=0;
30 34
31void tsc2100_read_data(void) 35void tsc2100_read_data(void)
32{ 36{
@@ -36,7 +40,11 @@ void tsc2100_read_data(void)
36 unsigned char out[] = {command >> 8, command & 0xff}; 40 unsigned char out[] = {command >> 8, command & 0xff};
37 unsigned char *p_adc_data=(unsigned char *)&adc_data; 41 unsigned char *p_adc_data=(unsigned char *)&adc_data;
38 42
39 spi_block_transfer(SPI_target_TSC2100, 43 adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS);
44
45 adc_last_read=current_tick;
46
47 spi_block_transfer(SPI_target_TSC2100, false,
40 out, sizeof(out), (char *)adc_data, sizeof(adc_data)); 48 out, sizeof(out), (char *)adc_data, sizeof(adc_data));
41 49
42 for(i=0; i<sizeof(adc_data); i+=2) 50 for(i=0; i<sizeof(adc_data); i+=2)
@@ -44,28 +52,55 @@ void tsc2100_read_data(void)
44} 52}
45 53
46/* Read X, Y, Z1, Z2 touchscreen coordinates. */ 54/* Read X, Y, Z1, Z2 touchscreen coordinates. */
47void tsc2100_read_touch(short *x, short* y, short *z1, short *z2) 55bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
48{ 56{
49 *x = adc_data[0]; 57 /* Note: This could cause problems if the current tick is not reset in ~1.3
50 *y = adc_data[1]; 58 * years. Noting this in the event that a suspend/resume function
51 *z1 = adc_data[2]; 59 * is added.
52 *z2 = adc_data[3]; 60 */
61 if( (adc_status&(3<<9)) && (adc_last_read - adc_last_touch_read>=0) ) {
62 *x = adc_data[0];
63 *y = adc_data[1];
64 *z1 = adc_data[2];
65 *z2 = adc_data[3];
66
67 adc_status&=~(3<<9);
68
69 adc_last_touch_read=current_tick;
70
71 return true;
72 } else {
73 return false;
74 }
53} 75}
54 76
55void tsc2100_read_volt(short *bat1, short *bat2, short *aux) 77bool tsc2100_read_volt(short *bat1, short *bat2, short *aux)
56{ 78{
57 *bat1 = adc_data[5]; 79 if( (adc_status&(7<<4)) && TIME_BEFORE(adc_last_volt_read, adc_last_read)) {
58 *bat2 = adc_data[6]; 80 *bat1 = adc_data[5];
59 *aux = adc_data[7]; 81 *bat2 = adc_data[6];
82 *aux = adc_data[7];
83
84 adc_status&=~(7<<4);
85 adc_last_volt_read=current_tick;
86 return true;
87 } else {
88 return false;
89 }
60} 90}
61 91
62void tsc2100_set_mode(unsigned char scan_mode) 92void tsc2100_set_mode(bool poweron, unsigned char scan_mode)
63{ 93{
64 short tsadc=(scan_mode<<TSADC_ADSCM_SHIFT)| /* mode */ 94 short tsadc=(scan_mode<<TSADC_ADSCM_SHIFT)| /* mode */
65 (0x3<<TSADC_RESOL_SHIFT)| /* 12 bit resolution */ 95 (0x3<<TSADC_RESOL_SHIFT)| /* 12 bit resolution */
66 (0x2<<TSADC_ADCR_SHIFT )| /* 2 MHz internal clock */ 96 (0x2<<TSADC_ADCR_SHIFT )| /* 2 MHz internal clock */
67 (0x2<<TSADC_PVSTC_SHIFT); 97 (0x2<<TSADC_PVSTC_SHIFT);
68 98
99 if(!poweron)
100 {
101 tsadc|=TSADC_ADST;
102 }
103
69 if(scan_mode<6) 104 if(scan_mode<6)
70 tsadc|=TSADC_PSTCM; 105 tsadc|=TSADC_PSTCM;
71 106
@@ -75,12 +110,15 @@ void tsc2100_set_mode(unsigned char scan_mode)
75void tsc2100_adc_init(void) 110void tsc2100_adc_init(void)
76{ 111{
77 /* Set the TSC2100 to read touchscreen */ 112 /* Set the TSC2100 to read touchscreen */
78 tsc2100_set_mode(0x01); 113 tsc2100_set_mode(true, 0x01);
79 114
80 tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS, 115 tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS,
81 (0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */ 116 (0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */
82 ); 117 );
83 118
119 /* An additional 2 mA can be saved here by powering down vref between
120 * conversions, but it adds a click to the audio on the M:Robe 500
121 */
84 tsc2100_writereg(TSREF_PAGE, TSREF_ADDRESS, 122 tsc2100_writereg(TSREF_PAGE, TSREF_ADDRESS,
85 TSREF_VREFM|TSREF_IREFV); 123 TSREF_VREFM|TSREF_IREFV);
86} 124}
@@ -90,7 +128,7 @@ short tsc2100_readreg(int page, int address)
90 unsigned short command = 0x8000|(page << 11)|(address << 5); 128 unsigned short command = 0x8000|(page << 11)|(address << 5);
91 unsigned char out[] = {command >> 8, command & 0xff}; 129 unsigned char out[] = {command >> 8, command & 0xff};
92 unsigned char in[2]; 130 unsigned char in[2];
93 spi_block_transfer(SPI_target_TSC2100, 131 spi_block_transfer(SPI_target_TSC2100, false,
94 out, sizeof(out), in, sizeof(in)); 132 out, sizeof(out), in, sizeof(in));
95 return (in[0]<<8)|in[1]; 133 return (in[0]<<8)|in[1];
96} 134}
@@ -101,7 +139,7 @@ void tsc2100_writereg(int page, int address, short value)
101 unsigned short command = (page << 11)|(address << 5); 139 unsigned short command = (page << 11)|(address << 5);
102 unsigned char out[4] = {command >> 8, command & 0xff, 140 unsigned char out[4] = {command >> 8, command & 0xff,
103 value >> 8, value & 0xff}; 141 value >> 8, value & 0xff};
104 spi_block_transfer(SPI_target_TSC2100, 142 spi_block_transfer(SPI_target_TSC2100, false,
105 out, sizeof(out), NULL, 0); 143 out, sizeof(out), NULL, 0);
106} 144}
107 145
@@ -111,3 +149,11 @@ void tsc2100_keyclick(void)
111 //short val = 0xC410; 149 //short val = 0xC410;
112 tsc2100_writereg(TSAC2_PAGE, TSAC2_ADDRESS, tsc2100_readreg(TSAC2_PAGE, TSAC2_ADDRESS)&0x8000); 150 tsc2100_writereg(TSAC2_PAGE, TSAC2_ADDRESS, tsc2100_readreg(TSAC2_PAGE, TSAC2_ADDRESS)&0x8000);
113} 151}
152
153#ifdef HAVE_HARDWARE_BEEP
154
155void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude)
156{
157 tsc2100_keyclick();
158}
159#endif
diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h
index 78802e3adf..5a97d8ba85 100644
--- a/firmware/export/config-mrobe500.h
+++ b/firmware/export/config-mrobe500.h
@@ -82,9 +82,7 @@
82/* 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
83 should be defined as well. */ 83 should be defined as well. */
84#define HAVE_LCD_SLEEP 84#define HAVE_LCD_SLEEP
85//#define HAVE_LCD_SLEEP_SETTING 85#define HAVE_LCD_SLEEP_SETTING
86/* Do this for now till lcd sleeping is working properly */
87#define LCD_SLEEP_TIMEOUT 0
88 86
89/* remote LCD */ 87/* remote LCD */
90#define HAVE_REMOTE_LCD 88#define HAVE_REMOTE_LCD
@@ -110,9 +108,14 @@
110#define HAVE_TOUCHSCREEN 108#define HAVE_TOUCHSCREEN
111#define HAVE_BUTTON_DATA 109#define HAVE_BUTTON_DATA
112 110
111/* define this if the target has volume keys which can be used in the lists */
112#define HAVE_VOLUME_IN_LIST
113
113/* Define this if you do software codec */ 114/* Define this if you do software codec */
114#define CONFIG_CODEC SWCODEC 115#define CONFIG_CODEC SWCODEC
115 116
117//#define HAVE_HARDWARE_BEEP
118
116/* There is no hardware tone control */ 119/* There is no hardware tone control */
117#define HAVE_SW_TONE_CONTROLS 120#define HAVE_SW_TONE_CONTROLS
118 121
@@ -152,8 +155,8 @@
152#define BATTERY_TYPES_COUNT 1 /* only one type */ 155#define BATTERY_TYPES_COUNT 1 /* only one type */
153 156
154/* define current usage levels */ 157/* define current usage levels */
155#define CURRENT_NORMAL 120 /* Measured */ 158#define CURRENT_NORMAL 100 /* Measured */
156#define CURRENT_BACKLIGHT 80 /* Over 200 mA total measured when on */ 159#define CURRENT_BACKLIGHT 100 /* Over 200 mA total measured when on */
157#define CURRENT_RECORD 0 /* no recording */ 160#define CURRENT_RECORD 0 /* no recording */
158 161
159/* Hardware controlled charging with monitoring */ 162/* Hardware controlled charging with monitoring */
@@ -178,11 +181,13 @@
178#define FLASH_SIZE 0x400000 181#define FLASH_SIZE 0x400000
179 182
180/* Define this to the CPU frequency */ 183/* Define this to the CPU frequency */
181#define CPU_FREQ 16934400 184#define CPU_FREQ 87500000
182 185
183/* Define this if you have ATA power-off control */ 186/* Define this if you have ATA power-off control */
184#define HAVE_ATA_POWER_OFF 187#define HAVE_ATA_POWER_OFF
185 188
189#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
190
186/* Virtual LED (icon) */ 191/* Virtual LED (icon) */
187#define CONFIG_LED LED_VIRTUAL 192#define CONFIG_LED LED_VIRTUAL
188 193
@@ -196,7 +201,7 @@
196#define FIRMWARE_OFFSET_FILE_DATA 8 201#define FIRMWARE_OFFSET_FILE_DATA 8
197 202
198/* Define this if you have adjustable CPU frequency */ 203/* Define this if you have adjustable CPU frequency */
199/* #define HAVE_ADJUSTABLE_CPU_FREQ */ 204#define HAVE_ADJUSTABLE_CPU_FREQ
200 205
201#define BOOTFILE_EXT "mrobe500" 206#define BOOTFILE_EXT "mrobe500"
202#define BOOTFILE "rockbox." BOOTFILE_EXT 207#define BOOTFILE "rockbox." BOOTFILE_EXT
diff --git a/firmware/export/tsc2100.h b/firmware/export/tsc2100.h
index 06714db862..7a06593fd7 100644
--- a/firmware/export/tsc2100.h
+++ b/firmware/export/tsc2100.h
@@ -22,9 +22,9 @@
22#define __TSC2100_H_ 22#define __TSC2100_H_
23 23
24void tsc2100_read_data(void); 24void tsc2100_read_data(void);
25void tsc2100_read_touch(short *x, short* y, short *z1, short *z2); 25bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2);
26void tsc2100_read_volt(short *bat1, short *bat2, short *aux); 26bool tsc2100_read_volt(short *bat1, short *bat2, short *aux);
27void tsc2100_set_mode(unsigned char scan_mode); 27void tsc2100_set_mode(bool poweron, unsigned char scan_mode);
28void tsc2100_adc_init(void); 28void tsc2100_adc_init(void);
29 29
30/* read a register */ 30/* read a register */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
index da3e2e9f44..e7e57a4f11 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
@@ -26,8 +26,6 @@
26#include "tsc2100.h" 26#include "tsc2100.h"
27#include "button-target.h" 27#include "button-target.h"
28 28
29void read_battery_inputs(void);
30
31void adc_init(void) 29void adc_init(void)
32{ 30{
33 /* Initialize the touchscreen and the battery readout */ 31 /* Initialize the touchscreen and the battery readout */
@@ -48,13 +46,24 @@ void GIO14(void)
48 46
49 switch (adscm) 47 switch (adscm)
50 { 48 {
51 case 1: 49 case 0x01:
52 case 2: 50 case 0x02:
53 touch_read_coord(); 51 case 0x03:
52 case 0x04:
53 case 0x05:
54 /* do a battery read - this will shutdown the adc till the next tick
55 */
56// tsc2100_set_mode(true, 0x0B);
54 break; 57 break;
58 case 0x06:
59 case 0x07:
60 case 0x08:
61 case 0x09:
55 case 0x0B: 62 case 0x0B:
56 read_battery_inputs(); 63 tsc2100_set_mode(true, 0x01);
57 break; 64 break;
58 } 65 }
66
59 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */ 67 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
60} 68}
69
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
index ab2289822b..751a59da94 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
@@ -34,7 +34,7 @@ int _backlight_brightness=DEFAULT_BRIGHTNESS_SETTING;
34static void _backlight_write_brightness(int brightness) 34static void _backlight_write_brightness(int brightness)
35{ 35{
36 uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb}; 36 uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb};
37 spi_block_transfer(SPI_target_BACKLIGHT, bl_command, 4, 0, 0); 37 spi_block_transfer(SPI_target_BACKLIGHT, false, bl_command, 4, 0, 0);
38} 38}
39 39
40void _backlight_on(void) 40void _backlight_on(void)
@@ -47,7 +47,6 @@ void _backlight_on(void)
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 */
51} 50}
52 51
53/* Assumes that the backlight has been initialized */ 52/* 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 09ff6cbd78..3e7077bd6d 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -19,8 +19,6 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22/* this file also handles the touch screen driver interface */
23
24#include "config.h" 22#include "config.h"
25#include "cpu.h" 23#include "cpu.h"
26#include "system.h" 24#include "system.h"
@@ -34,12 +32,8 @@
34#include "string.h" 32#include "string.h"
35#include "touchscreen.h" 33#include "touchscreen.h"
36 34
37static bool touch_available = false;
38static bool hold_button = false; 35static bool hold_button = false;
39 36
40static short touch_x, touch_y, touch_z1, touch_z2;
41static long last_touch = 0;
42
43static struct touch_calibration_point topleft, bottomright; 37static struct touch_calibration_point topleft, bottomright;
44 38
45/* Jd's tests.. These will hopefully work for everyone so we dont have to 39/* Jd's tests.. These will hopefully work for everyone so we dont have to
@@ -85,7 +79,6 @@ static int touch_to_pixels(short *val_x, short *val_y)
85 79
86void button_init_device(void) 80void button_init_device(void)
87{ 81{
88 touch_available = false;
89 /* GIO is the power button, set as input */ 82 /* GIO is the power button, set as input */
90 IO_GIO_DIR0 |= 0x01; 83 IO_GIO_DIR0 |= 0x01;
91 84
@@ -115,33 +108,25 @@ inline bool button_hold(void)
115 return hold_button; 108 return hold_button;
116} 109}
117 110
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) 111int button_read_device(int *data)
126{ 112{
127 int button_read = BUTTON_NONE; 113 int button_read = BUTTON_NONE;
114 short touch_x, touch_y, touch_z1, touch_z2;
128 static bool hold_button_old = false; 115 static bool hold_button_old = false;
129 116
130 *data = 0; 117 *data = 0;
131 118
132 /* Handle touchscreen */ 119 /* Handle touchscreen */
133 if (touch_available) 120 if (tsc2100_read_touch(&touch_x, &touch_y, &touch_z1, &touch_z2))
134 { 121 {
135 *data = touch_to_pixels(&touch_x, &touch_y); 122 *data = touch_to_pixels(&touch_x, &touch_y);
136 button_read |= touchscreen_to_pixels(touch_x, touch_y, data); 123 button_read |= touchscreen_to_pixels(touch_x, touch_y, data);
137
138 touch_available = false;
139 last_touch=current_tick;
140 } 124 }
141 125
126 tsc2100_set_mode(true, 0x01);
127
142 /* Handle power button */ 128 /* Handle power button */
143 if ((IO_GIO_BITSET0&0x01) == 0) 129 if ((IO_GIO_BITSET0&0x01) == 0) {
144 {
145 button_read |= BUTTON_POWER; 130 button_read |= BUTTON_POWER;
146 } 131 }
147 132
@@ -152,8 +137,7 @@ int button_read_device(int *data)
152 /* Take care of hold notifications */ 137 /* Take care of hold notifications */
153#ifndef BOOTLOADER 138#ifndef BOOTLOADER
154 /* give BL notice if HB state chaged */ 139 /* give BL notice if HB state chaged */
155 if (hold_button != hold_button_old) 140 if (hold_button != hold_button_old) {
156 {
157 backlight_hold_changed(hold_button); 141 backlight_hold_changed(hold_button);
158 hold_button_old=hold_button; 142 hold_button_old=hold_button;
159 } 143 }
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
index af5a6504e6..1dc453b800 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
@@ -60,15 +60,17 @@ void lcd_sleep()
60{ 60{
61 if (lcd_on) 61 if (lcd_on)
62 { 62 {
63 lcd_on = false;
64 memset16(FRAME, 0xFFFF, LCD_WIDTH*LCD_HEIGHT);
65 sleep(HZ/5);
63 /* Disabling these saves another ~15mA */ 66 /* Disabling these saves another ~15mA */
64 IO_OSD_OSDWINMD0&=~(0x01); 67 IO_OSD_OSDWINMD0&= ~(0x01);
65 IO_VID_ENC_VMOD&=~(0x01); 68 IO_VID_ENC_VMOD &= ~(0x01);
66 69
67 sleep(HZ/5); 70// IO_CLK_MOD1 &= ~(0x0018);
68 71
69 /* Disabling the LCD saves ~50mA */ 72 /* Disabling the LCD saves ~50mA */
70 IO_GIO_BITCLR2=1<<4; 73 IO_GIO_BITCLR2=1<<4;
71 lcd_on = false;
72 } 74 }
73} 75}
74 76
@@ -79,15 +81,19 @@ void lcd_awake(void)
79 { 81 {
80 lcd_on=true; 82 lcd_on=true;
81 83
82 IO_OSD_OSDWINMD0|=0x01; 84// IO_CLK_MOD1 |= 0x0018;
83 IO_VID_ENC_VMOD|=0x01; 85 IO_OSD_OSDWINMD0|= 0x01;
86 IO_VID_ENC_VMOD |= 0x01;
84 87
85 sleep(2); 88 sleep(2);
86 IO_GIO_BITSET2=1<<4; 89 IO_GIO_BITSET2=1<<4;
87 /* Wait long enough for a frame to be written */
88 sleep(HZ/20);
89 90
90 lcd_update(); 91 lcd_update();
92
93 /* Wait long enough for a frame to be written */
94 sleep(HZ/10);
95
96
91 lcd_activation_call_hook(); 97 lcd_activation_call_hook();
92 } 98 }
93} 99}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index 654ec96591..60949b2c18 100755
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -36,37 +36,41 @@ const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
36 0 36 0
37}; 37};
38 38
39/* 6.10 format */
40
39/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ 41/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
40const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = 42const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
41{ 43{
42 { 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 }, 44 { 375, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4500, 4950 },
43}; 45};
44 46
45/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ 47/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
46const unsigned short percent_to_volt_charge[11] = 48const unsigned short percent_to_volt_charge[11] =
47{ 49{
48 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320, 50 375, 1125, 1500, 1875, 2250, 2625, 3000, 3375, 3750, 4500, 4950,
49}; 51};
50
51void read_battery_inputs(void)
52{
53 short dummy1, dummy2;
54 tsc2100_read_volt(&current_voltage, &dummy1, &dummy2);
55
56 /* Set the TSC2100 back to read touches */
57 tsc2100_set_mode(0x01);
58}
59 52
60/* Returns battery voltage from ADC [millivolts] */ 53/* Returns battery voltage from ADC [millivolts] */
61unsigned int battery_adc_voltage(void) 54unsigned int battery_adc_voltage(void)
62{ 55{
56 short bat1, bat2, aux;
63 static unsigned last_tick = 0; 57 static unsigned last_tick = 0;
58 short tsadc;
59
60 if(tsc2100_read_volt(&bat1, &bat2, &aux)){
61 current_voltage=((short)((int)(bat1<<10)/4096*6*2.5));
62 }
64 63
65 if (TIME_BEFORE(last_tick+2*HZ, current_tick)) 64 if (TIME_BEFORE(last_tick+2*HZ, current_tick))
66 { 65 {
67 /* Set the TSC2100 to read voltages */ 66 tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
68 tsc2100_set_mode(0x0B); 67
69 last_tick = current_tick; 68 /* Set the TSC2100 to read voltages if not busy with pen */
69 if(!(tsadc & TSADC_PSTCM))
70 {
71 tsc2100_set_mode(true, 0x0B);
72 last_tick = current_tick;
73 }
70 } 74 }
71 75
72 return current_voltage; 76 return current_voltage;
diff --git a/firmware/target/arm/tms320dm320/spi-dm320.c b/firmware/target/arm/tms320dm320/spi-dm320.c
index 6375298c0f..2d5637b70e 100644
--- a/firmware/target/arm/tms320dm320/spi-dm320.c
+++ b/firmware/target/arm/tms320dm320/spi-dm320.c
@@ -65,10 +65,14 @@ static void spi_disable_all_targets(void)
65} 65}
66 66
67int spi_block_transfer(enum SPI_target target, 67int spi_block_transfer(enum SPI_target target,
68 const bool spi_msb_first,
68 const uint8_t *tx_bytes, unsigned int tx_size, 69 const uint8_t *tx_bytes, unsigned int tx_size,
69 uint8_t *rx_bytes, unsigned int rx_size) 70 uint8_t *rx_bytes, unsigned int rx_size)
70{ 71{
71 mutex_lock(&spi_mtx); 72 mutex_lock(&spi_mtx);
73
74 IO_SERIAL0_MODE = (IO_SERIAL0_MODE& ~(spi_msb_first<<9))|(spi_msb_first<<9);
75
72 /* Activate the slave select pin */ 76 /* Activate the slave select pin */
73 *spi_targets[target].setreg = spi_targets[target].bit; 77 *spi_targets[target].setreg = spi_targets[target].bit;
74 78
@@ -102,8 +106,8 @@ int spi_block_transfer(enum SPI_target target,
102void spi_init(void) 106void spi_init(void)
103{ 107{
104 mutex_init(&spi_mtx); 108 mutex_init(&spi_mtx);
105 /* Set SCLK idle level = 0 */ 109
106 IO_SERIAL0_MODE |= IO_SERIAL0_MODE_SCLK; 110 IO_SERIAL0_MODE = 0x3607;
107 /* Enable TX */ 111 /* Enable TX */
108 IO_SERIAL0_TX_ENABLE = 0x0001; 112 IO_SERIAL0_TX_ENABLE = 0x0001;
109#ifndef CREATIVE_ZVx 113#ifndef CREATIVE_ZVx
diff --git a/firmware/target/arm/tms320dm320/spi-target.h b/firmware/target/arm/tms320dm320/spi-target.h
index 013737b291..7fc0b72a28 100644
--- a/firmware/target/arm/tms320dm320/spi-target.h
+++ b/firmware/target/arm/tms320dm320/spi-target.h
@@ -38,6 +38,7 @@ enum SPI_target {
38 38
39void spi_init(void); 39void spi_init(void);
40int spi_block_transfer(enum SPI_target target, 40int spi_block_transfer(enum SPI_target target,
41 const bool spi_msb_first,
41 const uint8_t *tx_bytes, unsigned int tx_size, 42 const uint8_t *tx_bytes, unsigned int tx_size,
42 uint8_t *rx_bytes, unsigned int rx_size); 43 uint8_t *rx_bytes, unsigned int rx_size);
43 44
diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c
index 638e378159..0142f7b18b 100644
--- a/firmware/target/arm/tms320dm320/system-dm320.c
+++ b/firmware/target/arm/tms320dm320/system-dm320.c
@@ -217,6 +217,29 @@ void system_init(void)
217 IO_INTC_FISEL0 = 0; 217 IO_INTC_FISEL0 = 0;
218 IO_INTC_FISEL1 = 0; 218 IO_INTC_FISEL1 = 0;
219 IO_INTC_FISEL2 = 0; 219 IO_INTC_FISEL2 = 0;
220
221 /* setup the clocks */
222 IO_CLK_DIV0=0x0003;
223 IO_CLK_DIV1=0x0102;
224 IO_CLK_DIV2=0x021F;
225 IO_CLK_DIV3=0x1FFF;
226 IO_CLK_DIV4=0x1F00;
227
228 IO_CLK_PLLA=0x80A0;
229 IO_CLK_PLLB=0x80C0;
230
231 IO_CLK_SEL0=0x017E;
232 IO_CLK_SEL1=0x1000;
233 IO_CLK_SEL2=0x1001;
234
235 /* need to wait before bypassing */
236
237 IO_CLK_BYP=0x0000;
238
239 /* turn off some unneeded modules */
240 IO_CLK_MOD0 &= ~0x0018;
241 IO_CLK_MOD1 = 0x0918;
242 IO_CLK_MOD2 = ~0x7C58;
220 243
221 /* IRQENTRY only reflects enabled interrupts */ 244 /* IRQENTRY only reflects enabled interrupts */
222 IO_INTC_RAW = 0; 245 IO_INTC_RAW = 0;
@@ -224,6 +247,7 @@ void system_init(void)
224 IO_INTC_ENTRY_TBA0 = 0; 247 IO_INTC_ENTRY_TBA0 = 0;
225 IO_INTC_ENTRY_TBA1 = 0; 248 IO_INTC_ENTRY_TBA1 = 0;
226 249
250
227 int i; 251 int i;
228 /* Set interrupt priorities to predefined values */ 252 /* Set interrupt priorities to predefined values */
229 for(i = 0; i < 23; i++) 253 for(i = 0; i < 23; i++)
@@ -275,27 +299,13 @@ int system_memory_guard(int newmode)
275} 299}
276 300
277#ifdef HAVE_ADJUSTABLE_CPU_FREQ 301#ifdef HAVE_ADJUSTABLE_CPU_FREQ
278
279void set_cpu_frequency(long frequency) 302void set_cpu_frequency(long frequency)
280{ 303{
281 if (frequency == CPUFREQ_MAX) 304 if (frequency == CPUFREQ_MAX) {
282 { 305 IO_CLK_DIV0 = 0x0101; /* 175 MHz ARM */
283 asm volatile("mov r0, #0\n" 306 } else {
284 "mrc p15, 0, r0, c1, c0, 0\n" 307 IO_CLK_DIV0 = 0x0003; /* 87.5 MHz ARM - not much savings, about 3 mA */
285 "orr r0, r0, #3<<30\n" /* set to Asynchronous mode*/
286 "mcr p15, 0, r0, c1, c0, 0" : : : "r0");
287
288 FREQ = CPUFREQ_MAX;
289 }
290 else
291 {
292 asm volatile("mov r0, #0\n"
293 "mrc p15, 0, r0, c1, c0, 0\n"
294 "bic r0, r0, #3<<30\n" /* set to FastBus mode*/
295 "mcr p15, 0, r0, c1, c0, 0" : : : "r0");
296
297 FREQ = CPUFREQ_NORMAL;
298 } 308 }
299} 309}
300
301#endif 310#endif
311
diff --git a/firmware/target/arm/tms320dm320/system-target.h b/firmware/target/arm/tms320dm320/system-target.h
index f1e52ad5a0..63d314f572 100755
--- a/firmware/target/arm/tms320dm320/system-target.h
+++ b/firmware/target/arm/tms320dm320/system-target.h
@@ -23,9 +23,9 @@
23 23
24#include "system-arm.h" 24#include "system-arm.h"
25 25
26#define CPUFREQ_SLEEP 32768 26#define CPUFREQ_SLEEP 32768
27#define CPUFREQ_DEFAULT 24000000 27#define CPUFREQ_DEFAULT 87500000
28#define CPUFREQ_NORMAL 30000000 28#define CPUFREQ_NORMAL 87500000
29#define CPUFREQ_MAX 80000000 29#define CPUFREQ_MAX 175000000
30 30
31#endif /* SYSTEM_TARGET_H */ 31#endif /* SYSTEM_TARGET_H */