summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/dbop-as3525.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-01-06 23:41:36 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-01-06 23:41:36 +0000
commit57667c51cf09de052222484ce94fbd6da113a55c (patch)
treeb85872be9b6c204e7d66a9203a64d78c524a38a5 /firmware/target/arm/as3525/dbop-as3525.c
parent8e8e2627b27b28a855881db09f2c16bfb2193050 (diff)
downloadrockbox-57667c51cf09de052222484ce94fbd6da113a55c.tar.gz
rockbox-57667c51cf09de052222484ce94fbd6da113a55c.zip
Sansa AMS: refactor DBOP button reading (e200v2/Fuze/c200v2)
This gets rid of LCD glitches on Sansa Fuze, and now LCD transfers can get interrupted by button reading Flyspray: FS #10603 Author: Bertrik Sikken git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24192 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/dbop-as3525.c')
-rw-r--r--firmware/target/arm/as3525/dbop-as3525.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/dbop-as3525.c b/firmware/target/arm/as3525/dbop-as3525.c
new file mode 100644
index 0000000000..938eee2fb1
--- /dev/null
+++ b/firmware/target/arm/as3525/dbop-as3525.c
@@ -0,0 +1,77 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Bertrik Sikken
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 "config.h"
23#include "as3525.h"
24#include "dbop-as3525.h"
25
26#if defined(SANSA_FUZE)
27#define DBOP_PRECHARGE 0x80FF
28#elif defined(SANSA_E200V2) || defined(SANSA_C200V2)
29#define DBOP_PRECHARGE 0xF0FF
30#endif
31
32static short int dbop_input_value = 0;
33
34/* read the DBOP data pins */
35unsigned short dbop_read_input(void)
36{
37 unsigned int dbop_ctrl_old = DBOP_CTRL;
38 unsigned int dbop_timpol23_old = DBOP_TIMPOL_23;
39
40 /* make sure that the DBOP FIFO is empty */
41 while ((DBOP_STAT & (1<<10)) == 0);
42
43 /* write DBOP_DOUT to pre-charge DBOP data lines with a defined level */
44 DBOP_TIMPOL_23 = 0xe007e007; /* no strobe towards lcd */
45 int delay = 10;
46 while (delay--) asm volatile ("nop\n");
47 DBOP_CTRL = (1 << 19) | /* tri-state output */
48 (1 << 16) | /* enw=1 (enable write) */
49 (1 << 12); /* ow=1 (16-bit data width) */
50 DBOP_DOUT = DBOP_PRECHARGE;
51 while ((DBOP_STAT & (1<<10)) == 0);
52
53#if defined(SANSA_FUZE) || defined(SANSA_E200V2)
54 delay = 50;
55 while (delay--) asm volatile ("nop\n");
56#endif
57
58 /* perform a DBOP read */
59 DBOP_CTRL = (1 << 19) | /* tri-state output */
60 (1 << 15) | /* strd=1 (start read) */
61 (1 << 12) | /* ow=1 (16-bit data width) */
62 (31 << 0); /* rs_t=31 (read DBOP at end of cycle) */
63 while ((DBOP_STAT & (1<<16)) == 0);
64 dbop_input_value = DBOP_DIN;
65
66 /* restore previous values */
67 DBOP_TIMPOL_23 = dbop_timpol23_old;
68 DBOP_CTRL = dbop_ctrl_old;
69
70 return dbop_input_value;
71}
72
73/* for the debug menu */
74unsigned short dbop_debug(void)
75{
76 return dbop_input_value;
77}