new CanControl
Diff: CanControl.h
- Revision:
- 0:274e6fb7df45
- Child:
- 1:25258579a80d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CanControl.h Fri May 12 20:19:32 2017 +0000 @@ -0,0 +1,46 @@ +#ifndef CANCONTROL_H +#define CANCONTROL_H + +#include "mbed.h" + +#define BMSCANADDRESS 0x033 + +/** CanControl class + * Used to control the power on the CanBus + */ +class CanControl +{ + public: + /** Create CanControl instance + @param buckCan + @param ledCan + */ + CanControl(PinName buckCan); + + /** Disables/shuts down the Can bus + */ + bool disable(void); + + /** Enables/turn on the Can bus + */ + bool enable(void); + + /** Returns the status of the Canbus + 1 = enabled, 0 = disabled + */ + bool status(void){return enabled;} + + private: + /** Keep relay enabled + makes sure the relay stays enabled when the enable function is called + this happens by pinging the BMS every second (CAN address 0x033) + */ + void relay(void); + + DigitalOut _buckCan; + DigitalOut _canEnable; + Ticker repeat; + bool enabled; +}; + +#endif //CANCONTROL_H \ No newline at end of file