new CanControl

CanControl.h

Committer:
kwasymodo
Date:
2017-05-12
Revision:
0:274e6fb7df45
Child:
1:25258579a80d

File content as of revision 0:274e6fb7df45:

#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