From 12c8bea85ceb822d0764711b6e03f910b3faae3c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 14 Oct 2021 23:27:08 -0700 Subject: [PATCH] telelco-v0.2: Make config.pad_box override switches Some of the TeleLCO v0.2 switches are failing. Use the pad box config value to override if necessary. Signed-off-by: Keith Packard --- src/drivers/ao_pad.c | 11 ++++++----- src/kernel/ao_config.c | 11 ++++++++--- src/kernel/ao_config.h | 2 +- src/telefire-v0.2/ao_pins.h | 1 - 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index e9b54b04..f3975dbc 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -334,6 +334,7 @@ ao_pad_read_box(void) uint8_t byte = ao_74hc165_read(); uint8_t h, l; + PRINTD("box %02x\n", byte); h = byte >> 4; l = byte & 0xf; return h * 10 + l; @@ -357,10 +358,6 @@ static int ao_pad_read_box(void) { } #else -#if HAS_FIXED_PAD_BOX -#define ao_pad_read_box() ao_config.pad_box -#endif - #ifdef PAD_BOX #define ao_pad_read_box() PAD_BOX #endif @@ -384,7 +381,11 @@ ao_pad(void) continue; ao_pad_packet_time = ao_time(); - ao_pad_box = ao_pad_read_box(); + ao_pad_box = ao_config.pad_box; +#ifndef HAS_FIXED_PAD_BOX + if (ao_pad_box == 0 || ao_pad_box == 0xff) + ao_pad_box = ao_pad_read_box(); +#endif PRINTD ("tick %d box %d (me %d) cmd %d channels %02x\n", command.tick, command.box, ao_pad_box, command.cmd, command.channels); diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index 86d4838f..cfcad5bc 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -229,9 +229,14 @@ _ao_config_get(void) if (minor < 22) ao_config.aprs_format = AO_CONFIG_DEFAULT_APRS_FORMAT; #endif +#if HAS_PAD + if (minor < 22) { #if HAS_FIXED_PAD_BOX - if (minor < 22) ao_config.pad_box = 1; +#else + ao_config.pad_box = 0; +#endif + } if (minor < 23) ao_config.pad_idle = 120; #endif @@ -913,7 +918,7 @@ ao_config_aprs_format_show(void) } #endif /* HAS_APRS */ -#if HAS_FIXED_PAD_BOX +#if HAS_PAD void ao_config_pad_box_show(void) { @@ -1043,7 +1048,7 @@ __code struct ao_config_var ao_config_vars[] = { { "C <0 compressed, 1 uncompressed>\0APRS format", ao_config_aprs_format_set, ao_config_aprs_format_show }, #endif -#if HAS_FIXED_PAD_BOX +#if HAS_PAD { "B \0Set pad box (1-99)", ao_config_pad_box_set, ao_config_pad_box_show }, { "i \0Set idle timeout (0 disable)", diff --git a/src/kernel/ao_config.h b/src/kernel/ao_config.h index f730c73c..0bbb06d1 100644 --- a/src/kernel/ao_config.h +++ b/src/kernel/ao_config.h @@ -119,7 +119,7 @@ struct ao_config { #if HAS_APRS uint8_t aprs_format; /* minor version 22 */ #endif -#if HAS_FIXED_PAD_BOX +#if HAS_PAD uint8_t pad_box; /* minor version 22 */ uint8_t pad_idle; /* minor version 23 */ #endif diff --git a/src/telefire-v0.2/ao_pins.h b/src/telefire-v0.2/ao_pins.h index 8050668f..65f5bdcc 100644 --- a/src/telefire-v0.2/ao_pins.h +++ b/src/telefire-v0.2/ao_pins.h @@ -33,7 +33,6 @@ #define HAS_EEPROM 1 #define HAS_LOG 0 #define HAS_PAD 1 -#define HAS_FIXED_PAD_BOX 1 #define USE_INTERNAL_FLASH 1 #define DBG_ON_P1 0 #define IGNITE_ON_P2 0 -- 2.30.2