// ------------------------------------------------------------------
//
// TRAIN TIMER
// -----------
//
// Firmware for TRAIN02A board. It changes state of relay outputs
// as defined in configuration. Default configuration is in .h file
// and definitions may be changed online via USB port and if needed
// stored into EEPROM.
// 
// Uses ATmega8 at 8MHz (internal RC or external XTAL)
//
// (c) miho WWW.MLAB.CZ/PermaLink/TRAIN
//
// ------------------------------------------------------------------


// Version info
#define         VERSION                         "1.00"
#define         YEAR                            "2013"


// Default Timers onfiguration (8 timers)
#define DEFAULT_TIMES_ON                        { 1, 2, 3, 4, 5, 6, 7, 8}               // Time in [s] for "On"
#define DEFAULT_TIMES_OFF                       { 9, 8, 7, 6, 5, 4, 3, 2}               // Time in [s] for "Off"
#define DEFAULT_TIMES_ON_RND            { 0, 0, 0, 0, 0, 0, 0, 0}               // Random adition in [s] for "On"
#define DEFAULT_TIMES_OFF_RND           { 0, 0, 0, 0, 0, 0, 0, 0}               // Random adition in [s] for "Off"


// Time granularity
#define         F_TIME_GRAIN                    100                     // User Timer Time Quantum in Hz


// RS232 Config
#define         BAUD                                    9600            // Bd
#define         UART_TX0_BUFFER_SIZE    0x80            // TX FIFO - Must be power of 2 !
#define         UART_RX0_BUFFER_SIZE    0x80            // RX FIFO - Must be power of 2 !

#define         LINE_LENGTH                             40                      // Length of line


// --------------------------------


// USART RX/TX buffers
#define UART_RX0_BUFFER_MASK ( UART_RX0_BUFFER_SIZE - 1)
#define UART_TX0_BUFFER_MASK ( UART_TX0_BUFFER_SIZE - 1)

#if ( UART_RX0_BUFFER_SIZE & UART_RX0_BUFFER_MASK )
        #error RX0 buffer size is not a power of 2
#endif

#if ( UART_TX0_BUFFER_SIZE & UART_TX0_BUFFER_MASK )
        #error TX0 buffer size is not a power of 2
#endif


// Standard control ASCII chars
#define         CR                                              13
#define         LF                                              10
#define         BS                                              8
#define         DEL                                             127
#define         ESC                                             27