new CanControl

Committer:
kwasymodo
Date:
Fri May 12 20:30:34 2017 +0000
Revision:
1:25258579a80d
Parent:
0:274e6fb7df45
Child:
2:d7776fa70ef5
added CanControl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kwasymodo 0:274e6fb7df45 1 #ifndef CANCONTROL_H
kwasymodo 0:274e6fb7df45 2 #define CANCONTROL_H
kwasymodo 0:274e6fb7df45 3
kwasymodo 0:274e6fb7df45 4 #include "mbed.h"
kwasymodo 0:274e6fb7df45 5
kwasymodo 0:274e6fb7df45 6 #define BMSCANADDRESS 0x033
kwasymodo 0:274e6fb7df45 7
kwasymodo 0:274e6fb7df45 8 /** CanControl class
kwasymodo 0:274e6fb7df45 9 * Used to control the power on the CanBus
kwasymodo 0:274e6fb7df45 10 */
kwasymodo 0:274e6fb7df45 11 class CanControl
kwasymodo 0:274e6fb7df45 12 {
kwasymodo 0:274e6fb7df45 13 public:
kwasymodo 0:274e6fb7df45 14 /** Create CanControl instance
kwasymodo 1:25258579a80d 15 @param buck converter pin
kwasymodo 0:274e6fb7df45 16 */
kwasymodo 0:274e6fb7df45 17 CanControl(PinName buckCan);
kwasymodo 0:274e6fb7df45 18
kwasymodo 0:274e6fb7df45 19 /** Disables/shuts down the Can bus
kwasymodo 0:274e6fb7df45 20 */
kwasymodo 0:274e6fb7df45 21 bool disable(void);
kwasymodo 0:274e6fb7df45 22
kwasymodo 0:274e6fb7df45 23 /** Enables/turn on the Can bus
kwasymodo 0:274e6fb7df45 24 */
kwasymodo 0:274e6fb7df45 25 bool enable(void);
kwasymodo 0:274e6fb7df45 26
kwasymodo 0:274e6fb7df45 27 /** Returns the status of the Canbus
kwasymodo 0:274e6fb7df45 28 1 = enabled, 0 = disabled
kwasymodo 0:274e6fb7df45 29 */
kwasymodo 0:274e6fb7df45 30 bool status(void){return enabled;}
kwasymodo 0:274e6fb7df45 31
kwasymodo 0:274e6fb7df45 32 private:
kwasymodo 0:274e6fb7df45 33 /** Keep relay enabled
kwasymodo 0:274e6fb7df45 34 makes sure the relay stays enabled when the enable function is called
kwasymodo 0:274e6fb7df45 35 this happens by pinging the BMS every second (CAN address 0x033)
kwasymodo 0:274e6fb7df45 36 */
kwasymodo 0:274e6fb7df45 37 void relay(void);
kwasymodo 0:274e6fb7df45 38
kwasymodo 0:274e6fb7df45 39 DigitalOut _buckCan;
kwasymodo 0:274e6fb7df45 40 DigitalOut _canEnable;
kwasymodo 0:274e6fb7df45 41 Ticker repeat;
kwasymodo 0:274e6fb7df45 42 bool enabled;
kwasymodo 0:274e6fb7df45 43 };
kwasymodo 0:274e6fb7df45 44
kwasymodo 0:274e6fb7df45 45 #endif //CANCONTROL_H