#include "mbed.h"
Ticker ticker;
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(p26);
AnalogIn AnIn(p20);
CAN can1(p9, p10);
CAN can2(p30, p29);
char counter = 0 ;
int x=0, y=0,komanda=0,j=0;
void send() {
printf("send()\n");
y=AnIn.read();
if (y>0)
{
x=1;
komanda=1;
}
else{
komanda=0;
x=0;
}
if(can1.write(CANMessage(komanda, &counter, x)))
{
printf("wloop()\n");
counter++;
printf("Message sent: %d\n", counter);
}
led1 = !led1;}
int main() {
printf("main()\n");
ticker.attach(&send, 1);
CANMessage msg;
while(1) {
printf("loop()\n");
if(can2.read(msg)) {
printf("prittloooo: %d\n", msg);
j= can2 -> read(msg); // ERROR
printf("prittlaaaa: %d\n", j);
printf("Message received: %d\n", msg.data[0]);
led3=0;
led2 = !led2;
}
wait(0.2);
}
}