Nico Bollen / LIN

Dependents:   MBED_LIN_RGB_Master_Example

Revision:
0:c91a9ebab739
Child:
1:58b5d1e8fae3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LinMaster.h	Tue May 06 19:56:48 2014 +0000
@@ -0,0 +1,74 @@
+/**
+ * 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 "mbed.h"
+
+class LinMaster
+{
+public:
+    /** LIN master constructor
+     *
+     * @param Pin The pinname to be used for LIN communication
+     */
+    LinMaster(PinName Pin);
+
+    /** LIN master destructor */
+    ~LinMaster();
+
+    /** Initialise the LIN module
+     * - configure IO
+     * - configure Timer
+     *
+     * @return
+     *   true on succes,
+     *   false on fail
+     */
+    bool Init(void);
+
+    /** Set the LIN baudrate
+     *
+     * @param uBaud baudrate value in kbps (1..20000)
+     * @return
+     *   true on succes,
+     *   false on fail
+     */
+    bool Baudrate(uint16_t uBaud);
+
+    /** Get the LIN baudrate
+     *
+     * @return
+     *   The current configured LIN baudrate
+     */
+    uint16_t Baudrate(void);
+    
+    
+    bool SendFrame(bool blDir, uint8_t u8ID, uint8_t* ptrData, uint8_t u8Len);
+
+private:
+    uint16_t u16BitPeriod;
+    uint8_t u8BreakLen;
+    uint8_t u8DelimLen;
+    PinName MyPin;
+};