SPI implementation issues

BlairM
Posts: 4
Joined: Sat Aug 26, 2017 10:48 pm

SPI implementation issues

Postby BlairM » 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.

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;
  }
}
Maybe the ISR is not implemented in the ESP32? I am really a Newbie so struggling a bit.
Thanks in advance for any advice.

Who is online

Users browsing this forum: Google [Bot] and 100 guests