FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/buzzer/pwt.c @ 290:0e5ccb343284
implement PWT buzzer driver
The piece implemented here is the low-level driver component; there will
also be a higher-level buzzer melody player service, to be implemented
in RiViera land, that will be the sole caller of PWT API functions
provided by the present driver.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 26 Mar 2022 18:23:50 +0000 |
parents | |
children | a72feaed133a |
comparison
equal
deleted
inserted
replaced
289:4d203ef0eb4b | 290:0e5ccb343284 |
---|---|
1 /* | |
2 * This C module is a FreeCalypso addition: it implements hw driver functions | |
3 * for Calypso buzzer output in PWT mode. | |
4 */ | |
5 | |
6 #include "main/sys_types.h" | |
7 #include "pwt.h" | |
8 | |
9 #define ASIC_CONF_REG (*(volatile SYS_UWORD16 *) 0xFFFEF008) | |
10 #define PWT_MODE_MASK 0x0020 | |
11 | |
12 #define PWT_FRC_REG (*(volatile SYS_UWORD8 *) 0xFFFE8800) | |
13 #define PWT_VCR_REG (*(volatile SYS_UWORD8 *) 0xFFFE8801) | |
14 #define PWT_GCR_REG (*(volatile SYS_UWORD8 *) 0xFFFE8802) | |
15 | |
16 /* flag tells L1 to suppress deep sleep */ | |
17 SYS_BOOL PWT_tone_is_on; | |
18 | |
19 void PWT_block_on(void) | |
20 { | |
21 ASIC_CONF_REG |= PWT_MODE_MASK; | |
22 PWT_GCR_REG = 0x01; | |
23 } | |
24 | |
25 void PWT_block_off(void) | |
26 { | |
27 ASIC_CONF_REG &= ~PWT_MODE_MASK; | |
28 PWT_GCR_REG = 0; | |
29 } | |
30 | |
31 void PWT_play_tone(SYS_UWORD8 note, SYS_UWORD8 volume) | |
32 { | |
33 PWT_FRC_REG = note; | |
34 PWT_VCR_REG = (volume << 1) | 1; | |
35 PWT_tone_is_on = 1; | |
36 } | |
37 | |
38 void PWT_stop_tone(void) | |
39 { | |
40 PWT_VCR_REG = 0; | |
41 PWT_tone_is_on = 0; | |
42 } |