From: Mikko Rasa Date: Thu, 31 Oct 2013 22:14:23 +0000 (+0200) Subject: Fix S88 latching logic X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2a465d26c1c5209446f0d5c46a964019fcf5bce1;p=model-railway-devices.git Fix S88 latching logic --- diff --git a/s88w/s88w-r.c b/s88w/s88w-r.c index 1716532..f94a1be 100644 --- a/s88w/s88w-r.c +++ b/s88w/s88w-r.c @@ -42,9 +42,11 @@ uint8_t rx_buf[7]; uint8_t rx_fill = 0xFF; uint8_t input[128] = { 0 }; uint8_t latch[128] = { 0 }; +uint8_t output[128] = { 0 }; uint8_t out_offset = 0; uint8_t out_bits = 0; uint8_t out_fill = 0; +volatile uint8_t load_pos = 0xFF; volatile uint8_t reset_pos = 0xFF; uint8_t lcd_enabled = 0; uint8_t log_row = 0; @@ -70,6 +72,15 @@ int main() check_input(); + i = load_pos; + if(i!=0xFF) + { + output[i] = latch[i]; + if(++i>=sizeof(input)) + i = 0xFF; + load_pos = i; + } + i = reset_pos; if(i!=0xFF) { @@ -134,7 +145,7 @@ void check_input() uint8_t shift = 4*(j&1); uint8_t bits = decode_hex(rx_buf[3+i]); input[j/2] = (input[j/2]&~(0xF<