Nico Bollen / LIN

Dependents:   MBED_LIN_RGB_Master_Example

Embed: (wiki syntax)

« Back to documentation index

LinMaster Class Reference

LinMaster Class Reference

A master device LIN communication library for mbed. More...

#include <LinMaster.h>

Data Structures

struct  Frame_t
 Frame. More...

Public Types

enum  DriverStatus_t {
  INIT, IDLE, RXWAKEUP, DOMINANT,
  TRANSMIT, RECEIVE, TXWAKEUP
}
 

Bus status.

More...
enum  FrameError_t
 

Error code type.

More...
enum  FrameType_t
 

Frame Direction Type.

More...
enum  CrcType_t
 

CRC Type.

More...
enum  BrakeType_t
 

Brake Type.

More...

Public Member Functions

 LinMaster (PinName InPin, PinName OutPin)
 LIN master constructor.
 ~LinMaster ()
 LIN master destructor.
bool init (void)
 Initialise the LIN module

  • configure IO
  • configure Timer.

bool baudrate (uint16_t uBaud)
 Set the LIN baudrate.
uint16_t baudrate (void)
 Get the LIN baudrate.
DriverStatus_t status (void)
 Get the current LIN driver status.
FrameError_t last_error (void)
 Get the last error detected.
bool send_frame (Frame_t *ptrFrame)
 Send a frame on the LIN bus.
bool get_rx_data (Frame_t &ptrFrame)
 Receive a frame on the LIN bus.

Detailed Description

A master device LIN communication library for mbed.

 #include "mbed.h"
 #include "LinMaster.h"
 
 LinMaster lin(p10, p9);
 
 int main() {
     (void)lin.init();

     (void)MyLinMaster.send_frame(&M2Sframe);
     while(MyLinMaster.status() != LinMaster::IDLE);

     (void)MyLinMaster.send_frame(&S2Mframe);
     while(MyLinMaster.status() != LinMaster::IDLE);
     if (MyLinMaster.get_rx_data(S2Mframe) == true)
     {
     }
     else { }
 }

Definition at line 54 of file LinMaster.h.


Member Enumeration Documentation

Brake Type.

Definition at line 139 of file LinMaster.h.

enum CrcType_t

CRC Type.

Definition at line 133 of file LinMaster.h.

Bus status.

Enumerator:
INIT 

initializing

IDLE 

idle

RXWAKEUP 

wake up pulses detected since the last request

DOMINANT 

dominant level detected, longer than a wake up pulse

TRANSMIT 

busy receiving data

RECEIVE 

busy receiving data

TXWAKEUP 

busy sending a wake up pulse

Definition at line 93 of file LinMaster.h.

Error code type.

Definition at line 111 of file LinMaster.h.

Frame Direction Type.

Definition at line 127 of file LinMaster.h.


Constructor & Destructor Documentation

LinMaster ( PinName  InPin,
PinName  OutPin 
)

LIN master constructor.

Parameters:
PinThe pinname to be used for LIN communication

Definition at line 31 of file LinMaster.cpp.

~LinMaster (  )

LIN master destructor.

Definition at line 46 of file LinMaster.cpp.


Member Function Documentation

bool baudrate ( uint16_t  uBaud )

Set the LIN baudrate.

Parameters:
uBaudbaudrate value in kbps (1..20000)
Returns:
true on succes, false on fail

Definition at line 66 of file LinMaster.cpp.

uint16_t baudrate ( void   )

Get the LIN baudrate.

Returns:
The current configured LIN baudrate

Definition at line 79 of file LinMaster.cpp.

bool get_rx_data ( Frame_t ptrFrame )

Receive a frame on the LIN bus.

Parameters:
ptrFramepointer to the frame to receive
Returns:
true on succes, false on fail

Definition at line 167 of file LinMaster.cpp.

bool init ( void   )

Initialise the LIN module

  • configure IO
  • configure Timer.

Returns:
true on succes, false on fail

Definition at line 54 of file LinMaster.cpp.

FrameError_t last_error ( void   )

Get the last error detected.

Returns:
The last error detected

Definition at line 124 of file LinMaster.h.

bool send_frame ( Frame_t ptrFrame )

Send a frame on the LIN bus.

Parameters:
ptrFramepointer to the frame to transmit
Returns:
true on succes, false on fail

Definition at line 84 of file LinMaster.cpp.

DriverStatus_t status ( void   )

Get the current LIN driver status.

Returns:
The current LIN driver status

Definition at line 108 of file LinMaster.h.