The LIN middleware implements LIN 2.2 Slave node for the PSoC 4 devices. Options for the ISO 17987 is also available. The LIN Configurator tool makes it easy to configure the middleware.
Features:
Include mtb_lin.h to get access to all the functions and other declarations in this middleware. See the Quick Start Guide to start using the middleware.
Refer to the release notes for compatibility information.
Refer to the Specification Conformance section for the API deviation from the specification.
The Configuration Considerations section provides the guidance for all operation modes and use cases.
LIN middleware can be used in various Development Environments. Refer to the release notes.
This quick start guide is for an environment with the configured:
The below steps describe the simplest way of enabling the LIN Slave.
Launch ModusToolbox Library Manager and enable the LIN middleware. This step is required only if the ModusToolbox IDE is used. Otherwise, ensure the LIN Middleware is included in your project.
The following code snippet shows the mtbcfg_lin.h header file with the configuration generated by the LIN configurator:
The following code snippet shows the mtbcfg_lin.c source file with the configuration generated by the LIN configurator:
The following code snippet shows the LIN initialization:
Use LIN hardware like CY8CKIT-026-CAN and Lin Shield Kit and CY8CKIT-041S-MAX PSoC 4100S Max Pioneer kit.
Connect the device to the LIN Master. Configure LIN Master to send frames and observe updated signals in the LIN Slave application.
This section consists of different guides and instruction of how to enable, configure, and use the LIN middleware in a design. As you can see from the Quick Start Guide section, the settings of the LIN middleware are controlled with the mtb_stc_lin_config_t structure. Please see its description to learn about the parameters and values.
The following is a description of the most common use cases along with the configuration structure examples and code snippets. The list of sections under Configuration Considerations:
The standalone LIN Configurator tool helps configure the middleware. The tool output are generated source and header files. Generated files are mandatory for the middleware operation and must be added to your project. The header file provides access to instances of the LIN configuration structure mtb_stc_lin_config_t.
The LIN Configurator tool provides the User Guide, which can be found in the documentation.
The settings of the LIN middleware are controlled by the mtb_stc_lin_config_t structure. See its description to learn about the parameters and values.
The interrupt is mandatory for LIN middleware operation. The LIN middleware requires two interrupt sources for the proper operation: one for UART operation, other for SysTick timer operation.
The Bus Inactivity Timer is based on the SysTick timer. It is configured by default at Reset time to interrupt a period of 1 millisecond. The LIN middleware uses one callback handler (out of five) from the SysTick timer for one instance. The SysTick timer is configured and enabled automatically during initialization.
The UART interrupt has the configurable priority. Ensure that the UART priority has a level sufficient for a timely response to events on the bus.
This section describes the software and hardware resources used by the middleware.
This section describes the deviations from the API defined by the LIN specifications.
This section describes the differences between PSoC Creator LIN component and the LIN middleware API.
# | PSoC Creator LIN component | LIN middleware |
---|---|---|
1 | The result of the MTB_LIN_IOCTL_READ_STATUS operation of the l_ifc_ioctl() is returned by the function. | The result of the MTB_LIN_IOCTL_READ_STATUS operation of the l_ifc_ioctl() is returned via the pointer specified by the pv parameter. The function returns MTB_LIN_STATUS_SUCCESS. |
2 | No l_sys_irq_disable() and l_sys_irq_restore() implemented. | Added implementation of the l_sys_irq_disable() and l_sys_irq_restore(). |
3 | All the interrupt service routines are initialized inside of the component - no any actions required on the application level. | The communication and inactivity interrupt service routines should be implemented on the application level. Refer to the STEP 3: Update main.c section for the more details. |
This section describes MISRA-C:2012 compliance and deviations for the LIN.
MISRA stands for Motor Industry Software Reliability Association. The MISRA specification covers a set of 10 mandatory rules, 110 required rules, and 39 advisory rules that apply to the firmware design and has been put together by the Automotive Industry to enhance the quality and robustness of the firmware code embedded in automotive devices.
The MISRA specification defines two categories of deviations (see section 5.4 of the MISRA-C:2012 specification):
Project Deviations and Specific Deviations are documented later in this section.
Specific deviations are also documented in the source code, close to the deviation occurrence. For each deviation, a special macro identifies the relevant rule or directive number, and reason.
This section provides a MISRA compliance analysis environment description.
Component | Name | Version |
---|---|---|
Test Specification | MISRA-C:2012 Guidelines for the use of the C language in critical systems | March 2013 |
MISRA Checking Tool | Coverity Static Analysis Tool | 2020.03 |
The list of deviated rules is provided in the table below.
MISRA Rule | Required/Advisory | Rule Description | Description of Deviation(s) |
---|---|---|---|
1.2 | A | Language extensions are not used | The middleware library supports ISO:C99 standard. |
2.5 | A | A project does not contain unused macro definitions | The middleware library provides an API to the hardware. The macro is part of the API, which is defined for the application-level only. |
3.1 | R | The special comment symbols is not used within a comment | Special comment symbols are required for Doxygen comment support, it does not have any impact. |
8.7 | A | Functions and objects are not defined with external linkage if they are referenced in only one translation unit | The middleware library provides an API to the hardware. The functions and objects with external linkage are part of the API, which are defined for application-level only. |
11.4 | A | A conversion are not performed between the pointer to an object and an integer type | The cast from an unsigned integer to the pointer does not have any unintended effect, as it is a consequence of the definition of a structure based on hardware registers. |
11.5 | A | A conversion is not performed from the pointer to void into the pointer to an object | See specific deviations documented in the source code, close to the deviation occurrence. |
18.4 | A | The +, -, += and -= operators are not applied to an expression of the pointer type | See specific deviations documented in the source code, close to the deviation occurrence. |
Directive 4.8 | A | If a pointer to the structure or union is never dereferenced within a translation unit, then the implementation of the object is hidden | Deviated, since the object provided by HAL is used without dereferencing for the own needs of LIN middleware. |
Directive 4.9 | A | A function is used in preference to a function-like macro where they are interchangeable | Deviated, since function-like macros are used to allow more efficient code. |
Version | Changes | Reason for Change |
---|---|---|
1.10 | Added CAT2 Hardware Abstraction Layers (mtb-hal-cat2) 2.x support./td> | |
1.0 | Initial Version |
For more information, refer to the following documents: