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

Committer:
garivetm
Date:
Thu Feb 18 15:43:52 2016 +0000
Revision:
3:e6f72461e31f
Parent:
1:b69d05604535
Child:
4:0ed21bbd917b
Adding licence notice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garivetm 3:e6f72461e31f 1 /***************************************************************************
garivetm 3:e6f72461e31f 2 Copyright 2016 LARNAUDIE GARIVET
garivetm 3:e6f72461e31f 3
garivetm 3:e6f72461e31f 4 Licensed under the Apache License, Version 2.0 (the "License");
garivetm 3:e6f72461e31f 5 you may not use this file except in compliance with the License.
garivetm 3:e6f72461e31f 6 You may obtain a copy of the License at
garivetm 3:e6f72461e31f 7
garivetm 3:e6f72461e31f 8 http://www.apache.org/licenses/LICENSE-2.0
garivetm 3:e6f72461e31f 9
garivetm 3:e6f72461e31f 10 Unless required by applicable law or agreed to in writing, software
garivetm 3:e6f72461e31f 11 distributed under the License is distributed on an "AS IS" BASIS,
garivetm 3:e6f72461e31f 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
garivetm 3:e6f72461e31f 13 See the License for the specific language governing permissions and
garivetm 3:e6f72461e31f 14 limitations under the License.
garivetm 3:e6f72461e31f 15 ***************************************************************************/
garivetm 1:b69d05604535 16 #ifndef PeripheralCAN_H
garivetm 1:b69d05604535 17 #define PeripheralCAN_H
garivetm 1:b69d05604535 18
garivetm 1:b69d05604535 19 #include "mbed.h"
garivetm 1:b69d05604535 20 #include <vector>
garivetm 1:b69d05604535 21 #include "ControllerCAN.h"
garivetm 1:b69d05604535 22
garivetm 1:b69d05604535 23 class ControllerCAN;
garivetm 1:b69d05604535 24 /** My CAN Peripheral class
garivetm 1:b69d05604535 25 * Used as interface to create CAN Peripheral objets
garivetm 1:b69d05604535 26 *
garivetm 1:b69d05604535 27 * Examples :
garivetm 1:b69d05604535 28 * @code
garivetm 1:b69d05604535 29 * @endcode
garivetm 1:b69d05604535 30 */
garivetm 1:b69d05604535 31 class PeripheralCAN {
garivetm 1:b69d05604535 32 public :
garivetm 1:b69d05604535 33 /** Create PeripheralCAN instance
garivetm 1:b69d05604535 34 */
garivetm 1:b69d05604535 35 PeripheralCAN();
garivetm 1:b69d05604535 36
garivetm 1:b69d05604535 37 /** Create PeripheralCAN instance
garivetm 1:b69d05604535 38 *
garivetm 1:b69d05604535 39 * @param controller ControllerCAN instance controlling the PerpiherialCAN
garivetm 1:b69d05604535 40 */
garivetm 1:b69d05604535 41 PeripheralCAN(ControllerCAN* controller);
garivetm 1:b69d05604535 42
garivetm 1:b69d05604535 43 /** Initialize the instance
garivetm 1:b69d05604535 44 */
garivetm 1:b69d05604535 45 virtual void init(void);
garivetm 1:b69d05604535 46
garivetm 1:b69d05604535 47 /** Update the PeripheriamCAN instance
garivetm 1:b69d05604535 48 *
garivetm 1:b69d05604535 49 * @param Id Message Id to determine which variables are concerned,
garivetm 1:b69d05604535 50 * @param msg CANMessage instance containing data of interest
garivetm 1:b69d05604535 51 */
garivetm 1:b69d05604535 52 virtual void update(const unsigned short& Id, const CANMessage& msg);
garivetm 1:b69d05604535 53
garivetm 1:b69d05604535 54 /** Add an Id to the Id vector containing Ids of incoming message
garivetm 1:b69d05604535 55 * concerning the current instance
garivetm 1:b69d05604535 56 *
garivetm 1:b69d05604535 57 * @param Id Message Id to be added
garivetm 1:b69d05604535 58 */
garivetm 1:b69d05604535 59 void addIdRead(unsigned short* Id);
garivetm 1:b69d05604535 60
garivetm 1:b69d05604535 61 /** Write a message on CAN Bus
garivetm 1:b69d05604535 62 *
garivetm 1:b69d05604535 63 * @param Id Id message
garivetm 1:b69d05604535 64 * @param data char array containing data to be send
garivetm 1:b69d05604535 65 * @param len size of the data array
garivetm 1:b69d05604535 66 */
garivetm 1:b69d05604535 67 void writeOnCAN(unsigned short Id, const char *data, char len);
garivetm 1:b69d05604535 68 //short readOnCAN(unsigned short Id, CANMessage& msg);
garivetm 1:b69d05604535 69
garivetm 1:b69d05604535 70 /** Get the IdsRead vector
garivetm 1:b69d05604535 71 *
garivetm 1:b69d05604535 72 * @returns IdsRead vector
garivetm 1:b69d05604535 73 */
garivetm 1:b69d05604535 74 vector<unsigned short*> getIdsRead(void);
garivetm 1:b69d05604535 75
garivetm 1:b69d05604535 76 private :
garivetm 1:b69d05604535 77 vector<unsigned short*> IdsRead;
garivetm 1:b69d05604535 78 ControllerCAN* controllerCAN;
garivetm 1:b69d05604535 79 };
garivetm 1:b69d05604535 80
garivetm 1:b69d05604535 81 #endif