summaryrefslogtreecommitdiffstats
path: root/app/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/gpio.c')
-rw-r--r--app/gpio.c74
1 files changed, 63 insertions, 11 deletions
diff --git a/app/gpio.c b/app/gpio.c
index 0419cde..eea5bf0 100644
--- a/app/gpio.c
+++ b/app/gpio.c
@@ -1,12 +1,15 @@
#include "project.h"
#define DEBOUNCE 10
#define DIAL_BLACKOUT 90 /* (10pps) */
+#define L2_THRESHOLD 1500
-static int hs_poll;
-int hook;
+static int hs_poll=DEBOUNCE;
+int hook=1;
static int dial_poll;
static int dial_pulse_blackout;
static int pulse_count;
+static int dial_mute_time;
+
@@ -26,6 +29,10 @@ exti7_isr (void)
if (dial_pulse_blackout)
return;
dial_pulse_blackout = DIAL_BLACKOUT;
+
+ if ((!pulse_count) && (dial_mute_time>L2_THRESHOLD))
+ pulse_count=100;
+
pulse_count++;
}
@@ -86,15 +93,24 @@ hs_tick (void)
{
if (ringing)
{
- ring_off ();
+ ringer_off ();
answer_call ();
}
+ else
+ {
+ ringer_off ();
+ dialstr_clear ();
+ dialtone_on ();
+ }
}
if (hook)
{
- ring_off ();
+ ringer_off ();
terminate_call ();
+ dialstr_clear ();
+ dialtone_off();
+ modem_tone_off();
}
@@ -106,6 +122,8 @@ dial_tick (void)
{
int m;
+ dial_mute_time++;
+
if (dial_pulse_blackout)
dial_pulse_blackout--;
if (!dial_poll)
@@ -117,13 +135,46 @@ dial_tick (void)
m = ! !gpio_get (GPIOA, GPIO5);
- if (m)
- return;
- if (!pulse_count)
+ if (m) {
+ dial_mute_time=0;
return;
-
- dialstr_digit ((pulse_count == 10) ? 0 : pulse_count);
- pulse_count = 0;
+ }
+
+
+ switch (pulse_count) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ dialstr_digit ('0'+pulse_count);
+ break;
+
+ case 10:
+ dialstr_digit ('0');
+ break;
+ case 101:
+ dialstr_digit ('*');
+ break;
+ case 102:
+ dialstr_digit ('#');
+ break;
+ case 103:
+ dialstr_digit ('R');
+ break;
+ case 104:
+ dialstr_digit ('M');
+ break;
+ case 105:
+ dialstr_digit ('U');
+ break;
+ }
+
+ pulse_count=0;
}
@@ -133,7 +184,8 @@ void
toggle_fake_hook (void)
{
fake_hook ^= 1;
- hs_poll = DEBOUNCE;
+ hs_poll = 1;
+hs_tick();
}
void