X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=firmware%2Fs88w-r.c;fp=firmware%2Fs88w-r.c;h=dbd1ef175d9a7ea95279dc5bccfe85fe12c557f5;hb=238cd5e5bd9c6fa86ae85f5eb7a8ce00158f2f7c;hp=f64445d81c5a33f12b8f82ef1cae2ea21c7fba5d;hpb=d8a31ed675778c08ca781beb62863c62d6f0bd94;p=model-railway-devices.git diff --git a/firmware/s88w-r.c b/firmware/s88w-r.c index f64445d..dbd1ef1 100644 --- a/firmware/s88w-r.c +++ b/firmware/s88w-r.c @@ -27,6 +27,7 @@ D5 - S88 RESET #include #include "lcd.h" #include "serial.h" +#include "delay.h" #define DATA_OUT PORTD2 #define CLOCK PIND3 @@ -51,20 +52,22 @@ int main() uint8_t bits = 0; uint8_t n_bits = 8; uint8_t offset = 0; + uint8_t i; - DDRD = 0x06; // 00000110 - PIND = 0xC0; // 11000000 - DDRB = 0x20; // 00100000 - PINB = 0x1F; // 00011111 + DDRD = 0x06; // 00000110 + PORTD = 0xC0; // 11000000 + DDRB = 0x20; // 00100000 + PORTB = 0x1F; // 00011111 serial_init(9600); - serial_set_callback(receive); lcd_init(); - lcd_on(); - lcd_clear(); sei(); + lcd_clear(); + for(i=0; i<20; ++i) + lcd_write('0'); + while(1) { uint8_t d_pins; @@ -140,13 +143,11 @@ void receive(uint8_t c) input[j/2] = (input[j/2]&~(0xF<>4)); - lcd_write(hexdigit(input[i])); + lcd_gotoxy(19-offset-nibbles, 0); + for(i=0; i<=nibbles; ++i) + lcd_write(rx_buf[3+i]); + log_pos |= 0x80; } } rx_fill = 0xFF; @@ -164,10 +165,13 @@ void receive(uint8_t c) ++log_pos; if(log_pos>=60) log_pos = 0; - lcd_gotoxy(log_pos%20, 1+log_pos/20); + if(log_pos%20==0) + lcd_gotoxy(log_pos%20, 1+log_pos/20); lcd_write(255); } +SERIAL_SET_CALLBACK(receive) + uint8_t hexdigit(uint8_t n) { n &= 0xF;