diff options
Diffstat (limited to 'firmware/target/arm/as3525/dbop-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/dbop-as3525.c | 77 |
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 | |||
32 | static short int dbop_input_value = 0; | ||
33 | |||
34 | /* read the DBOP data pins */ | ||
35 | unsigned 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 */ | ||
74 | unsigned short dbop_debug(void) | ||
75 | { | ||
76 | return dbop_input_value; | ||
77 | } | ||