I posted the code below. I'm using webbot, so it relies relatively heavily on its own functions. I generally don't reset anything related to the interrupt in this version of the code.
The connection between master and slave worked well when I wasn't using interrupts: I just polled SPDR, and turned the LED on when its value was 1, and off when it was 0. The slave and the master, at that point, should have turned their LEDs on and off at the same time, and that's what happened. If it matters, both chips are ATMega644s, and there is an LED on PB0 for both of them.
Here is the code:
#define F_CPU 16000000UL //CPU Frequency
#define LEDPIN B0
#define MOSIPIN B5
#define MISOPIN B6
#define SCKPIN B7
#define SSPIN B4
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/signal.h>
#include "sys/atmega644.h"
#include "i2cBus.h"
#include "iopin.h"
//global variables
char readt;
//Apparently we're allowed to interrupt like this
ISR(SPI_STC_vect)
{
//So, if SPI_STC_vect has triggered, it means that communication is done. So let's set readt.
readt = SPDR;
pin_set(LEDPIN,FALSE);
delay_ms(2000);
}
void appInitHardware(void)
{
pin_make_input(MOSIPIN,FALSE);
pin_make_input(SCKPIN,FALSE);
pin_make_input(SSPIN,TRUE); //I believe it's LOW to select...
pin_make_output(MISOPIN,FALSE);
pin_make_output(LEDPIN,FALSE);
//initialize SPI. SPE == SPI Enable. SPIE == SPI INTERRUPT Enable
SPCR = (1<<SPE) | (1 << SPIE);
sei(); //Uh...this enables interrupts in general?
}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart)
{
return 0;
}
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
{
pin_set(LEDPIN,TRUE);
// while(!(SPSR & (1<<SPIF)))
// {
// ;
// }
// if(readt == 1)
// ;
//pin_set(LEDPIN,TRUE);
return 20000;
}
Maybe my interrupts just aren't doing anything?