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 #define LONG_DELAY 200000
58 #define SHORT_DELAY 50000
59 #define PAUSE_DELAY 50000
61 static inline void delay(int duration
)
64 for(i
=0;i
<duration
;i
++);
68 void bl_debug(bool bit
)
72 PDAT0
^= (1 << 2); //Toggle backlight
74 PDAT0
^= (1 << 2); //Toggle backlight
79 PDAT0
^= (1 << 2); //Toggle backlight
81 PDAT0
^= (1 << 2); //Toggle backlight
86 void bl_debug_count(unsigned int input
)
90 for (i
= 0; i
< input
; i
++)
92 PDAT0
^= (1 << 2); //Toggle backlight
94 PDAT0
^= (1 << 2); //Toggle backlight
98 void bl_debug_int(unsigned int input
,unsigned int count
)
101 for (i
= 0; i
< count
; i
++)
103 bl_debug(input
>>i
& 1);
105 delay(SHORT_DELAY
*6);
112 unsigned short data
= 0;
113 char write_data
[2], read_data
[16];
115 //Set backlight pin to output and enable
117 PCON0
= ((oldval
& ~(3 << 4)) | (1 << 4));
120 // Set codec reset pin inactive
121 PCON5
= (PCON5
& ~0xF) | 1;
126 // PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12));
131 PCON1
= ((oldval
& ~(0xf << 16)) | (2 << 16));
135 PCON1
= (oldval
& ~(0xf)) | 2;
137 // enable external interrupts
141 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
154 /* Calibrate the lot */
155 qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF
| QT1106_DI \
156 | QT1106_SLD_SLIDER
| QT1106_CAL_WHEEL
| QT1106_CAL_KEYS
| QT1106_RES_256
);
159 lcd_bitmap(rockboxlogo
, 0, 30, BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
162 /* Set to maximum sensitivity */
163 qt1106_io(QT1106_CT
| (0x00 << 8) );
167 #if 1 /* enable this to see info about the slider touchpad */
170 int slider
= qt1106_io(QT1106_MODE_FREE
| QT1106_MOD_INF \
171 | QT1106_DI
| QT1106_SLD_SLIDER
| QT1106_RES_256
);
172 snprintf(mystring
, 64, "%x %2.2x",(slider
& 0x008000)>>15, slider
&0xff);
173 lcd_puts(0,1,mystring
);
174 _backlight_set_brightness((slider
& 0xFF) >> 4);
177 if(slider & 0x008000)
178 bl_debug_count(((slider&0xff)) + 1);
182 #if 1 /* enable this to see info about the RTC */
183 rtc_read_datetime(read_data
);
184 for (i
= 0; i
< 7; i
++) {
185 snprintf(mystring
+ 2 * i
, 64, "%02X", read_data
[i
]);
187 lcd_puts(0, 10, mystring
);
190 #if 1 /* enable this so see info about the UDA1380 codec */
191 memset(read_data
, 0, sizeof(read_data
));
192 for (i
= 0; i
< 7; i
++) {
194 i2c_read(0x30, i
, 2, read_data
);
195 data
= read_data
[0] << 8 | read_data
[1];
196 snprintf(mystring
+ 4 * i
, 64, "%04X", data
);
198 lcd_puts(0, 11, mystring
);
201 #if 1 /* enable this to see info about IODMA channel 0 (PCM) */
202 snprintf(mystring
, 64, "DMA: %08X %08X", DMACADDR0
, DMACTCNT0
);
203 lcd_puts(0, 12, mystring
);
205 #if 1 /* enable this to see info about IIS */
206 snprintf(mystring
, 64, "IIS: %08X", I2SSTATUS
);
207 lcd_puts(0, 13, mystring
);