FreeCalypso > hg > fc-tourmaline
annotate src/cs/drivers/drv_app/buzzer/pwt.c @ 303:f76436d19a7a default tip
!GPRS config: fix long-standing AT+COPS chance hanging bug
There has been a long-standing bug in FreeCalypso going back years:
sometimes in the AT command bring-up sequence of an ACI-only MS,
the AT+COPS command would produce only a power scan followed by
cessation of protocol stack activity (only L1 ADC traces), instead
of the expected network search sequence. This behaviour was seen
in different FC firmware versions going back to Citrine, and seemed
to follow some law of chance, not reliably repeatable.
This bug has been tracked down and found to be specific to !GPRS
configuration, stemming from our TCS2/TCS3 hybrid and reconstruction
of !GPRS support that was bitrotten in TCS3.2/LoCosto version.
ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3
version and had to be pulled from TCS2 - but as it turns out,
there is a new field in the MMR_REG_REQ primitive that needs to be
set correctly, and that psa_mms.c module is the place where this
initialization needed to be added.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Jun 2023 08:23:37 +0000 |
parents | a72feaed133a |
children |
rev | line source |
---|---|
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C module is a FreeCalypso addition: it implements hw driver functions |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * for Calypso buzzer output in PWT mode. |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "main/sys_types.h" |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "pwt.h" |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
8 #include "fc-target.h" |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #define ASIC_CONF_REG (*(volatile SYS_UWORD16 *) 0xFFFEF008) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #define PWT_MODE_MASK 0x0020 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #define PWT_FRC_REG (*(volatile SYS_UWORD8 *) 0xFFFE8800) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #define PWT_VCR_REG (*(volatile SYS_UWORD8 *) 0xFFFE8801) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #define PWT_GCR_REG (*(volatile SYS_UWORD8 *) 0xFFFE8802) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 /* flag tells L1 to suppress deep sleep */ |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 SYS_BOOL PWT_tone_is_on; |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 void PWT_block_on(void) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
22 #ifdef TARGET_HAS_BUZZER |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 ASIC_CONF_REG |= PWT_MODE_MASK; |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 PWT_GCR_REG = 0x01; |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
25 #endif |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 void PWT_block_off(void) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
30 #ifdef TARGET_HAS_BUZZER |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 ASIC_CONF_REG &= ~PWT_MODE_MASK; |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 PWT_GCR_REG = 0; |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
33 #endif |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 void PWT_play_tone(SYS_UWORD8 note, SYS_UWORD8 volume) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 { |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
38 #ifdef TARGET_HAS_BUZZER |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 PWT_FRC_REG = note; |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 PWT_VCR_REG = (volume << 1) | 1; |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 PWT_tone_is_on = 1; |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
42 #endif |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 } |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 void PWT_stop_tone(void) |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 { |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
47 #ifdef TARGET_HAS_BUZZER |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 PWT_VCR_REG = 0; |
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 PWT_tone_is_on = 0; |
291
a72feaed133a
PWT buzzer driver: conditionalize on TARGET_HAS_BUZZER
Mychaela Falconia <falcon@freecalypso.org>
parents:
290
diff
changeset
|
50 #endif |
290
0e5ccb343284
implement PWT buzzer driver
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |