diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2011-11-16 10:25:43 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2011-11-16 10:25:43 +0000 |
commit | be716c0be80e3f64a81a3f19b683db40489f47a1 (patch) | |
tree | bc461ad1de8b5fda6c3c14d0cfd737bdc69ddc83 /firmware | |
parent | b7508a766df991539bec5e10fd7739001c1fdb99 (diff) | |
download | rockbox-be716c0be80e3f64a81a3f19b683db40489f47a1.tar.gz rockbox-be716c0be80e3f64a81a3f19b683db40489f47a1.zip |
Finally commit FS#5111 - piezo clicker for ipods!
Origional implementation by Robert Keevil with contributions from Frederik Vestre, Stoyan Stratev, Craig Elliott, Michael Sparmann, Thomas Schott, Rosso Maltese, and syncs from a bunch of other people!
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30995 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 7 | ||||
-rw-r--r-- | firmware/export/config/ipod4g.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipodcolor.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipodmini1g.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipodmini2g.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipodnano1g.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipodnano2g.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipodvideo.h | 2 | ||||
-rw-r--r-- | firmware/export/thread.h | 8 | ||||
-rw-r--r-- | firmware/target/arm/ipod/piezo.c | 209 | ||||
-rw-r--r-- | firmware/target/arm/ipod/piezo.h | 30 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c | 95 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/ipodnano2g/piezo.h | 24 |
13 files changed, 387 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 0f6c21d673..6a84b5fc11 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -1160,6 +1160,7 @@ target/arm/ata-pp5020.c | |||
1160 | target/arm/ipod/adc-ipod-pcf.c | 1160 | target/arm/ipod/adc-ipod-pcf.c |
1161 | target/arm/ipod/backlight-4g_color.c | 1161 | target/arm/ipod/backlight-4g_color.c |
1162 | target/arm/ipod/button-clickwheel.c | 1162 | target/arm/ipod/button-clickwheel.c |
1163 | target/arm/ipod/piezo.c | ||
1163 | target/arm/ipod/lcd-as-gray.S | 1164 | target/arm/ipod/lcd-as-gray.S |
1164 | target/arm/ipod/lcd-gray.c | 1165 | target/arm/ipod/lcd-gray.c |
1165 | target/arm/ipod/power-ipod.c | 1166 | target/arm/ipod/power-ipod.c |
@@ -1178,6 +1179,7 @@ target/arm/i2s-pp.c | |||
1178 | target/arm/ipod/adc-ipod-pcf.c | 1179 | target/arm/ipod/adc-ipod-pcf.c |
1179 | target/arm/ipod/backlight-4g_color.c | 1180 | target/arm/ipod/backlight-4g_color.c |
1180 | target/arm/ipod/button-clickwheel.c | 1181 | target/arm/ipod/button-clickwheel.c |
1182 | target/arm/ipod/piezo.c | ||
1181 | target/arm/ipod/lcd-color_nano.c | 1183 | target/arm/ipod/lcd-color_nano.c |
1182 | target/arm/ipod/lcd-as-color-nano.S | 1184 | target/arm/ipod/lcd-as-color-nano.S |
1183 | target/arm/ipod/power-ipod.c | 1185 | target/arm/ipod/power-ipod.c |
@@ -1196,6 +1198,7 @@ target/arm/i2s-pp.c | |||
1196 | target/arm/ipod/adc-ipod-pcf.c | 1198 | target/arm/ipod/adc-ipod-pcf.c |
1197 | target/arm/ipod/backlight-nano_video.c | 1199 | target/arm/ipod/backlight-nano_video.c |
1198 | target/arm/ipod/button-clickwheel.c | 1200 | target/arm/ipod/button-clickwheel.c |
1201 | target/arm/ipod/piezo.c | ||
1199 | target/arm/ipod/lcd-color_nano.c | 1202 | target/arm/ipod/lcd-color_nano.c |
1200 | target/arm/ipod/lcd-as-color-nano.S | 1203 | target/arm/ipod/lcd-as-color-nano.S |
1201 | target/arm/ipod/power-ipod.c | 1204 | target/arm/ipod/power-ipod.c |
@@ -1214,6 +1217,7 @@ target/arm/i2s-pp.c | |||
1214 | target/arm/ipod/adc-ipod-pcf.c | 1217 | target/arm/ipod/adc-ipod-pcf.c |
1215 | target/arm/ipod/backlight-nano_video.c | 1218 | target/arm/ipod/backlight-nano_video.c |
1216 | target/arm/ipod/button-clickwheel.c | 1219 | target/arm/ipod/button-clickwheel.c |
1220 | target/arm/ipod/piezo.c | ||
1217 | target/arm/ipod/power-ipod.c | 1221 | target/arm/ipod/power-ipod.c |
1218 | target/arm/ipod/powermgmt-ipod-pcf.c | 1222 | target/arm/ipod/powermgmt-ipod-pcf.c |
1219 | target/arm/ipod/video/lcd-as-video.S | 1223 | target/arm/ipod/video/lcd-as-video.S |
@@ -1268,6 +1272,7 @@ target/arm/i2s-pp.c | |||
1268 | target/arm/ipod/adc-ipod-pcf.c | 1272 | target/arm/ipod/adc-ipod-pcf.c |
1269 | target/arm/ipod/backlight-mini1g_mini2g.c | 1273 | target/arm/ipod/backlight-mini1g_mini2g.c |
1270 | target/arm/ipod/button-mini1g.c | 1274 | target/arm/ipod/button-mini1g.c |
1275 | target/arm/ipod/piezo.c | ||
1271 | target/arm/ipod/lcd-as-gray.S | 1276 | target/arm/ipod/lcd-as-gray.S |
1272 | target/arm/ipod/lcd-gray.c | 1277 | target/arm/ipod/lcd-gray.c |
1273 | target/arm/ipod/power-ipod.c | 1278 | target/arm/ipod/power-ipod.c |
@@ -1286,6 +1291,7 @@ target/arm/i2s-pp.c | |||
1286 | target/arm/ipod/adc-ipod-pcf.c | 1291 | target/arm/ipod/adc-ipod-pcf.c |
1287 | target/arm/ipod/backlight-mini1g_mini2g.c | 1292 | target/arm/ipod/backlight-mini1g_mini2g.c |
1288 | target/arm/ipod/button-clickwheel.c | 1293 | target/arm/ipod/button-clickwheel.c |
1294 | target/arm/ipod/piezo.c | ||
1289 | target/arm/ipod/lcd-as-gray.S | 1295 | target/arm/ipod/lcd-as-gray.S |
1290 | target/arm/ipod/lcd-gray.c | 1296 | target/arm/ipod/lcd-gray.c |
1291 | target/arm/ipod/power-ipod.c | 1297 | target/arm/ipod/power-ipod.c |
@@ -1639,6 +1645,7 @@ target/arm/s5l8700/pcm-s5l8700.c | |||
1639 | target/arm/s5l8700/wmcodec-s5l8700.c | 1645 | target/arm/s5l8700/wmcodec-s5l8700.c |
1640 | target/arm/s5l8700/ipodnano2g/audio-nano2g.c | 1646 | target/arm/s5l8700/ipodnano2g/audio-nano2g.c |
1641 | target/arm/s5l8700/ipodnano2g/adc-nano2g.c | 1647 | target/arm/s5l8700/ipodnano2g/adc-nano2g.c |
1648 | target/arm/s5l8700/ipodnano2g/piezo-nano2g.c | ||
1642 | #endif | 1649 | #endif |
1643 | #endif | 1650 | #endif |
1644 | #endif | 1651 | #endif |
diff --git a/firmware/export/config/ipod4g.h b/firmware/export/config/ipod4g.h index 165f5967b4..957e3a4da5 100644 --- a/firmware/export/config/ipod4g.h +++ b/firmware/export/config/ipod4g.h | |||
@@ -212,6 +212,8 @@ | |||
212 | /* Define this if you can read an absolute wheel position */ | 212 | /* Define this if you can read an absolute wheel position */ |
213 | #define HAVE_WHEEL_POSITION | 213 | #define HAVE_WHEEL_POSITION |
214 | 214 | ||
215 | #define HAVE_HARDWARE_CLICK | ||
216 | |||
215 | #define BOOTFILE_EXT "ipod" | 217 | #define BOOTFILE_EXT "ipod" |
216 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 218 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
217 | #define BOOTDIR "/.rockbox" | 219 | #define BOOTDIR "/.rockbox" |
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h index 645e20041c..cf021019b4 100644 --- a/firmware/export/config/ipodcolor.h +++ b/firmware/export/config/ipodcolor.h | |||
@@ -199,6 +199,8 @@ | |||
199 | /* Define this if you can read an absolute wheel position */ | 199 | /* Define this if you can read an absolute wheel position */ |
200 | #define HAVE_WHEEL_POSITION | 200 | #define HAVE_WHEEL_POSITION |
201 | 201 | ||
202 | #define HAVE_HARDWARE_CLICK | ||
203 | |||
202 | #define BOOTFILE_EXT "ipod" | 204 | #define BOOTFILE_EXT "ipod" |
203 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 205 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
204 | #define BOOTDIR "/.rockbox" | 206 | #define BOOTDIR "/.rockbox" |
diff --git a/firmware/export/config/ipodmini1g.h b/firmware/export/config/ipodmini1g.h index 777dc6f9a2..04fa68e500 100644 --- a/firmware/export/config/ipodmini1g.h +++ b/firmware/export/config/ipodmini1g.h | |||
@@ -202,6 +202,8 @@ | |||
202 | /* Define this if you have adjustable CPU frequency */ | 202 | /* Define this if you have adjustable CPU frequency */ |
203 | #define HAVE_ADJUSTABLE_CPU_FREQ | 203 | #define HAVE_ADJUSTABLE_CPU_FREQ |
204 | 204 | ||
205 | #define HAVE_HARDWARE_CLICK | ||
206 | |||
205 | #define BOOTFILE_EXT "ipod" | 207 | #define BOOTFILE_EXT "ipod" |
206 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 208 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
207 | #define BOOTDIR "/.rockbox" | 209 | #define BOOTDIR "/.rockbox" |
diff --git a/firmware/export/config/ipodmini2g.h b/firmware/export/config/ipodmini2g.h index c401170459..c10284e7a4 100644 --- a/firmware/export/config/ipodmini2g.h +++ b/firmware/export/config/ipodmini2g.h | |||
@@ -205,6 +205,8 @@ | |||
205 | /* Define this if you can read an absolute wheel position */ | 205 | /* Define this if you can read an absolute wheel position */ |
206 | #define HAVE_WHEEL_POSITION | 206 | #define HAVE_WHEEL_POSITION |
207 | 207 | ||
208 | #define HAVE_HARDWARE_CLICK | ||
209 | |||
208 | #define BOOTFILE_EXT "ipod" | 210 | #define BOOTFILE_EXT "ipod" |
209 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 211 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
210 | #define BOOTDIR "/.rockbox" | 212 | #define BOOTDIR "/.rockbox" |
diff --git a/firmware/export/config/ipodnano1g.h b/firmware/export/config/ipodnano1g.h index 388ba34447..50f0511384 100644 --- a/firmware/export/config/ipodnano1g.h +++ b/firmware/export/config/ipodnano1g.h | |||
@@ -199,6 +199,8 @@ | |||
199 | /* Define this if you can read an absolute wheel position */ | 199 | /* Define this if you can read an absolute wheel position */ |
200 | #define HAVE_WHEEL_POSITION | 200 | #define HAVE_WHEEL_POSITION |
201 | 201 | ||
202 | #define HAVE_HARDWARE_CLICK | ||
203 | |||
202 | #define BOOTFILE_EXT "ipod" | 204 | #define BOOTFILE_EXT "ipod" |
203 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 205 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
204 | #define BOOTDIR "/.rockbox" | 206 | #define BOOTDIR "/.rockbox" |
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h index 37a21b33ba..96cec799e4 100644 --- a/firmware/export/config/ipodnano2g.h +++ b/firmware/export/config/ipodnano2g.h | |||
@@ -191,6 +191,8 @@ | |||
191 | /* Define this if you can read an absolute wheel position */ | 191 | /* Define this if you can read an absolute wheel position */ |
192 | #define HAVE_WHEEL_POSITION | 192 | #define HAVE_WHEEL_POSITION |
193 | 193 | ||
194 | #define HAVE_HARDWARE_CLICK | ||
195 | |||
194 | /* Define this if you have adjustable CPU frequency */ | 196 | /* Define this if you have adjustable CPU frequency */ |
195 | #define HAVE_ADJUSTABLE_CPU_FREQ | 197 | #define HAVE_ADJUSTABLE_CPU_FREQ |
196 | 198 | ||
diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h index 1dd7d48e30..c4e2cb2986 100644 --- a/firmware/export/config/ipodvideo.h +++ b/firmware/export/config/ipodvideo.h | |||
@@ -218,6 +218,8 @@ | |||
218 | /* Define this if you can read an absolute wheel position */ | 218 | /* Define this if you can read an absolute wheel position */ |
219 | #define HAVE_WHEEL_POSITION | 219 | #define HAVE_WHEEL_POSITION |
220 | 220 | ||
221 | #define HAVE_HARDWARE_CLICK | ||
222 | |||
221 | /* define this if the device has larger sectors when accessed via USB */ | 223 | /* define this if the device has larger sectors when accessed via USB */ |
222 | /* (only relevant in disk.c, fat.c now always supports large virtual sectors) */ | 224 | /* (only relevant in disk.c, fat.c now always supports large virtual sectors) */ |
223 | #define MAX_LOG_SECTOR_SIZE 2048 | 225 | #define MAX_LOG_SECTOR_SIZE 2048 |
diff --git a/firmware/export/thread.h b/firmware/export/thread.h index d0f61f9d85..da06557f9c 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h | |||
@@ -65,10 +65,18 @@ | |||
65 | #if CONFIG_CODEC == SWCODEC | 65 | #if CONFIG_CODEC == SWCODEC |
66 | 66 | ||
67 | #ifdef HAVE_RECORDING | 67 | #ifdef HAVE_RECORDING |
68 | #ifdef HAVE_HARDWARE_CLICK | ||
69 | #define BASETHREADS 18 | ||
70 | #else | ||
71 | #define BASETHREADS 17 | ||
72 | #endif | ||
73 | #else | ||
74 | #ifdef HAVE_HARDWARE_CLICK | ||
68 | #define BASETHREADS 17 | 75 | #define BASETHREADS 17 |
69 | #else | 76 | #else |
70 | #define BASETHREADS 16 | 77 | #define BASETHREADS 16 |
71 | #endif | 78 | #endif |
79 | #endif | ||
72 | 80 | ||
73 | #else | 81 | #else |
74 | #define BASETHREADS 11 | 82 | #define BASETHREADS 11 |
diff --git a/firmware/target/arm/ipod/piezo.c b/firmware/target/arm/ipod/piezo.c new file mode 100644 index 0000000000..2c3968e79a --- /dev/null +++ b/firmware/target/arm/ipod/piezo.c | |||
@@ -0,0 +1,209 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006-2007 Robert Keevil | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "thread.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "usb.h" | ||
24 | #include "logf.h" | ||
25 | #include "piezo.h" | ||
26 | |||
27 | static long piezo_stack[DEFAULT_STACK_SIZE/sizeof(long)]; | ||
28 | static const char piezo_thread_name[] = "piezo"; | ||
29 | static struct event_queue piezo_queue; | ||
30 | static unsigned int duration; | ||
31 | static bool beeping; | ||
32 | |||
33 | enum { | ||
34 | Q_PIEZO_BEEP = 1, | ||
35 | Q_PIEZO_BEEP_FOR_TICK, | ||
36 | Q_PIEZO_BEEP_FOR_USEC, | ||
37 | Q_PIEZO_STOP | ||
38 | }; | ||
39 | |||
40 | static inline void piezo_hw_init(void) | ||
41 | { | ||
42 | #ifndef SIMULATOR | ||
43 | /*logf("PIEZO: hw_init");*/ | ||
44 | outl(inl(0x70000010) & ~0xc, 0x70000010); | ||
45 | outl(inl(0x6000600c) | 0x20000, 0x6000600c); /* enable device */ | ||
46 | #endif | ||
47 | } | ||
48 | |||
49 | static void piezo_hw_tick(unsigned int form_and_period) | ||
50 | { | ||
51 | #ifndef SIMULATOR | ||
52 | outl(0x80000000 | form_and_period, 0x7000a000); /* set pitch */ | ||
53 | #endif | ||
54 | } | ||
55 | |||
56 | static inline void piezo_hw_stop(void) | ||
57 | { | ||
58 | #ifndef SIMULATOR | ||
59 | outl(0x0, 0x7000a000); /* piezo off */ | ||
60 | #endif | ||
61 | } | ||
62 | |||
63 | static void piezo_thread(void) | ||
64 | { | ||
65 | struct queue_event ev; | ||
66 | long piezo_usec_off; | ||
67 | |||
68 | while(1) | ||
69 | { | ||
70 | queue_wait(&piezo_queue, &ev); | ||
71 | switch(ev.id) | ||
72 | { | ||
73 | case Q_PIEZO_BEEP: | ||
74 | piezo_hw_tick((unsigned int)ev.data); | ||
75 | beeping = true; | ||
76 | break; | ||
77 | case Q_PIEZO_BEEP_FOR_TICK: | ||
78 | piezo_hw_tick((unsigned int)ev.data); | ||
79 | beeping = true; | ||
80 | sleep(duration); | ||
81 | if (beeping) | ||
82 | piezo_hw_stop(); | ||
83 | beeping = false; | ||
84 | /* remove anything that appeared while sleeping */ | ||
85 | queue_clear(&piezo_queue); | ||
86 | break; | ||
87 | case Q_PIEZO_BEEP_FOR_USEC: | ||
88 | piezo_usec_off = USEC_TIMER + duration; | ||
89 | piezo_hw_tick((unsigned int)ev.data); | ||
90 | beeping = true; | ||
91 | while (TIME_BEFORE(USEC_TIMER, piezo_usec_off)) | ||
92 | if (duration >= 5000) yield(); | ||
93 | if (beeping) | ||
94 | piezo_hw_stop(); | ||
95 | beeping = false; | ||
96 | /* remove anything that appeared while sleeping */ | ||
97 | queue_clear(&piezo_queue); | ||
98 | break; | ||
99 | case Q_PIEZO_STOP: | ||
100 | if (beeping) | ||
101 | piezo_hw_stop(); | ||
102 | beeping = false; | ||
103 | break; | ||
104 | #ifndef SIMULATOR | ||
105 | case SYS_USB_CONNECTED: | ||
106 | /*logf("USB: Piezo core");*/ | ||
107 | piezo_hw_stop(); | ||
108 | queue_clear(&piezo_queue); | ||
109 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
110 | usb_wait_for_disconnect(&piezo_queue); | ||
111 | break ; | ||
112 | #endif | ||
113 | case SYS_TIMEOUT: | ||
114 | break; | ||
115 | } | ||
116 | yield(); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | |||
121 | void piezo_play(unsigned short inv_freq, unsigned char form) | ||
122 | { | ||
123 | queue_post(&piezo_queue, Q_PIEZO_BEEP, | ||
124 | (intptr_t)((unsigned int)form << 16 | inv_freq)); | ||
125 | } | ||
126 | |||
127 | void piezo_play_for_tick(unsigned short inv_freq, | ||
128 | unsigned char form, unsigned int dur) | ||
129 | { | ||
130 | duration = dur; | ||
131 | queue_post(&piezo_queue, Q_PIEZO_BEEP_FOR_TICK, | ||
132 | (intptr_t)((unsigned int)form << 16 | inv_freq)); | ||
133 | } | ||
134 | |||
135 | void piezo_play_for_usec(unsigned short inv_freq, | ||
136 | unsigned char form, unsigned int dur) | ||
137 | { | ||
138 | duration = dur; | ||
139 | queue_post(&piezo_queue, Q_PIEZO_BEEP_FOR_USEC, | ||
140 | (intptr_t)((unsigned int)form << 16 | inv_freq)); | ||
141 | } | ||
142 | |||
143 | void piezo_stop(void) | ||
144 | { | ||
145 | queue_post(&piezo_queue, Q_PIEZO_STOP, 0); | ||
146 | } | ||
147 | |||
148 | void piezo_clear(void) | ||
149 | { | ||
150 | queue_clear(&piezo_queue); | ||
151 | piezo_stop(); | ||
152 | } | ||
153 | |||
154 | bool piezo_busy(void) | ||
155 | { | ||
156 | return !queue_empty(&piezo_queue); | ||
157 | } | ||
158 | |||
159 | /* conversion factor based on the following data | ||
160 | |||
161 | period Hz | ||
162 | 10 8547 | ||
163 | 20 4465 | ||
164 | 30 3024 | ||
165 | 40 2286 | ||
166 | 50 1846 | ||
167 | 60 1537 | ||
168 | 70 1320 | ||
169 | 80 1165 | ||
170 | 90 1030 | ||
171 | 100 928 | ||
172 | |||
173 | someone with better recording/analysing equipment should be able | ||
174 | to get more accurate figures | ||
175 | */ | ||
176 | unsigned int piezo_hz(unsigned int hz) | ||
177 | { | ||
178 | if (hz > 0) | ||
179 | return 91225/hz; | ||
180 | else | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | void piezo_init(void) | ||
185 | { | ||
186 | /*logf("PIEZO: init");*/ | ||
187 | piezo_hw_init(); | ||
188 | queue_init(&piezo_queue, true); | ||
189 | create_thread(piezo_thread, piezo_stack, sizeof(piezo_stack), 0, | ||
190 | piezo_thread_name IF_PRIO(, PRIORITY_REALTIME) | ||
191 | IF_COP(, CPU)); | ||
192 | } | ||
193 | |||
194 | void piezo_button_beep(bool beep, bool force) | ||
195 | { | ||
196 | /* old on clickwheel action - piezo_play_for_usec(50, 0x80, 400); | ||
197 | old on button action - piezo_play_for_usec(50, 0x80, 3000); */ | ||
198 | |||
199 | if (force) | ||
200 | piezo_clear(); | ||
201 | |||
202 | if (queue_empty(&piezo_queue)) | ||
203 | { | ||
204 | if (beep) | ||
205 | piezo_play_for_tick(40, 0x80, HZ/5); | ||
206 | else | ||
207 | piezo_play_for_usec(91, 0x80, 4000); | ||
208 | } | ||
209 | } | ||
diff --git a/firmware/target/arm/ipod/piezo.h b/firmware/target/arm/ipod/piezo.h new file mode 100644 index 0000000000..78b50d0d39 --- /dev/null +++ b/firmware/target/arm/ipod/piezo.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006-2007 Robert Keevil | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | void piezo_init(void); | ||
21 | void piezo_play(unsigned short inv_freq, unsigned char form); | ||
22 | void piezo_play_for_tick(unsigned short inv_freq, | ||
23 | unsigned char form, unsigned int dur); | ||
24 | void piezo_play_for_usec(unsigned short inv_freq, | ||
25 | unsigned char form, unsigned int dur); | ||
26 | void piezo_stop(void); | ||
27 | void piezo_clear(void); | ||
28 | bool piezo_busy(void); | ||
29 | unsigned int piezo_hz(unsigned int hz); | ||
30 | void piezo_button_beep(bool beep, bool force); | ||
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c new file mode 100644 index 0000000000..d555b7232f --- /dev/null +++ b/firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c | |||
@@ -0,0 +1,95 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006-2007 Robert Keevil | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "system.h" | ||
21 | #include "kernel.h" | ||
22 | #include "piezo.h" | ||
23 | |||
24 | static unsigned int duration; | ||
25 | static bool beeping; | ||
26 | |||
27 | void INT_TIMERD(void) | ||
28 | { | ||
29 | /* clear interrupt */ | ||
30 | TDCON = TDCON; | ||
31 | if (!(--duration)) | ||
32 | { | ||
33 | beeping = 0; | ||
34 | TDCMD = (1 << 1); /* TD_CLR */ | ||
35 | } | ||
36 | } | ||
37 | |||
38 | void piezo_start(unsigned short cycles, unsigned short periods) | ||
39 | { | ||
40 | #ifndef SIMULATOR | ||
41 | duration = periods; | ||
42 | beeping = 1; | ||
43 | /* configure timer for 100 kHz */ | ||
44 | TDCMD = (1 << 1); /* TD_CLR */ | ||
45 | TDPRE = 30 - 1; /* prescaler */ | ||
46 | TDCON = (1 << 13) | /* TD_INT1_EN */ | ||
47 | (0 << 12) | /* TD_INT0_EN */ | ||
48 | (0 << 11) | /* TD_START */ | ||
49 | (2 << 8) | /* TD_CS = PCLK / 16 */ | ||
50 | (1 << 4); /* TD_MODE_SEL = PWM mode */ | ||
51 | TDDATA0 = cycles; /* set interval period */ | ||
52 | TDDATA1 = cycles << 1; /* set interval period */ | ||
53 | TDCMD = (1 << 0); /* TD_EN */ | ||
54 | |||
55 | /* enable timer interrupt */ | ||
56 | INTMSK |= INTMSK_TIMERD; | ||
57 | #endif | ||
58 | } | ||
59 | |||
60 | void piezo_stop(void) | ||
61 | { | ||
62 | #ifndef SIMULATOR | ||
63 | TDCMD = (1 << 1); /* TD_CLR */ | ||
64 | #endif | ||
65 | } | ||
66 | |||
67 | void piezo_clear(void) | ||
68 | { | ||
69 | piezo_stop(); | ||
70 | } | ||
71 | |||
72 | bool piezo_busy(void) | ||
73 | { | ||
74 | return beeping; | ||
75 | } | ||
76 | |||
77 | void piezo_init(void) | ||
78 | { | ||
79 | beeping = 0; | ||
80 | } | ||
81 | |||
82 | void piezo_button_beep(bool beep, bool force) | ||
83 | { | ||
84 | if (force) | ||
85 | while (beeping) | ||
86 | yield(); | ||
87 | |||
88 | if (!beeping) | ||
89 | { | ||
90 | if (beep) | ||
91 | piezo_start(22, 457); | ||
92 | else | ||
93 | piezo_start(40, 4); | ||
94 | } | ||
95 | } | ||
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/piezo.h b/firmware/target/arm/s5l8700/ipodnano2g/piezo.h new file mode 100644 index 0000000000..b8eae0943d --- /dev/null +++ b/firmware/target/arm/s5l8700/ipodnano2g/piezo.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006-2007 Robert Keevil | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | void piezo_init(void); | ||
21 | void piezo_stop(void); | ||
22 | void piezo_clear(void); | ||
23 | bool piezo_busy(void); | ||
24 | void piezo_button_beep(bool beep, bool force); | ||