AM263Px MCU+ SDK  11.00.00
LIN HLD

The General-Purpose LIN/SCI driver provides APIs to configure the available LIN modules in multiple modes.

Features Supported

  • Compatibility with LIN 1.3 , 2.0, and 2.1 protocols.
  • Configurable baud rate up to 20 kbps.
  • Two external pins: LINRX and LINTX.
  • Multi-buffered receive and transmit units.
  • Identification masks for message filtering.
  • Automatic commander header generation
    • Programmable synchronization break field.
    • Synchronization field.
    • Identifier field.
  • Responder Automatic Synchronization
    • Synchronization break detection.
    • Optional baud rate update.
    • Synchronization validation.
  • 231 programmable transmission rates with 7 fractional bits.
  • Wakeup on LINRX active level from transceiver.
  • Automatic idle bus detection
  • Error detection
    • Bit error.
    • Bus error.
    • No-response error.
    • Checksum error.
    • Synchronization field error.
    • Parity error.
  • Capability to use Direct Memory Access (DMA) to transmit and receive data.
  • 2 interrupt lines (INT0 and INT1) with user-configurable interrupt sources
    • Receive.
    • Transmit.
    • ID, error, and status.
  • Support for LIN 2.0 checksum.
  • Enhanced synchronizer finite state machine (FSM) support for frame processing.
  • Enhanced handling of extended frames.
  • Enhanced baud rate generator.

SysConfig Features

Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.

SysConfig can be used to configure below parameters apart from common configurations like Clock,MPU,RAT and others.

  • LIN module configuration parameters Such as Clock Source, Operating Mode, Transfer Mode, Baud Rate.
  • LIN instances and pin Configuration for each Instance.
  • LIN frame specific Configurations such as Parity, LIN Mode(Commander/Responder), Checksum Type, Sync Delimiter, Sync Break.
  • Based on above parameters, the SysConfig generated code does below as part of Drivers_open and Drivers_close functions.
    • Set LIN instance parameter configuration.
    • ISR/DMA Configuration for Transactions.

Features not Supported

  • Extended Frames.
  • Wake-Up on LINRX active level from transceiver.
  • Automatic Wake-Up.

Usage Overview

API Sequence

Initializing the LIN HLD Driver

LIN_init() must be called before any other LIN Open is called.

LIN_open() must be called before calling any LIN APIs. This function takes index and params to initialize an instance and returns the handle to the LIN instance.

Calling LIN_close() closes the instance passed.

Please note that the initialization of LIN HLD instances is taken care by the SysConfig generated code.

Example Usage

Include the below file to access the APIs

#include <drivers/lin.h>

Instance Open Example

/* Open Params Structure */
/* Initialize parameters */
LIN_Params_init(&params);
/* Call LIN open */
gLinHandle = LIN_open(CONFIG_LIN0, &params);
DebugP_assert(gLinHandle != NULL);

Instance Close Example

LIN_close(gLinHandle);

LIN Commander Write

uint8_t i = 0;
int32_t status = SystemP_SUCCESS;
uint8_t txData[8] __attribute__((aligned(CacheP_CACHELINE_ALIGNMENT)));
for (uint8_t i = 0; i < 8; i++)
{
txData[i] = 0xA1 + i;
}
LIN_SCI_Frame linFrame;
LIN_SCI_Frame_init(&linFrame);
linFrame.id = 0x11 + i;
linFrame.frameLen = i + 1U;
linFrame.dataBuf = txData;
status = LIN_SCI_transferFrame(gLinHandle, &linFrame);

API

APIs for LIN HLD

LIN_SCI_Frame::frameLen
uint8_t frameLen
Definition: sci_lin.h:558
LIN_OpenParams
Definition: sci_lin.h:670
CacheP_CACHELINE_ALIGNMENT
#define CacheP_CACHELINE_ALIGNMENT
Cache line size for alignment of buffers. Actual CPU defined cache line can be smaller that this valu...
Definition: CacheP.h:60
__attribute__
struct lld_sockaddr __attribute__
This is the SecureBoot Stream type which holds the data for a specific bootloader to HSM call....
LIN_SCI_transferFrame
int32_t LIN_SCI_transferFrame(LIN_Handle handle, LIN_SCI_Frame *frame)
API to initiate a LIN/SCI frame transfer.
LIN_SCI_Frame_init
void LIN_SCI_Frame_init(LIN_SCI_Frame *frame)
API to set default values of LIN_SCI_Frame in frame.
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
LIN_SCI_Frame
LIN Frame Structure.
Definition: sci_lin.h:552
LIN_SCI_Frame::id
uint8_t id
Definition: sci_lin.h:556
LIN_close
void LIN_close(LIN_Handle handle)
API to Close the LIN Instance specified by the handle.
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:177
LIN_open
LIN_Handle LIN_open(uint32_t index, LIN_OpenParams *openParams)
API to Open a given LIN Instance.
lin.h
LIN_SCI_Frame::dataBuf
void * dataBuf
Definition: sci_lin.h:560
LIN_Params_init
void LIN_Params_init(LIN_OpenParams *openParams)
API to initialize the LIN_OpenParams struct to its defaults.