CAN library containing a CAN controller object handling a FIFO, and CAN peripherals attached to it.
PeripheralCAN.cpp@4:0ed21bbd917b, 2018-05-05 (annotated)
- Committer:
- garivetm
- Date:
- Sat May 05 13:46:16 2018 +0000
- Revision:
- 4:0ed21bbd917b
- Parent:
- 2:c81dff9c8a93
- Child:
- 5:d1920eb1d63e
Make CAN instance static and update Pins to match with STM32L476RG
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garivetm | 2:c81dff9c8a93 | 1 | /*************************************************************************** |
garivetm | 2:c81dff9c8a93 | 2 | AUTHORS : BRUNO LARNAUDIE (Main functions) bruno.larnaudie@u-psud.fr |
garivetm | 2:c81dff9c8a93 | 3 | MATHIEU GARIVET (Object Oriented aspect) |
garivetm | 2:c81dff9c8a93 | 4 | * |
garivetm | 2:c81dff9c8a93 | 5 | INSTITUTION : IUT de CACHAN - 9 av. de la div. Leclerc - 94230 CACHAN |
garivetm | 2:c81dff9c8a93 | 6 | |
garivetm | 2:c81dff9c8a93 | 7 | VERSIONS : v1 (03/07/2012) : FIFO organisation |
garivetm | 2:c81dff9c8a93 | 8 | v2 (18/02/2016) : Controller aand Peripheral organisation |
garivetm | 2:c81dff9c8a93 | 9 | |
garivetm | 2:c81dff9c8a93 | 10 | **************************************************************************** |
garivetm | 2:c81dff9c8a93 | 11 | Copyright 2016 LARNAUDIE GARIVET |
garivetm | 2:c81dff9c8a93 | 12 | |
garivetm | 2:c81dff9c8a93 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); |
garivetm | 2:c81dff9c8a93 | 14 | you may not use this file except in compliance with the License. |
garivetm | 2:c81dff9c8a93 | 15 | You may obtain a copy of the License at |
garivetm | 2:c81dff9c8a93 | 16 | |
garivetm | 2:c81dff9c8a93 | 17 | http://www.apache.org/licenses/LICENSE-2.0 |
garivetm | 2:c81dff9c8a93 | 18 | |
garivetm | 2:c81dff9c8a93 | 19 | Unless required by applicable law or agreed to in writing, software |
garivetm | 2:c81dff9c8a93 | 20 | distributed under the License is distributed on an "AS IS" BASIS, |
garivetm | 2:c81dff9c8a93 | 21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
garivetm | 2:c81dff9c8a93 | 22 | See the License for the specific language governing permissions and |
garivetm | 2:c81dff9c8a93 | 23 | limitations under the License. |
garivetm | 2:c81dff9c8a93 | 24 | ***************************************************************************/ |
garivetm | 1:b69d05604535 | 25 | #include "mbed.h" |
garivetm | 1:b69d05604535 | 26 | #include "PeripheralCAN.h" |
garivetm | 1:b69d05604535 | 27 | |
garivetm | 1:b69d05604535 | 28 | PeripheralCAN::PeripheralCAN(){ |
garivetm | 1:b69d05604535 | 29 | } |
garivetm | 1:b69d05604535 | 30 | |
garivetm | 1:b69d05604535 | 31 | PeripheralCAN::PeripheralCAN(ControllerCAN* controller) : controllerCAN(controller) { |
garivetm | 1:b69d05604535 | 32 | controllerCAN->attach(this); |
garivetm | 1:b69d05604535 | 33 | } |
garivetm | 1:b69d05604535 | 34 | |
garivetm | 1:b69d05604535 | 35 | void PeripheralCAN::addIdRead(unsigned short* Id){ |
garivetm | 1:b69d05604535 | 36 | IdsRead.push_back(Id); |
garivetm | 1:b69d05604535 | 37 | } |
garivetm | 1:b69d05604535 | 38 | |
garivetm | 1:b69d05604535 | 39 | void PeripheralCAN::writeOnCAN(unsigned short Id, const char *data, char len){ |
garivetm | 1:b69d05604535 | 40 | if (len != 0){ |
garivetm | 1:b69d05604535 | 41 | while(!controllerCAN->writeData(Id, data, len)); |
garivetm | 1:b69d05604535 | 42 | } |
garivetm | 1:b69d05604535 | 43 | else{ |
garivetm | 1:b69d05604535 | 44 | while(!controllerCAN->writeRemote(Id)); |
garivetm | 1:b69d05604535 | 45 | } |
garivetm | 1:b69d05604535 | 46 | } |
garivetm | 1:b69d05604535 | 47 | |
garivetm | 1:b69d05604535 | 48 | void PeripheralCAN::init(void){ |
garivetm | 1:b69d05604535 | 49 | } |
garivetm | 1:b69d05604535 | 50 | |
garivetm | 1:b69d05604535 | 51 | void PeripheralCAN::update(const unsigned short& Id, const CANMessage& msg){ |
garivetm | 1:b69d05604535 | 52 | } |
garivetm | 1:b69d05604535 | 53 | |
garivetm | 1:b69d05604535 | 54 | vector<unsigned short*> PeripheralCAN::getIdsRead(void){ |
garivetm | 1:b69d05604535 | 55 | return IdsRead; |
garivetm | 4:0ed21bbd917b | 56 | } |