summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-02-17 02:36:48 +0000
committerThomas Martitz <kugel@rockbox.org>2009-02-17 02:36:48 +0000
commitbe84fcffbd4bcc6e009a2a223b269b61098fdb93 (patch)
treed4668a7601118d92991ee3f8957dd5f2fd280b3c /firmware
parent4b0ae103197be83586a0f082eb2d0ee57b579f30 (diff)
Some Sansa Fuze work: Get Home button working (no keymap changes yet, so it's not very noticeable) and "fix" debug menu from not showing the dbop data (see FIXME), some cleanup in the fuze's button driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20027 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-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 @@
#define _DEBUG_PRINTF(a,varargs...) \
snprintf(buf, sizeof(buf), (a), ##varargs); lcd_puts(0,line++,buf)
+/* FIXME: target tree is including ./debug-target.h rather than the one in
+ * sansa-fuze/, even though deps contains the correct one
+ * if I put the below into a sansa-fuze/debug-target.h, it doesn't work*/
+#ifdef SANSA_FUZE
+#define DEBUG_DBOP
+short button_dbop_data(void);
+#endif
+
+
/* TODO */
bool __dbg_hw_info(void)
@@ -54,10 +63,10 @@ bool __dbg_ports(void)
_DEBUG_PRINTF("GPIOB: %2x DIR: %2x", GPIOB_DATA, GPIOB_DIR);
_DEBUG_PRINTF("GPIOC: %2x DIR: %2x", GPIOC_DATA, GPIOC_DIR);
_DEBUG_PRINTF("GPIOD: %2x DIR: %2x", GPIOD_DATA, GPIOD_DIR);
-#ifdef TRACK_DBOP_DIN
+#ifdef DEBUG_DBOP
line++;
_DEBUG_PRINTF("[DBOP_DIN]");
- _DEBUG_PRINTF("DBOP_DIN: %4x", _dbop_din);
+ _DEBUG_PRINTF("DBOP_DIN: %4x", button_dbop_data());
#endif
lcd_update();
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 @@
*
****************************************************************************/
+#ifndef _DEBUG_TARGET_H_
+#define _DEBUG_TARGET_H_
#include <stdbool.h>
#define DEBUG_CANCEL BUTTON_LEFT
bool __dbg_hw_info(void);
bool __dbg_ports(void);
+#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;
#else
#define hold_button false
#endif /* !BOOTLOADER */
-static int int_btn = BUTTON_NONE;
-short _dbop_din = BUTTON_NONE;
+static short _dbop_din = BUTTON_NONE;
+
+extern void lcd_button_support(void);
void button_init_device(void)
{
@@ -53,12 +54,12 @@ void button_init_device(void)
/* clickwheel */
#if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL)
-static void get_wheel(void)
+static void clickwheel(void)
{
static unsigned int old_wheel_value = 0;
static unsigned int wheel_value = 0;
static unsigned int wheel_repeat = BUTTON_NONE;
- /* getting BUTTON_REPEAT works like this: We increment repeat by if the
+ /* getting BUTTON_REPEAT works like this: We increment repeat by 2 if the
* wheel was turned, and decrement it by 1 each tick,
* that means: if you change the wheel fast enough, repeat will be >1 and
* we send BUTTON_REPEAT
@@ -126,30 +127,15 @@ static void get_wheel(void)
}
#endif /* !defined(BOOTLOADER) && defined(SCROLLWHEEL) */
-#if !defined(BOOTLOADER)
-/* get hold button state */
-static void get_hold(void)
-{
- hold_button = _dbop_din & (1<<12);
-}
-#endif
-
bool button_hold(void)
{
return hold_button;
}
-static void get_power(void)
-{
- if (_dbop_din & (1<<8))
- int_btn |= BUTTON_POWER;
-}
-
-static void get_button_from_dbob(void)
+static int button_dbop(void)
{
- int_btn &= ~(BUTTON_HOLD|
- BUTTON_POWER);
-
+ int ret = 0;
+ lcd_button_support();
/* Wait for fifo to empty */
while ((DBOP_STAT & (1<<10)) == 0);
@@ -181,34 +167,43 @@ static void get_button_from_dbob(void)
DBOP_CTRL &= ~(1<<19);
#if !defined(BOOTLOADER)
- get_hold();
-#if defined(HAVE_SCROLLWHEEL)
- get_wheel();
+ hold_button = _dbop_din & (1<<12);
+ if (hold_button)
+ return BUTTON_NONE;
#endif
+ /* read power */
+ if (_dbop_din & (1<<8))
+ ret |= BUTTON_POWER;
+ if(!(_dbop_din & (1<<15)))
+ ret |= BUTTON_HOME;
+#if defined(HAVE_SCROLLWHEEL)
+ clickwheel();
#endif
- get_power();
+
+ return ret;
+}
+
+/* for the debug menu */
+short button_dbop_data(void)
+{
+ return _dbop_din;
}
-static void get_button_from_gpio(void)
+static int button_gpio(void)
{
- /* reset buttons we're going to read */
- int_btn &= ~(BUTTON_LEFT|
- BUTTON_RIGHT|
- BUTTON_UP|
- BUTTON_DOWN|
- BUTTON_SELECT);
+ int btn = BUTTON_NONE;
if(hold_button)
- return;
+ return btn;
/* set afsel, so that we can read our buttons */
GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
/* set dir so we can read our buttons (but reset the C pins first) */
GPIOB_DIR &= ~(1<<4);
GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
- GPIOC_PIN(2) |= (1<<2);
- GPIOC_PIN(3) |= (1<<3);
- GPIOC_PIN(4) |= (1<<4);
- GPIOC_PIN(5) |= (1<<5);
- GPIOC_PIN(6) |= (1<<6);
+ GPIOC_PIN(2) = (1<<2);
+ GPIOC_PIN(3) = (1<<3);
+ GPIOC_PIN(4) = (1<<4);
+ GPIOC_PIN(5) = (1<<5);
+ GPIOC_PIN(6) = (1<<6);
GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
@@ -218,31 +213,30 @@ static void get_button_from_gpio(void)
/* direct GPIO connections */
if (!GPIOC_PIN(3))
- int_btn |= BUTTON_LEFT;
+ btn |= BUTTON_LEFT;
if (!GPIOC_PIN(2))
- int_btn |= BUTTON_UP;
+ btn |= BUTTON_UP;
if (!GPIOC_PIN(6))
- int_btn |= BUTTON_DOWN;
+ btn |= BUTTON_DOWN;
if (!GPIOC_PIN(5))
- int_btn |= BUTTON_RIGHT;
+ btn |= BUTTON_RIGHT;
if (!GPIOC_PIN(4))
- int_btn |= BUTTON_SELECT;
+ btn |= BUTTON_SELECT;
/* return to settings needed for lcd */
GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6);
-}
-static inline void get_buttons_from_hw(void)
-{
- get_button_from_dbob();
- get_button_from_gpio();
+ return btn;
}
+
/*
* Get button pressed from hardware
*/
int button_read_device(void)
{
- get_buttons_from_hw();
+ int ret = BUTTON_NONE;
+ ret |= button_dbop();
+ ret |= button_gpio();
#ifndef BOOTLOADER
/* light handling */
if (hold_button != hold_button_old)
@@ -252,5 +246,5 @@ int button_read_device(void)
}
#endif /* BOOTLOADER */
- return int_btn; /* set in button_int */
+ return ret;
}
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 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Karl Kurbjun
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include <stdbool.h>
-
-#define DEBUG_CANCEL BUTTON_LEFT
-#define TRACK_DBOP_DIN
-extern short _dbop_din;
-bool __dbg_hw_info(void);
-bool __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? */
static bool display_flipped = false;
static int xoffset = 20; /* needed for flip */
+static volatile int _ystart, _ymax, _xstart, _xmax;
+
static void as3525_dbop_init(void)
{
CGU_DBOP = (1<<3) | CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ);
@@ -258,22 +260,20 @@ void lcd_init_device()
}
/* Set horizontal window addresses */
-static void lcd_window_x(int xmin, int xmax)
+void lcd_window_x(int xmin, int xmax)
{
xmin += xoffset;
xmax += xoffset;
-
lcd_write_reg(0x46, (xmax << 8) | xmin);
lcd_write_reg(0x20, xmin);
}
/* Set vertical window addresses */
-static void lcd_window_y(int ymin, int ymax)
+void lcd_window_y(int ymin, int ymax)
{
lcd_write_reg(0x47, ymax);
lcd_write_reg(0x48, ymin);
lcd_write_reg(0x21, ymin);
- lcd_write_cmd(0x22);
}
/* Update the display.
@@ -285,6 +285,8 @@ void lcd_update(void)
lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
+ /* we must disable interrupts because buttondriver also writes to lcd */
+ disable_irq();
lcd_window_x(0, LCD_WIDTH - 1);
lcd_window_y(0, LCD_HEIGHT - 1);
@@ -293,6 +295,7 @@ void lcd_update(void)
/* Write data */
lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
+ enable_irq();
}
/* Update a fraction of the display. */
@@ -324,6 +327,8 @@ void lcd_update_rect(int x, int y, int width, int height)
lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
+ /* we must disable interrupts because buttondriver also writes to lcd */
+ disable_irq();
lcd_window_x(x, xmax);
lcd_window_y(y, ymax);
@@ -338,4 +343,18 @@ void lcd_update_rect(int x, int y, int width, int height)
ptr += LCD_WIDTH;
}
while (++y <= ymax);
+ enable_irq();
+}
+
+/* writes one read pixel outside the visible area, needed for correct dbop reads */
+void lcd_button_support(void)
+{
+ fb_data data = 0xf<<12;
+ lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
+ /* Set start position and window */
+
+ lcd_window_x(-1, 1);
+ lcd_write_cmd(R_WRITE_DATA_2_GRAM);
+
+ lcd_write_data(&data, 1);
}