Index: branches/encoders/code/projects/template/main.c
===================================================================
--- branches/encoders/code/projects/template/main.c	(revision 564)
+++ branches/encoders/code/projects/template/main.c	(revision 565)
@@ -2,17 +2,22 @@
 #include "spi.h"
 
 #define MODE 0
-#define TEST 1
+#define TEST 0
+
 extern char spi_status;
 
 void recv_func(char c) {
-    if (c != '\n');
-	if(MODE)
-		usb_puts("MASTER");
-	else
-		usb_puts("SLAVE");
+    if (c != '0') {
+	    if(MODE)
+		    usb_puts("MASTER");
+	    else
+		    usb_puts("SLAVE");
 	
-	usb_puts(": received [");usb_putc(c);usb_puts("]\n\r");
+	    usb_puts(": received ["); 
+	    usb_putc(c); 
+	    usb_puts("]\n\r");
+    }
+
 	return;
 }
 
@@ -22,7 +27,24 @@
 {
 	dragonfly_init(ALL_ON);
 	spi_init(MODE, recv_func);
-	usb_puts("Init done\n\r");
+	usb_puts("Init done.\n\r");
+/*
+    if (TEST) {
+        if (MODE) {
+            while (1) {
+                spi_read(6);
+                delay_ms(1000);	
+            }
+        } else {
+            spi_send("SLAVE", 5);
+        }
+        
+    
+    }
+
+    while(1);
+*/
+
 	while(1) {
 		if(TEST){
 			if(MODE){
@@ -30,8 +52,9 @@
 				delay_ms(1000);
 			} else {
 				//if(!(spi_status & SPI_SEND))
-				spi_send("SLAVE ",6);
-				//delay_ms(800);
+				spi_send("SLAVE", 5);
+				
+				
 			}
 		} else {
 			if (MODE) {
@@ -40,7 +63,7 @@
 		}
 		
 	}
-	
+//	*/
 	return 0;
 	
 }
Index: branches/encoders/code/projects/template/Makefile
===================================================================
--- branches/encoders/code/projects/template/Makefile	(revision 564)
+++ branches/encoders/code/projects/template/Makefile	(revision 565)
@@ -115,9 +115,11 @@
 endif
 
 # Place -I, -L options here
-CINCS = -I../libdragonfly 
-CINCS += -L../libdragonfly
-
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
 #---------------- Compiler Options ----------------
 #  -g*:          generate debugging information
 #  -O*:          optimization level
@@ -195,7 +197,6 @@
 LDFLAGS += -ldragonfly
 
 
-
 #---------------- Programming Options (avrdude) ----------------
 
 # Programming hardware: alf avr910 avrisp bascom bsd 
Index: branches/encoders/code/projects/libdragonfly/spi.c
===================================================================
--- branches/encoders/code/projects/libdragonfly/spi.c	(revision 564)
+++ branches/encoders/code/projects/libdragonfly/spi.c	(revision 565)
@@ -47,7 +47,12 @@
      * Enable Interrupt, Enable SPI Module, LSB First, Master Mode, Clock div = 64
      */
     SPCR = 0x00;
-	SPCR = _BV(SPIE) | _BV(SPE) | _BV(DORD) | _BV(MSTR)| _BV(SPR1) | _BV(SPR0);
+    if (spi_mode == MASTER) {
+    	SPCR = _BV(SPIE) | _BV(SPE) | _BV(DORD) | _BV(MSTR)| _BV(SPR1) | _BV(SPR0);
+    } else {
+    	SPCR = _BV(SPIE) | _BV(SPE) | _BV(DORD) | ~_BV(MSTR)| _BV(SPR1) | _BV(SPR0);
+    }
+            
     SPSR = 0x00;
 	SPSR = _BV(SPI2X); 
 	
@@ -54,7 +59,7 @@
 	spi_status = SPI_IDLE;
 
     /* Set SCLK, SS, MOSI as outputs. MISO as input */
-	if(mode == MASTER) {
+	if(spi_mode == MASTER) {
 	    DDRB |= MOSI | SCLK | SS;
 	    DDRB &= ~MISO;
 		PORTB |= SS;	//Keep SS High until transmit
@@ -65,7 +70,7 @@
     }
 	
 	//sei();
-	usb_puts("spi_init: end\n");
+	//usb_puts("spi_init: end\n");
 }
 
 int spi_send(char *data, int bytes) {
@@ -96,7 +101,7 @@
 	}
 	
     SPDR = *data;
-    
+    /*
 	if(spi_mode)
 		usb_puts("MASTER");
 	else
@@ -103,7 +108,7 @@
 		usb_puts("SLAVE");
 		
 	usb_puts(": sending [");usb_putc(*data);usb_puts("]\n\r");
-	
+	*/
 	//sei();
 	
 	return 1;
@@ -119,7 +124,7 @@
 	        return;
 	    }
 	
-	    RING_BUFFER_ADD(spi_send_buff, '\n');
+	    RING_BUFFER_ADD(spi_send_buff, '0');
     }
     
     sei();
@@ -130,7 +135,7 @@
 		PORTB &= ~SS;	//Select slave
 	}
 	
-    SPDR = '\n';
+    SPDR = '0';
 
 }
 
@@ -153,6 +158,8 @@
 	//If we're the master and we're done sending, end the transmission
 	} else if (spi_mode == MASTER) {
 	    PORTB |= SS;
+	} else if (spi_mode == SLAVE) {
+	    SPDR = '0';
 	}
 	
 
