X-Git-Url: http://git.tdb.fi/?p=model-railway-devices.git;a=blobdiff_plain;f=firmware%2Fs88w-t.c;h=70c646c19984fb5583899d6a2b1a45c6ecab83b7;hp=e394d603032fe07b14047f554abc633afb451c7a;hb=238cd5e5bd9c6fa86ae85f5eb7a8ce00158f2f7c;hpb=d8a31ed675778c08ca781beb62863c62d6f0bd94 diff --git a/firmware/s88w-t.c b/firmware/s88w-t.c index e394d60..70c646c 100644 --- a/firmware/s88w-t.c +++ b/firmware/s88w-t.c @@ -17,9 +17,21 @@ D6 - input 5 D7 - input 6 B0 - input 7 B1 - input 8 +B2 - input 9 +B3 - input 10 +B4 - input 11 +B5 - input 12 Inputs are pulled high by internal pull-up resistors. Connect to GND to activate. + +The module can be configured by sending a string of form ":Shhh." over the +serial port, where hhh is a hex number. Lower two bits indicate the number of +inputs (00=4, 01=8, 10=12, 11=16) and upper ten bits indicate offset of lowest +input in multiples of 4 bits. At the moment there are no provisions for +having 16 physical inputs. + +Example: ":S016." would configure the module to have 12 inputs at offset 20. */ #include @@ -52,13 +64,11 @@ int main() DDRD = 0x02; // 00000010 PORTD = 0xFC; // 11111100 - DDRB = 0x20; // 00000000 + DDRB = 0x00; // 00000000 PORTB = 0x3F; // 00111111 serial_init(9600); - serial_set_callback(receive); - timer_init(1, 2); - timer_set_callback(send_state); + timer_start_hz(1, 1, 2); sei(); @@ -123,6 +133,8 @@ void receive(uint8_t c) } } +SERIAL_SET_CALLBACK(receive) + void send_state(void) { uint8_t i; @@ -135,6 +147,8 @@ void send_state(void) serial_write('.'); } +TIMER_SET_CALLBACK(1, send_state) + uint8_t hexdigit(uint8_t n) { n &= 0xF;