CANPort provides a higher level interface to a CAN communication channel, and provides timestamping, servicing additional hardware interfaces (optional activity LED, CAN transceiver slope control)
Diff: CANPort.h
- Revision:
- 3:4c780c641125
- Parent:
- 2:1824d1421b6d
diff -r 1824d1421b6d -r 4c780c641125 CANPort.h --- a/CANPort.h Fri Aug 30 21:44:31 2019 +0000 +++ b/CANPort.h Thu Sep 19 21:46:28 2019 +0000 @@ -28,17 +28,6 @@ #include "mbed.h" #include "CANMessage.h" -typedef enum { - HIGHSPEED, - NORMALSPEED, - STANDBY -} CANSlopeControl_T; - -typedef enum { - MONITOR, - ACTIVE -} CANBusMode_T; - /// This is the CANPort, which is the physical interface to CAN /// /// This derived class has a number of additional capabilities: @@ -47,9 +36,20 @@ /// \li counters, to keep track of received and transmitted messages /// \li and more... /// -class CANPort { +class CANPort : public CAN { public: + typedef enum { + HIGHSPEED, + NORMALSPEED, + STANDBY + } CANSlopeControl_T; + + typedef enum { + MONITOR, + ACTIVE + } CANBusMode_T; + /// The advanced form of the constructure to create a CANPort, name /// an activity indicator, and name a slope control pin /// @@ -119,9 +119,9 @@ /// @param tptr pointer to the object to call the member function on /// @param mptr pointer to the member function to be called /// - template <typename T> void Attach(T * tptr, void (T::*mptr)(void)) { - can->attach(callback(tptr, mptr)); - } + //template <typename T> void Attach(T * tptr, void (T::*mptr)(void)) { + // can->attach(callback(tptr, mptr)); + //} /// This provides control of the AutoReset feature /// @@ -200,9 +200,9 @@ /// will retain the rate setting and then permits the query of the bitrate. /// /// @param rate is the desired bitrate in bits per second. - /// @returns true if teh command succeeded + /// @returns true if the command succeeded /// - bool SetBitRate(int rate); + bool SetBitRate(uint32_t rate); /// This returns the current desired bitrate for the CAN channel /// @@ -211,7 +211,7 @@ /// /// @returns the bitrate in bits per second /// - int GetBitRate(); + uint32_t GetBitRate(); /// This returns the number of messages that were sent by this CAN channel /// @@ -265,7 +265,7 @@ private: CANCHANNEL_T channel; // user assigned port number of this port - CAN * can; // bind to a specific CAN + //CAN * can; // bind to a specific CAN CANBusMode_T busMode; // monitor or active mode int bitRate; // bit rate for this bus PwmOut * activityPin; // LED to indicate activity