I have a problem understanding the error message:
SPItest1:11: error: request for member 'begin' in 'spiTest', which is of non-class type 'SPIbase ()()'
I am just beginning to write this library routine and wanted to check for errors before I got too far.
The sketch is:
/*
*/
#include "SPIbase.h"
SPIbase spiTest();
void setup()
{
Serial.begin(9600);
spiTest.begin(6);
}
void loop()
{
bool fr = spiTest.SPIisFree(spiTest);
}
The library header file is:
#ifndef SPIBASE_H
#define SPIBASE_H
#include "Arduino.h"
typedef struct {
unsigned char ssPin;
unsigned char buffer[11];
}
SPIparams_t;
class SPIbase
{
SPIparams_t SPIparams;
public:
SPIbase();
void begin(unsigned char pin);
bool SPIisFree(SPIbase *client);
void SPIsetFree(SPIbase *client);
};
#endif
The cpp file is:
#include "SPIbase.h"
#include <avr/interrupt.h>
volatile SPIbase *basePtr;
SPIbase::SPIbase()
{
}
void SPIbase::begin(unsigned char pin)
{
SPIparams.ssPin = pin;
}
bool SPIbase::SPIisFree(SPIbase *client)
{
if (!basePtr) {
basePtr = client;
return true;
} else return basePtr == client;
}
void SPIbase::SPIsetFree(SPIbase *client)
{
if (basePtr == client) basePtr = 0;
}
What is wrong?