Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MBED_LIN_RGB_Master_Example
Diff: LinMaster.cpp
- Revision:
- 0:c91a9ebab739
- Child:
- 1:58b5d1e8fae3
diff -r 000000000000 -r c91a9ebab739 LinMaster.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LinMaster.cpp Tue May 06 19:56:48 2014 +0000 @@ -0,0 +1,79 @@ +/** + * Master device LIN communication library for mbed + * + * Copyright (C) 2014 TASS Belgium NV + * + * Released under GPL v2 + * + * Other licensing models might apply at the sole discretion of the copyright holders. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LinMaster.h" + +LinMaster::LinMaster(PinName Pin) +{ + MyPin = Pin; + u8BreakLen = 20; + u8DelimLen = 4; + (void)Baudrate(9600); +} + +LinMaster::~LinMaster() +{ + +} + +bool LinMaster::Init(void) +{ + DigitalInOut LinPin(MyPin); + LinPin.output(); + LinPin.write(1); + + return ( true ); +} + +bool LinMaster::Baudrate(uint16_t uBaud) +{ + bool blReturn = false; + + if ((uBaud > 0) && (uBaud <= 20000)) + { + u16BitPeriod = 1000000/uBaud; + blReturn = true; + } + + return ( blReturn ); +} + +uint16_t LinMaster::Baudrate(void) +{ + return ( 1000000/u16BitPeriod ); +} + +bool LinMaster::SendFrame(bool blDir, uint8_t u8ID, uint8_t* ptrData, uint8_t u8Len) +{ + DigitalInOut LinPin(MyPin); + LinPin.output(); + LinPin.write(1); + + wait_us(u16BitPeriod); + + return ( true ); +} + +/* EOF */ \ No newline at end of file