I has some code that compiles fine for a 328P. When I try to compile for Teensy 3.2 I get this error:
> spiSlaveTeensy:166: error: expected constructor, destructor, or type conversion before '(' token
> ISR(255)
> ^
> exit status 1
> expected constructor, destructor, or type conversion before '(' token
Here is the interrupt routine:
ISR(SPI_STC_vect)
{
// while (!(SPSR & _BV(SPIF))) ;
// digitalWrite(4, LOW);
c = SPDR;
while (!(SPSR & 1<<SPIF)) ;
c = (c << 8) | SPDR;
digitalWrite(4, LOW);
digitalWrite(4, LOW);
while (!(SPSR & 1<<SPIF)) ;
d = SPDR;
digitalWrite(4, LOW);
while (!(SPSR & 1<<SPIF)) ;
d = (d << 8) | SPDR;
spiDataAvailable = true;
interrupts();
}
The setup:
#include <SPI.h>
int clk = 13;
int dat = 11;
int ss = 10;
//volatile bool rLoad = false;
//volatile bool tLoad = false;
volatile boolean spiDataAvailable = false;
volatile uint16_t c, d;
void setup()
{
Serial.begin(250000);
delay(1000);
// pinMode(clk, INPUT);
//pinMode(dat, INPUT);
// pinMode(dat, INPUT_PULLUP);
pinMode(4, OUTPUT);
Serial.println("teensy 32b spi");
delay(100);
SPI.setDataMode (SPI_MODE0);
SPCR |= bit (SPE); // turn on SPI in slave mode
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
SPI.attachInterrupt();
}
Your help is appreciated.
John
> spiSlaveTeensy:166: error: expected constructor, destructor, or type conversion before '(' token
> ISR(255)
> ^
> exit status 1
> expected constructor, destructor, or type conversion before '(' token
Here is the interrupt routine:
ISR(SPI_STC_vect)
{
// while (!(SPSR & _BV(SPIF))) ;
// digitalWrite(4, LOW);
c = SPDR;
while (!(SPSR & 1<<SPIF)) ;
c = (c << 8) | SPDR;
digitalWrite(4, LOW);
digitalWrite(4, LOW);
while (!(SPSR & 1<<SPIF)) ;
d = SPDR;
digitalWrite(4, LOW);
while (!(SPSR & 1<<SPIF)) ;
d = (d << 8) | SPDR;
spiDataAvailable = true;
interrupts();
}
The setup:
#include <SPI.h>
int clk = 13;
int dat = 11;
int ss = 10;
//volatile bool rLoad = false;
//volatile bool tLoad = false;
volatile boolean spiDataAvailable = false;
volatile uint16_t c, d;
void setup()
{
Serial.begin(250000);
delay(1000);
// pinMode(clk, INPUT);
//pinMode(dat, INPUT);
// pinMode(dat, INPUT_PULLUP);
pinMode(4, OUTPUT);
Serial.println("teensy 32b spi");
delay(100);
SPI.setDataMode (SPI_MODE0);
SPCR |= bit (SPE); // turn on SPI in slave mode
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
SPI.attachInterrupt();
}
Your help is appreciated.
John