comparison src/cs/drivers/drv_app/buzzer/pwt.c @ 291:a72feaed133a

PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER Here we add a new target config preprocessor symbol TARGET_HAS_BUZZER, currently defined for c11x and c139; later we also expect to have it on for FC Venus, and in FC Magnetite we are going to turn it on for target dsample, just for the sake of completeness and philosophical correctness.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Mar 2022 19:31:18 +0000
parents 0e5ccb343284
children
comparison
equal deleted inserted replaced
290:0e5ccb343284 291:a72feaed133a
3 * for Calypso buzzer output in PWT mode. 3 * for Calypso buzzer output in PWT mode.
4 */ 4 */
5 5
6 #include "main/sys_types.h" 6 #include "main/sys_types.h"
7 #include "pwt.h" 7 #include "pwt.h"
8 #include "fc-target.h"
8 9
9 #define ASIC_CONF_REG (*(volatile SYS_UWORD16 *) 0xFFFEF008) 10 #define ASIC_CONF_REG (*(volatile SYS_UWORD16 *) 0xFFFEF008)
10 #define PWT_MODE_MASK 0x0020 11 #define PWT_MODE_MASK 0x0020
11 12
12 #define PWT_FRC_REG (*(volatile SYS_UWORD8 *) 0xFFFE8800) 13 #define PWT_FRC_REG (*(volatile SYS_UWORD8 *) 0xFFFE8800)
16 /* flag tells L1 to suppress deep sleep */ 17 /* flag tells L1 to suppress deep sleep */
17 SYS_BOOL PWT_tone_is_on; 18 SYS_BOOL PWT_tone_is_on;
18 19
19 void PWT_block_on(void) 20 void PWT_block_on(void)
20 { 21 {
22 #ifdef TARGET_HAS_BUZZER
21 ASIC_CONF_REG |= PWT_MODE_MASK; 23 ASIC_CONF_REG |= PWT_MODE_MASK;
22 PWT_GCR_REG = 0x01; 24 PWT_GCR_REG = 0x01;
25 #endif
23 } 26 }
24 27
25 void PWT_block_off(void) 28 void PWT_block_off(void)
26 { 29 {
30 #ifdef TARGET_HAS_BUZZER
27 ASIC_CONF_REG &= ~PWT_MODE_MASK; 31 ASIC_CONF_REG &= ~PWT_MODE_MASK;
28 PWT_GCR_REG = 0; 32 PWT_GCR_REG = 0;
33 #endif
29 } 34 }
30 35
31 void PWT_play_tone(SYS_UWORD8 note, SYS_UWORD8 volume) 36 void PWT_play_tone(SYS_UWORD8 note, SYS_UWORD8 volume)
32 { 37 {
38 #ifdef TARGET_HAS_BUZZER
33 PWT_FRC_REG = note; 39 PWT_FRC_REG = note;
34 PWT_VCR_REG = (volume << 1) | 1; 40 PWT_VCR_REG = (volume << 1) | 1;
35 PWT_tone_is_on = 1; 41 PWT_tone_is_on = 1;
42 #endif
36 } 43 }
37 44
38 void PWT_stop_tone(void) 45 void PWT_stop_tone(void)
39 { 46 {
47 #ifdef TARGET_HAS_BUZZER
40 PWT_VCR_REG = 0; 48 PWT_VCR_REG = 0;
41 PWT_tone_is_on = 0; 49 PWT_tone_is_on = 0;
50 #endif
42 } 51 }