CAN library containing a CAN controller object handling a FIFO, and CAN peripherals attached to it.
ControllerCAN.h
- Committer:
- garivetm
- Date:
- 2016-02-06
- Revision:
- 1:b69d05604535
- Parent:
- 0:ebe6f5e97160
- Child:
- 2:c81dff9c8a93
File content as of revision 1:b69d05604535:
#ifndef CONTROLLERCAN_H #define CONTROLLERCAN_H #include "mbed.h" #include "PeripheralCAN.h" #include <vector> #define SIZE_FIFO 32 class PeripheralCAN; /** My CAN Controller class * Used to manage reading and writing procedures on a CAN Bus * * Examples : * @code * @endcode */ class ControllerCAN { public : /** Create ControllerCAN instance */ ControllerCAN(); /** Destroy ControllerCAN instance */ ~ControllerCAN(); /** Write a CANMessage on CAN Bus * * @param Id Id message * @param data char array containing data to be send * @param len size of the data array * @returns * 1 if write was successful, * 0 if write failed */ long writeData(long Id, const char *data, char len); /** Write a remote CANMessage on CAN Bus * * @param Id Id message * @returns * 1 if write was successful, * 0 if write failed */ long writeRemote(long Id); /** Attach a PeripheralCAN instance to a ControllerCAN * * @param peripheral Pointer on a PeripheralCAN instance */ void attach(PeripheralCAN* peripheral); /** Read one message on the CAN FIFO * * @returns * -1 if no match is found between the message Id and all Ids of * the PeripheralCAN instances attached to the ControllerCAN, * 1 if a match is found */ char FIFOread(void); //void FIFO_remove_msg(void); private : CAN can; vector<PeripheralCAN*> peripherals; unsigned char FIFO_ecriture; signed char FIFO_lecture; signed char FIFO_occupation; signed char FIFO_max_occupation; CANMessage can_MsgRx[SIZE_FIFO]; /** Interrupt Service Routine called whenever a CAN frame received interrupt * is generated. */ void can_ISR_Reader(void); //static void CAN_automate_reception(void); }; #endif