// #include <can.h>      // Include CAN library
// #include <mcp2515.h>  // Include MCP2515 library
#include <SPI.h>      // Include SPI library
#include <EEPROM.h>
#include <pt.h>  // include protothread library

static struct pt pt1, pt2;  // each protothread needs one of these

void setup()  // Set up serial interface and CAN bus interface
{
  Serial.begin(115200);
  SPI.begin();

  PT_INIT(&pt1);  // initialise the two
  PT_INIT(&pt2);  // protothread variables
}

/* exactly the same as the protothreadMainLoop function */
static int protothreadMainLoop(struct pt *pt) {
  PT_BEGIN(pt);
  while (1) {
    Serial.println("PROTO LOOP");
    PT_END(pt);
  }
}
static int protothreadAmbianceKeeper(struct pt *pt) {
  PT_BEGIN(pt);
  while (1) {
    Serial.println("AMBIANCE KEEPER");
    PT_END(pt);
  }
}

void loop() {
  Serial.println("loop ");
  protothreadMainLoop(&pt1);  // schedule the two protothreads
  protothreadAmbianceKeeper(&pt2); // by calling them infinitely
}