Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
lin.h File Reference

LIN (Local Interconnect Network) driver API. More...

#include <errno.h>
#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/clock.h>
#include <zephyr/sys/util.h>
#include <zephyr/syscalls/lin.h>

Go to the source code of this file.

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.
#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.

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).

Detailed Description

LIN (Local Interconnect Network) driver API.

This file contains definitions and API for LIN communication.