Index: firmware/FSC/usb_src/FSC.c
===================================================================
--- firmware/FSC/usb_src/FSC.c	(revision 10754)
+++ firmware/FSC/usb_src/FSC.c	(revision 10754)
@@ -0,0 +1,1090 @@
+//-----------------------------------------------------------------------------
+#include "typedefs.h"
+#include "application.h"
+#include "spi_master.h"
+#include "ad7719_adc.h"
+#include "atmega_adc.h"    
+#include "usart.h"
+#include "macros.h"
+#include "interpol.h"
+//#include "w5100_spi_interface.h"
+#include <avr/interrupt.h>
+#include <avr/wdt.h>
+#include <stdlib.h>
+//-----------------------------------------------------------------------------
+// definition of some functions:
+// these function are implemented in this file, this is not doog coding style.
+// sooner or later, they will be moved into more apropriate files.
+U08	increase_adc (U08 channel);
+U08	increase_ad7719 (U08 channel);
+void Set_V_Muxer (U08 channel);
+void Set_T_Muxer(U08 channel);
+void talk(void);// never used up to now.
+void ad7719_output(U08 channel, U32 data);
+void adc_output(U08 channel, U08 data);
+void adc_output_all();
+void parse(); //doesn't do anything at the moment
+void check_if_measured_all() ;
+void print_ad7719_nicely();
+void print_adc_nicely();
+void print_temp_nicely();
+// end of function definition:
+//-----------------------------------------------------------------------------
+
+// MAIN WORKFLOW GLOBAL VARIABLES
+	bool verbose;
+	bool heartbeat_enable;
+
+// USART global variables
+	U08 usart_rx_buffer[USART_RX_BUFFER_SIZE];
+	U08 usart_tx_buffer[USART_TX_BUFFER_SIZE];
+	U08 usart_received_chars;
+	U08 usart_rx_buffer_index = 0;
+	U08 usart_tx_buffer_index = 0;
+  	U08 usart_last_char; 					// last received char
+
+// USART FLAGS
+	bool usart_tx_buffer_overflow = false;	// true if usart_tx_buffer was full.
+	bool usart_rx_ready = false;			// EOL was received, parser needs to be called
+	
+// TIMER global variable
+	volatile U32 local_ms = 0;
+
+// AD7719 global variables
+	#define TEMP_CHANNELS 64
+	#define CHANNEL_BITMAP 8
+	#define AD7719_READINGS_UNTIL_SETTLED 3 // bei3:480ms
+	U32 ad7719_values[TEMP_CHANNELS];
+	U08 ad7719_enables[CHANNEL_BITMAP];
+	U08 ad7719_channels_ready[CHANNEL_BITMAP];
+	U08 ad7719_readings_since_last_muxing = 0;
+	U08 ad7719_current_channel = 0;
+	U32 ad7719_current_reading = 0;
+	bool ad7719_measured_all = false;
+	
+// ATMEGA ADC global variables
+	#define V_CHANNELS 40
+	#define I_CHANNELS 40
+	#define H_CHANNELS 4
+	#define V_BITMAP 5
+	#define I_BITMAP 5
+	#define H_BITMAP 1
+	#define ADC_READINGS_UNTIL_SETTLED 1
+	U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS]; // stores measured voltage in steps of 16mV
+	U08 adc_enables[V_BITMAP + I_BITMAP + H_BITMAP];
+	U08 adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP];
+	U08 adc_readings_since_last_muxing = 0;
+	U08 adc_current_channel = 0;
+	U08 adc_current_reading = 0;
+	bool adc_measured_all = false;
+
+	bool once_told_you = true;
+	bool debug_mode = false;
+
+//-----------------------------------------------------------------------------
+//   M A I N    ---   M A I N    ---   M A I N    ---   M A I N    ---  M A I N    
+//-----------------------------------------------------------------------------
+int main(void)
+{
+	app_init();		  // Setup: Watchdog and I/Os
+	usart_init();		// Initialize serial interface   
+	spi_init(); 		// Initialize SPI interface as master
+	ad7719_init(); 		// Initialize AD7719 ADC as SPI slave 
+	atmega_adc_init();
+
+// TIMER2 is used as local clock:
+// configure timer 2
+	TCCR2 = (1<<WGM21); // CTC Modus
+	TCCR2 |= (1<<CS21) | (1<<CS20); // Prescaler 64 --> counts up every 8us
+	OCR2 = 125-1; 					// --> output compare interrupt occurs every 125 x 8us = 1ms
+	// Compare Interrupt erlauben
+	TIMSK |= (1<<OCIE2);
+
+  //  Enable interrupts
+  sei();              
+
+  PORTB &= ~(1<<PB2);
+  
+ad7719_enables[0]=0x00;
+ad7719_enables[1]=0x00;
+ad7719_enables[2]=0x00;
+ad7719_enables[3]=0x00;
+ad7719_enables[4]=0x00;
+ad7719_enables[5]=0x00;
+ad7719_enables[6]=0x00;
+ad7719_enables[7]=0x00;  
+for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+	ad7719_channels_ready[i]=0;
+}
+ad7719_current_channel = increase_ad7719 (ad7719_current_channel);
+
+for ( U08 i=0; i<V_BITMAP + I_BITMAP; ++i ) {
+	adc_enables[i]=0xFF;
+	adc_channels_ready[i]=0;
+}
+	adc_enables[V_BITMAP + I_BITMAP + H_BITMAP -1] = 0x0F;
+	adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP -1]=0;
+
+	static U08 welcome[]="\n\nwelcome to FACT FSC commandline interface v0.4\nDN 17.03.2011\nready?";
+	usart_write_str(welcome);
+
+
+//MAIN LOOP
+while (1)
+{
+
+	//IF one of the ADC measured all channels, we wanted to know.
+	check_if_measured_all();
+	
+	if (ad7719_measured_all && adc_measured_all && !once_told_you)
+	{
+		adc_output_all();
+		once_told_you = true;
+	}
+//----------------------------------------------------------------------------
+
+	if (heartbeat_enable) PORTB ^= (1<<PB3); // toggle Out2_spare --> heartbeat
+//----------------------------------------------------------------------------
+	//IF we need to send away one byte, and ready to send
+
+	if ( (usart_tx_buffer_index > 0) && (UCSRA & (1<<UDRE)) ) { 
+		UDR = usart_tx_buffer[0];
+		// THis is shit
+		for (U08 i=0 ; i < USART_TX_BUFFER_SIZE; ++i) {
+			usart_tx_buffer[i] = usart_tx_buffer[i+1];
+		}
+		usart_tx_buffer_index--;
+	}
+//----------------------------------------------------------------------------
+
+	//IF we just received one byte, and there is enough space in the RX_buffer
+	if ( (UCSRA & (1<<RXC)) && (usart_rx_buffer_index < USART_RX_BUFFER_SIZE) ){
+		usart_last_char = UDR;
+		if (usart_last_char == '\n'){ // if EOL was received
+			usart_rx_ready = true;
+		}else {
+		usart_rx_buffer[usart_rx_buffer_index] = usart_last_char;
+		usart_rx_buffer_index++;
+		}
+		// here is still something strange .... better send an enter automatically
+	} else if (UCSRA & (1<<RXC)) { // if there is no scace in the buffer; read anyway.
+		usart_last_char = UDR;
+		usart_rx_buffer_index =0;
+	}
+//----------------------------------------------------------------------------
+
+	//IF USART DOR bit is set, PC is sending data to fast!!!
+	if ( UCSRA & (1<<DOR) ){
+		// flush TX_buffer and write warning message in
+		// maybe even switch off every measurement. ?
+	}
+//----------------------------------------------------------------------------
+
+	//IF TX_BUFFER was overrun.	
+	if (usart_tx_buffer_overflow) {
+		// flash TX_buffer and write warning message in
+		// maybe even switch off every measurement. ?
+		//
+		// this should only happen, in verbose mode and with low baudrates.
+	}
+//----------------------------------------------------------------------------
+	
+	//IF one command was received. 
+	//	-It is not allowed to send more than one command between two '\n'
+	if (usart_rx_ready){ 
+		parse();
+		usart_rx_buffer_index = 0;
+		usart_rx_ready = false;
+	}
+//----------------------------------------------------------------------------
+
+	//IF ATmega internal ADC did finish a conversion --every 200us
+	if ( (ADCSRA & (1<<ADIF)) && !adc_measured_all) {
+		adc_current_reading = ADCH;
+		if (adc_readings_since_last_muxing == ADC_READINGS_UNTIL_SETTLED) {
+			adc_values[adc_current_channel] = adc_current_reading;
+			adc_readings_since_last_muxing=0;
+			// note that this channel is ready, now and 
+			//adc_output(adc_current_channel, adc_current_reading);
+			// proceed to the next enabled channel.
+			adc_channels_ready[adc_current_channel/8] |= (1<<(adc_current_channel%8));
+			adc_current_channel = increase_adc (adc_current_channel);
+			Set_V_Muxer(adc_current_channel);
+			_delay_ms(10);
+		} else { // the ADC did not settle yet, we discard the reading
+			++adc_readings_since_last_muxing;
+			// current reading is not used for anything else
+		}
+	}
+//----------------------------------------------------------------------------
+
+	//IF AD7719 ADC just finished a conversion -- every 60ms
+	
+	if (AD7719_IS_READY() && !ad7719_measured_all) {
+			ad7719_current_reading = read_adc(); // --takes at 4MHz SCLK speed about 6us
+		// AD7719 is only read out if settled. saves time.	
+		if (ad7719_readings_since_last_muxing == AD7719_READINGS_UNTIL_SETTLED) {
+			ad7719_values[ad7719_current_channel] = ad7719_current_reading;
+			ad7719_readings_since_last_muxing=0;
+			if (debug_mode) {
+				usart_write_U32_hex(ad7719_current_reading);
+				usart_write_char('\n');
+				usart_write_char('\n');
+			}
+			// now prepare the data to be send away via USART.
+			//ad7719_output(ad7719_current_channel, ad7719_current_reading);
+			// note that this channel is ready, now and 
+			// proceed to the next enabled channel.
+			ad7719_channels_ready[ad7719_current_channel/8] |= (1<<(ad7719_current_channel%8));
+			ad7719_current_channel = increase_ad7719 (ad7719_current_channel);
+			Set_T_Muxer(ad7719_current_channel);
+		} else { // the AD7719 did not settle yet, we discard the reading
+			++ad7719_readings_since_last_muxing;
+			if (debug_mode) {
+				usart_write_U32_hex(ad7719_current_reading);
+				usart_write_char('\n'); 
+			}
+
+			// current reading is not used for anything else
+		}
+	}
+
+//----------------------------------------------------------------------------
+/*
+	if (verbose == true)
+		// talk() was just defined so the 
+		// code is not at this place ... look down.
+		talk();
+*/
+
+} // end of MAIN LOOP
+//-----------------------------------------------------------------------------
+//    E N D     E N D     E N D     E N D     E N D     E N D     E N D     
+//-----------------------------------------------------------------------------
+
+
+
+float resistance;
+
+U08 SA_mux_val = 0x00;
+U08 SB_mux_val = 0x00;
+
+//U08 counter = 0;
+U08 Res_or_Volt = 0x00;
+
+
+while (TRUE)
+	 {
+
+
+  ++Res_or_Volt;
+  if (Res_or_Volt <= 64){
+
+
+		// if USART data arrives. i.e. data via USB
+		// the usart_rx_ready flag is set TRUE
+		// now process the incoming data which is stored in 
+		// U08 usart_rx_buffer[USART_RX_BUFFER_SIZE]
+		// and tell the USART interface, it may receive new data
+		// by setting the usart_rx_ready flag FALSE again
+		++SA_mux_val;
+		if (Res_or_Volt == 1) SB_mux_val = 16;
+		else if (SA_mux_val == 64) SA_mux_val = 32;
+		else if (SA_mux_val == 16) SA_mux_val = 48;
+		else if (SA_mux_val == 32) SA_mux_val = 0;
+		PORTA = (SA_mux_val & 0x3F); 
+				
+//		usart_write_str((pU08)"SA:");
+		usart_write_U08(SA_mux_val,2);
+		usart_write_str((pU08)" Sensor:");
+		usart_write_U08((SA_mux_val % 8)+1,2);
+		usart_write_str((pU08)" an Temperatur_");
+		switch (SA_mux_val / 8)
+		{
+			case 0: usart_write_str((pU08)"C");
+			break;
+			case 1: usart_write_str((pU08)"D");
+			break;
+			case 2: usart_write_str((pU08)"A");
+			break;
+			case 3: usart_write_str((pU08)"B");
+			break;
+			case 4: usart_write_str((pU08)"G");
+			break;
+			case 5: usart_write_str((pU08)"H");
+			break;
+			case 6: usart_write_str((pU08)"E");
+			break;
+			case 7: usart_write_str((pU08)"F");
+			break;
+			default: usart_write_str((pU08)"alarm!");
+			break;
+		}
+//		usart_write_str((pU08)"\n");
+		usart_write_str((pU08)"  ");
+
+
+		startconv(0);
+
+	
+		while (!AD7719_IS_READY())
+		{
+		// just wait until ADC is redy -- really bad code here!
+		}	    			
+ 		
+		resistance = getresistance();
+							//Start a new A/D Conversion
+    	//temp = 	readandsendtemp();
+		//adcword = getadc();
+		
+		//temperature = gettemp();
+		usart_write_str((pU08)"R:");
+		usart_write_float(resistance,3,4);
+		usart_write_str((pU08)"kOhm ");
+		
+		//_delay_ms(200);
+
+		startconv(0);
+
+		while (!AD7719_IS_READY())
+		{
+		// just wait until ADC is redy -- really bad code here!
+		}	    			
+   		//Start a new A/D Conversion
+    	//temp = 	readandsendtemp();
+		//adcword = getadc();
+		resistance = getresistance();
+		//temperature = gettemp();
+		usart_write_str((pU08)"R:");
+		usart_write_float(resistance,3,4);
+		usart_write_str((pU08)"kOhm ");			
+
+//usart_write_str((pU08)"\n");
+switch (SA_mux_val)
+		{
+			case 7: usart_write_str((pU08)"\n\n");
+			break;
+			case 15: usart_write_str((pU08)"\n\n");
+			break;
+			case 23: usart_write_str((pU08)"\n\n");
+			break;
+			case 31: usart_write_str((pU08)"\n\n");
+			break;
+			case 39: usart_write_str((pU08)"\n\n");
+			break;
+			case 47: usart_write_str((pU08)"\n\n");
+			break;
+			case 55: usart_write_str((pU08)"\n\n");
+			break;
+			case 63: usart_write_str((pU08)"\n\n");
+			break;
+			default: usart_write_str((pU08)"\n");
+			break; 
+		}
+SB_mux_val = 0;
+}
+else if (Res_or_Volt == 148) Res_or_Volt = 0;
+else {
+
+
+		++SB_mux_val;		
+		if (SB_mux_val == 84) SB_mux_val = 0;
+		else if (SB_mux_val == 74) SB_mux_val = 82;
+		else if (SB_mux_val == 82) SB_mux_val = 72;
+		else if (SB_mux_val == 72) SB_mux_val = 74;
+		else if (SB_mux_val == 48) SB_mux_val = 64;
+		else if (SB_mux_val == 64) SB_mux_val = 32;
+		else if (SB_mux_val == 32) SB_mux_val = 48;
+		PORTC = (SB_mux_val & 0x7F);
+ 
+
+
+
+usart_write_str((pU08)"8bit-ADC: ");
+
+if (SB_mux_val < 64)
+{
+		switch (SB_mux_val / 16)
+		{
+			case 0: usart_write_str((pU08)"voltage_A: ");
+			break;
+			case 1: usart_write_str((pU08)"voltage_B: ");
+			break;
+			case 2: usart_write_str((pU08)"voltage_D: ");
+			break;
+			case 3: usart_write_str((pU08)"voltage_C: ");
+			break;
+		}
+
+		if (SB_mux_val % 2 == 0) {
+			usart_write_str((pU08)"U");
+			usart_write_U08( (SB_mux_val%16)/2 , 1 );
+		} else {
+			usart_write_str((pU08)"I");
+			usart_write_U08( ((SB_mux_val%16)-1)/2 , 1 );
+		}
+
+
+} else {
+
+
+	if (SB_mux_val < 72)  {
+		usart_write_str((pU08)"voltage_E: ");
+		if (SB_mux_val % 2 == 0) {
+			usart_write_str((pU08)"U");
+			usart_write_U08( (SB_mux_val%8)/2 , 1 );
+		} else {
+			usart_write_str((pU08)"I");
+			usart_write_U08( ((SB_mux_val%8)-1)/2 , 1 );
+		}
+
+	}
+else if (SB_mux_val == 72) usart_write_str((pU08)"humidity_A: H0");
+else if (SB_mux_val == 73) usart_write_str((pU08)"humidity_A: H1");
+
+else if (SB_mux_val < 82) {
+		usart_write_str((pU08)"voltage_F: ");
+		if (SB_mux_val % 2 == 0) {
+			usart_write_str((pU08)"U");
+			usart_write_U08( ((SB_mux_val-2)%8)/2 , 1 );
+		} else {
+			usart_write_str((pU08)"I");
+			usart_write_U08( (((SB_mux_val-2)%8)-1)/2 , 1 );
+		}
+
+	}
+else if (SB_mux_val == 82) usart_write_str((pU08)"humidity_B: H0");
+else if (SB_mux_val == 83) usart_write_str((pU08)"humidity_B: H1");
+}
+
+for (U08 counter = 0; counter < 1; ++counter) {
+	while (ADCSRA & (1<<ADSC) );    // wait until internal ADC is ready
+	float voltage;
+	voltage = ( (float)ADCH ) / 256 * 4.096;
+	usart_write_str((pU08)" ");
+	usart_write_float(voltage,3,4);
+
+
+}
+//usart_write_str((pU08)"\n");
+
+switch (SB_mux_val)
+		{
+			case 15: usart_write_str((pU08)"\n\n");
+			break;
+			case 31: usart_write_str((pU08)"\n\n");
+			break;
+			case 47: usart_write_str((pU08)"\n\n");
+			break;
+			case 63: usart_write_str((pU08)"\n\n");
+			break;
+			case 71: usart_write_str((pU08)"\n\n");
+			break;
+			case 73: usart_write_str((pU08)"\n\n");
+			break;
+			case 81: usart_write_str((pU08)"\n\n");
+			break;
+			case 83: usart_write_str((pU08)"\n\n");
+			break;
+			default: usart_write_str((pU08)"\n");
+			break; 
+		}
+
+SA_mux_val = 15;
+}		
+	/*	
+		if ( usart_rx_ready == TRUE )
+		{
+			//understand what it means and react
+			
+			switch (usart_rx_buffer[0])
+			{
+				
+				case 'h':
+				{
+					// toggle the heartbeat mode on or off.
+					heartbeat_enable = !heartbeat_enable;
+					break;
+				}
+				case 'a':
+				{
+					// conduct adc - AD7719 SPI interface test
+					
+					break;
+				}
+				case 'e':
+				{
+					// conduct ethernet module SPI interface test
+					strtol((char*) usart_rx_buffer+1, NULL, 0);
+					break;
+				}
+
+				default:
+				{
+					usart_write_str((pU08)"? you wrote: ");
+					usart_write_str((pU08)usart_rx_buffer);
+					usart_write_str((pU08)"\n");
+					break;
+				}
+			}
+			
+			heartbeat_enable = !heartbeat_enable;
+			usart_rx_ready = FALSE;
+		}
+*/
+// das ist ein paar schritte zu früh.
+// erstmal müssen die interfaces getestet werden.
+/*
+
+		for (U08 i = 0; i<16; i++)
+	  	{ 
+			
+	   		if((~PIND) & 0x08)  // PD4 is #ADC_RDY input. Inverted logic! if PD4=0 this evaluates to true					
+	    	{		
+				PORTA = (PORTA & 0xF0) | ((i) & 0x0F); 	// switch muxer
+		   		startconv();							//Start a new A/D Conversion
+		    	//temp = 	readandsendtemp();
+				//adcword = getadc();
+				//resistance = getresistance();
+				temperature = gettemp();
+				usart_write_float(temperature,2,4);
+				usart_write_str((pU08)"\t");
+
+			} // end of if adc ready
+			else
+			{
+			i--;
+			}
+		} // end of for loop over 16 channels
+		usart_write_crlf();
+
+*/
+
+ 	}	// end of infinite while loop
+} // end of main()
+
+
+ISR (TIMER2_COMP_vect)
+{
+ ++local_ms;
+}
+
+
+U08	increase_adc (U08 channel){
+bool valid_ch_found = false;
+	while (!valid_ch_found){
+	
+		// just increase 'channel' or turnover to zero.
+		++channel;
+		if (channel == V_CHANNELS + I_CHANNELS + H_CHANNELS)
+			channel = 0;
+	
+		// check if this channel is enabled in the bitmap
+		if (adc_enables[channel/8] & (1<<channel%8))
+			valid_ch_found = true;
+	} // end of while loop
+	return channel;
+} // end if increase_adc;
+
+U08	increase_ad7719 (U08 channel){
+bool valid_ch_found = false;
+	while (!valid_ch_found){
+	
+		// just increase 'channel' or turnover to zero.
+		++channel;
+		if (channel == TEMP_CHANNELS)
+			channel = 0;
+	
+		// check if this channel is enabled in the bitmap
+		if (ad7719_enables[channel/8] & (1<<channel%8))
+			valid_ch_found = true;
+	} // end of while loop
+	return channel;
+} // end if increase_adc;
+
+
+// Sets voltage Muxer to current channel
+// this is a Muxing, and therefor the adc might need some time to settle.
+// Since there are:
+//	- 40 voltage monitor channels
+// 	- 40 current monitor channels
+// 	- 4 humidity monitor channels
+// the muxer is set as follows.
+// channel 00..39 --> looking at the voltage channels
+// channel 40..79 --> looking at the current channels
+// channel 80..83 --> looking at the humidities
+void Set_V_Muxer (U08 channel){
+U08 SB = 0;
+	// voltages
+	if (channel < 40) {
+		if (channel < 36)
+			SB = channel*2;
+		else
+			SB = (channel+1)*2;
+	}
+	// currents
+	else if (channel < 80) {
+		channel -= 40;
+		if (channel < 36)
+			SB = channel*2+1;
+		else
+			SB = (channel+1)*2+1;
+	}
+	// humidities
+	else if (channel < 84) {
+		channel -= 80;
+		switch (channel) {
+			case 0:
+				SB = 0x48; //0100.1000
+				break;
+			case 1:
+				SB = 0x49; //0100.1001
+				break;
+			case 2:
+				SB = 0x58; //0101.0010
+				break;
+			case 3:
+				SB = 0x58; //0101.0011
+				break;
+		} // end of switch-case
+	} // end of if (channel < some_number)
+
+	PORTC = (PORTC & 0x80) | (0x7F & SB); // Here the muxer is switched.
+}
+
+void Set_T_Muxer(U08 channel) {
+U08 SA = 0x00;
+
+	switch (channel/16) {
+		case 0:
+			SA |= 1<<4; // 0001.0000
+			break;
+		case 1:
+			break;		// 0000.0000
+		case 2:
+			SA |= (1<<4)|(1<<5); // 0011.0000
+			break;
+		case 3:
+			SA |= 1<<5;  // 0010.0000
+			break;
+	}
+	
+	SA =  SA | (channel%16);
+	
+	PORTA = (PORTA & 0xC0) | (0x3F & SA); // Here the muxer is switched.
+}
+
+void talk(void){
+
+/*
+// makes no sense to declare the 'new_measurement' vars here
+// but maybe the whole function will be deleted, anyway ...
+// I'm thinking about it.
+bool ad7719_new_measurement;
+bool atmega_adc_new_measurement;
+	if (verbose == true) { 
+		// somebody wants to read every new measured value, even if it is trash!
+			// do not actually send away data !
+			// just prepare the data to be send away.
+		if ( ad7719_new_measurement  == true ) {
+			add_str_to_output_stream("ad7719: reading:");
+			add_dec_to_output_stream(reading_since_last_muxer_switch,1);
+			add_str_to_output_stream(" temperature channel:");
+			add_dec_to_output_stream(current_temperature_channel,2);
+			add_str_to_output_stream(" = ");
+			add_float_to_output_stream(current_ad7719_value,4,3);
+			add_str_to_output_stream("\n");
+		}
+		if (atmega_adc_new_measurement == true) {
+			add_str_to_output_stream("atmega_adc: reading:");
+			add_dec_to_output_stream(reading_since_last_muxer_switch,1);
+			add_str_to_output_stream(" voltage channel:");
+			add_dec_to_output_stream(current_voltage_channel,2);
+			add_str_to_output_stream(" = ");
+			add_float_to_output_stream(current_atmega_adc_value,4,3);
+			add_str_to_output_stream("\n");
+		}
+	} // end of: if verbose
+*/
+} // end of talk()
+
+// this function generates some output.
+void ad7719_output(U08 channel, U32 data) {
+float value = 0;
+	usart_write_str((pU08)"R:"); //R for resistance
+	usart_write_char('A'+channel/8); // Letters A,B,C,D,E,F,G,H
+	//usart_write_char(' '); 
+	usart_write_U08(channel%8+1,1); // Numbers 1...8
+	usart_write_char(':'); 
+	
+
+	value = (6.25 * data) / ((U32)1 << 25);
+	usart_write_float(value, 3,6);
+	//usart_write_U32_hex(data); //data
+
+
+}
+
+void adc_output(U08 channel, U08 data) {
+
+//	if (channel < 40) 
+//		usart_write_str((pU08)"V:"); 
+//	else if (channel < 80)
+//		usart_write_str((pU08)"I:"); 
+//	else if (channel < 84)
+//		usart_write_str((pU08)"H:"); 
+
+	if (channel <80)
+	{
+		switch ((channel%40)/4) {
+			case 0:
+			case 1:
+				usart_write_char('A'); 
+			break;
+			case 2:
+			case 3:
+				usart_write_char('B');
+				break;
+			case 4:
+			case 5:
+				usart_write_char('C'); 
+				break;
+			case 6:
+			case 7:
+				usart_write_char('D'); 
+				break;
+			case 8:
+				usart_write_char('E');
+				break;
+			case 9:
+				usart_write_char('F');
+				break;
+			default:
+				usart_write_char('?');
+				break;
+			}
+	}
+	else // channel 80..83
+	{
+		usart_write_char('H');
+	}
+	//usart_write_char(' '); 
+	
+	if ( (channel%40)/4 == 9)
+		usart_write_U08((channel)%4+1,1); // Numbers 1...4
+	else
+		usart_write_U08((channel)%8+1,1); // Numbers 1...8
+	
+	
+	//usart_write_U08(channel,2); // Numbers 1...8
+	usart_write_char(':'); 
+	usart_write_U16((U16)data*16, 4); //data
+}
+
+
+void adc_output_all() {
+	print_adc_nicely();
+	print_ad7719_nicely();
+}
+
+
+// this method parses the data, 
+// which came in via USART
+// later it might as well parse the data from ethernet.
+void parse() {
+U08 command = usart_rx_buffer[0];
+// look at first byte
+// I hope, I can manage to use one byte commands
+	usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
+	usart_write_str((pU08)"got:");
+	usart_write_str(usart_rx_buffer);
+	
+	
+
+	switch (command) {
+		case 'E': 	// AD7719 enable bitmaps may be set
+		usart_write_str((pU08)"\n set enable bits of AD7719 Port ");
+			if ((usart_rx_buffer_index>=5) && 
+			(usart_rx_buffer[2] >= 'A' && usart_rx_buffer[2] <= 'H'))
+			{
+			usart_write_char(usart_rx_buffer[2]);
+			usart_write_str((pU08)" to ");
+			usart_write_U08_hex(usart_rx_buffer[4]);
+			usart_write_char('\n');
+				ad7719_enables[usart_rx_buffer[2]-'A']=usart_rx_buffer[4];
+				ad7719_channels_ready[usart_rx_buffer[2]-'A']=0x00;
+			}
+			else if  ((usart_rx_buffer_index=3) && 
+			(usart_rx_buffer[1] >= 'A' && usart_rx_buffer[1] <= 'H'))
+			{
+				usart_write_char(usart_rx_buffer[1]);
+				if (usart_rx_buffer[2]!='0') {
+					usart_write_str((pU08)" to 0xFF\n");
+					ad7719_enables[usart_rx_buffer[1]-'A']=0xFF;
+				} else
+				{
+					usart_write_str((pU08)" to 0x00\n");
+					ad7719_enables[usart_rx_buffer[1]-'A']=0x00;
+				}
+				ad7719_channels_ready[usart_rx_buffer[1]-'A']=0x00;	
+			}
+			else
+			{
+				usart_write_str((pU08)"\n something wrong\n");
+				usart_write_str((pU08)"usart_rx_buffer_index: ");
+				usart_write_U08(usart_rx_buffer_index, 3);
+				usart_write_str((pU08)"\n usart_rx_buffer[2]: ");
+				usart_write_char(usart_rx_buffer[2]);
+				usart_write_str((pU08)"\n usart_rx_buffer[4]: ");
+				usart_write_U08_hex(usart_rx_buffer[4]);
+				usart_write_char('\n');
+			}
+			break;
+		case 'e':	// ATmega internal ADC enable bitmaps may be set
+			usart_write_str((pU08)"\n setting ADC enable registers all");
+			if (usart_rx_buffer[1] == '0'){
+				usart_write_str((pU08)"OFF \n");
+				for ( U08 i=0; i<V_BITMAP + I_BITMAP; ++i ) {
+				adc_enables[i]=0x00;
+				adc_channels_ready[i]=0;
+			}
+				adc_enables[V_BITMAP + I_BITMAP + H_BITMAP -1] = 0x00;
+				adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP -1]=0;
+			} else {
+				usart_write_str((pU08)"ON\n");
+				for ( U08 i=0; i<V_BITMAP + I_BITMAP; ++i ) {
+				adc_enables[i]=0xFF;
+				adc_channels_ready[i]=0;
+			}
+				adc_enables[V_BITMAP + I_BITMAP + H_BITMAP -1] = 0x0F;
+				adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP -1]=0;
+			}
+			
+			
+			break;
+		case 'h':
+			usart_write_str((pU08)"\nheartbeat ");
+			heartbeat_enable = true;
+			if (usart_rx_buffer[1] == '0'){
+				heartbeat_enable = false;
+				usart_write_str((pU08)"off\n");
+			} else {
+				usart_write_str((pU08)"on\n");
+			}
+			break;
+		case 'G': 			// GET the Temperature channels, which are enabled
+			once_told_you = false;
+			for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+				ad7719_channels_ready[i]=0;
+			}
+			break;
+		case 'g':			// GET the voltage/current/humidity channels, which are enabled
+			once_told_you = false;
+			for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
+				adc_channels_ready[i]=0;
+			}
+			break;
+
+		case 'Q':
+			for (U08 i=0; i< TEMP_CHANNELS;++i) {
+				if (i%8 == 0) usart_write_char('\n');
+				usart_write_U32_hex(ad7719_values[i]);
+				usart_write_char('\t');
+			}
+			usart_write_char('\n');
+			break;
+
+		case 'q':
+			// output:	U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS];
+			for (U08 i=0; i< V_CHANNELS + I_CHANNELS + H_CHANNELS;++i) {
+				if (i%8 == 0) usart_write_char('\n');
+				usart_write_U16(adc_values[i]*16, 5);
+				usart_write_char('\t');
+			}
+			usart_write_char('\n');
+			break;
+
+		case 'P':
+			print_ad7719_nicely();
+			break;
+			
+		case 'p':
+			print_adc_nicely();
+			break;
+
+		case 'T':
+			print_temp_nicely();
+			break;
+
+
+		case 's':
+			
+			usart_write_str((pU08)"adc status:\n");
+			for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i) {
+				usart_write_U08_bin(adc_enables[i]);	
+				usart_write_char(' ');
+			}
+			usart_write_char('\n');
+			for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i){
+				usart_write_U08_bin(adc_channels_ready[i]);
+				usart_write_char(' ');
+			}
+			usart_write_char('\n');
+		
+			usart_write_str((pU08)"ad7719 status:\n");
+			for (U08 i=0; i< CHANNEL_BITMAP;++i) {
+				usart_write_U08_bin(ad7719_enables[i]);
+				usart_write_char(' ');
+			}
+			usart_write_char('\n');
+			for (U08 i=0; i< CHANNEL_BITMAP;++i){
+				usart_write_U08_bin(ad7719_channels_ready[i]);
+				usart_write_char(' ');
+			}
+			usart_write_char('\n');
+				
+			usart_write_str((pU08)"time:");
+			usart_write_float((float)local_ms/1000 , 1,7);
+			usart_write_str((pU08)" sec.\n");
+			
+			usart_write_str((pU08)"adc measured all: ");
+			if (adc_measured_all)
+				usart_write_str((pU08)" true\n");
+			else
+				usart_write_str((pU08)"false\n");
+
+			usart_write_str((pU08)"ad7719 measured all: ");
+			if (ad7719_measured_all)
+				usart_write_str((pU08)" true\n");
+			else
+				usart_write_str((pU08)"false\n");
+			
+			usart_write_str((pU08)"adc current channel:");
+			usart_write_U08(adc_current_channel,2);
+			usart_write_char('\n');
+			
+			usart_write_str((pU08)"ad7719 current channel:");
+			usart_write_U08(ad7719_current_channel,2);
+			usart_write_char('\n');
+			break;	
+
+		case 'd':
+			usart_write_str((pU08)"\ndebug mode ");
+			debug_mode = true;
+			if (usart_rx_buffer[1] == '0'){
+				debug_mode = false;
+				usart_write_str((pU08)"off\n");
+			} else {
+				usart_write_str((pU08)"on\n");
+			}
+			break;		
+	}
+	
+	
+	usart_write_str((pU08)"\nready?");
+	for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
+		usart_rx_buffer[i] = 0;
+}
+
+void check_if_measured_all() {
+	adc_measured_all = true;
+	for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
+		if ((adc_enables[i] ^ adc_channels_ready[i]) != 0x00) {
+			adc_measured_all = false;
+			break;
+		}
+	}
+	ad7719_measured_all = true;
+	for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+		if ((ad7719_enables[i] ^ ad7719_channels_ready[i]) != 0x00) {
+			ad7719_measured_all = false;
+			break;
+		}
+	}
+
+
+}
+
+void print_ad7719_nicely() 
+{
+	float value;
+
+		usart_write_str((pU08)"\n printing measured resistance in kohms:\n");
+
+	for (U08 i=0; i< TEMP_CHANNELS;++i) {
+		if (i%8 == 0) usart_write_char('\n');
+
+		// print channel name:
+		usart_write_str((pU08)"R:"); //R for resistance
+		usart_write_char('A'+i/8); // Letters A,B,C,D,E,F,G,H
+		//usart_write_char(' '); 
+		usart_write_U08(i%8+1,1); // Numbers 1...8
+		usart_write_char(':'); 
+
+		// check if this channel is enabled in the bitmap
+		if (ad7719_enables[i/8] & (1<<i%8))
+		{
+			value = (6.25 * 1.024 * ad7719_values[i]) / ((U32)1 << 25);
+			usart_write_float(value, 3,6);
+			//usart_write_U32(ad7719_values[i],8);
+			//usart_write_U32_hex(data); //data
+			usart_write_str((pU08)"  ");	
+		} else {
+			usart_write_str((pU08)"        ");	
+		}
+		//usart_write_char('\n');
+	}
+}
+
+void print_adc_nicely() {
+	usart_write_str((pU08)"\n printing voltages in mV:\n");
+	// output:	U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS];
+	for (U08 i=0; i< V_CHANNELS + I_CHANNELS + H_CHANNELS;++i) {
+	if (i%8 == 0) usart_write_char('\n');
+
+	if (i==0)
+		usart_write_str((pU08)"voltages:\n");
+	if (i==40)
+		usart_write_str((pU08)"currents in mV :-) :\n");
+	if (i==80)
+		usart_write_str((pU08)"humiditiesin mV :-) :\n");
+
+
+		
+		adc_output(i, adc_values[i]);
+		usart_write_str((pU08)"   ");
+	}
+	usart_write_char('\n');
+}
+
+
+void print_temp_nicely() 
+{
+	float temp;
+
+		usart_write_str((pU08)"\n printing measured temperature in °C:\n");
+
+	for (U08 i=0; i< TEMP_CHANNELS;++i) {
+		if (i%8 == 0) usart_write_char('\n');
+
+		// print channel name:
+		usart_write_str((pU08)"T:"); //R for resistance
+		usart_write_char('A'+i/8); // Letters A,B,C,D,E,F,G,H
+		//usart_write_char(' '); 
+		usart_write_U08(i%8+1,1); // Numbers 1...8
+		usart_write_char(':'); 
+
+		// check if this channel is enabled in the bitmap
+		if (ad7719_enables[i/8] & (1<<i%8))
+		{
+			temp = calc_temp(ad7719_values[i]);
+			usart_write_float(temp, 3,6);
+			//usart_write_U32(ad7719_values[i],8);
+			//usart_write_U32_hex(data); //data
+			usart_write_str((pU08)"  ");	
+		} else {
+			usart_write_str((pU08)"        ");	
+		}
+		//usart_write_char('\n');
+	}
+}
Index: firmware/FSC/usb_src/ad7719_adc.c
===================================================================
--- firmware/FSC/usb_src/ad7719_adc.c	(revision 10754)
+++ firmware/FSC/usb_src/ad7719_adc.c	(revision 10754)
@@ -0,0 +1,157 @@
+//-----------------------------------------------------------------------------
+
+#include "ad7719_adc.h"       
+#include "spi_master.h"    
+
+//-----------------------------------------------------------------------------
+
+void ad7719_init(void)
+{
+
+	// ADC communiaction works like this:
+	// a write operation to the COM register takes place - telling the device what up next.
+	// a write or read operation to another register takes place
+	// COM register bits have the following meaning:
+	//
+	// |  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  |
+	// |#WEN |R/#W | zero| zero|  A3 |  A2 |  A1 |  A0 |
+	//
+	// #WEN (inversed write enable) must be zero inorder to clock more bits into the SPI interface.
+	// R/#W (read / not write) must be zero if the next operation will be a WRITE. one if the next is READ.
+	// A3-A0 denote the address of the next register.
+
+  
+  CLR_BIT(ADC_PRT,ADC_RST);		// Reset ADC (active low) 	
+  SET_BIT(ADC_PRT,ADC_RST);		// Stop Reset ADC
+
+
+  CLR_BIT(PORTD,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(FILTER_RD); // Next Operation is write to IOCON
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(0); // Next Operation is write to IOCON
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(IOCON_WR); // Next Operation is write to IOCON
+  SET_BIT(PORTD,SPI_AD_CS);
+  
+  _delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);
+  spi_transfer_byte(IOCON_INIT_HIGH);  	// Write to IOCON1 
+  SET_BIT(PORTD,SPI_AD_CS);
+_delay_us(50);
+  CLR_BIT(PORTD,SPI_AD_CS);
+  spi_transfer_byte(IOCON_INIT_LOWBYTE);  	// Write to IOCON2 
+  SET_BIT(PORTD,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(FILTER_WR);     	// Next Operation is write to FILTER  Start SPI
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+  CLR_BIT(PORTD,SPI_AD_CS);
+
+  spi_transfer_byte(FILTER_INIT);  	// Write to FILTER 
+  SET_BIT(PORTD,SPI_AD_CS);	// Set CS high
+_delay_us(50);
+  CLR_BIT(PORTD,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(AD1CON_WR);     	// Next Operation is write to AD1CON  Start SPI
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);
+  spi_transfer_byte(AD1CON_INIT);  	// Write to AD1CON
+  SET_BIT(PORTD,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(AD0CON_WR);     	// Next Operation is write to AD0CON  Start SPI
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);
+  spi_transfer_byte(AD0CON_INIT);  	// Write to AD0CON
+  SET_BIT(PORTD,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(MODE_WR);     	// Next Operation is write to MODE Start SPI
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);
+  spi_transfer_byte(MODE_CONT);  	// Write to MODE
+  SET_BIT(PORTD,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(FILTER_RD); // Next Operation is write to IOCON
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTD,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(0); // Next Operation is write to IOCON
+  SET_BIT(PORTD,SPI_AD_CS);
+
+_delay_us(50);
+
+
+} 
+          
+void startconv(U08 continuous)
+{
+	CLR_BIT(PORTD,SPI_AD_CS);       // Set CS low
+	spi_transfer_byte(MODE_WR);        // Next Operation is write to Mode Register
+  SET_BIT(PORTD,SPI_AD_CS);
+  CLR_BIT(PORTD,SPI_AD_CS);
+	if (continuous)	spi_transfer_byte(MODE_SINGLE);	 // Start new A/D conversion
+	else spi_transfer_byte(MODE_CONT);	 // Start continous conversion mode
+	SET_BIT(PORTD,SPI_AD_CS);  
+}
+
+void stopconv(void)
+{
+	CLR_BIT(PORTD,SPI_AD_CS);       // Set CS low
+	spi_transfer_byte(MODE_WR);        // Next Operation is write to Mode Register
+    SET_BIT(PORTD,SPI_AD_CS);
+    CLR_BIT(PORTD,SPI_AD_CS);
+	spi_transfer_byte(MODE_IDLE);
+	SET_BIT(PORTD,SPI_AD_CS);  
+}
+
+
+U32 read_adc(void)
+{ 
+	CLR_BIT(PORTD,SPI_AD_CS);       // Set CS low
+	spi_transfer_byte(AD0DAT_RD);   // Next Operation is read from Main ADC Data Register
+    SET_BIT(PORTD,SPI_AD_CS);
+	_delay_us(50);
+
+    CLR_BIT(PORTD,SPI_AD_CS);
+	U32 value=0; 					// actually a 24bit value is returned
+	value |= spi_transfer_byte(0) ;
+	value =value<<8;
+	value |= spi_transfer_byte(0) ;
+	value =value<<8;
+	value |= spi_transfer_byte(0) ;
+	SET_BIT(PORTD,SPI_AD_CS);	// Set CS high
+	return value;                                                                                                 
+}   
+  
+  
Index: firmware/FSC/usb_src/ad7719_adc.h
===================================================================
--- firmware/FSC/usb_src/ad7719_adc.h	(revision 10754)
+++ firmware/FSC/usb_src/ad7719_adc.h	(revision 10754)
@@ -0,0 +1,95 @@
+#ifndef __AD7719_ADC_H
+#define __AD7719_ADC_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "num_conversion.h"
+//-----------------------------------------------------------------------------
+// Bit Definitions
+#define ADC_RDY PD6
+#define ADC_RST PD7
+#define AD7719_IS_READY() (!(PIND & (1<<PD6))) // TRUE if PD6=0 AD_RDY is inverted logic.
+
+// Port Definitions
+#define ADC_PRT PORTD
+#define ADC_DDR DDRD
+#define ADC_PIN PIND
+
+
+// ON CHIP REGISTER ADDRESSES
+#define STATUS_RD 0x40
+
+#define MODE_WR 0x01
+#define MODE_RD 0x41
+
+#define AD0CON_WR 0x02
+#define AD0CON_RD 0x42
+
+#define AD1CON_WR 0x03
+#define AD1CON_RD 0x43
+
+#define FILTER_WR 0x04
+#define FILTER_RD 0x44
+
+#define AD0DAT_RD 0x45
+#define AD1DAT_RD 0x46
+
+#define IOCON_WR 0x07
+#define IOCON_RD 0x47
+
+#define AD0OFS_WR 0x08
+#define AD0OFS_RD 0x48
+
+#define AD1OFS_WR 0x09
+#define AD1OFS_RD 0x49
+
+#define AD0GAIN_WR 0x0A
+#define AD0GAIN_RD 0x4A
+
+#define AD1GAIN_WR 0x0B
+#define AD1GAIN_RD 0x4B
+
+#define ID_RD 0x4F
+
+// REGISTER INIT VALUES
+
+	//Init Configure and Initialize AD7719
+	//http://designtools.analog.com/dt/adc/codegen/ad7719.html 
+
+#define IOCON_INIT_HIGH 0x03	//0000.0011 // I-sources I1 and I2 are switched on, thats all
+#define IOCON_INIT_LOWBYTE 0x00
+
+#define FILTER_INIT 0x52	//0x52 euro use 50Hz = -171dB and 60Hz = -58dB Rejectjon Updaterate = 4Hz
+											// 0x52=82 decimal. f_ADC=16.6Hz; t_ADC=60ms; t_settle = 120ms
+
+#define AD1CON_INIT 0x31	//0011.0001  	
+	// AD1EN is set --> AUX ADc is used for Temp measurement.
+	// ACH = 011 --> Tempsensor
+	// U/#B = 0 --> bipolar, but i'm not entirely sure if this is correct.
+	// ARN = 1 --> input range is REFIN2 , but when tempsensor is chosen, internal ref is used ... 
+
+#define AD0CON_INIT 0x8E // 1000.1110
+	// AD0EN is set
+	// WL is cleared --> 24bit
+	// CH = 00 --> AIN1 , AIN2 used 
+	// U/#B = 1 --> unipolar
+	// RN=110 --> input range = +-1.28V --> whatever this means in ratiometric measurements.
+
+
+#define MODE_IDLE 0x01
+#define MODE_SINGLE 0x02
+#define MODE_CONT 0x03
+#define MODE_INTERNAL_ZERO_CAL 0x04		// not tested
+#define MODE_INTERNAL_FULL_CAL 0x05		// not tested
+
+// since the ADC is chopped, one should wait 3 conversions
+// after the muxer was switched, until the reading is okay.
+#define READINGS_UNTIL_AD7719_SETTLED 3
+
+void ad7719_init(void);
+void startconv(U08 continuous);
+void stopconv(void);
+U32 read_adc(void);
+//-----------------------------------------------------------------------------
+#endif
Index: firmware/FSC/usb_src/application.c
===================================================================
--- firmware/FSC/usb_src/application.c	(revision 10754)
+++ firmware/FSC/usb_src/application.c	(revision 10754)
@@ -0,0 +1,92 @@
+//-----------------------------------------------------------------------------
+
+#include "application.h"
+#include <avr/wdt.h> 
+
+
+//-----------------------------------------------------------------------------
+
+volatile U08 app_reset_source;
+//-----------------------------------------------------------------------------
+
+void app_init(void)
+{
+  app_reset_source = MCUSR; // Save last reset source
+  MCUSR = 0x00; // Clear reset source for next reset cycle
+
+
+	// Dangerous here: I still do not know much about the watchdog.
+	// This code is still from Udo Juerss. 
+
+  // The watchdog timer is disabled by default ("startup.asm")
+	#ifdef USE_WATCHDOG
+	 WDTCSR = WDTOE | (1 << WDE); // Enable watchdog reset (~16ms)
+	#endif
+
+	// define PORTS
+	// USART
+	DDRD &= ~(1<<PD0);				// PD0 = RXD is input
+	DDRD |= 1<<PD1; 					// PD1 = TXD is output
+	
+
+	// SPARE OUT/-INPUTS
+	DDRB |= (1<<PB2) | (1<<PB3); 	// set Out1_spare & out2_spare as outputs
+	DDRA &= ~(1<<PA7);				// set In1_spare as input
+	DDRC &= ~(1<<PC7);				// set In2_spare as input
+	PORTA |= (1<<PA7); 				// swtich on pullup on In1_spare
+	PORTC |= (1<<PC7); 				// swtich on pullup on In2_spare
+
+	// ATmega internal ADC input 
+	DDRA &= ~(1<<PA6);
+
+	// MUXER ADDRESS OUTs
+	DDRA |= 0x3F; // SA-pins -> output
+	DDRC |= 0x7F; // SB-pins -> output
+
+	// SPI
+	// set all CS's: output
+	DDRB |= (1 << SPI_E_CS);
+	DDRD |= (1 << SPI_AD_CS) |(1 << SPI_M_CS) |(1 << SPI_A_CS);
+
+	// set all Chips selects HIGH
+	PORTB |= (1 << SPI_E_CS);
+	PORTD |= (1 << SPI_AD_CS) |(1 << SPI_M_CS) |(1 << SPI_A_CS);
+
+	// set MOSI and SCK: output & // set MISO: input
+	SPI_DDR |= (1 << SPI_MOSI);
+	SPI_DDR |= (1 << SPI_SCLK);
+	SPI_DDR &= ~(1 << SPI_MISO);
+
+	// set MOSI, SCK: HIGH. MISO leave alone.
+	SPI_PRT |= (1 << SPI_MOSI);
+	SPI_PRT |= (1 << SPI_SCLK);
+	//SPI_PRT |= (1 << SPI_MISO);
+
+	// ADC 
+	DDRD &= ~(1<<PD6);					// PD6 is AD_READY input
+	DDRD |= 1<<PD7;							// PD7 is AD_RESET output
+
+	// ACCELEROMETER
+	DDRD &= ~(1<<PD2);					// PD2 is ACC_READY input
+
+	//MAX6662   <--- not assembled 
+	// DDRB &= ~(1<<PB0); 			// PB0 is over temperature alert input
+	// DDRB &= ~(1<<PB1);				// PB1 is general temperature altert input
+}
+
+
+
+//-----------------------------------------------------------------------------
+
+void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale) // Set watchdog prescale
+{
+  U08 sreg_backup = SREG; // Copy status register to variable
+  U08 wdtcsr_value = WDE + wdt_prescale; // Set new prescale value to variable
+
+  cli(); // Disable interrups
+  wdt_reset(); // Reset watchdog
+
+  WDTCR |= (1 << WDTOE) | (1 << WDE); // Unlock register access, 4 cycles to store new value
+  WDTCR = wdtcsr_value; // Set new watchdog prescaler
+  SREG = sreg_backup; // Restore status register
+}
Index: firmware/FSC/usb_src/application.h
===================================================================
--- firmware/FSC/usb_src/application.h	(revision 10754)
+++ firmware/FSC/usb_src/application.h	(revision 10754)
@@ -0,0 +1,44 @@
+#ifndef __APPLICATION_H
+#define __APPLICATION_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+//-----------------------------------------------------------------------------
+
+#define USART_RX_BUFFER_SIZE 32 // Receive buffer size
+#define USART_TX_BUFFER_SIZE 5 // Receive buffer size. MUST not be larger 255
+
+#define USART_BAUDRATE 9600 // USART baudrate original
+#define USART_USE_TX // Transmitter used?
+#define USART_USE_RX // Receiver used?
+//#define USART_USE_RX_IRQ // RX interrupt used?
+#define USART_USE_UPPERCASE // Convert received chars to uppercase?
+//-----------------------------------------------------------------------------
+
+// SPI DEFINITIONS
+// Port Definitions
+#define SPI_PRT PORTB
+#define SPI_DDR DDRB
+
+// Bit Definitions
+#define SPI_SCLK PB7
+#define SPI_MOSI PB5
+#define SPI_MISO PB6
+
+#define SPI_E_CS PB4 		
+#define SPI_AD_CS PD3 		
+#define SPI_M_CS PD4		
+#define SPI_A_CS PD5		
+
+
+
+
+//-----------------------------------------------------------------------------
+extern volatile U08 app_reset_source;
+//-----------------------------------------------------------------------------
+
+void app_init(void); // Initialize application
+void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale
+//-----------------------------------------------------------------------------
+
+#endif
Index: firmware/FSC/usb_src/atmega_adc.c
===================================================================
--- firmware/FSC/usb_src/atmega_adc.c	(revision 10754)
+++ firmware/FSC/usb_src/atmega_adc.c	(revision 10754)
@@ -0,0 +1,22 @@
+#include "atmega_adc.h"
+#include "typedefs.h"
+
+void atmega_adc_init(void)
+{
+//ADC einschalten
+	ADCSRA |= (1<<ADPS2) | (1<<ADPS1);     // ADC_clk = 125kHz
+	ADCSRA &= ~(1<<ADPS0);
+		// normal conversion takes: 13 adc_clk cycles = 104us
+		// 1st conversion takes longer: 25 clk cycles = 200us
+	ADCSRA |= 1<<ADATE; // autotrigger enable
+	SFIOR &= ~(0xE0);		//ADTS=000 --> free running mode 
+	ADCSRA |= (1<<ADEN);                  // ADC aktivieren
+
+	ADMUX &= ~(1<<REFS0); 
+	ADMUX &= ~(1<<REFS1); 	//REFS = 00 --> use external reference voltage.
+	ADMUX |= 1<<ADLAR;		//ADLAR =1 	--> left adjust ac result in ADCH register --> 8bit resolution only.				
+	ADMUX |= (0x1F & 0x06); //MUX = 0x06 --> Pin ADC6 = PA6 is used as ADC input pin.
+	
+	ADCSRA |= (1<<ADSC); 	// start 1st conversion
+
+}
Index: firmware/FSC/usb_src/atmega_adc.h
===================================================================
--- firmware/FSC/usb_src/atmega_adc.h	(revision 10754)
+++ firmware/FSC/usb_src/atmega_adc.h	(revision 10754)
@@ -0,0 +1,6 @@
+#ifndef __ATMEGA_ADC_H
+#define __ATMEGA_ADC_H
+
+
+void atmega_adc_init(void);
+#endif
Index: firmware/FSC/usb_src/interpol.c
===================================================================
--- firmware/FSC/usb_src/interpol.c	(revision 10754)
+++ firmware/FSC/usb_src/interpol.c	(revision 10754)
@@ -0,0 +1,518 @@
+//-----------------------------------------------------------------------------
+
+#include "interpol.h"
+#include "usart.h"
+#include "ad7719_adc.h" 
+//#include "typedefs.h"
+//#include "application.h"
+#include "num_conversion.h"
+#include "math.h"
+//-----------------------------------------------------------------------------
+/*
+Temperatur Sensoren von IST nach DIN60751, Kl.B 
+Messfehler +/- 0.30+0.005*|t|
+
+R(t) = R0(1 + At + Bt^2 + C(t-100)t^3)  t = [-200, 0]°C
+R(t) = R0(1 + At + Bt^2)				t = [0, 850]°C
+
+A = 3.9083*10^-3[°C^-1]
+B = -5.775*10^-7[°C^-2]
+C = -4.183*10^-12[°C^-4]
+
+Strom durch R ist konstant 400uA
+Intervallweise lineare Interpolation der Funktion R(t) mit MATLAB polyfit
+adcword = 13107200 * u(temperatur)
+*/
+ U08 space_STR[] = "  |";
+ U08 OoR_STR[] = "  OoR  |";
+
+
+
+ float gettemp(void)
+ {
+
+  
+  U8  temprange = 17;
+  U32 adcword=0;
+  float temp=-3.14; // should be initialized in a proper way, but I dont know how :-)
+  const U32 min = 0x404054;
+  const U32 max = 0x8CAF50;
+  const U32 s	= 0x4C6F0;		//(max-min)/16 = s(lice)
+  	
+  adcword = read_adc();
+
+ if  (adcword >= (min + 8*s))
+   {
+     if  (adcword >= (min + 12*s))
+	   {
+	     if  (adcword >= (min + 14*s))
+		   {
+			 if   (adcword >= (min + 15*s)) 
+			   { 
+			     if (adcword < max)
+				   {
+		            temprange = 16;
+				   }
+			   }
+			 else
+			   {
+				 temprange = 15;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 13*s))
+			    {
+				  temprange = 14;
+				}
+			  else
+			    {
+				  temprange = 13;
+				}
+		   }   
+	   }
+	 else
+	   {
+	     if  (adcword >= (min + 10*s))
+		   {
+			 if  (adcword >= (min + 11*s))
+			   {
+				 temprange = 12;
+			   }
+			 else
+			   {
+				 temprange = 11;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 9*s))
+			    {
+				  temprange = 10;
+				}
+			  else
+			    {
+				  temprange = 9;
+				}
+		   }   
+	   }
+   } 
+ else
+ {
+     if  (adcword >= (min + 4*s))
+	   {
+	     if  (adcword >= (min + 6*s))
+		   {
+			 if  (adcword >= (min + 7*s))
+			   {
+				 temprange = 8;
+			   }
+			 else
+			   {
+				 temprange = 7;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 5*s))
+			    {
+				  temprange = 6;
+				}
+			  else
+			    {
+				  temprange = 5;
+				}
+		   }   
+	   }
+	 else
+	   {
+	     if  (adcword >= (min + 2*s))
+		   {
+			 if  (adcword >= (min + 3*s))
+			   {
+				 temprange = 4;
+			   }
+			 else
+			   {
+				 temprange = 3;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + s))
+			    {
+				  temprange = 2;
+				}
+			  else
+			    { 
+				  if  (adcword > min)
+				    {
+				      temprange = 1;
+ 					}
+				}
+		   }   
+	   }
+   } 
+
+
+ switch (temprange)
+  {
+    case 1:{ // Temp. Range [-50°C , -34.375°C[
+      temp = ((float)adcword / 20764.727846 - 252.7721); 		//20764.727846 - 252.7721
+	  }
+    break;
+
+    case 2:{ // Temp. Range [-34.375°C , -18.75°C[
+      temp = ((float)adcword / 20658.049789 - 253.8995);		//20658.049789 - 253.8995
+	  }
+    break;
+
+    case 3:{ // Temp. Range [-18.75°C , -3.125°C[		
+      temp = ((float)adcword / 20557.997603 - 255.0436);		//20557.997603 - 255.0436
+	  }
+    break;
+
+    case 4:{ // Temp. Range [-3.125°C , 12.5°C]
+      temp = ((float)adcword / 20462.362624 - 256.2209); 		//20462.362624 - 256.2209
+	  }
+    break;
+
+    case 5:{ // Temp. Range [12.5°C , 28.125°C]
+      temp = ((float)adcword / 20367.745024 - 257.4692);		//20367.745024 - 257.4692
+	  }
+    break;
+	
+    case 6:{ // Temp. Range [28.125°C , 43.75°C]
+      temp = ((float)adcword / 20273.127424 - 258.8021);		//20273.127424 - 258.8021
+	  }
+    break;
+	
+    case 7:{ // Temp. Range [43.75°C , 59.375°C]
+      temp = ((float)adcword / 20178.509824 - 260.2208);		//20178.509824 - 260.2208
+	  }
+    break;
+	
+    case 8:{ // Temp. Range [59.375°C , 75°C]
+      temp = ((float)adcword / 20083.892224 - 261.7265);		//20083.892224 - 261.7265
+	  }
+    break;
+	
+    case 9:{ // Temp. Range [75°C , 90.625°C]
+      temp = ((float)adcword / 19989.274624 - 263.3203);		//19989.274624 - 263.3203
+	  }
+    break;
+	
+    case 10:{ // Temp. Range [90.625°C , 106.25°C]
+      temp = ((float)adcword / 19894.657024 - 265.0037);		//19894.657024 - 265.0037
+	  }
+    break;
+	
+    case 11:{ // Temp. Range [106.25°C , 121.875°C]
+      temp = ((float)adcword / 19800.039424 - 266.7778);		//19800.039424 - 266.7778
+	  }
+    break;
+	
+    case 12:{ // Temp. Range [121.875°C , 137.5°C]
+      temp = ((float)adcword / 19705.421824 - 268.6439);		//19705.421824 - 268.6439
+	  }
+    break;
+	
+    case 13:{ // Temp. Range [137.5°C , 153.125°C]
+      temp = ((float)adcword / 19610.804224 - 270.6035);		//19610.804224 - 270.6035
+	  }
+    break;
+	
+    case 14:{ // Temp. Range [153.125°C , 168.75°C]
+      temp = ((float)adcword / 19516.186624 - 272.6578);		//19516.186624 - 272.6578
+	  }
+    break;
+	
+    case 15:{ // Temp. Range [168.75°C , 184.375°C]
+      temp = ((float)adcword / 19421.569024 - 274.8082);		//19421.569024 - 274.8082
+	  }
+    break;
+	
+    case 16:{ // Temp. Range [184.375°C , 200°C]
+      temp = ((float)adcword / 19326.951424 - 277.0562);		//19326.951424 - 277.0562
+	  }
+    break;
+    default:{ // Temp. Range beyond [-50C , 200C]
+	  PORTC = (PORTC | 0x04);
+	  }
+  }// end of switch case statement
+  return temp;
+
+ }
+
+ void readandsendpress(void)
+ {
+  U32 adcword=0;
+  float press;
+
+  adcword = read_adc();
+
+ if ( (adcword > 0x253332) && (adcword < 0xF80000) ) // Press. Range is [0Bar , 250Bar]
+   {
+    press = ((float)adcword / (62 * 836.658790402)) - 63.0091; // 62 Ohm
+	usart_write_float(press,2,5);
+	usart_write_flash_str(space_STR);
+   } 
+ else
+   {
+	usart_write_flash_str(OoR_STR);  // Press. is beyond [0Bar , 250Bar]
+    PORTC = (PORTC | 0x04);
+   }
+
+ }
+
+
+/*
+Temperatur Sensoren von IST nach DIN60751, Kl.B 
+Messfehler +/- 0.30+0.005*|t|
+
+R(t) = R0(1 + At + Bt^2 + C(t-100)t^3)  t = [-200, 0]°C
+R(t) = R0(1 + At + Bt^2)				t = [0, 850]°C
+
+A = 3.9083*10^-3[°C^-1]
+B = -5.775*10^-7[°C^-2]
+C = -4.183*10^-12[°C^-4]
+
+Strom durch R ist konstant 400uA
+Messung ist ratiometrisch bezogen auf Referenzwiderstand an ADC Pin5 (REFIN-) und Pin6 (REFIN+)
+Referenzwiderstand ist ca. 6.28kOhm.
+ADC hat internes gain von 2.
+
+*/
+
+float getresistance(void)
+{
+  
+  U32 adcword=0;
+  float resistance;
+  const float R_REF=6.25; // kilo-ohms	
+  adcword = read_adc();
+  U32 fullscale = 16777215L; //2^24 -1
+  
+  resistance = ((float)adcword / (float)fullscale) /2.0 * R_REF; // divide through 2.0 because of PGA in ADC.
+
+  return resistance; // in kilo-ohms
+}
+
+U32 getadc(void) 
+{
+return read_adc();
+}
+
+
+ float calc_temp(U32 adcword)
+ {
+  U8  temprange = 17;
+  
+  float temp=NAN;
+  const U32 min = 0x404054;
+  const U32 max = 0x8CAF50;
+  const U32 s	= 0x4C6F0;		//(max-min)/16 = s(lice)
+
+ if  (adcword >= (min + 8*s))
+   {
+     if  (adcword >= (min + 12*s))
+	   {
+	     if  (adcword >= (min + 14*s))
+		   {
+			 if   (adcword >= (min + 15*s)) 
+			   { 
+			     if (adcword < max)
+				   {
+		            temprange = 16;
+				   }
+			   }
+			 else
+			   {
+				 temprange = 15;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 13*s))
+			    {
+				  temprange = 14;
+				}
+			  else
+			    {
+				  temprange = 13;
+				}
+		   }   
+	   }
+	 else
+	   {
+	     if  (adcword >= (min + 10*s))
+		   {
+			 if  (adcword >= (min + 11*s))
+			   {
+				 temprange = 12;
+			   }
+			 else
+			   {
+				 temprange = 11;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 9*s))
+			    {
+				  temprange = 10;
+				}
+			  else
+			    {
+				  temprange = 9;
+				}
+		   }   
+	   }
+   } 
+ else
+ {
+     if  (adcword >= (min + 4*s))
+	   {
+	     if  (adcword >= (min + 6*s))
+		   {
+			 if  (adcword >= (min + 7*s))
+			   {
+				 temprange = 8;
+			   }
+			 else
+			   {
+				 temprange = 7;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + 5*s))
+			    {
+				  temprange = 6;
+				}
+			  else
+			    {
+				  temprange = 5;
+				}
+		   }   
+	   }
+	 else
+	   {
+	     if  (adcword >= (min + 2*s))
+		   {
+			 if  (adcword >= (min + 3*s))
+			   {
+				 temprange = 4;
+			   }
+			 else
+			   {
+				 temprange = 3;
+			   }
+		   }
+		 else
+		   {
+		      if  (adcword >= (min + s))
+			    {
+				  temprange = 2;
+				}
+			  else
+			    { 
+				  if  (adcword > min)
+				    {
+				      temprange = 1;
+ 					}
+				}
+		   }   
+	   }
+   } 
+
+
+ switch (temprange)
+  {
+    case 1:{ // Temp. Range [-50°C , -34.375°C[
+      temp = ((float)adcword / 20764.727846 - 252.7721); 		//20764.727846 - 252.7721
+	  }
+    break;
+
+    case 2:{ // Temp. Range [-34.375°C , -18.75°C[
+      temp = ((float)adcword / 20658.049789 - 253.8995);		//20658.049789 - 253.8995
+	  }
+    break;
+
+    case 3:{ // Temp. Range [-18.75°C , -3.125°C[		
+      temp = ((float)adcword / 20557.997603 - 255.0436);		//20557.997603 - 255.0436
+	  }
+    break;
+
+    case 4:{ // Temp. Range [-3.125°C , 12.5°C]
+      temp = ((float)adcword / 20462.362624 - 256.2209); 		//20462.362624 - 256.2209
+	  }
+    break;
+
+    case 5:{ // Temp. Range [12.5°C , 28.125°C]
+      temp = ((float)adcword / 20367.745024 - 257.4692);		//20367.745024 - 257.4692
+	  }
+    break;
+	
+    case 6:{ // Temp. Range [28.125°C , 43.75°C]
+      temp = ((float)adcword / 20273.127424 - 258.8021);		//20273.127424 - 258.8021
+	  }
+    break;
+	
+    case 7:{ // Temp. Range [43.75°C , 59.375°C]
+      temp = ((float)adcword / 20178.509824 - 260.2208);		//20178.509824 - 260.2208
+	  }
+    break;
+	
+    case 8:{ // Temp. Range [59.375°C , 75°C]
+      temp = ((float)adcword / 20083.892224 - 261.7265);		//20083.892224 - 261.7265
+	  }
+    break;
+	
+    case 9:{ // Temp. Range [75°C , 90.625°C]
+      temp = ((float)adcword / 19989.274624 - 263.3203);		//19989.274624 - 263.3203
+	  }
+    break;
+	
+    case 10:{ // Temp. Range [90.625°C , 106.25°C]
+      temp = ((float)adcword / 19894.657024 - 265.0037);		//19894.657024 - 265.0037
+	  }
+    break;
+	
+    case 11:{ // Temp. Range [106.25°C , 121.875°C]
+      temp = ((float)adcword / 19800.039424 - 266.7778);		//19800.039424 - 266.7778
+	  }
+    break;
+	
+    case 12:{ // Temp. Range [121.875°C , 137.5°C]
+      temp = ((float)adcword / 19705.421824 - 268.6439);		//19705.421824 - 268.6439
+	  }
+    break;
+	
+    case 13:{ // Temp. Range [137.5°C , 153.125°C]
+      temp = ((float)adcword / 19610.804224 - 270.6035);		//19610.804224 - 270.6035
+	  }
+    break;
+	
+    case 14:{ // Temp. Range [153.125°C , 168.75°C]
+      temp = ((float)adcword / 19516.186624 - 272.6578);		//19516.186624 - 272.6578
+	  }
+    break;
+	
+    case 15:{ // Temp. Range [168.75°C , 184.375°C]
+      temp = ((float)adcword / 19421.569024 - 274.8082);		//19421.569024 - 274.8082
+	  }
+    break;
+	
+    case 16:{ // Temp. Range [184.375°C , 200°C]
+      temp = ((float)adcword / 19326.951424 - 277.0562);		//19326.951424 - 277.0562
+	  }
+    break;
+    default:
+		break;
+  }// end of switch case statement
+  return temp;
+
+ }
+
+
Index: firmware/FSC/usb_src/interpol.h
===================================================================
--- firmware/FSC/usb_src/interpol.h	(revision 10754)
+++ firmware/FSC/usb_src/interpol.h	(revision 10754)
@@ -0,0 +1,19 @@
+#ifndef __INTERPOL_H
+#define __INTERPOL_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "num_conversion.h"
+//-----------------------------------------------------------------------------
+
+// function prototype
+
+
+ float gettemp(void);
+ void readandsendpress(void);
+ float getresistance(void);
+ U32 getadc(void);
+ float calc_temp(U32 adcword);
+//-----------------------------------------------------------------------------
+#endif
Index: firmware/FSC/usb_src/macros.h
===================================================================
--- firmware/FSC/usb_src/macros.h	(revision 10754)
+++ firmware/FSC/usb_src/macros.h	(revision 10754)
@@ -0,0 +1,21 @@
+#ifndef __MACROS_H
+#define __MACROS_H
+//-----------------------------------------------------------------------------
+
+#define SET_BIT(byte,bit) (byte |= (1 << bit)) // Set bit in byte
+#define CLR_BIT(byte,bit) (byte &= ~(1 << bit)) // Clear bit in byte
+#define TGL_BIT(byte,bit) (byte ^= (1 << bit)) // Toggle bit in byte
+
+#define IS_SET(reg,bit) (reg & bit) // TRUE if bit = 1
+#define IS_CLR(reg,bit) !(reg & bit) // TRUE if bit = 0
+
+#define BIT(x) (1 << (x)) // Define bit value
+#define HI(x) ((x) >> 8) // Highbyte of 16-bit value
+
+#define ABS(x) ((x >= 0) ? x : -x) // Absolute value of x
+
+#define HI_HEX(x) ("0123456789ABCDEF" [x >> 4]) // Create hex of high nibble
+#define LO_HEX(x) ("0123456789ABCDEF" [x & 0x0F]) // Create hex of low nibble
+//-----------------------------------------------------------------------------
+
+#endif
Index: firmware/FSC/usb_src/muxer_fsc.c
===================================================================
--- firmware/FSC/usb_src/muxer_fsc.c	(revision 10754)
+++ firmware/FSC/usb_src/muxer_fsc.c	(revision 10754)
@@ -0,0 +1,74 @@
+#include "muxer_fsc.h"
+
+// Sets voltage Muxer to current channel
+// this is a Muxing, and therefor the adc might need some time to settle.
+// Since there are:
+//	- 40 voltage monitor channels
+// 	- 40 current monitor channels
+// 	- 4 humidity monitor channels
+// the muxer is set as follows.
+// channel 00..39 --> looking at the voltage channels
+// channel 40..79 --> looking at the current channels
+// channel 80..83 --> looking at the humidities
+void Set_V_Muxer (U08 channel){
+U08 SB = 0;
+	// voltages
+	if (channel < 40) {
+		if (channel < 36)
+			SB = channel*2;
+		else
+			SB = (channel+1)*2;
+	}
+	// currents
+	else if (channel < 80) {
+		channel -= 40;
+		if (channel < 36)
+			SB = channel*2+1;
+		else
+			SB = (channel+1)*2+1;
+	}
+	// humidities
+	else if (channel < 84) {
+		channel -= 80;
+		switch (channel) {
+			case 0:
+				SB = 0x48; //0100.1000
+				break;
+			case 1:
+				SB = 0x49; //0100.1001
+				break;
+			case 2:
+				SB = 0x58; //0101.0010
+				break;
+			case 3:
+				SB = 0x58; //0101.0011
+				break;
+		} // end of switch-case
+	} // end of if (channel < some_number)
+
+	PORTC = (PORTC & 0x80) | (0x7F & SB); // Here the muxer is switched.
+}
+
+void Set_T_Muxer(U08 channel) {
+U08 SA = 0x00;
+
+	switch (channel/16) {
+		case 0:
+			SA |= 1<<4; // 0001.0000
+			break;
+		case 1:
+			break;		// 0000.0000
+		case 2:
+			SA |= (1<<4)|(1<<5); // 0011.0000
+			break;
+		case 3:
+			SA |= 1<<5;  // 0010.0000
+			break;
+	}
+	
+	SA =  SA | (channel%16);
+	
+	PORTA = (PORTA & 0xC0) | (0x3F & SA); // Here the muxer is switched.
+}
+
+
Index: firmware/FSC/usb_src/muxer_fsc.h
===================================================================
--- firmware/FSC/usb_src/muxer_fsc.h	(revision 10754)
+++ firmware/FSC/usb_src/muxer_fsc.h	(revision 10754)
@@ -0,0 +1,19 @@
+// include either muxer_fsc.h or muxer_msr.h
+#ifndef __MUXER_FSC_H
+#define __MUXER_FSC_H
+
+#include "typedefs.h"
+
+	#ifndef __MUXER_XXX_H_
+	#  define __MUXER_XXX_H "muxer_fsc.h"
+	#else
+	#  error "Attempt to include more than one <muxer_xxx.h> file."
+	#endif
+
+	void Set_V_Muxer(U08 channel);
+	void Set_T_Muxer(U08 channel);
+
+
+
+
+#endif
Index: firmware/FSC/usb_src/num_conversion.c
===================================================================
--- firmware/FSC/usb_src/num_conversion.c	(revision 10754)
+++ firmware/FSC/usb_src/num_conversion.c	(revision 10754)
@@ -0,0 +1,378 @@
+//-----------------------------------------------------------------------------
+
+#include "num_conversion.h"
+#include "math.h"
+//-----------------------------------------------------------------------------
+
+//__flash U08 NC_HEX_ARRAY[] = "0123456789ABCDEF";
+U08 NC_HEX_ARRAY[] = "0123456789ABCDEF";
+//-----------------------------------------------------------------------------
+
+U08 nc_buffer[NC_BUFFER_LENGTH]; // Conversion buffer
+U08 nc_format_buffer[NC_BUFFER_LENGTH]; // Format buffer
+
+static U08 nc_int_digits[8];
+static U08 nc_dec_digits[6];
+//-----------------------------------------------------------------------------
+
+pU08 nc_format(pU08 source_ptr,U08 digits)
+{
+  U08 len = strlen((const char *)source_ptr);
+  pU08 dest_ptr = (pU08)&nc_format_buffer;
+
+  // Fillup loop
+  while (digits-- > len)
+  {
+    *dest_ptr++ = NC_FILL_CHAR;
+  }
+
+  // Copy loop
+  while (len--)
+  {
+    *dest_ptr++ = *source_ptr++;
+  }
+
+  *dest_ptr = 0; // Terminate format string
+
+  return (pU08)&nc_format_buffer;
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U08_to_str(U08 value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_S08_to_str(S08 signed_value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+  U08 value;
+
+  if (signed_value < 0)
+  {
+    *pstr++ = '-';
+    value = -signed_value;
+  }
+  else
+  {
+    value = signed_value;
+  }
+
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U08_to_hex(U08 value)
+{
+  pU08 pstr = nc_buffer;
+
+  *pstr++ = NC_HEX_ARRAY[value >> 4];
+  *pstr++ = NC_HEX_ARRAY[value & 0x0F];
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U08_to_bin(U08 value)
+{
+  pU08 pstr = nc_buffer;
+  U08 n;
+
+  for (n = 7; n < 8; n--)
+  {
+    if (value & (1 << n))
+    {
+      *pstr++ = '1';
+    }
+    else
+    {
+      *pstr++ = '0';
+    }
+  }
+
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U16_to_str(U16 value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+
+  if (value >= 10000) *pstr++ = ('0' + (value / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10)*pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_S16_to_str(S16 signed_value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+  U16 value;
+
+  if (signed_value < 0)
+  {
+    *pstr++ = '-';
+    value = -signed_value;
+  }
+  else
+  {
+    value = signed_value;
+  }
+
+  if (value >= 10000) *pstr++ = ('0' + (value / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U16_to_hex(U16 value)
+{
+  pU08 pstr = nc_buffer;
+  tMEM16 data;
+
+  data.word = value;
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) & 0x0F];
+
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U32_to_str(U32 value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+
+  if (value >= 1000000000) *pstr++ = ('0' + (value / 1000000000));
+  if (value >= 100000000) *pstr++ = ('0' + (value % 1000000000 / 100000000));
+  if (value >= 10000000) *pstr++ = ('0' + (value % 100000000 / 10000000));
+  if (value >= 1000000) *pstr++ = ('0' + (value % 10000000 / 1000000));
+  if (value >= 100000) *pstr++ = ('0' + (value % 1000000 / 100000));
+  if (value >= 10000) *pstr++ = ('0' + (value % 100000 / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_S32_to_str(S32 signed_value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+  U32 value;
+
+  if (signed_value < 0)
+  {
+    *pstr++ = '-';
+    value = -signed_value;
+  }
+  else
+  {
+    value = signed_value;
+  }
+
+  if (value >= 1000000000) *pstr++ = ('0' + (value / 1000000000));
+  if (value >= 100000000) *pstr++ = ('0' + (value % 1000000000 / 100000000));
+  if (value >= 10000000) *pstr++ = ('0' + (value % 100000000 / 10000000));
+  if (value >= 1000000) *pstr++ = ('0' + (value % 10000000 / 1000000));
+  if (value >= 100000) *pstr++ = ('0' + (value % 1000000 / 100000));
+  if (value >= 10000) *pstr++ = ('0' + (value % 100000 / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U32_to_hex(U32 value)
+{
+  pU08 pstr = nc_buffer;
+  tMEM32 data;
+
+  data.dword = value;
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[3]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[3]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[2]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[2]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) & 0x0F];
+
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_float_to_str(float value,U08 decimals,U08 digits)
+{
+  S08 n;
+  U08 int_count;
+  U08 dec_count;
+  float dec_part;
+  U32 int_part;
+  pU08 pstr = nc_buffer;
+
+  if (decimals > 5)
+  {
+    decimals = 5;
+  }
+
+	if (isnan(value)){
+		pstr[0]=pstr[2]='n';
+		pstr[1]='a';
+		pstr[3]=0;
+		return nc_buffer;
+	}
+  if (value < 0.0)
+  {
+    *pstr++ = '-';
+    value = -value;
+  }
+
+  int_part = value;
+  dec_part = value - int_part;
+  int_count = 0;
+  dec_count = 0;
+
+  if (int_part == 0)
+  {
+    *pstr++ = '0';
+  }
+
+  while (int_part > 0)
+  {
+    nc_int_digits[int_count] = int_part % 10;
+    int_part = int_part - nc_int_digits[int_count];
+
+    if (int_part > 0)
+    {
+      int_part = int_part / 10;
+    }
+
+    int_count++; // go to the next digit
+  }
+
+  while (dec_count < decimals)
+  {
+    dec_part = dec_part * 10.0;
+    nc_dec_digits[dec_count] = dec_part;
+
+    if (nc_dec_digits[dec_count] > 0)
+    {
+      dec_part = dec_part - nc_dec_digits[dec_count];
+    }
+
+    dec_count++;
+  }
+
+  for (n = int_count - 1; n > -1; n--)
+  {
+    *pstr++ = 48 + nc_int_digits[n];
+  }
+
+  *pstr++ = '.';
+
+  for (n = 0; n < dec_count; n++)
+  {
+    *pstr++ = 48 + nc_dec_digits[n];
+  }
+
+  // Terminate string
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
Index: firmware/FSC/usb_src/num_conversion.h
===================================================================
--- firmware/FSC/usb_src/num_conversion.h	(revision 10754)
+++ firmware/FSC/usb_src/num_conversion.h	(revision 10754)
@@ -0,0 +1,29 @@
+#ifndef __NUM_CONVERSION_H
+#define __NUM_CONVERSION_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+//-----------------------------------------------------------------------------
+
+#define NC_BUFFER_LENGTH 16 // Conversion buffer size
+#define NC_FILL_CHAR 32 // Character for post digits
+//-----------------------------------------------------------------------------
+
+extern U08 nc_buffer[];
+//-----------------------------------------------------------------------------
+
+pU08 nc_format(pU08 source_ptr,U08 digits);
+pU08 nc_U08_to_str(U8 value,U08 digits);
+pU08 nc_S08_to_str(S08 signed_value,U08 digits);
+pU08 nc_U08_to_hex(U08 value);
+pU08 nc_U08_to_bin(U08 value);
+pU08 nc_U16_to_str(U16 value,U08 digits);
+pU08 nc_S16_to_str(S16 signed_value,U08 digits);
+pU08 nc_U16_to_hex(U16 value);
+pU08 nc_U32_to_str(U32 value,U08 digits);
+pU08 nc_S32_to_str(S32 signed_value,U08 digits);
+pU08 nc_U32_to_hex(U32 value);
+pU08 nc_float_to_str(float value,U08 decimals,U08 digits);
+//-----------------------------------------------------------------------------
+
+#endif
Index: firmware/FSC/usb_src/output.c
===================================================================
--- firmware/FSC/usb_src/output.c	(revision 10754)
+++ firmware/FSC/usb_src/output.c	(revision 10754)
@@ -0,0 +1,173 @@
+#include "output.h"
+#include "usart.h"
+
+void print_status() {
+	usart_write_str((pU08)"adc status:\n");
+	for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i) {
+		usart_write_U08_bin(adc_enables[i]);	
+		usart_write_char(' ');
+	}
+	usart_write_char('\n');
+	for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i){
+		usart_write_U08_bin(adc_channels_ready[i]);
+		usart_write_char(' ');
+	}
+	usart_write_char('\n');
+
+	usart_write_str((pU08)"ad7719 status:\n");
+	for (U08 i=0; i< CHANNEL_BITMAP;++i) {
+		usart_write_U08_bin(ad7719_enables[i]);
+		usart_write_char(' ');
+	}
+	usart_write_char('\n');
+	for (U08 i=0; i< CHANNEL_BITMAP;++i){
+		usart_write_U08_bin(ad7719_channels_ready[i]);
+		usart_write_char(' ');
+	}
+	usart_write_char('\n');
+
+	usart_write_str((pU08)"time:");
+	usart_write_float((float)local_ms/1000 , 1,7);
+	usart_write_str((pU08)" sec.\n");
+
+	usart_write_str((pU08)"adc measured all: ");
+	if (adc_measured_all)
+		usart_write_str((pU08)" true\n");
+	else
+		usart_write_str((pU08)"false\n");
+
+	usart_write_str((pU08)"ad7719 measured all: ");
+	if (ad7719_measured_all)
+		usart_write_str((pU08)" true\n");
+	else
+		usart_write_str((pU08)"false\n");
+
+	usart_write_str((pU08)"adc current channel:");
+	usart_write_U08(adc_current_channel,2);
+	usart_write_char('\n');
+
+	usart_write_str((pU08)"ad7719 current channel:");
+	usart_write_U08(ad7719_current_channel,2);
+	usart_write_char('\n');
+
+}
+void print_adc_nicely() {
+	usart_write_str((pU08)"\n printing voltages in mV:\n");
+	// output:	U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS];
+	for (U08 i=0; i< V_CHANNELS + I_CHANNELS + H_CHANNELS;++i) {
+		if (i%8 == 0) usart_write_char('\n');
+		adc_output(i, adc_values[i]);
+		usart_write_str((pU08)"   ");
+	}
+	usart_write_char('\n');
+}
+
+
+void print_ad7719_nicely() 
+{
+	float value;
+
+	usart_write_str((pU08)"\n printing measured resistance in kohms:\n");
+
+	for (U08 i=0; i< TEMP_CHANNELS;++i) {
+		if (i%8 == 0) usart_write_char('\n');
+
+		// print channel name:
+		usart_write_str((pU08)"R:"); //R for resistance
+		usart_write_char('A'+i/8); // Letters A,B,C,D,E,F,G,H
+		//usart_write_char(' '); 
+		usart_write_U08(i%8+1,1); // Numbers 1...8
+		usart_write_char(':'); 
+
+		// check if this channel is enabled in the bitmap
+		if (ad7719_enables[i/8] & (1<<i%8))
+		{
+			value = (6.25 * 1.024 * ad7719_values[i]) / ((U32)1 << 25);
+			usart_write_float(value, 3,6);
+			//usart_write_U32(ad7719_values[i],8);
+			//usart_write_U32_hex(data); //data
+			usart_write_str((pU08)" ");	
+		} else {
+			usart_write_str((pU08)"         ");	
+		}
+		//usart_write_char('\n');
+	}
+}
+
+void ad7719_output(U08 channel, U32 data) {
+float value = 0;
+	usart_write_str((pU08)"R:"); //R for resistance
+	usart_write_char('A'+channel/8); // Letters A,B,C,D,E,F,G,H
+	//usart_write_char(' '); 
+	usart_write_U08(channel%8+1,1); // Numbers 1...8
+	usart_write_char(':'); 
+	
+
+	value = (6.25 * data) / ((U32)1 << 25);
+	usart_write_float(value, 3,6);
+	//usart_write_U32_hex(data); //data
+
+
+}
+
+void adc_output(U08 channel, U08 data) {
+
+//	if (channel < 40) 
+//		usart_write_str((pU08)"V:"); 
+//	else if (channel < 80)
+//		usart_write_str((pU08)"I:"); 
+//	else if (channel < 84)
+//		usart_write_str((pU08)"H:"); 
+
+	if (channel <80)
+	{
+		switch ((channel%40)/4) {
+			case 0:
+			case 1:
+				usart_write_char('A'); 
+			break;
+			case 2:
+			case 3:
+				usart_write_char('B');
+				break;
+			case 4:
+			case 5:
+				usart_write_char('C'); 
+				break;
+			case 6:
+			case 7:
+				usart_write_char('D'); 
+				break;
+			case 8:
+				usart_write_char('E');
+				break;
+			case 9:
+				usart_write_char('F');
+				break;
+			default:
+				usart_write_char('?');
+				break;
+			}
+	}
+	else // channel 80..83
+	{
+		usart_write_char('H');
+	}
+	//usart_write_char(' '); 
+	
+	if ( (channel%40)/4 == 9)
+		usart_write_U08((channel)%4+1,1); // Numbers 1...4
+	else
+		usart_write_U08((channel)%8+1,1); // Numbers 1...8
+	
+	
+	//usart_write_U08(channel,2); // Numbers 1...8
+	usart_write_char(':'); 
+	usart_write_U16((U16)data*16, 4); //data
+}
+
+
+void adc_output_all() {
+	print_adc_nicely();
+	print_ad7719_nicely();
+}
Index: firmware/FSC/usb_src/output.h
===================================================================
--- firmware/FSC/usb_src/output.h	(revision 10754)
+++ firmware/FSC/usb_src/output.h	(revision 10754)
@@ -0,0 +1,13 @@
+#ifndef __OUTPUT_H
+#define __OUTPUT_H
+
+#include "typedefs.h"
+
+void ad7719_output(U08 channel, U32 data);
+void adc_output(U08 channel, U08 data);
+void adc_output_all();
+void print_ad7719_nicely();
+void print_adc_nicely();
+
+
+#endif
Index: firmware/FSC/usb_src/parser.c
===================================================================
--- firmware/FSC/usb_src/parser.c	(revision 10754)
+++ firmware/FSC/usb_src/parser.c	(revision 10754)
@@ -0,0 +1,73 @@
+#include "parser.h"
+#include "output.h"
+// this method parses the data, 
+// which came in via USART
+// later it might as well parse the data from ethernet.
+void parse_ascii() {
+	usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
+	usart_write_str((pU08)"got:");
+	usart_write_str(usart_rx_buffer);
+	
+// look at first byte
+// I hope, I can manage to use one byte commands
+	switch (usart_rx_buffer[0]) {
+		case 'E': 	// AD7719 enable bitmaps may be set
+			set_ad7719_enable_register();
+			break;
+		case 'e':	// ATmega internal ADC enable bitmaps may be set
+			// not supported yet.
+			set_adc_enable_register();
+			break;
+		case 'h':
+			usart_write_str((pU08)"\nheartbeat ");
+			heartbeat_enable = true;
+			if (usart_rx_buffer[1] == '0'){
+				heartbeat_enable = false;
+				usart_write_str((pU08)"off\n");
+			} else {
+				usart_write_str((pU08)"on\n");
+			}
+			break;
+		case 'G': 			// GET the Temperature channels, which are enabled
+			once_told_you = false;
+			for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+				ad7719_channels_ready[i]=0;
+			}
+			break;
+
+		case 'g':			// GET the voltage/current/humidity channels, which are enabled
+			once_told_you = false;
+			for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
+				adc_channels_ready[i]=0;
+			}
+			break;
+
+		case 'P':
+			print_ad7719_nicely();
+			break;
+			
+		case 'p':
+			print_adc_nicely();
+			break;
+
+		case 's':
+			print_status();
+			break;	
+
+		case 'd':
+			usart_write_str((pU08)"\ndebug mode ");
+			debug_mode = true;
+			if (usart_rx_buffer[1] == '0'){
+				debug_mode = false;
+				usart_write_str((pU08)"off\n");
+			} else {
+				usart_write_str((pU08)"on\n");
+			}
+			break;		
+	}
+	
+	
+	usart_write_str((pU08)"\nready?");
+	for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
+		usart_rx_buffer[i] = 0;
+}
Index: firmware/FSC/usb_src/parser.h
===================================================================
--- firmware/FSC/usb_src/parser.h	(revision 10754)
+++ firmware/FSC/usb_src/parser.h	(revision 10754)
@@ -0,0 +1,6 @@
+#ifndef __PARSER_H
+#define __PARSER_H
+
+void parse_ascii(); 
+
+#endif
Index: firmware/FSC/usb_src/spi_master.c
===================================================================
--- firmware/FSC/usb_src/spi_master.c	(revision 10754)
+++ firmware/FSC/usb_src/spi_master.c	(revision 10754)
@@ -0,0 +1,283 @@
+//-----------------------------------------------------------------------------
+#include "spi_master.h"
+
+//-----------------------------------------------------------------------------
+volatile U08 spi_clock_index;
+volatile U08 spi_cpol;
+volatile U08 spi_cpha;
+volatile U08 spi_dord;
+volatile BOOL spi_ss_active_high;
+volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE];
+volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE];
+
+volatile U08 SPI_DEVICE_SS[4]={SPI_E_CS ,SPI_AD_CS ,SPI_M_CS ,SPI_A_CS };
+volatile BOOL SPI_DEVICE_ACTIVE_HIGH[4]={false ,false ,false ,false };
+//-----------------------------------------------------------------------------
+
+
+
+
+void spi_init(void)
+{
+  // there are a total of 4 devices on the SPI bus:
+	// 1.) Ethernet Modul WIZ812MJ 
+	// 2.) AD7719 24bit ADC
+	// 3.) LIS3LV accelerometer
+	// 4.) MAX6662 temp sensor <---- not assembled!
+
+	// We check if they all can live with the same SPI settings:
+	// 1.) Ethernet modul:
+	// supports spi mode=0 or mode=3 --> eighther cpol=cpha=0 or cpol=cpha=1
+	//	THAT IS NOT TRUE!!!!
+	// only mode 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!1
+	// MSB first
+	// SCLK time 70ns minimum --> 14.2MHz maximum
+	//
+	// 2.) AD7719
+	// supports mode=3 --> cpol=cpha=1
+	// MSB first
+	// SCLK time 200ns minimum --> 5MHz maximum
+	//
+	// 3.) LIS3LV
+	// SPI CLK idles high 				--> cpol=1
+	// data valid at rising edge. --> cpha=1 as well 
+	// ==> mode 3 is supported only.
+	// MSB first, but take take at multi byte transfers. LSbyte first
+	// SCLK time - is not mentioned in the datasheet
+	//
+	// 4.) MAX6662 Tempsensor
+	// since it is not assembled, this information is not necessary.
+
+	// fastes SPI CLK frequency can be 					--> F_CPU/2 	= 4MHz
+	// slowest can be 													--> F_CPU/128	= 62.5KHz
+	
+	// Lets try with the fastest!
+	spi_clock_index = 0;  // Set Clockindex for lowest clock speed (F_CPU / 128)
+
+  spi_dord = 0;					// Data Order MSB first dord = 0  --> good for all devices
+  spi_cpol = 1;	spi_cpha = 1;					// SPI mode=3 			--> good for all devices
+  spi_setup(); 					// Setup SPI bits and clock speed
+
+}
+//-----------------------------------------------------------------------------
+void spi_setup(void)
+{
+  // Disable SPI, clear all flags
+  SPCR = 0;
+
+  // Set/Clear bits DORD, CPOL and CPHA in SPI Control Register
+  spi_dord & 0x01 ? (SPCR |= (1 << DORD)) : (SPCR &= ~(1 << DORD));
+  spi_cpol & 0x01 ? (SPCR |= (1 << CPOL)) : (SPCR &= ~(1 << CPOL));
+  spi_cpha & 0x01 ? (SPCR |= (1 << CPHA)) : (SPCR &= ~(1 << CPHA));
+
+  switch (spi_clock_index)
+  {
+    case 0:{ // F_CPU / 128
+      SPCR |= (1 << SPR1) | (1 << SPR0);
+      SPSR &= ~(1 <<SPI2X);
+	  }
+    break;
+
+    case 1:{ // F_CPU / 64
+      SPCR |= (1 << SPR1);
+      SPSR &= ~(1 << SPI2X);
+	  }
+    break;
+
+    case 2:{ // F_CPU / 32
+      SPCR |= (1 << SPR1);
+      SPSR |= (1 << SPI2X);
+	  }
+    break;
+
+    case 3:{ // F_CPU / 16
+      SPCR |= (1 << SPR0);
+      SPSR &= ~(1 << SPI2X);
+	  }
+    break;
+
+    case 4:{ // F_CPU / 8
+      SPCR |= (1 << SPR0);
+      SPSR |= (1 << SPI2X);
+	  }
+    break;
+
+    case 5: // F_CPU / 4
+      SPSR &= ~(1 << SPI2X);
+    break;
+
+    case 6: // F_CPU / 2
+      SPSR |= (1 << SPI2X);
+    break;
+
+    default:{ // F_CPU / 128
+      SPCR |= (1 << SPR1) | (1 << SPR0);
+      SPSR &= ~(1 << SPI2X);
+	  }
+  }
+
+  // Enable SPI in Master Mode
+  SPCR |= (1 << SPE) | (1 << MSTR);
+}
+
+//-----------------------------------------------------------------------------
+
+void spi_set_clock_index(U08 clock_index)
+{
+  if (clock_index > SPI_MAX_CLOCK_INDEX)
+  {
+    clock_index = SPI_MAX_CLOCK_INDEX;
+  }
+
+  spi_clock_index = clock_index;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+//-----------------------------------------------------------------------------
+
+void spi_set_dord(U08 dord)
+{
+  if (dord > 1)
+  {
+    dord = 1;
+  }
+
+  spi_dord = dord;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+//-----------------------------------------------------------------------------
+
+void spi_set_cpol(U08 cpol)
+{
+  if (cpol > 1)
+  {
+    cpol = 1;
+  }
+
+  spi_cpol = cpol;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+//-----------------------------------------------------------------------------
+
+void spi_set_cpha(U08 cpha)
+{
+  if (cpha > 1)
+  {
+    cpha = 1;
+  }
+
+  spi_cpha = cpha;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+
+//-----------------------------------------------------------------------------
+
+void spi_transfer(U08 bytes, U08 device)
+{
+/*
+#define SPI_E_CS PB4 		//device 0
+#define SPI_AD_CS PD3 		//device 1
+#define SPI_M_CS PD4		//device 2
+#define SPI_A_CS PD5		//device 3
+*/
+  U08 n;
+  // Transfer requested bytes
+  for (n = 0; n < bytes; n++)
+  {
+  // Check for active slave select level
+  if (SPI_DEVICE_ACTIVE_HIGH[device])
+  {
+		if (device == 0) {
+    	PORTB |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		} else {
+			PORTD |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		}
+  }
+  else
+  {
+		if (device == 0) {
+    	PORTB &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		} else {
+			PORTD &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		}
+  }
+
+  
+    spi_read_buffer[n] = spi_transfer_byte(spi_write_buffer[n]);
+  
+
+  // Check for inactive slave select level
+  if (SPI_DEVICE_ACTIVE_HIGH[device])
+  {
+		if (device == 0) {
+    	PORTB &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		} else {
+			PORTD &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		}
+  }
+  else
+  {
+		if (device == 0) {
+    	PORTB |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		} else {
+			PORTD |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		}
+  }
+  
+  }
+}
+//-----------------------------------------------------------------------------
+
+U08 spi_transfer_byte(U08 data)
+{
+  // Start SPI Transfer
+	if (!(SPCR & (1<<MSTR)) )
+		SPCR |= 1<<MSTR;
+  SPDR = data;
+
+  // Wait for transfer completed
+  while (!(SPSR & (1 << SPIF)))
+  {
+  }
+
+  // Return result of transfer
+  return SPDR;
+}
+
+//-----------------------------------------------------------------------------
+void spi_transfer_string(U08 length, U08* addr, U08 device)
+{
+/*
+#define SPI_E_CS PB4 		//device 0
+#define SPI_AD_CS PD3 	//device 1
+#define SPI_M_CS PD4		//device 2
+#define SPI_A_CS PD5		//device 3
+*/
+  U08 n;
+  
+  // I assume the CS line is in "not enable"-state;
+	if ( device == 0 ){
+  	TGL_BIT(PORTB, SPI_DEVICE_SS[device]);  // I toggle the line
+	} else {
+		TGL_BIT(PORTD, SPI_DEVICE_SS[device]);  // I toggle the line
+	}
+  // now the line is in "enable"-state
+  
+
+  // Transfer requested bytes
+  for (n = 0; n < length; n++)
+  {
+    spi_transfer_byte(addr[n]);
+  }
+	
+		if ( device == 0 ){
+  	TGL_BIT(PORTB, SPI_DEVICE_SS[device]);  // I toggle the line
+	} else {
+		TGL_BIT(PORTD, SPI_DEVICE_SS[device]);  // I toggle the line
+	}
+
+}
+//-----------------------------------------------------------------------------
Index: firmware/FSC/usb_src/spi_master.h
===================================================================
--- firmware/FSC/usb_src/spi_master.h	(revision 10754)
+++ firmware/FSC/usb_src/spi_master.h	(revision 10754)
@@ -0,0 +1,37 @@
+#ifndef __SPI_MASTER_H
+#define __SPI_MASTER_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "usart.h"
+//-----------------------------------------------------------------------------
+#define SPI_READ_BUFFER_SIZE 16
+#define SPI_WRITE_BUFFER_SIZE 16
+
+#define SPI_MAX_SLAVE_INDEX 2 //?
+#define SPI_MAX_CLOCK_INDEX 6 //?
+//-----------------------------------------------------------------------------
+extern volatile U08 spi_clock_index;
+extern volatile U08 spi_cpol;
+extern volatile U08 spi_cpha;
+extern volatile U08 spi_dord;
+extern volatile U08 SPI_DEVICE_SS[4];
+extern volatile BOOL SPI_DEVICE_ACTIVE_HIGH[4];
+
+extern volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE];
+extern volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE];
+//-----------------------------------------------------------------------------
+
+void spi_init(void);
+void spi_transfer(U08 bytes, U08 device);
+U08 spi_transfer_byte(U08 data);
+void spi_set_clock_index(U08 clock_index);
+void spi_set_dord(U08 dord);
+void spi_set_cpol(U08 cpol);
+void spi_set_cpha(U08 cpha);
+void spi_setup(void);
+void spi_transfer_string(U08 length, U08* addr, U08 device);
+//-----------------------------------------------------------------------------
+
+#endif
Index: firmware/FSC/usb_src/tests.c
===================================================================
--- firmware/FSC/usb_src/tests.c	(revision 10754)
+++ firmware/FSC/usb_src/tests.c	(revision 10754)
@@ -0,0 +1,47 @@
+#include "tests.h"
+
+#include "typedefs.h"
+
+void test_out_spare_pins(void)
+{
+
+	// set everything as inputs -- high Z
+	DDRA = 0x00;
+	DDRB = 0x00;
+	DDRC = 0x00;
+	DDRD = 0x00;
+
+	DDRB |= 1<<PB2; // set spare out1 as output
+	DDRB |= 1<<PB3; // set spare out2 as output
+
+	DDRB |= 1<<PB4; 
+
+	PORTC |= 1<<PC7; // switch PC7 pullup on
+	PORTA |= 1<<PA7; // switch PA7 pullup on
+
+	while (true)
+	{
+		 
+		if ( (PINC & (1<<PC7)) == 0 )
+		{
+			PORTB |= 1 << PB2;
+		} else {
+			PORTB &= ~(1<<PB2);
+		}
+
+		/*
+		if ( (PINA & (1<<PA7)) == 0 )
+		{
+			PORTB |= 1 << PB3;
+		} else {
+			PORTB &= ~(1<<PB3);
+		}
+*/
+
+		PORTB ^= 1<<PB3;
+		PORTB ^= 1<<PB4;
+	}
+
+
+
+}
Index: firmware/FSC/usb_src/tests.h
===================================================================
--- firmware/FSC/usb_src/tests.h	(revision 10754)
+++ firmware/FSC/usb_src/tests.h	(revision 10754)
@@ -0,0 +1,1 @@
+void test_out_spare_pins(void) ;
Index: firmware/FSC/usb_src/typedefs.h
===================================================================
--- firmware/FSC/usb_src/typedefs.h	(revision 10754)
+++ firmware/FSC/usb_src/typedefs.h	(revision 10754)
@@ -0,0 +1,141 @@
+#ifndef __TYPEDEFS_H
+#define __TYPEDEFS_H
+//-----------------------------------------------------------------------------
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+#include <util/delay.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include "macros.h"
+#include <avr/pgmspace.h>
+
+//-----------------------------------------------------------------------------
+
+#define true 1
+#define TRUE 1
+#define ON 1
+#define on 1
+#define SET 1
+#define set 1
+
+#define false 0
+#define FALSE 0
+#define OFF 0
+#define off 0
+#define CLEAR 0
+#define clear 0
+
+#define BIT0 0x01
+#define BIT1 0x02
+#define BIT2 0x04
+#define BIT3 0x08
+#define BIT4 0x10
+#define BIT5 0x20
+#define BIT6 0x40
+#define BIT7 0x80
+#define BIT8 0x0100
+#define BIT9 0x0200
+#define BIT10 0x0400
+#define BIT11 0x0800
+#define BIT12 0x1000
+#define BIT13 0x2000
+#define BIT14 0x4000
+#define BIT15 0x8000
+#define BIT16 0x010000
+#define BIT17 0x020000
+#define BIT18 0x040000
+#define BIT19 0x080000
+#define BIT20 0x100000
+#define BIT21 0x200000
+#define BIT22 0x400000
+#define BIT23 0x800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+//-----------------------------------------------------------------------------
+
+// Typendeklarationen
+typedef signed char S8;
+typedef signed char S08;
+typedef signed char tS08;
+typedef unsigned char U8;
+typedef unsigned char U08;
+typedef unsigned char tU08;
+
+typedef signed int S16;
+typedef signed int tS16;
+typedef unsigned int U16;
+typedef unsigned int tU16;
+typedef signed long S32;
+typedef signed long tS32;
+typedef unsigned long U32;
+typedef unsigned long tU32;
+
+typedef S08 *pS8;
+typedef S08 *pS08;
+typedef U08 *pU8;
+typedef U08 *pU08;
+typedef S16 *pS16;
+typedef U16 *pU16;
+typedef S32 *pS32;
+typedef U32 *pU32;
+typedef float *pfloat;
+
+typedef U08 BOOL;
+typedef BOOL *pBOOL;
+typedef U08 bool;
+
+//typedef U08 __flash *fpU08; //geht nicht mit gcc
+//typedef U08 PROGMEM prog_U08;
+//typedef prog_U08 *fpU08;
+typedef U08 *fpU08;
+
+typedef union uMEM16 // Word and Byte access to 16-Bit data
+{
+  U16 word; // Word
+  pU16 pword; // Pointer to Word
+  U08 byte[2]; // Byte
+  pU08 pbyte; // Pointer to Byte
+} tMEM16;
+
+typedef union uMEM32 // DWord, Word and Byte access to 32-Bit data
+{
+  U32 dword; // DWORD
+  pU32 pdword[2]; // Pointer to U32
+
+  float fp; // Float
+  pfloat pfp[2]; // Pointer to float
+
+  U16 word[2]; // Word
+  pU16 pword[2]; // Pointer to U16
+
+  U08 byte[4]; // Byte
+  pU08 pbyte[2]; // Pointer to U08
+
+} tMEM32;
+
+typedef enum // Enumeration of watchdog prescale values
+{
+  WDT_PS_2K, // 2048 cycles (16ms)
+  WDT_PS_4K, // 40968 cycles (32ms)
+  WDT_PS_8K, // 8192 cycles (64ms)
+  WDT_PS_16K, // 16384 cycles (0.125s)
+  WDT_PS_32K, // 32768 cycles (0.25s)
+  WDT_PS_64K, // 65536 cycles (0.5s)
+  WDT_PS_128K, // 131072 cycles (1.0s)
+  WDT_PS_256K, // 262144 cycles (2.0s)
+  WDT_PS_512K, // 524288 cycles (4.0s)
+  WDT_PS_1024K // 1048576 cycles (8.0s)
+} tWDT_PRESCALE;
+//-----------------------------------------------------------------------------
+
+#endif
Index: firmware/FSC/usb_src/usart.c
===================================================================
--- firmware/FSC/usb_src/usart.c	(revision 10754)
+++ firmware/FSC/usb_src/usart.c	(revision 10754)
@@ -0,0 +1,269 @@
+//-----------------------------------------------------------------------------
+
+#include "usart.h"
+#include <avr/interrupt.h>
+//-----------------------------------------------------------------------------
+
+#ifdef USART_USE_RX_IRQ
+  U08 usart_rx_buffer[USART_RX_BUFFER_SIZE];
+  //U08 *usart_rx_buffer_ptr = &usart_rx_buffer[0];
+  U08 usart_received_chars;
+  volatile BOOL usart_rx_ready = false;
+  static U08 usart_rx_buffer_index = 0;
+  static U08 usart_receive_char;
+  static BOOL usart_receive_suspended = false;
+  volatile BOOL ISR_toggle_out = false;
+#endif
+//-----------------------------------------------------------------------------
+
+void usart_init(void)
+{
+  USART_SET_BAUDRATE(USART_BAUDRATE);
+
+  UCSRA = 0x00;
+
+  UCSRB = 0x00; // Disable receiver and transmitter and interrupts
+
+#ifdef USART_USE_RX
+  UCSRB |= (1 << RXEN);			// Turn on receiver
+	DDRD &= ~(1<<PD0);				// PD0 is RXD
+#endif
+
+#ifdef USART_USE_RX_IRQ
+  UCSRB |= (1 << RXCIE);		// Enable rx interrupt
+#endif
+
+#ifdef USART_USE_TX
+  UCSRB |= (1 << TXEN);			// Turn on transmitter
+	DDRD |= 1<<PD1; 					// PD1 is TXD
+#endif
+
+  UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0); // 8-Bit character length
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_char(U08 data)
+{
+  while (!(UCSRA & (1 << UDRE))) ; // Wait until tx register is empty
+  UDR = data;
+
+//	if ( usart_tx_buffer_index < USART_TX_BUFFER_SIZE-1){
+//		usart_tx_buffer[usart_tx_buffer_index] = data;
+//		++usart_tx_buffer_index;
+//	} else {
+//		usart_tx_buffer_overflow = true;
+//	}
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_crlf(void)
+{
+  usart_write_char(USART_CHAR_CR);
+  usart_write_char(USART_CHAR_LF);
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_str(pU08 str)
+{
+  while (*str)
+  {
+    usart_write_char(*str++);
+  }
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_flash_str(fpU08 str)
+{
+  while (*str)
+  {
+    usart_write_char(*str++);
+  }
+}
+//-----------------------------------------------------------------------------
+
+void usart_writeln_flash_str(fpU08 str)
+{
+  while (*str)
+  {
+    usart_write_char(*str++);
+  }
+
+  usart_write_char(USART_CHAR_CR);
+  usart_write_char(USART_CHAR_LF);
+}
+//-----------------------------------------------------------------------------
+
+void usart_writeln_str(pU08 str)
+{
+  usart_write_str(str);
+  usart_write_char(USART_CHAR_CR);
+  usart_write_char(USART_CHAR_LF);
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U08(U08 value,U08 digits)
+{
+  usart_write_str(nc_U08_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_S08(S08 value,U08 digits)
+{
+  usart_write_str(nc_S08_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U08_hex(U08 value)
+{
+  usart_write_str(nc_U08_to_hex(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U08_bin(U08 value)
+{
+  usart_write_str(nc_U08_to_bin(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U16(U16 value,U08 digits)
+{
+  usart_write_str(nc_U16_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_S16(S16 value,U08 digits)
+{
+  usart_write_str(nc_S16_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U16_hex(U16 value)
+{
+  usart_write_str(nc_U16_to_hex(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U32(U32 value,U08 digits)
+{
+  usart_write_str(nc_U32_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_S32(S32 value,U08 digits)
+{
+  usart_write_str(nc_S32_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U32_hex(U32 value)
+{
+  usart_write_str(nc_U32_to_hex(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_float(float value,U08 decimals,U08 digits)
+{
+  usart_write_str(nc_float_to_str(value,decimals,digits));
+}
+//-----------------------------------------------------------------------------
+
+#ifdef USART_USE_RX_IRQ
+
+ISR(SIG_USART_RECV)
+{
+  if (ISR_toggle_out) PORTB ^= (1<<PB3); // toggle Out2_spare when starting ISR
+
+  usart_receive_char = UDR;
+
+  if (usart_rx_ready) // Exit if ready flag is still set 
+  {
+    return;
+  }
+
+  // If CR received, then set ready flag
+  if (usart_receive_char == USART_CHAR_CR)
+  {
+    usart_rx_buffer[usart_rx_buffer_index] = 0; // Terminate input string
+    usart_received_chars = usart_rx_buffer_index;
+    usart_rx_buffer_index = 0;
+    usart_receive_suspended = false;
+    usart_rx_ready = TRUE;
+    return;
+  }
+
+  // Ignore all characters till next CR
+  if (usart_receive_suspended)
+  {
+    return;
+  }
+
+  // Check for underscore or comment
+  if (usart_receive_char == '_' || usart_receive_char == ';')
+  {
+    usart_receive_suspended = true;
+
+    return;
+  }
+
+  // If Backspace received, then delete last character
+  if (usart_receive_char == USART_CHAR_BS && usart_rx_buffer_index)
+  {
+    usart_rx_buffer_index--;
+
+    return;
+  }
+
+  // Ignore invalid characters
+  if (usart_receive_char < USART_CHAR_SPC)
+  {
+    return;
+  }
+
+#ifdef USART_USE_UPPERCASE
+  if (usart_receive_char >= 'a' && usart_receive_char <= 'z')
+  {
+    usart_receive_char -= 32;
+  }
+#endif
+
+  if (usart_rx_buffer_index < USART_RX_BUFFER_SIZE - 1) // Store character
+  {
+    usart_rx_buffer[usart_rx_buffer_index++] = usart_receive_char;
+    usart_writeln_str(usart_rx_buffer);
+  }
+
+  //usart_write_char(usart_rx_buffer[usart_rx_buffer_index]);
+ //usart_writeln_str(usart_rx_buffer);
+ //usart_write_char(usart_rx_buffer[1,2]);
+ //usart_write_char(usart_rx_buffer[usart_rx_buffer_index]);
+ //usart_writeln_flash_str(*usart_rx_buffer);
+ //usart_write_char(usart_rx_buffer);
+}  
+#endif 
+/*
+#define uart_maxstrlen 64
+ 
+volatile U8 uart_str_complete=0;
+volatile U8 uart_str_count=0;
+volatile U8 uart_string[uart_maxstrlen+1]="";
+
+ISR(USART_RXC_vect)
+{
+    unsigned char buffer = 64;
+    // Daten aus dem Puffer lesen
+    buffer = UDR;
+	UDR = buffer;
+	if ( uart_str_complete==0 ){	// wenn uart_string gerade in Verwendung, neues Zeichen verwerfen
+		// Daten werden erst in string geschrieben, wenn nicht String-Ende/max Zeichenlänge erreicht ist/string gerade verarbeitet wird
+	  	if (buffer!='\n' && buffer!='\r' && uart_str_count<uart_maxstrlen-1){
+			uart_string[uart_str_count]=buffer;
+			uart_str_count++;
+		} else {
+			uart_string[uart_str_count]='\0';
+			uart_str_count=0;
+			uart_str_complete=1;
+		}
+	}
+}
+
+*/
Index: firmware/FSC/usb_src/usart.h
===================================================================
--- firmware/FSC/usb_src/usart.h	(revision 10754)
+++ firmware/FSC/usb_src/usart.h	(revision 10754)
@@ -0,0 +1,54 @@
+#ifndef __USART_H
+#define __USART_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "num_conversion.h"
+//-----------------------------------------------------------------------------
+
+#define USART_CHAR_BS 8
+#define USART_CHAR_LF 10
+#define USART_CHAR_CR 13
+#define USART_CHAR_ESC 27
+#define USART_CHAR_SPC 32
+//-----------------------------------------------------------------------------
+
+#define USART_SET_BAUDRATE(br) (UBRRH = (U08)((((U32)F_CPU) /\
+                                ((U32)br * 16) - 1) >> 8),\
+                                UBRRL = (U08)(((U32)F_CPU) /\
+                                ((U32)br * 16) - 1))
+//-----------------------------------------------------------------------------
+/*
+extern U08 usart_rx_buffer[];
+extern volatile BOOL usart_rx_ready;
+extern volatile BOOL ISR_toggle_out;
+extern U08 usart_received_chars;
+*/
+extern bool usart_tx_buffer_overflow;
+extern U08 usart_tx_buffer_index;
+extern U08 usart_tx_buffer[USART_TX_BUFFER_SIZE];
+extern U08 usart_received_chars;
+//-----------------------------------------------------------------------------
+
+void usart_init(void);
+void usart_write_char(U08 data);
+void usart_write_crlf(void);
+void usart_write_str(pU08 str);
+void usart_writeln_str(pU08 str);
+void usart_write_flash_str(fpU08 str);
+void usart_writeln_flash_str(fpU08 str);
+void usart_write_U08(U08 value,U08 digits);
+void usart_write_S08(S08 value,U08 digits);
+void usart_write_U08_hex(U08 value);
+void usart_write_U08_bin(U08 value);
+void usart_write_U16(U16 value,U08 digits);
+void usart_write_S16(S16 value,U08 digits);
+void usart_write_U16_hex(U16 value);
+void usart_write_U32(U32 value,U08 digits);
+void usart_write_S32(S32 value,U08 digits);
+void usart_write_U32_hex(U32 value);
+void usart_write_float(float value,U08 decimals,U08 digits);
+//-----------------------------------------------------------------------------
+
+#endif
Index: firmware/FSC/usb_src/w5100_spi_interface.c
===================================================================
--- firmware/FSC/usb_src/w5100_spi_interface.c	(revision 10754)
+++ firmware/FSC/usb_src/w5100_spi_interface.c	(revision 10754)
@@ -0,0 +1,302 @@
+//-----------------------------------------------------------------------------
+
+#include "w5100_spi_interface.h"       
+#include "spi_master.h"    
+volatile BOOL sock0_connection_established = false;
+volatile U08 eth_read_buffer[ETH_READ_BUFFER_SIZE];
+volatile U08 eth_write_buffer[ETH_WRITE_BUFFER_SIZE];
+
+//-----------------------------------------------------------------------------
+
+void w5100_write( U16 addr, U08 data)
+{
+spi_write_buffer[0]=0xF0;
+spi_write_buffer[1]=(U08)(addr>>8);
+spi_write_buffer[2]=(U08)(addr);
+spi_write_buffer[3]=data;
+
+spi_transfer(4, 0); 
+// spi_read_buffer should contain 0x00 0x01 0x02 and 0x03 ... nice check!
+}
+
+U08 w5100_read( U16 addr)
+{
+spi_write_buffer[0]=0x0F;
+spi_write_buffer[1]=(U08)(addr>>8);
+spi_write_buffer[2]=(U08)(addr);
+spi_write_buffer[3]=0x00;
+
+spi_transfer(4, 0); 
+return spi_read_buffer[3]; 
+// spi_read_buffer should contain 0x00 0x01 0x02 and data ... nice check!
+}
+
+U08 w5100_init (void) 
+{
+U08 sock0_status;
+
+	// set FSCs MAC Address to value defined in w5100_spi_interface.h
+	w5100_write( CM_SHAR0, FSC_MAC_ADDRESS0 );
+	w5100_write( CM_SHAR1, FSC_MAC_ADDRESS1 );
+	w5100_write( CM_SHAR2, FSC_MAC_ADDRESS2 );
+	w5100_write( CM_SHAR3, FSC_MAC_ADDRESS3 );
+	w5100_write( CM_SHAR4, FSC_MAC_ADDRESS4 );
+	w5100_write( CM_SHAR5, FSC_MAC_ADDRESS5 );
+
+	//set IP
+	w5100_write( CM_SIPR0, FSC_IP_ADDRESS0 );
+	w5100_write( CM_SIPR1, FSC_IP_ADDRESS1 );
+	w5100_write( CM_SIPR2, FSC_IP_ADDRESS2 );
+	w5100_write( CM_SIPR3, FSC_IP_ADDRESS3 );
+
+	// set subnet mask
+	w5100_write( CM_SUBR0, FSC_SUBNET_MASK0 );
+	w5100_write( CM_SUBR1, FSC_SUBNET_MASK1 );
+	w5100_write( CM_SUBR2, FSC_SUBNET_MASK2 );
+	w5100_write( CM_SUBR3, FSC_SUBNET_MASK3 );
+
+	// set IP of Gateway used by FSC
+	w5100_write( CM_GAR0, FSC_GATEWAY_ADDRESS0 );
+	w5100_write( CM_GAR1, FSC_GATEWAY_ADDRESS1 );
+	w5100_write( CM_GAR2, FSC_GATEWAY_ADDRESS2 );
+	w5100_write( CM_GAR3, FSC_GATEWAY_ADDRESS3 );
+
+	//set socket read and write fifo sizes
+	w5100_write( CM_RMSR, 0x0A); // --> 4k for socket 0 and 1
+	w5100_write( CM_TMSR, 0x0A); // --> 4k for socket 0 and 1
+
+
+	w5100_write ( S0_MR, 0x01); 		// set Socket 0 as TCP
+	w5100_write ( S0_PORT0, 0x13 ); 	// Port 5000 -> 0x1388 
+	w5100_write ( S0_PORT1, 0x88 ); 
+	w5100_write ( S0_CR, CR_OPEN );		// issue Socket open command
+	sock0_status = w5100_read(S0_SR); // request socket 0 status
+	if ( sock0_status != SR_SOCK_INIT)
+	{
+		return sock0_status;
+	}
+
+	w5100_write ( S0_CR, CR_LISTEN );		// issue Socket listen command
+	sock0_status = w5100_read(S0_SR); // request socket 0 status
+	if ( sock0_status != SR_SOCK_LISTEN)
+	{
+		return sock0_status;
+	}
+
+	return sock0_status;
+}
+
+
+BOOL w5100_is_established()
+{
+	if ( w5100_read(S0_SR) == SR_SOCK_ESTABLISHED )
+	{
+		sock0_connection_established = true;
+	}
+	else
+	{
+		sock0_connection_established = false;
+	}
+	return sock0_connection_established;
+
+}
+
+U08 w5100_sock_status()
+{
+	return w5100_read(S0_SR);
+}
+
+
+// getters of TX and RX registers
+// 		S0_TX_FSR
+U16 get_S0_TX_FSR()
+{
+U16 freesize;
+freesize=w5100_read(S0_TX_FSR1);
+freesize = freesize << 8;
+freesize += w5100_read(S0_TX_FSR0);
+return freesize;
+}
+
+//		S0_TX_RD
+U16 get_S0_TX_RD()
+{
+U16 readpointer;
+readpointer=w5100_read(S0_TX_RD1);
+readpointer = readpointer << 8;
+readpointer += w5100_read(S0_TX_RD0);
+return readpointer;
+}
+
+//		S0_TX_WR
+U16 get_S0_TX_WR()
+{
+U16 writepointer;
+writepointer=w5100_read(S0_TX_WR1);
+writepointer = writepointer << 8;
+writepointer += w5100_read(S0_TX_WR0);
+return writepointer;
+}
+
+//		S0_RX_RSR
+U16 get_S0_RX_RSR()
+{
+U16 received_size;
+received_size=w5100_read(S0_RX_RSR1);
+received_size = received_size << 8;
+received_size += w5100_read(S0_RX_RSR0);
+return received_size;
+}
+
+//		S0_RX_RD
+U16 get_S0_RX_RD()
+{
+U16 readpointer;
+readpointer=w5100_read(S0_RX_RD1);
+readpointer = readpointer << 8;
+readpointer += w5100_read(S0_RX_RD0);
+return readpointer;
+}
+
+// setters for some RX and TX registers
+//		S0_TX_WR
+void set_S0_TX_WR(U16 value)
+{
+U08 high_byte = (value>>8);
+U08 low_byte = (value<<8)>>8;
+w5100_write(S0_TX_WR1, high_byte);
+w5100_write(S0_TX_WR0, low_byte);
+}
+
+//		S0_TX_RD
+void set_S0_RX_RD(U16 value)
+{
+U08 high_byte = (value>>8);
+U08 low_byte = (value<<8)>>8;
+w5100_write(S0_TX_RD1, high_byte);
+w5100_write(S0_TX_RD0, low_byte);
+}
+
+U08 w5100_get_RX(U08 NumBytes, BOOL send_ACK)
+{
+	U16 size = get_S0_RX_RSR();
+	U16 upper_size, lower_size;
+	if (NumBytes > ETH_READ_BUFFER_SIZE)
+	{
+		NumBytes = ETH_READ_BUFFER_SIZE;
+	}
+	if (size == 0)
+	{
+		return 0;
+	}
+	else if ( size < NumBytes )
+	{
+		NumBytes = size;
+	}
+
+	// now calculate the offset address
+	// calculated according to W5100 datasheet page: 43
+	U16 last_RX_read_pointer = get_S0_RX_RD();
+	U16 offset = last_RX_read_pointer & S0_RX_MASK;
+	U16 start_address =  S0_RX_BASE + offset;
+
+	if ((offset + NumBytes) > (S0_RX_MASK + 1) )  // if data is turned over in RX-mem
+	{
+		upper_size = (S0_RX_MASK + 1) - offset;
+		lower_size = NumBytes - upper_size;
+		for (U08 i = 0; i < upper_size; ++i)
+		{
+			eth_read_buffer[i] = w5100_read(start_address + i);
+		}
+		for (U08 i = 0; i < lower_size; ++i)
+		{
+			eth_read_buffer[upper_size + i] = w5100_read(S0_RX_BASE + i);
+		}
+	}
+	else // if not data turn over in RX-mem
+	{
+		for (U08 i = 0; i < NumBytes; ++i)
+		{
+			eth_read_buffer[i] = w5100_read(start_address + i);
+		}
+	}
+
+	// inform W5100 about how much data was read out.
+	set_S0_RX_RD(last_RX_read_pointer + NumBytes);
+
+	// if user wishes, W5100 may inform peer about receiption.
+	// this should be done quickly, otherwise timeout may occur on 
+	// peer side, and peer retransmitts or so ... 
+	// 
+	// maybe it is necessary to acknowledge receiption very early.
+	// I think there is an option in Socket mode register for this.
+	if (send_ACK)
+	{
+		w5100_write ( S0_CR, CR_RECV );
+	}
+
+	return NumBytes;
+}
+
+// returns number of words, transmitted into TX - buffer.
+U08 w5100_set_TX(U08 NumBytes)
+{
+	U16 freesize = get_S0_TX_FSR();
+	if (freesize == 0)
+	{
+		return 0;
+	}
+	if (freesize < NumBytes)
+	{
+		NumBytes = freesize;
+	}
+	
+	U16 last_TX_write_pointer = get_S0_TX_WR();
+	U16 offset = last_TX_write_pointer & S0_TX_MASK;
+	U16 start_address =  S0_TX_BASE + offset;
+
+
+	U16 upper_size, lower_size;
+	if (NumBytes > ETH_READ_BUFFER_SIZE)
+	{
+		NumBytes = ETH_READ_BUFFER_SIZE;
+	}
+	if (freesize == 0)
+	{
+		return 0;
+	}
+	else if ( freesize < NumBytes )
+	{
+		NumBytes = freesize;
+	}
+
+	// now calculate the offset address
+	// calculated according to W5100 datasheet page: 43
+
+	if ((offset + NumBytes) > (S0_RX_MASK + 1) )  // if data is turned over in RX-mem
+	{
+		upper_size = (S0_RX_MASK + 1) - offset;
+		lower_size = NumBytes - upper_size;
+		for (U08 i = 0; i < upper_size; ++i)
+		{
+			eth_read_buffer[i] = w5100_read(start_address + i);
+		}
+		for (U08 i = 0; i < lower_size; ++i)
+		{
+			eth_read_buffer[upper_size + i] = w5100_read(S0_RX_BASE + i);
+		}
+	}
+	else // if not data turn over in RX-mem
+	{
+		for (U08 i = 0; i < NumBytes; ++i)
+		{
+			eth_read_buffer[i] = w5100_read(start_address + i);
+		}
+	}
+
+	// inform W5100 about how much data was read out.
+	set_S0_RX_RD(last_TX_write_pointer + NumBytes);
+
+
+	return NumBytes;
+}
Index: firmware/FSC/usb_src/w5100_spi_interface.h
===================================================================
--- firmware/FSC/usb_src/w5100_spi_interface.h	(revision 10754)
+++ firmware/FSC/usb_src/w5100_spi_interface.h	(revision 10754)
@@ -0,0 +1,197 @@
+#ifndef __W5100_SPI_INTERFACE_H
+#define __W5100_SPI_INTERFACE_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "num_conversion.h"
+
+extern volatile BOOL sock0_connection_established;
+
+
+#define ETH_READ_BUFFER_SIZE 16
+#define ETH_WRITE_BUFFER_SIZE 16
+extern volatile U08 eth_read_buffer[ETH_READ_BUFFER_SIZE];
+extern volatile U08 eth_write_buffer[ETH_WRITE_BUFFER_SIZE];
+//-----------------------------------------------------------------------------
+// Port Definitions
+// Pin Definitions
+// W5100 is SPI device 0
+// -- so there is no need to define special pins.
+// -- refer to the device by using the global buffers:
+// 	volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE];
+//	volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE];
+//
+//	and the spi function:
+// 	void spi_transfer(U08 bytes, U08 device)
+// 
+//	when only sending one byte, you can do:
+//	U08 returnvalue;
+//	CLR_BIT(SPI_DEVICE_SS_PRT[0], SPI_DEVICE_SS[0]);  	// Set CS low
+//	returnvalue = spi_transfer_byte(0xFF);     	
+//  SET_BIT(SPI_DEVICE_SS_PRT[0], SPI_DEVICE_SS[0]);	// Set CS high
+//
+//	W5100 supports SPI modes 0 and 3  --> cpol/cpha= 0/0 or 1/1
+
+// we only use socket 0 in this application. So only a few of W5100 adresses are mentioned here
+// W5100 MEM Addresses
+// Common registers:
+#define CM_MR    0x0000		// mode register
+#define CM_GAR0  0x0001		// Gateway adress 
+#define CM_GAR1  0x0002		// Gateway adress 
+#define CM_GAR2  0x0003		// Gateway adress 
+#define CM_GAR3  0x0004		// Gateway adress 
+#define CM_SUBR0 0x0005		// Subnetmask adress 
+#define CM_SUBR1 0x0006		// Subnetmask adress 
+#define CM_SUBR2 0x0007		// Subnetmask adress 
+#define CM_SUBR3 0x0008		// Subnetmask adress 
+#define CM_SHAR0 0x0009		// Source Hardware adress: MAC
+#define CM_SHAR1 0x000A		// Source Hardware adress: MAC
+#define CM_SHAR2 0x000B		// Source Hardware adress: MAC
+#define CM_SHAR3 0x000C		// Source Hardware adress: MAC
+#define CM_SHAR4 0x000D		// Source Hardware adress: MAC
+#define CM_SHAR5 0x000E		// Source Hardware adress: MAC
+#define CM_SIPR0 0x000F		// Source IP adress
+#define CM_SIPR1 0x0010		// Source IP adress
+#define CM_SIPR2 0x0011		// Source IP adress
+#define CM_SIPR3 0x0012		// Source IP adress
+#define CM_IR    0x0015		// Interrupt
+#define CM_IMR   0x0016		// Source IP adress
+#define CM_RTR0  0x0017		// retry time register
+#define CM_RTR1  0x0018		// retry time register
+#define CM_RCR   0x0019		// Retry count 
+#define CM_RMSR  0x001A		// RX mem size					-- full mem size for sock0 --> value=0x03
+#define CM_TMSR  0x001B		// TX mem size					-- full mem size for sock0 --> value=0x03
+
+// Socket 0 registers
+#define S0_MR 		0x0400		// Socket 0 mode			-- for TCP value = 0x01 (set bit 5 for no delay ACK)
+#define S0_CR		0x0401		// socket 0 command			-- for commands see below
+#define S0_IR		0x0402		// socket 0 interrupt		-- see bit description below
+#define S0_SR		0x0403		// socket 0 status			-- see below
+#define S0_PORT0	0x0404		// socket 0 Port			-- FSC might get port number 0x1F5C = 8028, since we have only one FSC in cam
+#define S0_PORT1	0x0405		// socket 0 Port 			-- 0xF5C1= 62913 is okay as well ... 
+#define S0_MSSR0	0x0412		// max segment size			--
+#define S0_MSSR1	0x0413		// max segment size			-- reset value is 0xFFFF; is set to other party value, if in TCP passive mode
+#define S0_TX_FSR0	0x0420		// socket 0 TX free size
+#define S0_TX_FSR1	0x0421		// socket 0 TX free size
+#define S0_TX_RD0	0x0422		// socket 0 TX read pointer	-- read only:
+#define S0_TX_RD1	0x0423		// socket 0 TX read pointer
+#define S0_TX_WR0	0x0424		// socket 0 TX write pointer
+#define S0_TX_WR1	0x0425		// socket 0 TX write pointer
+#define S0_RX_RSR0	0x0426		// socket 0 RX received size 
+#define S0_RX_RSR1	0x0427		// socket 0 RX received size 
+#define S0_RX_RD0	0x0428		// socket 0 RX read pointer
+#define S0_RX_RD1	0x0429		// socket 0 RX read pointer 
+
+
+
+// some register values:
+#define MR_TCP			0
+#define MR_NOACKDELAY	5
+
+#define CR_OPEN			0x01
+#define CR_LISTEN		0x02
+#define CR_CONECT		0x04
+#define CR_DISCON		0x08
+#define CR_CLOSE		0x10
+#define CR_SEND			0x20
+#define CR_RECV			0x40
+#define CR_SEND_MAC		0x21
+#define CR_SEND_KEEP	0x22
+
+#define IR_SEND_OK		4
+#define IR_TIMEOUT		3
+#define IR_RECV			2
+#define IR_DISCON		1
+#define IR_CON			0
+
+#define SR_SOCK_CLOSED			0x00
+#define SR_SOCK_INIT			0x13
+#define SR_SOCK_LISTEN			0x14
+#define SR_SOCK_ESTABLISHED		0x17
+#define SR_SOCK_CLOSE_WAIT		0x1C
+#define SR_SOCK_UDP				0x22
+#define SR_SOCK_IPRAW			0x32
+#define SR_SOCK_MACRAW			0x42
+#define SR_SOCK_PPPOE			0x5F
+//changing
+#define SR_SOCK_SYNSENT			0x15
+#define SR_SOCK_SYNRECV			0x16
+#define SR_SOCK_FIN_WAIT		0x18
+#define SR_SOCK_CLOSING			0x1A
+#define SR_SOCK_TIME_WAIT		0x1B
+#define SR_SOCK_LAST_ACK		0x1D
+#define SR_SOCK_ARP0			0x11
+#define SR_SOCK_ARP1			0x21
+#define SR_SOCK_ARP2			0x31
+
+// low level functions
+void w5100_write( U16 addr, U08 data);
+U08 w5100_read( U16 addr);
+
+//------------------------------------------------------------------------------
+// Description of w5100_init() function:
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+// BASIC SETTINGS:
+//------------------------------------------------------------------------------
+// leave common MR in default state: 0x00
+// leave IMR in default state: 0x00 no interrupt will occur, since #INT line is not routed
+// leave RTR in default state: 0x07D0  --> 200ms
+// leave RCR in default state: 0x08, after 8 re-transmissionsm, the TIMEOUT bit in Sn_IR is set '1'
+//------------------------------------------------------------------------------
+// NETWORK SETTING:
+// set GAR to FSC_GATEWAY_ADDRESS
+#define FSC_GATEWAY_ADDRESS0 0xC0		// 192.33.96.1
+#define FSC_GATEWAY_ADDRESS1 0x21
+#define FSC_GATEWAY_ADDRESS2 0x60
+#define FSC_GATEWAY_ADDRESS3 0x01
+// set SHAR to FSC_MAC_ADDRESS
+#define FSC_MAC_ADDRESS0 0xFA	//FA:C7:0F:AD:22:01
+#define FSC_MAC_ADDRESS1 0xC7
+#define FSC_MAC_ADDRESS2 0x0F 
+#define FSC_MAC_ADDRESS3 0xAD
+#define FSC_MAC_ADDRESS4 0x22
+#define FSC_MAC_ADDRESS5 0x01
+// set SUBR to FSC_SUBNET_MASK
+#define FSC_SUBNET_MASK0 0xFF	//255.255.248.0
+#define FSC_SUBNET_MASK1 0xFF
+#define FSC_SUBNET_MASK2 0xF8
+#define FSC_SUBNET_MASK3 0x00
+// set SIPR to FSC_IP_ADDRESS
+#define FSC_IP_ADDRESS0 0xC0	// 192.33.99.247
+#define FSC_IP_ADDRESS1 0x21
+#define FSC_IP_ADDRESS2 0x63
+#define FSC_IP_ADDRESS3 0xF7
+//------------------------------------------------------------------------------
+// MEM SETTINGS:
+// we plan the possible use of 2 Sockets:
+// Socket 0 for command input and requested data output
+// Socket 1 as a Webserver
+//
+// set RMSR=0x0A --> 4k memory for Socket 0 and 1 
+#define RX_MEM_BASE 0x6000
+#define S0_RX_BASE  0x6000 			// since it is the first socket its base adress is just the RX MEM SPACE BASE
+#define S0_RX_MASK  0x0FFF			// this is 4k - 1
+#define S1_RX_BASE  0x7000			// 2nd socket start, right after first socket
+#define S1_RX_MASK  0x0FFF			// again: 4k - 1
+// set TMSR=0x0A --> 4k mem for each socket
+#define TX_MEM_BASE 0x4000
+#define S0_TX_BASE  0x4000 			// since it is the first socket its base adress is just the RX MEM SPACE BASE
+#define S0_TX_MASK  0x0FFF			// this is 4k - 1
+#define S1_TX_BASE  0x5000			// 2nd socket start, right after first socket
+#define S1_TX_MASK  0x0FFF			// again: 4k - 1
+//------------------------------------------------------------------------------
+U08 w5100_init();
+
+
+// -- returns: TRUE if socket status is == SR_SOCK_ESTABLISHED
+BOOL w5100_is_established();
+// request socket status info:
+U08 w5100_sock_status();
+
+
+U16 w5100_get_received_size();
+U16 w5100_get_start_address();
+//-----------------------------------------------------------------------------
+#endif //__W5100_SPI_INTERFACE_H
