/* BlueDataDistributor - data distribution module from ethernet to 32 serial ports
 * version 0.1.1 date 2006-10-07
 * Copyright (C) 2006 Stefan Schuermans <stefan@blinkenarea.org>
 * a BlinkenArea project - http://www.blinkenarea.org/
 */

#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/wdt.h>

#include "arp.h"
#include "config.h"
#include "random.h"
#include "rtl8019.h"
#include "serial.h"
#include "status.h"
#include "tcp.h"
#include "timing.h"

// main code entry point
int main( void )
{
  wdt_reset( );
#ifdef DEBUG
  wdt_disable( );
#else
  wdt_enable( WDTO_60MS );
#endif
  wdt_reset( );

  // initialize modules
  ArpInit( );
  ConfigInit( );
  RtlInit( );
  SerialInit( );
  StatusInit( );
  TcpInit( );
  TimingInit( );

  // get configuration from switches
  ConfigGetFromSwitches( );
  RtlInit( ); // re-initialize RTL8019

  // enable interrupts
  sei( );

  // main loop
  while( 1 )
  {
    wdt_reset( );
    RandomTask( );
    wdt_reset( );
    RtlTask( );
    wdt_reset( );
    TimingTask( );
  }

  return 0;
}

