Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- ptpaterson
- Date:
- 2016-11-04
- Revision:
- 0:5abca479f387
- Child:
- 1:7cf308c1484d
File content as of revision 0:5abca479f387:
#include "mbed.h"
#include "CanPipe.h"
Ticker ticker;
DigitalOut led1(LED1);
CAN m_can(P0_11, P0_31);
CanPipe m_can_pipe(&m_can);
char counter = 0;
void send() {
led1 = !led1;
m_can_pipe.PostMessage(CANMessage(1337, &counter, 1));
}
int callback1(CANMessage &msg) { return CanPipe::kOkay; }
int callback2(CANMessage &msg) { return CanPipe::kOkay; }
int callback3(CANMessage &msg) { return CanPipe::kOkay; }
int main() {
int handle;
handle = m_can_pipe.RegisterFilter(0x200, 0x780);
m_can_pipe.RegisterCallback(callback1, handle);
handle = m_can_pipe.RegisterFilter(0x281, 0x780);
m_can_pipe.RegisterCallback(callback2, handle);
m_can_pipe.RegisterCallback(callback3, handle);
ticker.attach(send, 1);
while (1) {
__WFI(); //sleep();
m_can_pipe.HandleMessages();
}
}