summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/iaudio7/ata2501.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7/ata2501.c')
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
deleted file mode 100644
index f7526b2b9a..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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 "system.h"
24#include "cpu.h"
25#include "button.h"
26
27#include "ata2501.h"
28
29#define STB (1<<5)
30#define SDATA (1<<4)
31#define RESET (1<<6)
32#define SIFMD (1<<7)
33#define STB_DELAY 200
34
35static inline void ndelay(unsigned long nsecs)
36{
37 nsecs /= 8;
38 while (nsecs)
39 nsecs--;
40}
41
42/*
43 TODO: sensitivity
44*/
45void ata2501_init(void)
46{
47 GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
48 GPIOD_DIR &= ~SDATA;
49
50 GPIOD &= ~STB;
51 GPIOD |= (1 << 8) | SIFMD | (1 << 9);
52
53 GPIOD &= ~RESET;
54 ndelay(1000);
55 GPIOD |= RESET;
56}
57
58unsigned short ata2501_read(void)
59{
60 unsigned short ret = 0;
61 int i;
62
63 for (i = 0; i < 12; i++) {
64 GPIOD |= STB;
65 ndelay(100);
66 ret <<= 1;
67 if (GPIOD & SDATA)
68 ret |= 1;
69 GPIOD &= ~STB;
70 ndelay(100);
71 }
72
73 return ret;
74}
75
76//#define ATA2501_TEST
77#ifdef ATA2501_TEST
78#include "lcd.h"
79
80static
81void bits(char *str, unsigned short val)
82{
83 int i;
84
85 for (i = 0; i < 12; i++)
86 str[i] = (val & (1 << i)) ? '1' : '0';
87 str[i] = 0;
88}
89
90void ata2501_test(void)
91{
92 char buf[100];
93 ata2501_init();
94
95 while (1) {
96 unsigned short data;
97 int line = 0;
98
99 data = ata2501_read();
100 lcd_clear_display();
101 lcd_puts(0, line++, "ATA2501 test");
102
103 bits(buf, data);
104 lcd_puts(0, line++, buf);
105
106 lcd_update();
107 sleep(HZ/10);
108 }
109}
110#endif