I am busy with the firmware of a custom motorcontroller. For protyping i use the nucleo L432 with the mbed os.
The communication with the master controller is organized with the CAN bus. I would have a interupt routine when there is data received. This code work very good when placed in the main file but i would like to implement this code in a seperate class. But when i try to compile this solution i keep receiving the follow error from the compiler: Error: Nonstandard form for taking the address of a member function in "Lib/CANimp.cpp", Line: 19, Col: 18
Does anyone have a solution for this?
**CANimp.h**
#define CANIMP_H
#include "mbed.h"
class CANimp {
public:
CANimp(PinName can_rd, PinName can_td);
void send(void);
private:
CAN can1;
void rcv(void);
};
#endif
**CANimp.cpp**
#include "CANimp.h"
#include "mbed.h"
void CANimp::rcv() {
CANMessage msg1;
can1.read(msg1);
if(msg1.data[0] == 1)
{
float speed = msg1.data[1] / 255.0;
printf("set speed to %f \n", speed);
//Motordriver.setPWM(speed);
}
printf("Message received: %d %d\n\n", msg1.data[0], msg1.data[1]);
}
CANimp::CANimp(PinName can_rd, PinName can_td) : can1(can_rd, can_td)
{
can1.frequency(250000);
can1.attach(&rcv, CAN::RxIrq);
}
void CANimp::send() {
pc.printf("send()\n");
char temp[8];
temp[0] = 1;
temp[1] = 255;
temp[2] = 50;
if (can1.write(CANMessage(1338, temp, 3))) {
//pc.printf("wloop()\n");
//pc.printf("Message sent: %d\n", counter);
wait(0.02);
}
}