CAN library containing a CAN controller object handling a FIFO, and CAN peripherals attached to it.

PeripheralCAN.h

Committer:
garivetm
Date:
2016-02-06
Revision:
1:b69d05604535
Child:
3:e6f72461e31f

File content as of revision 1:b69d05604535:

#ifndef PeripheralCAN_H
#define PeripheralCAN_H

#include "mbed.h"
#include <vector>
#include "ControllerCAN.h"

class ControllerCAN;
/** My CAN Peripheral class
 * Used as interface to create CAN Peripheral objets
 *
 * Examples :
 * @code
 * @endcode
 */
class PeripheralCAN {
    public :
    /** Create PeripheralCAN instance
     */
    PeripheralCAN();
    
    /** Create PeripheralCAN instance
     *
     * @param controller ControllerCAN instance controlling the PerpiherialCAN
     */
    PeripheralCAN(ControllerCAN* controller);
    
    /** Initialize the instance 
     */
    virtual void init(void);
    
    /** Update the PeripheriamCAN instance
     *
     * @param Id Message Id to determine which variables are concerned,
     * @param msg CANMessage instance containing data of interest
     */
    virtual void update(const unsigned short& Id, const CANMessage& msg);
    
    /** Add an Id to the Id vector containing Ids of incoming message
     * concerning the current instance
     *
     * @param Id Message Id to be added
     */
    void addIdRead(unsigned short* Id);
    
    /** Write a message on CAN Bus
     *
     * @param Id Id message
     * @param data char array containing data to be send
     * @param len size of the data array 
     */
    void writeOnCAN(unsigned short Id, const char *data, char len);
    //short readOnCAN(unsigned short Id, CANMessage& msg);
    
    /** Get the IdsRead vector
     *
     * @returns IdsRead vector
     */    
    vector<unsigned short*> getIdsRead(void);
    
    private :
    vector<unsigned short*> IdsRead;
    ControllerCAN* controllerCAN;
};

#endif