1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Karl Kurbjun
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
32 #include "backlight.h"
33 #include "backlight-target.h"
39 #include "rbunicode.h"
42 #include "uart-target.h"
52 struct touch_calibration_point tl
, br
;
54 void touchpad_get_one_point(struct touch_calibration_point
*p
)
57 int start
= current_tick
;
58 while (TIME_AFTER(start
+(HZ
/3), current_tick
))
60 if (button_read_device()&BUTTON_TOUCHPAD
)
62 data
= button_get_last_touch();
64 p
->val_y
= data
&0xffff;
74 void touchpad_calibrate_screen(void)
77 printf("touch the center of the crosshairs to calibrate");
78 /* get the topleft value */
79 lcd_hline(MARGIN
-LEN
, MARGIN
+LEN
, MARGIN
);
80 lcd_vline(MARGIN
, MARGIN
-LEN
, MARGIN
+LEN
);
82 tl
.px_x
= MARGIN
; tl
.px_y
= MARGIN
;
83 touchpad_get_one_point(&tl
);
85 printf("touch the center of the crosshairs to calibrate");
86 /* get the topright value */
87 lcd_hline(LCD_WIDTH
-MARGIN
-LEN
, LCD_WIDTH
-MARGIN
+LEN
, LCD_HEIGHT
-MARGIN
);
88 lcd_vline(LCD_WIDTH
-MARGIN
, LCD_HEIGHT
-MARGIN
-LEN
, LCD_HEIGHT
-MARGIN
+LEN
);
90 br
.px_x
= LCD_WIDTH
-MARGIN
; br
.px_y
= LCD_HEIGHT
-MARGIN
;
91 touchpad_get_one_point(&br
);
94 printf("tl %d %d", tl
.val_x
, tl
.val_y
);
95 printf("br %d %d", br
.val_x
, br
.val_y
);
97 set_calibration_points(&tl
, &br
);
102 int button
=0, *address
=0x0;
104 use_calibration(false);
105 touchpad_calibrate_screen();
106 use_calibration(true);
111 struct tm
*t
= get_time();
112 printf("%d:%d:%d %d %d %d", t
->tm_hour
, t
->tm_min
, t
->tm_sec
, t
->tm_mday
, t
->tm_mon
, t
->tm_year
);
113 printf("time: %d", mktime(t
));
115 button
= button_get(false);
116 if (button
== BUTTON_POWER
)
119 IO_GIO_BITSET1
|=1<<10;
121 if(button
==BUTTON_RC_PLAY
)
123 else if (button
==BUTTON_RC_DOWN
)
125 else if (button
==BUTTON_RC_FF
)
127 else if (button
==BUTTON_RC_REW
)
131 // tsc2100_read_values(&x, &y, &z1, &z2);
132 // printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
133 // printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
134 // printf("current tick: %04x", current_tick);
135 // printf("Address: 0x%08x Data: 0x%08x", address, *address);
136 // printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1));
137 // printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2));
138 // // tsc2100_keyclick(); /* doesnt work :( */
142 if (button
&BUTTON_TOUCHPAD
)
144 if (button
&BUTTON_REL
)
146 unsigned int data
= button_get_data();
147 int x
= (data
&0xffff0000)>>16, y
= data
&0x0000ffff;
150 printf("%x %d %d\n", button
, x
,y
);
151 lcd_hline(x
-5, x
+5, y
);
152 lcd_vline(x
, y
-5, y
+5);
162 unsigned char* loadbuffer
;
165 int(*kernel_entry
)(void);
177 lcd_setfont(FONT_SYSFIXED
);
179 /* Show debug messages if button is pressed */
180 // if(button_read_device())
183 printf("Rockbox boot loader");
184 printf("Version %s", APPSVERSION
);
188 /* Enter USB mode without USB thread */
191 const char msg
[] = "Bootloader USB mode";
193 lcd_putsxy( (LCD_WIDTH
- (SYSFONT_WIDTH
* strlen(msg
))) / 2,
194 (LCD_HEIGHT
- SYSFONT_HEIGHT
) / 2, msg
);
197 ide_power_enable(true);
204 ata_spin(); /* Prevent the drive from spinning down */
228 rc
= disk_mount_all();
234 printf("Loading firmware");
236 loadbuffer
= (unsigned char*) 0x00900000;
237 buffer_size
= (unsigned char*)0x01900000 - loadbuffer
;
239 rc
= load_firmware(loadbuffer
, BOOTFILE
, buffer_size
);
241 error(EBOOTFILE
, rc
);
245 kernel_entry
= (void*) loadbuffer
;