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.
CANInterface.h@0:1ce2190bc4d2, 2014-04-30 (annotated)
- Committer:
- ashleymills
- Date:
- Wed Apr 30 13:51:22 2014 +0000
- Revision:
- 0:1ce2190bc4d2
Simple can interface. Based on work by SKPang, but heavily cleaned up and abstracted.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ashleymills | 0:1ce2190bc4d2 | 1 | #pragma once |
| ashleymills | 0:1ce2190bc4d2 | 2 | #include "mbed.h" |
| ashleymills | 0:1ce2190bc4d2 | 3 | |
| ashleymills | 0:1ce2190bc4d2 | 4 | class CANInterface { |
| ashleymills | 0:1ce2190bc4d2 | 5 | public: |
| ashleymills | 0:1ce2190bc4d2 | 6 | enum BusSpeed { |
| ashleymills | 0:1ce2190bc4d2 | 7 | CAN_SPEED_125=125000, |
| ashleymills | 0:1ce2190bc4d2 | 8 | CAN_SPEED_250=250000, |
| ashleymills | 0:1ce2190bc4d2 | 9 | CAN_SPEED_500=500000 |
| ashleymills | 0:1ce2190bc4d2 | 10 | }; |
| ashleymills | 0:1ce2190bc4d2 | 11 | |
| ashleymills | 0:1ce2190bc4d2 | 12 | enum MessageType { |
| ashleymills | 0:1ce2190bc4d2 | 13 | CAN_PID_REQUEST=0x7DF, |
| ashleymills | 0:1ce2190bc4d2 | 14 | CAN_PID_REPLY=0x7E8 |
| ashleymills | 0:1ce2190bc4d2 | 15 | }; |
| ashleymills | 0:1ce2190bc4d2 | 16 | |
| ashleymills | 0:1ce2190bc4d2 | 17 | CANInterface(PinName rd, PinName td); |
| ashleymills | 0:1ce2190bc4d2 | 18 | ~CANInterface(); |
| ashleymills | 0:1ce2190bc4d2 | 19 | int makeRequest(uint8_t pid, uint8_t *outBuf, int *outLen); |
| ashleymills | 0:1ce2190bc4d2 | 20 | |
| ashleymills | 0:1ce2190bc4d2 | 21 | private: |
| ashleymills | 0:1ce2190bc4d2 | 22 | CAN *_can; |
| ashleymills | 0:1ce2190bc4d2 | 23 | Timer *_timer; |
| ashleymills | 0:1ce2190bc4d2 | 24 | int _timeout; |
| ashleymills | 0:1ce2190bc4d2 | 25 | }; |