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.
Diff: main.cpp
- Revision:
- 0:f2565808eea5
- Child:
- 1:3644b10bce2f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jun 04 04:40:58 2016 +0000 @@ -0,0 +1,58 @@ +#include <mbed.h> +#include <USBSerial.h> +#include "slcan.h" + +static const uint16_t VID = 0x1209; +static const uint16_t PID = 0x0001; +static const uint16_t VERSION = 0x0001; + + +CAN can1(D9, D10); +/* +USBSerial virtualUART(VID, PID, VERSION, false); +USBSLCAN slcan(virtualUART, can1); +*/ + +Serial hwUART(USBTX, USBRX); +SerialSLCAN slcan(hwUART, can1); + +Timer timer; +DigitalOut led(LED1); +DigitalOut led2(LED2); + +int main() { + can1.mode(CAN::Reset); + //can1.frequency(500000); + //can1.mode(CAN::Silent); + + //virtualUART.connect(false); + hwUART.baud(115200); + + led = 0; + led2 = 1; + while(1) { + bool active = false; + active = slcan.update(); + /* + if (virtualUART.configured()) { + led2 = 0; + active = slcan.update(); + } else { + led2 = 1; + virtualUART.connect(false); + } + */ + + if (active) { + timer.reset(); + timer.start(); + } + + if (timer.read_ms() > 100) { + led = 0; + timer.stop(); + } else { + led = 1; + } + } +} \ No newline at end of file