new CanControl
CanControl.h@0:274e6fb7df45, 2017-05-12 (annotated)
- Committer:
- kwasymodo
- Date:
- Fri May 12 20:19:32 2017 +0000
- Revision:
- 0:274e6fb7df45
- Child:
- 1:25258579a80d
new CanControl
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:274e6fb7df45 | 15 | @param buckCan |
kwasymodo | 0:274e6fb7df45 | 16 | @param ledCan |
kwasymodo | 0:274e6fb7df45 | 17 | */ |
kwasymodo | 0:274e6fb7df45 | 18 | CanControl(PinName buckCan); |
kwasymodo | 0:274e6fb7df45 | 19 | |
kwasymodo | 0:274e6fb7df45 | 20 | /** Disables/shuts down the Can bus |
kwasymodo | 0:274e6fb7df45 | 21 | */ |
kwasymodo | 0:274e6fb7df45 | 22 | bool disable(void); |
kwasymodo | 0:274e6fb7df45 | 23 | |
kwasymodo | 0:274e6fb7df45 | 24 | /** Enables/turn on the Can bus |
kwasymodo | 0:274e6fb7df45 | 25 | */ |
kwasymodo | 0:274e6fb7df45 | 26 | bool enable(void); |
kwasymodo | 0:274e6fb7df45 | 27 | |
kwasymodo | 0:274e6fb7df45 | 28 | /** Returns the status of the Canbus |
kwasymodo | 0:274e6fb7df45 | 29 | 1 = enabled, 0 = disabled |
kwasymodo | 0:274e6fb7df45 | 30 | */ |
kwasymodo | 0:274e6fb7df45 | 31 | bool status(void){return enabled;} |
kwasymodo | 0:274e6fb7df45 | 32 | |
kwasymodo | 0:274e6fb7df45 | 33 | private: |
kwasymodo | 0:274e6fb7df45 | 34 | /** Keep relay enabled |
kwasymodo | 0:274e6fb7df45 | 35 | makes sure the relay stays enabled when the enable function is called |
kwasymodo | 0:274e6fb7df45 | 36 | this happens by pinging the BMS every second (CAN address 0x033) |
kwasymodo | 0:274e6fb7df45 | 37 | */ |
kwasymodo | 0:274e6fb7df45 | 38 | void relay(void); |
kwasymodo | 0:274e6fb7df45 | 39 | |
kwasymodo | 0:274e6fb7df45 | 40 | DigitalOut _buckCan; |
kwasymodo | 0:274e6fb7df45 | 41 | DigitalOut _canEnable; |
kwasymodo | 0:274e6fb7df45 | 42 | Ticker repeat; |
kwasymodo | 0:274e6fb7df45 | 43 | bool enabled; |
kwasymodo | 0:274e6fb7df45 | 44 | }; |
kwasymodo | 0:274e6fb7df45 | 45 | |
kwasymodo | 0:274e6fb7df45 | 46 | #endif //CANCONTROL_H |