tree browser: return native path delimiters in returned path
[Rockbox.git] / firmware / drivers / fmradio.c
blobc64d06e066fe87042c4ac057bb094f6403ca1688
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "lcd.h"
20 #include "sh7034.h"
21 #include "kernel.h"
22 #include "thread.h"
23 #include "debug.h"
24 #include "system.h"
26 #if CONFIG_TUNER
28 /* Signals:
29 DI (Data In) - PB0 (doubles as data pin for the LCD)
30 CL (Clock) - PB1 (doubles as clock for the LCD)
31 CE (Chip Enable) - PB3 (also chip select for the LCD, but active low)
32 DO (Data Out) - PB4
35 /* cute little functions */
36 #define CE_LO and_b(~0x08, PBDRL_ADDR)
37 #define CE_HI or_b(0x08, PBDRL_ADDR)
38 #define CL_LO and_b(~0x02, PBDRL_ADDR)
39 #define CL_HI or_b(0x02, PBDRL_ADDR)
40 #define DO (PBDR & 0x10)
41 #define DI_LO and_b(~0x01, PBDRL_ADDR)
42 #define DI_HI or_b(0x01, PBDRL_ADDR)
44 #define START or_b((0x08 | 0x02), PBDRL_ADDR)
46 /* delay loop */
47 #define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0)
50 int fmradio_read(int addr)
52 int i;
53 int data = 0;
55 START;
57 /* First address bit */
58 CL_LO;
59 if(addr & 2)
60 DI_HI;
61 else
62 DI_LO;
63 DELAY;
64 CL_HI;
65 DELAY;
67 /* Second address bit */
68 CL_LO;
69 if(addr & 1)
70 DI_HI;
71 else
72 DI_LO;
73 DELAY;
74 CL_HI;
75 DELAY;
77 for(i = 0; i < 21;i++)
79 CL_LO;
80 DELAY;
81 data <<= 1;
82 data |= (DO)?1:0;
83 CL_HI;
84 DELAY;
87 CE_LO;
89 return data;
92 void fmradio_set(int addr, int data)
94 int i;
96 /* Include the address in the data */
97 data |= addr << 21;
99 START;
101 for(i = 0; i < 23;i++)
103 CL_LO;
104 DELAY;
105 if(data & (1 << 22))
106 DI_HI;
107 else
108 DI_LO;
110 data <<= 1;
111 CL_HI;
112 DELAY;
115 CE_LO;
118 #endif