SPI implementation issues
Posted: Wed Apr 25, 2018 9:03 am
Hello All,
I have a ATMEGA2560 I wish to pass data back and forward to from a ESP32. The arduino code will not compile for the ESP32. I get the error "exit status 1 expected constructor, destructor, or type conversion before '(' token" when it tries to compile the ISR routine as per the below code example. The code is just a test routine for the ESP32 to be the slave. It will compile the master code and when running the below on the Mega the test does not work. But one problem at a time.
Maybe the ISR is not implemented in the ESP32? I am really a Newbie so struggling a bit.
Thanks in advance for any advice.
I have a ATMEGA2560 I wish to pass data back and forward to from a ESP32. The arduino code will not compile for the ESP32. I get the error "exit status 1 expected constructor, destructor, or type conversion before '(' token" when it tries to compile the ISR routine as per the below code example. The code is just a test routine for the ESP32 to be the slave. It will compile the master code and when running the below on the Mega the test does not work. But one problem at a time.
Code: Select all
#include <SPI.h>
#include <Arduino.h>
volatile boolean process_it;
volatile byte Svalrecieved, Svalsent;
int jj = 0;
void setup(void)
{
// Set Miso pin as output
pinMode(MISO, OUTPUT);
//turn on SPI in slave mode
SPCR |= _BV(SPE);
//get ready for an interupt
SPI.attachInterrupt();
}
ISR (SPI_STC_vect){
Svalrecieved = SPDR;
process_it = true;
}
void loop(void)
{
if (process_it)
{
Svalsent = jj;
SPDR = Svalsent;
jj++;
if (jj > 254) jj = 0;
}
}
Thanks in advance for any advice.