2 Firmware for model railway control interface
10 Connections for Pololu high-powered motor driver:
14 Connections for S88 bus:
21 ADC0 - current sensor (adjusted for 185 mV/A, centered at Vcc/2)
22 ADC1 - input voltage (adjusted for divisor of 11)
24 This is not a complete control device. Rather, it is a low-level bus driver,
25 intended to be controlled with a computer program. In particular, no state is
26 kept about locomotives or solenoids. It is up to the controlling program to
27 maintain a refresh cycle, turn off solenoids after a sufficient delay, etc.
29 Commands are received as a packetized stream over the serial interface. Each
30 packet begins with a header byte, which is bitwise not of the packet's length,
31 not including the header byte itself. The longest allowed packet is 15 bytes.
32 Thus, the high four bits of the header byte are always ones. The first data
33 byte specifies the command, and the rest of the packet is command arguments.
35 After a command has been processed, a similarly packetized response is sent.
37 Track output is asynchronous up to a single packet. If an output command is
38 received while a previous packet is still being sent to the track, execution
39 blocks until the operation completes. The command returns as soon as sending
40 its data to the track can start.
43 #include <avr/interrupt.h>
44 #include "interface.h"