FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/buzzer/buzzer.c @ 269:4f839e1991e8
.../drv_app/buzzer/buzzer.[ch]: rm trailing white space
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 13 Jun 2021 18:28:01 +0000 |
parents | 4e78acac3d88 |
children | 4f59ca578891 |
comparison
equal
deleted
inserted
replaced
268:f2e52cab0a73 | 269:4f839e1991e8 |
---|---|
16 #include "buzzer.h" | 16 #include "buzzer.h" |
17 #include "timer/timer.h" | 17 #include "timer/timer.h" |
18 | 18 |
19 #include "board.cfg" | 19 #include "board.cfg" |
20 | 20 |
21 /* | 21 /* |
22 * Initialize buzzer | 22 * Initialize buzzer |
23 * | 23 * |
24 */ | 24 */ |
25 void BZ_Init(void) | 25 void BZ_Init(void) |
26 { | 26 { |
27 } | 27 } |
28 | 28 |
29 /* | 29 /* |
30 * BZ_Enable / BZ_Disable | 30 * BZ_Enable / BZ_Disable |
31 * | 31 * |
32 * Enable / disable buzzer | 32 * Enable / disable buzzer |
33 * | 33 * |
34 * The buzzer uses timer 1 | 34 * The buzzer uses timer 1 |
35 */ | 35 */ |
36 void BZ_Enable(void) | 36 void BZ_Enable(void) |
37 { | 37 { |
38 *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= BZ_ON; | 38 *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= BZ_ON; |
39 } | 39 } |
40 | 40 |
41 void BZ_Disable(void) | 41 void BZ_Disable(void) |
42 { | 42 { |
43 *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) &= ~BZ_ON; | 43 *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) &= ~BZ_ON; |
44 } | 44 } |
45 | 45 |
46 /* | 46 /* |
47 * BZ_Tone | 47 * BZ_Tone |
48 * | 48 * |
49 * Changes the timer count to set the tone frequency in Hz | 49 * Changes the timer count to set the tone frequency in Hz |
50 * | 50 * |
51 * 58 ticks= 1 ms, which give a frequency of 500 Hz | 51 * 58 ticks= 1 ms, which give a frequency of 500 Hz |
52 * | 52 * |
53 * | 53 * |
54 */ | 54 */ |
55 void BZ_Tone(int f) | 55 void BZ_Tone(int f) |
61 *((volatile SYS_UWORD16 *) ARMIO_LOAD_TIM) = f; | 61 *((volatile SYS_UWORD16 *) ARMIO_LOAD_TIM) = f; |
62 } | 62 } |
63 | 63 |
64 /* | 64 /* |
65 * BZ_Volume | 65 * BZ_Volume |
66 * | 66 * |
67 * Changes the buzzer volume | 67 * Changes the buzzer volume |
68 * | 68 * |
69 */ | 69 */ |
70 void BZ_Volume(int v) | 70 void BZ_Volume(int v) |
71 { | 71 { |
72 // the level range is 0 up to 63 | 72 // the level range is 0 up to 63 |
73 if (v > 63) | 73 if (v > 63) |
77 *((volatile SYS_UWORD16 *) BZ_LEVEL) = v; | 77 *((volatile SYS_UWORD16 *) BZ_LEVEL) = v; |
78 } | 78 } |
79 | 79 |
80 /* | 80 /* |
81 * BZ_KeyBeep_ON | 81 * BZ_KeyBeep_ON |
82 * | 82 * |
83 * Audio feedback to user after keybeep | 83 * Audio feedback to user after keybeep |
84 * | 84 * |
85 */ | 85 */ |
86 void BZ_KeyBeep_ON(void) | 86 void BZ_KeyBeep_ON(void) |
87 { | 87 { |
89 | 89 |
90 BZ_Init (); | 90 BZ_Init (); |
91 BZ_Volume (255); | 91 BZ_Volume (255); |
92 BZ_Enable (); | 92 BZ_Enable (); |
93 BZ_Tone (50); | 93 BZ_Tone (50); |
94 | 94 |
95 for (i = 0; i < 17000; i++) | 95 for (i = 0; i < 17000; i++) |
96 ; | 96 ; |
97 | 97 |
98 BZ_Disable (); | 98 BZ_Disable (); |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 | 102 |
103 /* | 103 /* |
104 * BZ_KeyBeep_OFF | 104 * BZ_KeyBeep_OFF |
105 * | 105 * |
106 * Audio feedback to user after keybeep | 106 * Audio feedback to user after keybeep |
107 * | 107 * |
108 */ | 108 */ |
109 void BZ_KeyBeep_OFF(void) | 109 void BZ_KeyBeep_OFF(void) |
110 { | 110 { |
112 | 112 |
113 BZ_Init (); | 113 BZ_Init (); |
114 BZ_Volume (255); | 114 BZ_Volume (255); |
115 BZ_Enable (); | 115 BZ_Enable (); |
116 BZ_Tone (100); | 116 BZ_Tone (100); |
117 | 117 |
118 for (i = 0; i < 17000; i++) | 118 for (i = 0; i < 17000; i++) |
119 ; | 119 ; |
120 | 120 |
121 BZ_Disable (); | 121 BZ_Disable (); |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 | 125 |
126 /* | 126 /* |
127 * LT_Enable / LT_Disable | 127 * LT_Enable / LT_Disable |
128 * | 128 * |
129 * Enable / disable LCD lighting | 129 * Enable / disable LCD lighting |
130 * | 130 * |
131 */ | 131 */ |
132 void LT_Enable(void) | 132 void LT_Enable(void) |
133 { | 133 { |
134 #if (BOARD == 7 || BOARD == 8 || BOARD == 9) | 134 #if (BOARD == 7 || BOARD == 8 || BOARD == 9) |
135 *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= LT_ON; | 135 *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= LT_ON; |
143 } | 143 } |
144 | 144 |
145 | 145 |
146 /* | 146 /* |
147 * LT_Level | 147 * LT_Level |
148 * | 148 * |
149 * Set LCD display level | 149 * Set LCD display level |
150 */ | 150 */ |
151 void LT_Level(SYS_WORD8 level) | 151 void LT_Level(SYS_WORD8 level) |
152 { | 152 { |
153 if (level > 63) level=63; | 153 if (level > 63) level=63; |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 /* | 160 /* |
161 * LT_Status | 161 * LT_Status |
162 * | 162 * |
163 * Return lighting status for sleep manager | 163 * Return lighting status for sleep manager |
164 * | 164 * |
165 */ | 165 */ |
166 SYS_BOOL LT_Status(void) | 166 SYS_BOOL LT_Status(void) |
167 { | 167 { |
168 #if (BOARD == 7 || BOARD == 8 || BOARD == 9) | 168 #if (BOARD == 7 || BOARD == 8 || BOARD == 9) |
169 if (*((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) & LT_ON) | 169 if (*((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) & LT_ON) |
170 return(1); // the light is on | 170 return(1); // the light is on |
171 else | 171 else |
172 return(0); | 172 return(0); |
173 #endif | 173 #endif |
174 | 174 |
175 return(0); | 175 return(0); |
176 | 176 |
177 } | 177 } |