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

Revision:
0:ebe6f5e97160
Child:
1:b69d05604535
diff -r 000000000000 -r ebe6f5e97160 ControllerCAN.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ControllerCAN.h	Sat Feb 06 14:10:54 2016 +0000
@@ -0,0 +1,83 @@
+#ifndef CONTROLLERCAN_H
+#define CONTROLLERCAN_H
+
+#include "mbed.h"
+#include "PeripherialCAN.h"
+#include <vector>
+
+#define SIZE_FIFO 32
+
+class PeripherialCAN;
+
+/** 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 PeripherialCAN instance to a ControllerCAN
+     *
+     * @param peripherial Pointer on a PeripherialCAN instance
+     */
+    void attach(PeripherialCAN* peripherial);
+    
+    /** Read one message on the CAN FIFO
+     *
+     * @returns
+     *  -1 if no match is found between the message Id and all Ids of 
+     *     the PeripherialCAN instances attached to the ControllerCAN,
+     *  1 if a match is found
+     */
+    char FIFOread(void);
+    //void FIFO_remove_msg(void);
+    
+    private :
+    
+    CAN can;
+    vector<PeripherialCAN*> peripherials;
+    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
\ No newline at end of file