|
Zephyr Project API 4.4.99
A Scalable Open Source RTOS
|
Interfaces for LIN controllers. More...
Files | |
| file | lin.h |
| LIN (Local Interconnect Network) driver API. | |
Data Structures | |
| struct | lin_config |
| LIN configuration structure. More... | |
| struct | lin_msg |
| LIN message structure. More... | |
| struct | lin_event |
| LIN event structure. More... | |
| struct | lin_filter |
| LIN frame filter configuration (responder mode only). More... | |
| struct | lin_driver_config |
| Common LIN driver configuration structure. More... | |
| struct | lin_driver_data |
| Common LIN driver data structure. More... | |
| struct | lin_driver_api |
| @driver_ops{LIN Controller} More... | |
Macros | |
| #define | LIN_ERR_BUS_COLLISION BIT(0) |
| LIN error flags . | |
| #define | LIN_ERR_INVALID_CHECKSUM BIT(1) |
| LIN checksum error. | |
| #define | LIN_ERR_COUNTER_OVERFLOW BIT(2) |
| LIN counter overflow. | |
| #define | LIN_ERR_OVERRUN BIT(3) |
| LIN overrun error. | |
| #define | LIN_ERR_PARITY BIT(4) |
| LIN parity error. | |
| #define | LIN_ERR_FRAMING BIT(5) |
| LIN framing error. | |
| #define | LIN_DT_DRIVER_CONFIG_GET(node_id, _min_bitrate, _max_bitrate) |
Static initializer for lin_driver_config struct. | |
| #define | LIN_DT_DRIVER_CONFIG_INST_GET(inst, _min_bitrate, _max_bitrate) |
Static initializer for lin_driver_config struct from DT_DRV_COMPAT instance. | |
Typedefs | |
| typedef uint32_t | lin_config_flags_t |
| Provide a type to hold LIN controller configuration flags. | |
| typedef uint32_t | lin_error_flags_t |
| Provide a type to hold LIN error flags. | |
| typedef void(* | lin_event_callback_t) (const struct device *dev, const struct lin_event *event, void *user_data) |
| LIN event callback function type. | |
| typedef int(* | lin_start_t) (const struct device *dev) |
| Callback API for starting LIN controller. | |
| typedef int(* | lin_stop_t) (const struct device *dev) |
| Callback API for stopping LIN controller. | |
| typedef int(* | lin_configure_t) (const struct device *dev, const struct lin_config *config) |
| Callback API for configuring LIN controller. | |
| typedef int(* | lin_get_config_t) (const struct device *dev, struct lin_config *config) |
| Callback API for getting LIN configuration. | |
| typedef int(* | lin_send_t) (const struct device *dev, const struct lin_msg *msg, k_timeout_t timeout) |
| Callback API for sending LIN message. | |
| typedef int(* | lin_receive_t) (const struct device *dev, struct lin_msg *msg, k_timeout_t timeout) |
| Callback API for receiving LIN message. | |
| typedef int(* | lin_response_t) (const struct device *dev, const struct lin_msg *msg, k_timeout_t timeout) |
| Callback API for processing LIN response messages. | |
| typedef int(* | lin_read_t) (const struct device *dev, struct lin_msg *msg, k_timeout_t timeout) |
| Callback API for reading LIN response message See lin_read() for argument description. | |
| typedef int(* | lin_wakeup_send_t) (const struct device *dev) |
| Callback API for sending a LIN wakeup signal. | |
| typedef int(* | lin_set_event_callback_t) (const struct device *dev, lin_event_callback_t callback, void *user_data) |
| Callback API for setting LIN transmit event callback. | |
| typedef int(* | lin_set_rx_filter_t) (const struct device *dev, const struct lin_filter *filter) |
| Callback API for setting a LIN RX filter. | |
Enumerations | |
| enum | lin_checksum_type { LIN_CHECKSUM_CLASSIC = 0 , LIN_CHECKSUM_ENHANCED } |
| LIN checksum type. More... | |
| enum | lin_event_type { LIN_EVT_RX_HEADER = 0 , LIN_EVT_TX_HEADER , LIN_EVT_RX_DATA , LIN_EVT_TX_DATA , LIN_EVT_TX_WAKEUP , LIN_EVT_RX_WAKEUP , LIN_EVT_ERR } |
| LIN event types. More... | |
| enum | lin_mode { LIN_MODE_COMMANDER = 0 , LIN_MODE_RESPONDER } |
| LIN operation mode. More... | |
Functions | |
| static uint8_t | lin_get_frame_id (uint8_t pid) |
| Helper function to extract LIN frame identifier from protected identifier (PID). | |
| static uint8_t | lin_compute_pid (uint8_t id) |
| Helper function to compute LIN protected identifier (PID) from frame identifier. | |
| static bool | lin_verify_pid (uint8_t pid) |
| Helper function to verify LIN protected identifier (PID). | |
| const struct device * | lin_get_transceiver (const struct device *dev) |
| Get the LIN transceiver device associated with the LIN controller. | |
| int | lin_start (const struct device *dev) |
| Start LIN controller. | |
| int | lin_stop (const struct device *dev) |
| Stop LIN controller. | |
| int | lin_configure (const struct device *dev, const struct lin_config *config) |
| Configure LIN controller. | |
| int | lin_get_config (const struct device *dev, struct lin_config *config) |
| Get current LIN configuration. | |
| int | lin_send (const struct device *dev, const struct lin_msg *msg, k_timeout_t timeout) |
| Send LIN message (commander mode only). | |
| int | lin_receive (const struct device *dev, struct lin_msg *msg, k_timeout_t timeout) |
| Receive LIN message (commander mode only). | |
| int | lin_response (const struct device *dev, const struct lin_msg *msg, k_timeout_t timeout) |
| Respond to a received header (responder mode only). | |
| int | lin_read (const struct device *dev, struct lin_msg *msg, k_timeout_t timeout) |
| Start data reception (responder mode only). | |
| int | lin_wakeup_send (const struct device *dev) |
| Send LIN wakeup signal. | |
| static int | lin_set_event_callback (const struct device *dev, lin_event_callback_t callback, void *user_data) |
| Set LIN event callback. | |
| int | lin_set_rx_filter (const struct device *dev, const struct lin_filter *filter) |
| Set a LIN RX filter (responder mode only). | |
| #define | LIN_ID_MASK 0x3FU |
| LIN frame definitions. | |
| #define | LIN_BUS_CONFLICT_DETECTION BIT(0) |
| LIN device configuration flags . | |
| #define | LIN_BUS_AUTO_SYNC BIT(1) |
| LIN bus auto synchronization enabled. | |
Interfaces for LIN controllers.
| #define LIN_BUS_CONFLICT_DETECTION BIT(0) |
| #define LIN_DT_DRIVER_CONFIG_GET | ( | node_id, | |
| _min_bitrate, | |||
| _max_bitrate ) |
#include <lin.h>
Static initializer for lin_driver_config struct.
| node_id | Devicetree node identifier |
| _min_bitrate | minimum bitrate supported by the LIN controller |
| _max_bitrate | maximum bitrate supported by the LIN controller |
| #define LIN_DT_DRIVER_CONFIG_INST_GET | ( | inst, | |
| _min_bitrate, | |||
| _max_bitrate ) |
#include <lin.h>
Static initializer for lin_driver_config struct from DT_DRV_COMPAT instance.
| inst | DT_DRV_COMPAT instance number |
| _min_bitrate | minimum bitrate supported by the LIN controller |
| _max_bitrate | maximum bitrate supported by the LIN controller |
| #define LIN_ID_MASK 0x3FU |
| typedef uint32_t lin_config_flags_t |
#include <lin.h>
Provide a type to hold LIN controller configuration flags.
| typedef int(* lin_configure_t) (const struct device *dev, const struct lin_config *config) |
#include <lin.h>
Callback API for configuring LIN controller.
See lin_configure() for argument description.
| typedef uint32_t lin_error_flags_t |
| typedef void(* lin_event_callback_t) (const struct device *dev, const struct lin_event *event, void *user_data) |
#include <lin.h>
LIN event callback function type.
This function is called when a LIN event occurs.
| dev | Pointer to the LIN device structure |
| event | Pointer to the LIN event structure |
| user_data | Pointer to arbitrary user data. |
| typedef int(* lin_get_config_t) (const struct device *dev, struct lin_config *config) |
#include <lin.h>
Callback API for getting LIN configuration.
See lin_get_config() for argument description.
| typedef int(* lin_read_t) (const struct device *dev, struct lin_msg *msg, k_timeout_t timeout) |
#include <lin.h>
Callback API for reading LIN response message See lin_read() for argument description.
| typedef int(* lin_receive_t) (const struct device *dev, struct lin_msg *msg, k_timeout_t timeout) |
#include <lin.h>
Callback API for receiving LIN message.
See lin_receive() for argument description.
| typedef int(* lin_response_t) (const struct device *dev, const struct lin_msg *msg, k_timeout_t timeout) |
#include <lin.h>
Callback API for processing LIN response messages.
See lin_response() for argument description.
| typedef int(* lin_send_t) (const struct device *dev, const struct lin_msg *msg, k_timeout_t timeout) |
| typedef int(* lin_set_event_callback_t) (const struct device *dev, lin_event_callback_t callback, void *user_data) |
#include <lin.h>
Callback API for setting LIN transmit event callback.
See lin_set_event_callback() for argument description.
| typedef int(* lin_set_rx_filter_t) (const struct device *dev, const struct lin_filter *filter) |
#include <lin.h>
Callback API for setting a LIN RX filter.
See lin_set_rx_filter() for argument description.
| typedef int(* lin_start_t) (const struct device *dev) |
#include <lin.h>
Callback API for starting LIN controller.
See lin_start() for argument description.
| typedef int(* lin_stop_t) (const struct device *dev) |
| typedef int(* lin_wakeup_send_t) (const struct device *dev) |
#include <lin.h>
Callback API for sending a LIN wakeup signal.
See lin_wakeup_send() for argument description.
| enum lin_checksum_type |
#include <lin.h>
LIN checksum type.
| Enumerator | |
|---|---|
| LIN_CHECKSUM_CLASSIC | Classic checksum. |
| LIN_CHECKSUM_ENHANCED | Enhanced checksum. |
| enum lin_event_type |
#include <lin.h>
LIN event types.
| enum lin_mode |
#include <lin.h>
LIN operation mode.
| Enumerator | |
|---|---|
| LIN_MODE_COMMANDER | LIN commander node. |
| LIN_MODE_RESPONDER | LIN responder node. |
| int lin_configure | ( | const struct device * | dev, |
| const struct lin_config * | config ) |
#include <lin.h>
Configure LIN controller.
This function configures the LIN controller with the given settings.
| dev | Pointer to the LIN device structure |
| config | Pointer to the configuration structure |
| int lin_get_config | ( | const struct device * | dev, |
| struct lin_config * | config ) |
#include <lin.h>
Get current LIN configuration.
This function retrieves the current configuration of the LIN controller.
| dev | Pointer to the LIN device structure |
| config | Pointer to configuration structure |
#include <lin.h>
Get the LIN transceiver device associated with the LIN controller.
This function retrieves the LIN transceiver device associated with the specified LIN controller.
| dev | Pointer to the LIN device structure |
| int lin_read | ( | const struct device * | dev, |
| struct lin_msg * | msg, | ||
| k_timeout_t | timeout ) |
#include <lin.h>
Start data reception (responder mode only).
This is an interrupt-driven API that a responder node uses to initiate a non-blocking reception of a LIN message's data. It should be called when a LIN_EVT_RX_HEADER event occurs to receive the response for the corresponding header.
Only call this API if a header has been received.
| dev | Pointer to the LIN device structure |
| msg | Pointer to the LIN message structure |
| timeout | Timeout waiting for reception to complete |
| 0 | on success |
| -EPERM | if the device is not in responder mode |
| -EFAULT | if there is no header received |
| negative | errno code on failure |
| int lin_receive | ( | const struct device * | dev, |
| struct lin_msg * | msg, | ||
| k_timeout_t | timeout ) |
#include <lin.h>
Receive LIN message (commander mode only).
This function setup an asynchronous LIN read transaction with a specified LIN identifier. When device work in commander mode:
| dev | Pointer to the LIN device structure |
| msg | Pointer to the LIN message structure |
| timeout | Timeout waiting to complete transmission |
| 0 | on success |
| -EPERM | if the device is not in commander mode |
| negative | errno code on failure |
| int lin_response | ( | const struct device * | dev, |
| const struct lin_msg * | msg, | ||
| k_timeout_t | timeout ) |
#include <lin.h>
Respond to a received header (responder mode only).
This is an interrupt-driven API for a responder node to respond to a LIN header sent by the commander node. For a responder node, it should be called when a LIN_EVT_RX_HEADER event occurs to publish the response for the received header.
Only call this API if a header has been received.
| dev | Pointer to the LIN device structure |
| msg | Pointer to the LIN message structure |
| timeout | Timeout waiting for the response to complete |
| 0 | on success |
| -EPERM | if the device is not in responder mode |
| -EFAULT | if there is no header received |
| negative | errno code on failure |
| int lin_send | ( | const struct device * | dev, |
| const struct lin_msg * | msg, | ||
| k_timeout_t | timeout ) |
#include <lin.h>
Send LIN message (commander mode only).
This function setup an asynchronous LIN write transaction with a specified LIN identifier. When device work in commander mode:
| dev | Pointer to LIN device structure |
| msg | Pointer to input LIN message structure |
| timeout | Timeout waiting to complete transmission |
| 0 | on success |
| -EPERM | if the device not in commander mode |
| negative | errno code on failure |
|
inlinestatic |
#include <lin.h>
Set LIN event callback.
This function sets a callback that will be called on LIN events.
| dev | Pointer to the LIN device structure. |
| callback | Pointer to the callback function. |
| user_data | Pointer to user data passed to the callback. |
| int lin_set_rx_filter | ( | const struct device * | dev, |
| const struct lin_filter * | filter ) |
#include <lin.h>
Set a LIN RX filter (responder mode only).
This function sets a header filter for LIN messages based on ID and mask. In case there is no filter set, all incoming messages are accepted.
When an accepted header is received, a LIN_EVT_RX_HEADER event is generated.
| dev | Pointer to the LIN device structure. |
| filter | Pointer to the LIN filter structure. |
| 0 | on success |
| -EPERM | in case device is in commander mode. |
| negative | error code on failure. |
| int lin_start | ( | const struct device * | dev | ) |
#include <lin.h>
Start LIN controller.
This function brings the LIN controller to active state, allowing it to participate in LIN communication. It also enables the LIN transceiver (if supported).
| dev | Pointer to the LIN device structure |
| 0 | if successful. |
| -EALREADY | if the LIN controller is already started. |
| negative | errno code on failure. |
| int lin_stop | ( | const struct device * | dev | ) |
#include <lin.h>
Stop LIN controller.
This function brings the LIN controller into the deactivated state, preventing it from participating in LIN communication. It also disables the LIN transceiver (if supported).
| dev | Pointer to the LIN device structure |
| 0 | on success |
| -EALREADY | if the LIN controller is already stopped. |
| negative | errno code on failure |
#include <lin.h>
Helper function to verify LIN protected identifier (PID).
| pid | Protected identifier to verify |