diff options
author | Cástor Muñoz <cmvidal@gmail.com> | 2017-03-03 22:46:57 +0100 |
---|---|---|
committer | Cástor Muñoz <cmvidal@gmail.com> | 2017-03-03 22:50:38 +0100 |
commit | 1ba5ef716d37a9fe7f0863caed2fab8570b2c7c4 (patch) | |
tree | 2e209052bc802183b73a705f77ebc552250c9353 /firmware/target/arm/s5l8702/ipod6g/piezo-6g.c | |
parent | 8ff1b6b6033aad55fadf076f066da5d8b7d2e631 (diff) | |
download | rockbox-1ba5ef716d37a9fe7f0863caed2fab8570b2c7c4.tar.gz rockbox-1ba5ef716d37a9fe7f0863caed2fab8570b2c7c4.zip |
ipod6g: rename some target files
As preparation to add new targets to the s5l8702 directory,
rename files as:
s5l8702/ipod6g/*-ipod6g.c -> s5l8702/ipod6g/*-6g.c
Change-Id: I0cd03d6bcf39b2aa198235f9014cb6948bbafcd5
Diffstat (limited to 'firmware/target/arm/s5l8702/ipod6g/piezo-6g.c')
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/piezo-6g.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8702/ipod6g/piezo-6g.c b/firmware/target/arm/s5l8702/ipod6g/piezo-6g.c new file mode 100644 index 0000000000..06735673be --- /dev/null +++ b/firmware/target/arm/s5l8702/ipod6g/piezo-6g.c | |||
@@ -0,0 +1,125 @@ | |||
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 | piezo_stop(); | ||
35 | } | ||
36 | |||
37 | static void piezo_start(unsigned short cycles, unsigned short periods) | ||
38 | { | ||
39 | #ifndef SIMULATOR | ||
40 | duration = periods; | ||
41 | beeping = 1; | ||
42 | /* select TA_OUT function on GPIO ports */ | ||
43 | PCON0 = (PCON0 & 0x00ffffff) | 0x53000000; | ||
44 | /* configure timer for 100 kHz (12 MHz / 4 / 30) */ | ||
45 | TACMD = (1 << 1); /* TA_CLR */ | ||
46 | TAPRE = 30 - 1; /* prescaler */ | ||
47 | TACON = (1 << 13) | /* TA_INT1_EN */ | ||
48 | (0 << 12) | /* TA_INT0_EN */ | ||
49 | (0 << 11) | /* TA_START */ | ||
50 | (1 << 8) | /* TA_CS = ECLK / 4 */ | ||
51 | (1 << 6) | /* select ECLK (12 MHz) */ | ||
52 | (1 << 4); /* TA_MODE_SEL = PWM mode */ | ||
53 | TADATA0 = cycles; /* set interval period */ | ||
54 | TADATA1 = cycles << 1; /* set interval period */ | ||
55 | TACMD = (1 << 0); /* TA_EN */ | ||
56 | #endif | ||
57 | } | ||
58 | |||
59 | void piezo_stop(void) | ||
60 | { | ||
61 | #ifndef SIMULATOR | ||
62 | beeping = 0; | ||
63 | TACMD = (1 << 1); /* TA_CLR */ | ||
64 | /* configure GPIO for the lowest power consumption */ | ||
65 | PCON0 = (PCON0 & 0x00ffffff) | 0xee000000; | ||
66 | #endif | ||
67 | } | ||
68 | |||
69 | void piezo_clear(void) | ||
70 | { | ||
71 | piezo_stop(); | ||
72 | } | ||
73 | |||
74 | bool piezo_busy(void) | ||
75 | { | ||
76 | return beeping; | ||
77 | } | ||
78 | |||
79 | void piezo_init(void) | ||
80 | { | ||
81 | piezo_stop(); | ||
82 | } | ||
83 | |||
84 | void piezo_button_beep(bool beep, bool force) | ||
85 | { | ||
86 | if (force) | ||
87 | while (beeping) | ||
88 | yield(); | ||
89 | |||
90 | if (!beeping) | ||
91 | { | ||
92 | if (beep) | ||
93 | piezo_start(22, 457); | ||
94 | else | ||
95 | piezo_start(40, 4); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | #ifdef BOOTLOADER | ||
100 | void piezo_tone(uint32_t period /*uS*/, int32_t duration /*ms*/) | ||
101 | { | ||
102 | int32_t stop = USEC_TIMER + duration*1000; | ||
103 | uint32_t level = 0; | ||
104 | |||
105 | while ((int32_t)USEC_TIMER - stop < 0) | ||
106 | { | ||
107 | level ^= 1; | ||
108 | GPIOCMD = 0x0060e | level; | ||
109 | udelay(period >> 1); | ||
110 | } | ||
111 | |||
112 | GPIOCMD = 0x0060e; | ||
113 | } | ||
114 | |||
115 | void piezo_seq(uint16_t *seq) | ||
116 | { | ||
117 | uint16_t period; | ||
118 | |||
119 | while ((period = *seq++) != 0) | ||
120 | { | ||
121 | piezo_tone(period, *seq++); | ||
122 | udelay(*seq++ * 1000); | ||
123 | } | ||
124 | } | ||
125 | #endif | ||