diff options
author | Cástor Muñoz <cmvidal@gmail.com> | 2012-02-11 23:41:54 +0100 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-02-11 23:46:35 +0100 |
commit | e29619b4d23ae100379f64d83e3e2858a042bbf8 (patch) | |
tree | 639219a8ddf8be07c5864ca298a786aaa48244df /firmware/target/arm/s5l8702 | |
parent | 6162d813e7bf29d53d040547dc6fd826ca0270df (diff) | |
download | rockbox-e29619b4d23ae100379f64d83e3e2858a042bbf8.tar.gz rockbox-e29619b4d23ae100379f64d83e3e2858a042bbf8.zip |
FS#12524 - iPod Classic/6G: hardware click support
Based on the piezo driver for the nano2g.
Signed-off-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'firmware/target/arm/s5l8702')
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/piezo-ipod6g.c | 95 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/piezo.h | 26 |
2 files changed, 121 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8702/ipod6g/piezo-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/piezo-ipod6g.c new file mode 100644 index 0000000000..6a50ffc43c --- /dev/null +++ b/firmware/target/arm/s5l8702/ipod6g/piezo-ipod6g.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 | * 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 "system.h" | ||
23 | #include "kernel.h" | ||
24 | #include "piezo.h" | ||
25 | |||
26 | static unsigned int duration; | ||
27 | static bool beeping; | ||
28 | |||
29 | void INT_TIMERA(void) | ||
30 | { | ||
31 | /* clear interrupt */ | ||
32 | TACON = TACON; | ||
33 | if (!(--duration)) | ||
34 | { | ||
35 | beeping = 0; | ||
36 | TACMD = (1 << 1); /* TA_CLR */ | ||
37 | } | ||
38 | } | ||
39 | |||
40 | static void piezo_start(unsigned short cycles, unsigned short periods) | ||
41 | { | ||
42 | #ifndef SIMULATOR | ||
43 | duration = periods; | ||
44 | beeping = 1; | ||
45 | /* configure timer for 100 kHz */ | ||
46 | TACMD = (1 << 1); /* TA_CLR */ | ||
47 | TAPRE = 30 - 1; /* prescaler */ /* 12 MHz / 4 / 30 = 100 kHz */ | ||
48 | TACON = (1 << 13) | /* TA_INT1_EN */ | ||
49 | (0 << 12) | /* TA_INT0_EN */ | ||
50 | (0 << 11) | /* TA_START */ | ||
51 | (1 << 8) | /* TA_CS = PCLK / 4 */ | ||
52 | (1 << 6) | /* UNKNOWN bit */ /* external 12 MHz clock ??? */ | ||
53 | (1 << 4); /* TA_MODE_SEL = PWM mode */ | ||
54 | TADATA0 = cycles; /* set interval period */ | ||
55 | TADATA1 = cycles << 1; /* set interval period */ | ||
56 | TACMD = (1 << 0); /* TA_EN */ | ||
57 | #endif | ||
58 | } | ||
59 | |||
60 | void piezo_stop(void) | ||
61 | { | ||
62 | #ifndef SIMULATOR | ||
63 | TACMD = (1 << 1); /* TA_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/s5l8702/ipod6g/piezo.h b/firmware/target/arm/s5l8702/ipod6g/piezo.h new file mode 100644 index 0000000000..987d4ffdda --- /dev/null +++ b/firmware/target/arm/s5l8702/ipod6g/piezo.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006-2007 Robert Keevil | ||
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 | void piezo_init(void); | ||
23 | void piezo_stop(void); | ||
24 | void piezo_clear(void); | ||
25 | bool piezo_busy(void); | ||
26 | void piezo_button_beep(bool beep, bool force); | ||