Testing program for Interrupts
main.cpp
- Committer:
- alexliao1995
- Date:
- 2014-03-19
- Revision:
- 0:0a01a8b970fc
File content as of revision 0:0a01a8b970fc:
#include "mbed.h"
CAN canObject(p30,p29);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Serial pc(USBTX, USBRX);
void test(void) {
led1= !led1;
return;
}
bool speed() {
char can_msg[3];
can_msg[0] = 0x3D;
can_msg[1] = 0x30;
can_msg[2] = 0x00;
bool success = canObject.write(CANMessage(0x211, can_msg, 3));
led2 = !led2;
return success;
}
int main()
{
pc.baud(115200);
wait(0.2);
canObject.frequency(250000);
wait(0.2);
canObject.attach(&test, CAN::RxIrq);
wait(1);
if(speed());
wait(1);
if(speed());
while(1) {
}
}