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
LinMaster.cpp
- Committer:
- bollenn
- Date:
- 2014-05-06
- Revision:
- 1:58b5d1e8fae3
- Parent:
- 0:c91a9ebab739
- Child:
- 2:6d4c7f841a5d
File content as of revision 1:58b5d1e8fae3:
/* * 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(FrameDir Dir, uint8_t u8ID, uint8_t* ptrData, uint8_t u8Len) { DigitalInOut LinPin(MyPin); LinPin.output(); LinPin.write(1); wait_us(u16BitPeriod); return ( true ); } /* EOF */