FreeCalypso > hg > fc-tourmaline
comparison src/cs/drivers/drv_app/buzzer/vibrator.c @ 289:4d203ef0eb4b
implement vibrator on/off control driver
The piece implemented here is just the HW on/off driver; on top of
this driver there will be a VIBR service (to be implemented in RiViera
land) that will implement vibration pulse trains.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 26 Mar 2022 17:03:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
288:25d3ee009d19 | 289:4d203ef0eb4b |
---|---|
1 /* | |
2 * This C module is a FreeCalypso addition: it implements hardware vibrator | |
3 * control as appropriate for different hw targets. | |
4 */ | |
5 | |
6 #include "main/sys_types.h" | |
7 #include "memif/mem.h" | |
8 #include "armio/armio.h" | |
9 #include "buzzer.h" | |
10 #include "vibrator.h" | |
11 #include "abb/abb.h" | |
12 | |
13 #include "board.cfg" | |
14 #include "fc-target.h" | |
15 | |
16 /* flag tells L1 to suppress deep sleep */ | |
17 SYS_BOOL HW_vibrator_is_on; | |
18 | |
19 void HW_vibrator_on(SYS_UWORD8 level) | |
20 { | |
21 HW_vibrator_is_on = 1; | |
22 #ifdef CONFIG_TARGET_PIRELLI | |
23 /* vibrator is controlled via BU output */ | |
24 BZ_Tone(0); | |
25 BZ_Volume(level >> 2); | |
26 BZ_Enable(); | |
27 #elif defined(CONFIG_TARGET_COMPAL) | |
28 /* vibrator is controlled via Iota AUX DAC */ | |
29 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x20); | |
30 ABB_Write_Register_on_page(PAGE0, AUXDAC, (level << 2) | 3); | |
31 #endif | |
32 } | |
33 | |
34 void HW_vibrator_off(void) | |
35 { | |
36 #ifdef CONFIG_TARGET_PIRELLI | |
37 BZ_Disable(); | |
38 #elif defined(CONFIG_TARGET_COMPAL) | |
39 ABB_Write_Register_on_page(PAGE0, AUXDAC, 0); | |
40 ABB_Write_Register_on_page(PAGE0, TOGBR1, 0x10); | |
41 #endif | |
42 HW_vibrator_is_on = 0; | |
43 } |