]> git.gag.com Git - fw/altos/blob - src/drivers/ao_pad.c
altos: Clean up st7565 LCD driver
[fw/altos] / src / drivers / ao_pad.c
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #include <ao.h>
20 #include <ao_exti.h>
21 #include <ao_pad.h>
22 #include <ao_74hc165.h>
23 #include <ao_radio_cmac.h>
24
25 static uint8_t ao_pad_ignite;
26 static struct ao_pad_command    command;
27 static struct ao_pad_query      query;
28 static uint8_t  ao_pad_armed;
29 static AO_TICK_TYPE     ao_pad_arm_time;
30 static uint8_t  ao_pad_box;
31 static uint8_t  ao_pad_disabled;
32 static AO_TICK_TYPE     ao_pad_packet_time;
33
34 #ifndef AO_PAD_RSSI_MINIMUM
35 #define AO_PAD_RSSI_MINIMUM     -90
36 #endif
37
38 #define DEBUG   1
39
40 #if DEBUG
41 static uint8_t  ao_pad_debug;
42 #define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0)
43 #define FLUSHD()    (ao_pad_debug ? (flush(), 0) : 0)
44 #else
45 #define PRINTD(...)
46 #define FLUSHD()
47 #endif
48
49 static void
50 ao_siren(uint8_t v)
51 {
52 #ifdef AO_SIREN
53         ao_gpio_set(AO_SIREN_PORT, AO_SIREN_PIN, v);
54 #else
55 #if HAS_BEEP
56         ao_beep(v ? AO_BEEP_MID : 0);
57 #else
58         (void) v;
59 #endif
60 #endif
61 }
62
63 static void
64 ao_strobe(uint8_t v)
65 {
66 #ifdef AO_STROBE
67         ao_gpio_set(AO_STROBE_PORT, AO_STROBE_PIN, v);
68 #else
69         (void) v;
70 #endif
71 }
72
73 #ifdef AO_PAD_PORT_0
74 #define pins_pad(pad)   (*((AO_PAD_ ## pad ## _PORT) == AO_PAD_PORT_0 ? (&pins0) : (&pins1)))
75 #else
76 #define pins_pad(pad)   pins0
77 #define AO_PAD_PORT_0 AO_PAD_PORT
78 #endif
79
80 static void
81 ao_pad_run(void)
82 {
83         AO_PORT_TYPE    pins0;
84 #ifdef AO_PAD_PORT_1
85         AO_PORT_TYPE    pins1;
86 #endif
87
88         for (;;) {
89                 while (!ao_pad_ignite)
90                         ao_sleep(&ao_pad_ignite);
91                 /*
92                  * Actually set the pad bits
93                  */
94                 pins0 = 0;
95 #ifdef AO_PAD_PORT_1
96                 pins1 = 0;
97 #endif
98 #if AO_PAD_NUM > 0
99                 if (ao_pad_ignite & (1 << 0))
100                         pins_pad(0) |= (1 << AO_PAD_PIN_0);
101 #endif
102 #if AO_PAD_NUM > 1
103                 if (ao_pad_ignite & (1 << 1))
104                         pins_pad(1) |= (1 << AO_PAD_PIN_1);
105 #endif
106 #if AO_PAD_NUM > 2
107                 if (ao_pad_ignite & (1 << 2))
108                         pins_pad(2) |= (1 << AO_PAD_PIN_2);
109 #endif
110 #if AO_PAD_NUM > 3
111                 if (ao_pad_ignite & (1 << 3))
112                         pins_pad(3) |= (1 << AO_PAD_PIN_3);
113 #endif
114 #if AO_PAD_NUM > 4
115                 if (ao_pad_ignite & (1 << 4))
116                         pins_pad(4) |= (1 << AO_PAD_PIN_4);
117 #endif
118 #if AO_PAD_NUM > 5
119                 if (ao_pad_ignite & (1 << 5))
120                         pins_pad(5) |= (1 << AO_PAD_PIN_5);
121 #endif
122 #if AO_PAD_NUM > 6
123                 if (ao_pad_ignite & (1 << 6))
124                         pins_pad(6) |= (1 << AO_PAD_PIN_6);
125 #endif
126 #if AO_PAD_NUM > 7
127                 if (ao_pad_ignite & (1 << 7))
128                         pins_pad(7) |= (1 << AO_PAD_PIN_7);
129 #endif
130 #ifdef AO_PAD_PORT_1
131                 PRINTD("ignite pins 0x%x 0x%x\n", pins0, pins1);
132                 ao_gpio_set_bits(AO_PAD_PORT_0, pins0);
133                 ao_gpio_set_bits(AO_PAD_PORT_1, pins1);
134 #else
135                 PRINTD("ignite pins 0x%x\n", pins0);
136                 ao_gpio_set_bits(AO_PAD_PORT_0, pins0);
137 #endif
138                 while (ao_pad_ignite) {
139                         ao_pad_ignite = 0;
140
141                         ao_delay(AO_PAD_FIRE_TIME);
142                 }
143 #ifdef AO_PAD_PORT_1
144                 ao_gpio_clr_bits(AO_PAD_PORT_0, pins0);
145                 ao_gpio_clr_bits(AO_PAD_PORT_1, pins1);
146                 PRINTD("turn off pins 0x%x 0x%x\n", pins0, pins1);
147 #else
148                 ao_gpio_set_bits(AO_PAD_PORT_0, pins0);
149                 PRINTD("turn off pins 0x%x\n", pins0);
150 #endif
151         }
152 }
153
154 #define AO_PAD_ARM_SIREN_INTERVAL       200
155
156 /* Resistor values needed for various voltage test ratios:
157  *
158  *      Net names involved:
159  *
160  *      V_BATT          Battery power, after the initial power switch
161  *      V_PYRO          Pyro power, after the pyro power switch (and initial power switch)
162  *      PYRO_SENSE      ADC input to sense V_PYRO voltage
163  *      BATT_SENSE      ADC input to sense V_BATT voltage
164  *      IGNITER         FET output to pad (the other pad lead hooks to V_PYRO)
165  *      IGNITER_SENSE   ADC input to sense igniter voltage
166  *
167  *      AO_PAD_R_V_BATT_BATT_SENSE      Resistor from battery rail to battery sense input
168  *      AO_PAD_R_BATT_SENSE_GND         Resistor from battery sense input to ground
169  *
170  *      AO_PAD_R_V_BATT_V_PYRO          Resistor from battery rail to pyro rail
171  *      AO_PAD_R_V_PYRO_PYRO_SENSE      Resistor from pyro rail to pyro sense input
172  *      AO_PAD_R_PYRO_SENSE_GND         Resistor from pyro sense input to ground
173  *
174  *      AO_PAD_R_V_PYRO_IGNITER         Optional resistors from pyro rail to FET igniter output
175  *      AO_PAD_R_IGNITER_IGNITER_SENSE  Resistors from FET igniter output to igniter sense ADC inputs
176  *      AO_PAD_R_IGNITER_SENSE_GND      Resistors from igniter sense ADC inputs to ground
177  */
178
179 static int16_t
180 ao_pad_decivolt(int16_t adc, int16_t r_plus, int16_t r_minus)
181 {
182         int32_t mul = (int32_t) AO_ADC_REFERENCE_DV * (r_plus + r_minus);
183         int32_t div = (int32_t) AO_ADC_MAX * r_minus;
184         return (int16_t) (((int32_t) adc * mul + mul/2) / div);
185 }
186
187 static void
188 ao_pad_monitor(void)
189 {
190         uint8_t                 c;
191         uint8_t                 sample;
192         AO_LED_TYPE     prev = 0, cur = 0;
193         uint8_t         beeping = 0;
194         volatile struct ao_data *packet;
195         uint16_t        arm_beep_time = 0;
196
197         sample = ao_data_head;
198         ao_led_set(LEDS_AVAILABLE);
199         ao_delay(AO_MS_TO_TICKS(1000));
200         ao_led_set(0);
201         for (;;) {
202                 int16_t                 pyro;
203
204                 ao_arch_critical(
205                         while (sample == ao_data_head)
206                                 ao_sleep((void *) &ao_data_head);
207                         );
208
209
210                 packet = &ao_data_ring[sample];
211                 sample = ao_data_ring_next(sample);
212
213                 /* Reply battery voltage */
214                 query.battery = (uint8_t) ao_pad_decivolt(packet->adc.batt, AO_PAD_R_V_BATT_BATT_SENSE, AO_PAD_R_BATT_SENSE_GND);
215
216                 /* Current pyro voltage */
217                 pyro = ao_pad_decivolt(packet->adc.pyro,
218                                        AO_PAD_R_V_PYRO_PYRO_SENSE,
219                                        AO_PAD_R_PYRO_SENSE_GND);
220
221                 cur = 0;
222                 if (pyro > query.battery * 7 / 8) {
223                         query.arm_status = AO_PAD_ARM_STATUS_ARMED;
224                         cur |= AO_LED_ARMED;
225                 } else {
226                         query.arm_status = AO_PAD_ARM_STATUS_DISARMED;
227                         arm_beep_time = 0;
228                 }
229                 if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2))
230                         cur |= AO_LED_RED;
231                 else if (ao_radio_cmac_rssi < AO_PAD_RSSI_MINIMUM)
232                         cur |= AO_LED_AMBER;
233                 else
234                         cur |= AO_LED_GREEN;
235
236                 for (c = 0; c < AO_PAD_NUM; c++) {
237                         int16_t         sense = ao_pad_decivolt(packet->adc.sense[c],
238                                                                 AO_PAD_R_IGNITER_IGNITER_SENSE,
239                                                                 AO_PAD_R_IGNITER_SENSE_GND);
240                         uint8_t status = AO_PAD_IGNITER_STATUS_UNKNOWN;
241
242                         /*
243                          *      Here's the resistor stack on each
244                          *      igniter channel. Note that
245                          *      AO_PAD_R_V_PYRO_IGNITER is optional
246                          *
247                          *                                      v_pyro \
248                          *      AO_PAD_R_V_PYRO_IGNITER                 igniter
249                          *                                      output /
250                          *      AO_PAD_R_IGNITER_IGNITER_SENSE         \
251                          *                                      sense   relay
252                          *      AO_PAD_R_IGNITER_SENSE_GND             /
253                          *                                      gnd ---
254                          *
255                          */
256
257 #ifdef AO_PAD_R_V_PYRO_IGNITER
258                         if (sense <= pyro / 8) {
259                                 /* close to zero → relay is closed */
260                                 status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_CLOSED;
261                                 if ((ao_time() % 100) < 50)
262                                         cur |= AO_LED_CONTINUITY(c);
263                         }
264                         else
265 #endif
266                         {
267                                 if (sense >= (pyro * 7) / 8) {
268
269                                         /* sense close to pyro voltage; igniter is good
270                                          */
271                                         status = AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN;
272                                         cur |= AO_LED_CONTINUITY(c);
273                                 } else {
274
275                                         /* relay not shorted (if we can tell),
276                                          * and igniter not obviously present
277                                          */
278                                         status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN;
279                                 }
280                         }
281                         query.igniter_status[c] = status;
282                 }
283                 if (cur != prev) {
284                         PRINTD("change leds from %02x to %02x\n",
285                                prev, cur);
286                         FLUSHD();
287                         ao_led_set(cur);
288                         prev = cur;
289                 }
290
291                 if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_PAD_ARM_TIME)
292                         ao_pad_armed = 0;
293
294                 if (ao_pad_armed) {
295                         ao_strobe(1);
296                         ao_siren(1);
297                         beeping = 1;
298                 } else if (query.arm_status == AO_PAD_ARM_STATUS_ARMED && !beeping) {
299                         if (arm_beep_time == 0) {
300                                 arm_beep_time = AO_PAD_ARM_SIREN_INTERVAL;
301                                 beeping = 1;
302                                 ao_siren(1);
303                         }
304                         --arm_beep_time;
305                 } else if (beeping) {
306                         beeping = 0;
307                         ao_siren(0);
308                         ao_strobe(0);
309                 }
310         }
311 }
312
313 void
314 ao_pad_disable(void)
315 {
316         if (!ao_pad_disabled) {
317                 ao_pad_disabled = 1;
318                 ao_radio_recv_abort();
319         }
320 }
321
322 void
323 ao_pad_enable(void)
324 {
325         ao_pad_disabled = 0;
326         ao_wakeup (&ao_pad_disabled);
327 }
328
329 #if HAS_74HC165
330 static uint8_t
331 ao_pad_read_box(void)
332 {
333         uint8_t         byte = ao_74hc165_read();
334         uint8_t         h, l;
335
336         h = byte >> 4;
337         l = byte & 0xf;
338         return h * 10 + l;
339 }
340 #endif
341
342 #ifdef AO_PAD_SELECTOR_PORT
343 static uint8_t ao_pad_read_box(void) {
344         AO_PORT_TYPE    value = ao_gpio_get_all(AO_PAD_SELECTOR_PORT);
345         unsigned        pin;
346         uint8_t         select = 1;
347
348         for (pin = 0; pin < sizeof (AO_PORT_TYPE) * 8; pin++) {
349                 if (AO_PAD_SELECTOR_PINS & (1 << pin)) {
350                         if ((value & (1 << pin)) == 0)
351                                 return select;
352                         select++;
353                 }
354         }
355         return ao_config.pad_box;
356 }
357 #else
358
359 #if HAS_FIXED_PAD_BOX
360 #define ao_pad_read_box()       ao_config.pad_box
361 #endif
362
363 #ifdef PAD_BOX
364 #define ao_pad_read_box()       PAD_BOX
365 #endif
366
367 #endif
368
369 static void
370 ao_pad(void)
371 {
372         int16_t tick_difference;
373         int8_t  ret;
374
375         ao_pad_box = 0;
376         for (;;) {
377                 FLUSHD();
378                 while (ao_pad_disabled)
379                         ao_sleep(&ao_pad_disabled);
380                 ret = ao_radio_cmac_recv(&command, sizeof (command), 0);
381                 PRINTD ("receive packet status %d rssi %d\n", ret, ao_radio_cmac_rssi);
382                 if (ret != AO_RADIO_CMAC_OK)
383                         continue;
384                 ao_pad_packet_time = ao_time();
385
386                 ao_pad_box = ao_pad_read_box();
387
388                 PRINTD ("tick %d box %d (me %d) cmd %d channels %02x\n",
389                         command.tick, command.box, ao_pad_box, command.cmd, command.channels);
390
391                 switch (command.cmd) {
392                 case AO_PAD_ARM:
393                         if (command.box != ao_pad_box) {
394                                 PRINTD ("box number mismatch\n");
395                                 break;
396                         }
397
398                         if (command.channels & ~(AO_PAD_ALL_CHANNELS))
399                                 break;
400
401                         tick_difference = (int16_t) (command.tick - (uint16_t) ao_time());
402                         PRINTD ("arm tick %d local tick %d\n", command.tick, (uint16_t) ao_time());
403                         if (tick_difference < 0)
404                                 tick_difference = -tick_difference;
405                         if (tick_difference > 10) {
406                                 PRINTD ("tick difference too large %d\n", tick_difference);
407                                 break;
408                         }
409                         if (query.arm_status != AO_PAD_ARM_STATUS_ARMED) {
410                                 PRINTD ("box not armed locally\n");
411                                 break;
412                         }
413                         PRINTD ("armed\n");
414                         ao_pad_armed = command.channels;
415                         ao_pad_arm_time = ao_time();
416                         break;
417
418                 case AO_PAD_QUERY:
419                         if (command.box != ao_pad_box) {
420                                 PRINTD ("box number mismatch\n");
421                                 break;
422                         }
423
424                         query.tick = (uint16_t) ao_time();
425                         query.box = ao_pad_box;
426                         query.channels = AO_PAD_ALL_CHANNELS;
427                         query.armed = ao_pad_armed;
428                         PRINTD ("query tick %d box %d channels %02x arm %d arm_status %d igniter %d,%d,%d,%d\n",
429                                 query.tick, query.box, query.channels, query.armed,
430                                 query.arm_status,
431                                 query.igniter_status[0],
432                                 query.igniter_status[1],
433                                 query.igniter_status[2],
434                                 query.igniter_status[3]);
435                         ao_radio_cmac_send(&query, sizeof (query));
436                         break;
437                 case AO_PAD_FIRE:
438                         if (!ao_pad_armed) {
439                                 PRINTD ("not armed\n");
440                                 break;
441                         }
442                         if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_SEC_TO_TICKS(20)) {
443                                 PRINTD ("late pad arm_time %ld time %ld\n",
444                                         (long) ao_pad_arm_time, ao_time());
445                                 break;
446                         }
447                         PRINTD ("ignite\n");
448                         ao_pad_ignite = ao_pad_armed;
449                         ao_pad_arm_time = ao_time();
450                         ao_wakeup(&ao_pad_ignite);
451                         break;
452                 case AO_PAD_STATIC:
453                         if (!ao_pad_armed) {
454                                 PRINTD ("not armed\n");
455                                 break;
456                         }
457 #if HAS_LOG
458                         if (!ao_log_running) ao_log_start();
459 #endif
460                         if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_SEC_TO_TICKS(20)) {
461                                 PRINTD ("late pad arm_time %ld time %ld\n",
462                                         (long) ao_pad_arm_time, (long) ao_time());
463                                 break;
464                         }
465                         PRINTD ("ignite\n");
466                         ao_pad_ignite = ao_pad_armed;
467                         ao_pad_arm_time = ao_time();
468                         ao_wakeup(&ao_pad_ignite);
469                         break;
470                 case AO_PAD_ENDSTATIC:
471 #if HAS_LOG
472                         ao_log_stop();
473 #endif
474                         break;
475                 }
476         }
477 }
478
479 static void
480 ao_pad_test(void)
481 {
482         uint8_t c;
483
484         printf ("Arm switch: ");
485         switch (query.arm_status) {
486         case AO_PAD_ARM_STATUS_ARMED:
487                 printf ("Armed\n");
488                 break;
489         case AO_PAD_ARM_STATUS_DISARMED:
490                 printf ("Disarmed\n");
491                 break;
492         case AO_PAD_ARM_STATUS_UNKNOWN:
493                 printf ("Unknown\n");
494                 break;
495         }
496
497         for (c = 0; c < AO_PAD_NUM; c++) {
498                 printf ("Pad %d: ", c);
499                 switch (query.igniter_status[c]) {
500                 case AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_CLOSED:     printf ("No igniter. Relay closed\n"); break;
501                 case AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN:       printf ("No igniter. Relay open\n"); break;
502                 case AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN:     printf ("Good igniter. Relay open\n"); break;
503                 case AO_PAD_IGNITER_STATUS_UNKNOWN:                     printf ("Unknown\n"); break;
504                 }
505         }
506 }
507
508 static void
509 ao_pad_manual(void)
510 {
511         uint8_t ignite;
512         int     repeat;
513         ao_cmd_white();
514         if (!ao_match_word("DoIt"))
515                 return;
516         ignite = 1 << ao_cmd_decimal();
517         if (ao_cmd_status != ao_cmd_success)
518                 return;
519         repeat = (uint8_t) ao_cmd_decimal();
520         if (ao_cmd_status != ao_cmd_success) {
521                 repeat = 1;
522                 ao_cmd_status = ao_cmd_success;
523         }
524         while (repeat-- > 0) {
525                 ao_pad_ignite = ignite;
526                 ao_wakeup(&ao_pad_ignite);
527                 ao_delay(AO_PAD_FIRE_TIME>>1);
528         }
529 }
530
531 static struct ao_task ao_pad_task;
532 static struct ao_task ao_pad_ignite_task;
533 static struct ao_task ao_pad_monitor_task;
534
535 #if DEBUG
536 static void
537 ao_pad_set_debug(void)
538 {
539         uint32_t r = ao_cmd_decimal();
540         if (ao_cmd_status == ao_cmd_success)
541                 ao_pad_debug = r != 0;
542 }
543
544
545 static void
546 ao_pad_alarm_debug(void)
547 {
548         uint8_t which, value;
549         which = ao_cmd_decimal() != 0;
550         if (ao_cmd_status != ao_cmd_success)
551                 return;
552         value = ao_cmd_decimal() != 0;
553         if (ao_cmd_status != ao_cmd_success)
554                 return;
555         printf ("Set %s to %d\n", which ? "siren" : "strobe", value);
556         if (which)
557                 ao_siren(value);
558         else
559                 ao_strobe(value);
560 }
561 #endif
562
563 const struct ao_cmds ao_pad_cmds[] = {
564         { ao_pad_test,  "t\0Test pad continuity" },
565         { ao_pad_manual,        "i <key> <n>\0Fire igniter. <key> is doit with D&I" },
566 #if DEBUG
567         { ao_pad_set_debug,     "D <0 off, 1 on>\0Debug" },
568         { ao_pad_alarm_debug,   "S <0 strobe, 1 siren> <0 off, 1 on>\0Set alarm output" },
569 #endif
570         { 0, NULL }
571 };
572
573 #ifndef AO_PAD_PORT_1
574 #define AO_PAD_0_PORT   AO_PAD_PORT
575 #define AO_PAD_1_PORT   AO_PAD_PORT
576 #define AO_PAD_2_PORT   AO_PAD_PORT
577 #define AO_PAD_3_PORT   AO_PAD_PORT
578 #define AO_PAD_4_PORT   AO_PAD_PORT
579 #define AO_PAD_5_PORT   AO_PAD_PORT
580 #define AO_PAD_6_PORT   AO_PAD_PORT
581 #define AO_PAD_7_PORT   AO_PAD_PORT
582 #endif
583
584 void
585 ao_pad_init(void)
586 {
587 #ifdef AO_PAD_SELECTOR_PORT
588         int pin;
589
590         for (pin = 0; pin < (int) sizeof (AO_PORT_TYPE) * 8; pin++) {
591                 if (AO_PAD_SELECTOR_PINS & (1 << pin))
592                         ao_enable_input(AO_PAD_SELECTOR_PORT, pin, AO_EXTI_MODE_PULL_UP);
593         }
594 #endif
595 #if AO_PAD_NUM > 0
596         ao_enable_output(AO_PAD_0_PORT, AO_PAD_PIN_0, 0);
597 #endif
598 #if AO_PAD_NUM > 1
599         ao_enable_output(AO_PAD_1_PORT, AO_PAD_PIN_1, 0);
600 #endif
601 #if AO_PAD_NUM > 2
602         ao_enable_output(AO_PAD_2_PORT, AO_PAD_PIN_2, 0);
603 #endif
604 #if AO_PAD_NUM > 3
605         ao_enable_output(AO_PAD_3_PORT, AO_PAD_PIN_3, 0);
606 #endif
607 #if AO_PAD_NUM > 4
608         ao_enable_output(AO_PAD_4_PORT, AO_PAD_PIN_4, 0);
609 #endif
610 #if AO_PAD_NUM > 5
611         ao_enable_output(AO_PAD_5_PORT, AO_PAD_PIN_5, 0);
612 #endif
613 #if AO_PAD_NUM > 5
614         ao_enable_output(AO_PAD_6_PORT, AO_PAD_PIN_6, 0);
615 #endif
616 #if AO_PAD_NUM > 7
617         ao_enable_output(AO_PAD_7_PORT, AO_PAD_PIN_7, 0);
618 #endif
619 #ifdef AO_STROBE
620         ao_enable_output(AO_STROBE_PORT, AO_STROBE_PIN, 0);
621 #endif
622 #ifdef AO_SIREN
623         ao_enable_output(AO_SIREN_PORT, AO_SIREN_PIN, 0);
624 #endif
625         ao_cmd_register(&ao_pad_cmds[0]);
626         ao_add_task(&ao_pad_task, ao_pad, "pad listener");
627         ao_add_task(&ao_pad_ignite_task, ao_pad_run, "pad igniter");
628         ao_add_task(&ao_pad_monitor_task, ao_pad_monitor, "pad monitor");
629 }