1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Greg White
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
39 #include "backlight.h"
40 #include "backlight-target.h"
46 #include "rbunicode.h"
49 #include "bitmaps/rockboxlogo.h"
51 #include "i2c-s5l8700.h"
52 #include "dma-target.h"
57 char version
[] = APPSVERSION
;
58 #define LONG_DELAY 200000
59 #define SHORT_DELAY 50000
60 #define PAUSE_DELAY 50000
62 static inline void delay(int duration
)
65 for(i
=0;i
<duration
;i
++);
69 void bl_debug(bool bit
)
73 PDAT0
^= (1 << 2); //Toggle backlight
75 PDAT0
^= (1 << 2); //Toggle backlight
80 PDAT0
^= (1 << 2); //Toggle backlight
82 PDAT0
^= (1 << 2); //Toggle backlight
87 void bl_debug_count(unsigned int input
)
91 for (i
= 0; i
< input
; i
++)
93 PDAT0
^= (1 << 2); //Toggle backlight
95 PDAT0
^= (1 << 2); //Toggle backlight
99 void bl_debug_int(unsigned int input
,unsigned int count
)
102 for (i
= 0; i
< count
; i
++)
104 bl_debug(input
>>i
& 1);
106 delay(SHORT_DELAY
*6);
113 unsigned short data
= 0;
114 char write_data
[2], read_data
[16];
116 //Set backlight pin to output and enable
118 PCON0
= ((oldval
& ~(3 << 4)) | (1 << 4));
121 // Set codec reset pin inactive
122 PCON5
= (PCON5
& ~0xF) | 1;
127 // PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12));
132 PCON1
= ((oldval
& ~(0xf << 16)) | (2 << 16));
136 PCON1
= (oldval
& ~(0xf)) | 2;
138 // enable external interrupts
142 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
155 /* Calibrate the lot */
156 qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF
| QT1106_DI \
157 | QT1106_SLD_SLIDER
| QT1106_CAL_WHEEL
| QT1106_CAL_KEYS
| QT1106_RES_256
);
160 lcd_bitmap(rockboxlogo
, 0, 30, BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
163 /* Set to maximum sensitivity */
164 qt1106_io(QT1106_CT
| (0x00 << 8) );
168 #if 1 /* enable this to see info about the slider touchpad */
171 int slider
= qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF \
172 | QT1106_DI
| QT1106_SLD_SLIDER
| QT1106_RES_256
);
173 snprintf(mystring
, 64, "%x %2.2x",(slider
& 0x008000)>>15, slider
&0xff);
174 lcd_puts(0,1,mystring
);
175 _backlight_set_brightness((slider
& 0xFF) >> 4);
178 if(slider & 0x008000)
179 bl_debug_count(((slider&0xff)) + 1);
183 #if 1 /* enable this to see info about the RTC */
184 rtc_read_datetime(read_data
);
185 for (i
= 0; i
< 7; i
++) {
186 snprintf(mystring
+ 2 * i
, 64, "%02X", read_data
[i
]);
188 lcd_puts(0, 10, mystring
);
191 #if 1 /* enable this so see info about the UDA1380 codec */
192 memset(read_data
, 0, sizeof(read_data
));
193 for (i
= 0; i
< 7; i
++) {
195 i2c_read(0x30, i
, 2, read_data
);
196 data
= read_data
[0] << 8 | read_data
[1];
197 snprintf(mystring
+ 4 * i
, 64, "%04X", data
);
199 lcd_puts(0, 11, mystring
);
202 #if 1 /* enable this to see info about IODMA channel 0 (PCM) */
203 snprintf(mystring
, 64, "DMA: %08X %08X", DMACADDR0
, DMACTCNT0
);
204 lcd_puts(0, 12, mystring
);
206 #if 1 /* enable this to see info about IIS */
207 snprintf(mystring
, 64, "IIS: %08X", I2SSTATUS
);
208 lcd_puts(0, 13, mystring
);