summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/as3525/debug-as3525.c13
-rw-r--r--firmware/target/arm/as3525/debug-target.h3
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/button-fuze.c96
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/debug-target.h28
-rw-r--r--firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c27
5 files changed, 82 insertions, 85 deletions
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c
index a388f12601..a70a07be9a 100644
--- a/firmware/target/arm/as3525/debug-as3525.c
+++ b/firmware/target/arm/as3525/debug-as3525.c
@@ -31,6 +31,15 @@
31#define _DEBUG_PRINTF(a,varargs...) \ 31#define _DEBUG_PRINTF(a,varargs...) \
32 snprintf(buf, sizeof(buf), (a), ##varargs); lcd_puts(0,line++,buf) 32 snprintf(buf, sizeof(buf), (a), ##varargs); lcd_puts(0,line++,buf)
33 33
34/* FIXME: target tree is including ./debug-target.h rather than the one in
35 * sansa-fuze/, even though deps contains the correct one
36 * if I put the below into a sansa-fuze/debug-target.h, it doesn't work*/
37#ifdef SANSA_FUZE
38#define DEBUG_DBOP
39short button_dbop_data(void);
40#endif
41
42
34/* TODO */ 43/* TODO */
35 44
36bool __dbg_hw_info(void) 45bool __dbg_hw_info(void)
@@ -54,10 +63,10 @@ bool __dbg_ports(void)
54 _DEBUG_PRINTF("GPIOB: %2x DIR: %2x", GPIOB_DATA, GPIOB_DIR); 63 _DEBUG_PRINTF("GPIOB: %2x DIR: %2x", GPIOB_DATA, GPIOB_DIR);
55 _DEBUG_PRINTF("GPIOC: %2x DIR: %2x", GPIOC_DATA, GPIOC_DIR); 64 _DEBUG_PRINTF("GPIOC: %2x DIR: %2x", GPIOC_DATA, GPIOC_DIR);
56 _DEBUG_PRINTF("GPIOD: %2x DIR: %2x", GPIOD_DATA, GPIOD_DIR); 65 _DEBUG_PRINTF("GPIOD: %2x DIR: %2x", GPIOD_DATA, GPIOD_DIR);
57#ifdef TRACK_DBOP_DIN 66#ifdef DEBUG_DBOP
58 line++; 67 line++;
59 _DEBUG_PRINTF("[DBOP_DIN]"); 68 _DEBUG_PRINTF("[DBOP_DIN]");
60 _DEBUG_PRINTF("DBOP_DIN: %4x", _dbop_din); 69 _DEBUG_PRINTF("DBOP_DIN: %4x", button_dbop_data());
61#endif 70#endif
62 lcd_update(); 71 lcd_update();
63 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) 72 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
diff --git a/firmware/target/arm/as3525/debug-target.h b/firmware/target/arm/as3525/debug-target.h
index 0769a2f11d..553eeb94e8 100644
--- a/firmware/target/arm/as3525/debug-target.h
+++ b/firmware/target/arm/as3525/debug-target.h
@@ -19,8 +19,11 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#ifndef _DEBUG_TARGET_H_
23#define _DEBUG_TARGET_H_
22#include <stdbool.h> 24#include <stdbool.h>
23 25
24#define DEBUG_CANCEL BUTTON_LEFT 26#define DEBUG_CANCEL BUTTON_LEFT
25bool __dbg_hw_info(void); 27bool __dbg_hw_info(void);
26bool __dbg_ports(void); 28bool __dbg_ports(void);
29#endif
diff --git a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
index e52a1d37d8..0e50ec659a 100644
--- a/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
+++ b/firmware/target/arm/as3525/sansa-fuze/button-fuze.c
@@ -42,8 +42,9 @@ static bool hold_button_old = false;
42#else 42#else
43#define hold_button false 43#define hold_button false
44#endif /* !BOOTLOADER */ 44#endif /* !BOOTLOADER */
45static int int_btn = BUTTON_NONE; 45static short _dbop_din = BUTTON_NONE;
46short _dbop_din = BUTTON_NONE; 46
47extern void lcd_button_support(void);
47 48
48void button_init_device(void) 49void button_init_device(void)
49{ 50{
@@ -53,12 +54,12 @@ void button_init_device(void)
53 54
54/* clickwheel */ 55/* clickwheel */
55#if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL) 56#if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL)
56static void get_wheel(void) 57static void clickwheel(void)
57{ 58{
58 static unsigned int old_wheel_value = 0; 59 static unsigned int old_wheel_value = 0;
59 static unsigned int wheel_value = 0; 60 static unsigned int wheel_value = 0;
60 static unsigned int wheel_repeat = BUTTON_NONE; 61 static unsigned int wheel_repeat = BUTTON_NONE;
61 /* getting BUTTON_REPEAT works like this: We increment repeat by if the 62 /* getting BUTTON_REPEAT works like this: We increment repeat by 2 if the
62 * wheel was turned, and decrement it by 1 each tick, 63 * wheel was turned, and decrement it by 1 each tick,
63 * that means: if you change the wheel fast enough, repeat will be >1 and 64 * that means: if you change the wheel fast enough, repeat will be >1 and
64 * we send BUTTON_REPEAT 65 * we send BUTTON_REPEAT
@@ -126,30 +127,15 @@ static void get_wheel(void)
126} 127}
127#endif /* !defined(BOOTLOADER) && defined(SCROLLWHEEL) */ 128#endif /* !defined(BOOTLOADER) && defined(SCROLLWHEEL) */
128 129
129#if !defined(BOOTLOADER)
130/* get hold button state */
131static void get_hold(void)
132{
133 hold_button = _dbop_din & (1<<12);
134}
135#endif
136
137bool button_hold(void) 130bool button_hold(void)
138{ 131{
139 return hold_button; 132 return hold_button;
140} 133}
141 134
142static void get_power(void) 135static int button_dbop(void)
143{
144 if (_dbop_din & (1<<8))
145 int_btn |= BUTTON_POWER;
146}
147
148static void get_button_from_dbob(void)
149{ 136{
150 int_btn &= ~(BUTTON_HOLD| 137 int ret = 0;
151 BUTTON_POWER); 138 lcd_button_support();
152
153 /* Wait for fifo to empty */ 139 /* Wait for fifo to empty */
154 while ((DBOP_STAT & (1<<10)) == 0); 140 while ((DBOP_STAT & (1<<10)) == 0);
155 141
@@ -181,34 +167,43 @@ static void get_button_from_dbob(void)
181 DBOP_CTRL &= ~(1<<19); 167 DBOP_CTRL &= ~(1<<19);
182 168
183#if !defined(BOOTLOADER) 169#if !defined(BOOTLOADER)
184 get_hold(); 170 hold_button = _dbop_din & (1<<12);
185#if defined(HAVE_SCROLLWHEEL) 171 if (hold_button)
186 get_wheel(); 172 return BUTTON_NONE;
187#endif 173#endif
174 /* read power */
175 if (_dbop_din & (1<<8))
176 ret |= BUTTON_POWER;
177 if(!(_dbop_din & (1<<15)))
178 ret |= BUTTON_HOME;
179#if defined(HAVE_SCROLLWHEEL)
180 clickwheel();
188#endif 181#endif
189 get_power(); 182
183 return ret;
184}
185
186/* for the debug menu */
187short button_dbop_data(void)
188{
189 return _dbop_din;
190} 190}
191 191
192static void get_button_from_gpio(void) 192static int button_gpio(void)
193{ 193{
194 /* reset buttons we're going to read */ 194 int btn = BUTTON_NONE;
195 int_btn &= ~(BUTTON_LEFT|
196 BUTTON_RIGHT|
197 BUTTON_UP|
198 BUTTON_DOWN|
199 BUTTON_SELECT);
200 if(hold_button) 195 if(hold_button)
201 return; 196 return btn;
202 /* set afsel, so that we can read our buttons */ 197 /* set afsel, so that we can read our buttons */
203 GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); 198 GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
204 /* set dir so we can read our buttons (but reset the C pins first) */ 199 /* set dir so we can read our buttons (but reset the C pins first) */
205 GPIOB_DIR &= ~(1<<4); 200 GPIOB_DIR &= ~(1<<4);
206 GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6); 201 GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
207 GPIOC_PIN(2) |= (1<<2); 202 GPIOC_PIN(2) = (1<<2);
208 GPIOC_PIN(3) |= (1<<3); 203 GPIOC_PIN(3) = (1<<3);
209 GPIOC_PIN(4) |= (1<<4); 204 GPIOC_PIN(4) = (1<<4);
210 GPIOC_PIN(5) |= (1<<5); 205 GPIOC_PIN(5) = (1<<5);
211 GPIOC_PIN(6) |= (1<<6); 206 GPIOC_PIN(6) = (1<<6);
212 207
213 GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); 208 GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
214 209
@@ -218,31 +213,30 @@ static void get_button_from_gpio(void)
218 213
219 /* direct GPIO connections */ 214 /* direct GPIO connections */
220 if (!GPIOC_PIN(3)) 215 if (!GPIOC_PIN(3))
221 int_btn |= BUTTON_LEFT; 216 btn |= BUTTON_LEFT;
222 if (!GPIOC_PIN(2)) 217 if (!GPIOC_PIN(2))
223 int_btn |= BUTTON_UP; 218 btn |= BUTTON_UP;
224 if (!GPIOC_PIN(6)) 219 if (!GPIOC_PIN(6))
225 int_btn |= BUTTON_DOWN; 220 btn |= BUTTON_DOWN;
226 if (!GPIOC_PIN(5)) 221 if (!GPIOC_PIN(5))
227 int_btn |= BUTTON_RIGHT; 222 btn |= BUTTON_RIGHT;
228 if (!GPIOC_PIN(4)) 223 if (!GPIOC_PIN(4))
229 int_btn |= BUTTON_SELECT; 224 btn |= BUTTON_SELECT;
230 /* return to settings needed for lcd */ 225 /* return to settings needed for lcd */
231 GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6); 226 GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
232 GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6); 227 GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6);
233}
234 228
235static inline void get_buttons_from_hw(void) 229 return btn;
236{
237 get_button_from_dbob();
238 get_button_from_gpio();
239} 230}
231
240/* 232/*
241 * Get button pressed from hardware 233 * Get button pressed from hardware
242 */ 234 */
243int button_read_device(void) 235int button_read_device(void)
244{ 236{
245 get_buttons_from_hw(); 237 int ret = BUTTON_NONE;
238 ret |= button_dbop();
239 ret |= button_gpio();
246#ifndef BOOTLOADER 240#ifndef BOOTLOADER
247 /* light handling */ 241 /* light handling */
248 if (hold_button != hold_button_old) 242 if (hold_button != hold_button_old)
@@ -252,5 +246,5 @@ int button_read_device(void)
252 } 246 }
253#endif /* BOOTLOADER */ 247#endif /* BOOTLOADER */
254 248
255 return int_btn; /* set in button_int */ 249 return ret;
256} 250}
diff --git a/firmware/target/arm/as3525/sansa-fuze/debug-target.h b/firmware/target/arm/as3525/sansa-fuze/debug-target.h
deleted file mode 100644
index 7ba5b2e4db..0000000000
--- a/firmware/target/arm/as3525/sansa-fuze/debug-target.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23
24#define DEBUG_CANCEL BUTTON_LEFT
25#define TRACK_DBOP_DIN
26extern short _dbop_din;
27bool __dbg_hw_info(void);
28bool __dbg_ports(void);
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
index b8feeb103e..f9de3c3117 100644
--- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
+++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
@@ -42,6 +42,8 @@ static bool display_on = false; /* is the display turned on? */
42static bool display_flipped = false; 42static bool display_flipped = false;
43static int xoffset = 20; /* needed for flip */ 43static int xoffset = 20; /* needed for flip */
44 44
45static volatile int _ystart, _ymax, _xstart, _xmax;
46
45static void as3525_dbop_init(void) 47static void as3525_dbop_init(void)
46{ 48{
47 CGU_DBOP = (1<<3) | CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ); 49 CGU_DBOP = (1<<3) | CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ);
@@ -258,22 +260,20 @@ void lcd_init_device()
258} 260}
259 261
260/* Set horizontal window addresses */ 262/* Set horizontal window addresses */
261static void lcd_window_x(int xmin, int xmax) 263void lcd_window_x(int xmin, int xmax)
262{ 264{
263 xmin += xoffset; 265 xmin += xoffset;
264 xmax += xoffset; 266 xmax += xoffset;
265
266 lcd_write_reg(0x46, (xmax << 8) | xmin); 267 lcd_write_reg(0x46, (xmax << 8) | xmin);
267 lcd_write_reg(0x20, xmin); 268 lcd_write_reg(0x20, xmin);
268} 269}
269 270
270/* Set vertical window addresses */ 271/* Set vertical window addresses */
271static void lcd_window_y(int ymin, int ymax) 272void lcd_window_y(int ymin, int ymax)
272{ 273{
273 lcd_write_reg(0x47, ymax); 274 lcd_write_reg(0x47, ymax);
274 lcd_write_reg(0x48, ymin); 275 lcd_write_reg(0x48, ymin);
275 lcd_write_reg(0x21, ymin); 276 lcd_write_reg(0x21, ymin);
276 lcd_write_cmd(0x22);
277} 277}
278 278
279/* Update the display. 279/* Update the display.
@@ -285,6 +285,8 @@ void lcd_update(void)
285 285
286 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); 286 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
287 287
288 /* we must disable interrupts because buttondriver also writes to lcd */
289 disable_irq();
288 lcd_window_x(0, LCD_WIDTH - 1); 290 lcd_window_x(0, LCD_WIDTH - 1);
289 lcd_window_y(0, LCD_HEIGHT - 1); 291 lcd_window_y(0, LCD_HEIGHT - 1);
290 292
@@ -293,6 +295,7 @@ void lcd_update(void)
293 295
294 /* Write data */ 296 /* Write data */
295 lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); 297 lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
298 enable_irq();
296} 299}
297 300
298/* Update a fraction of the display. */ 301/* Update a fraction of the display. */
@@ -324,6 +327,8 @@ void lcd_update_rect(int x, int y, int width, int height)
324 327
325 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); 328 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
326 329
330 /* we must disable interrupts because buttondriver also writes to lcd */
331 disable_irq();
327 lcd_window_x(x, xmax); 332 lcd_window_x(x, xmax);
328 lcd_window_y(y, ymax); 333 lcd_window_y(y, ymax);
329 334
@@ -338,4 +343,18 @@ void lcd_update_rect(int x, int y, int width, int height)
338 ptr += LCD_WIDTH; 343 ptr += LCD_WIDTH;
339 } 344 }
340 while (++y <= ymax); 345 while (++y <= ymax);
346 enable_irq();
347}
348
349/* writes one read pixel outside the visible area, needed for correct dbop reads */
350void lcd_button_support(void)
351{
352 fb_data data = 0xf<<12;
353 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
354 /* Set start position and window */
355
356 lcd_window_x(-1, 1);
357 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
358
359 lcd_write_data(&data, 1);
341} 360}