Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
|
API for NXP SJA1000 (and compatible) CAN controller frontend drivers. More...
#include <zephyr/drivers/can.h>
Go to the source code of this file.
Data Structures | |
struct | can_sja1000_config |
SJA1000 driver internal configuration structure. More... | |
struct | can_sja1000_rx_filter |
SJA1000 driver internal RX filter structure. More... | |
struct | can_sja1000_data |
SJA1000 driver internal data structure. More... | |
Typedefs | |
typedef void(* | can_sja1000_write_reg_t) (const struct device *dev, uint8_t reg, uint8_t val) |
SJA1000 driver front-end callback for writing a register value. | |
typedef uint8_t(* | can_sja1000_read_reg_t) (const struct device *dev, uint8_t reg) |
SJA1000 driver front-end callback for reading a register value. | |
Functions | |
int | can_sja1000_set_timing (const struct device *dev, const struct can_timing *timing) |
SJA1000 callback API upon setting CAN bus timing See can_set_timing() for argument description. | |
int | can_sja1000_get_capabilities (const struct device *dev, can_mode_t *cap) |
SJA1000 callback API upon getting CAN controller capabilities See can_get_capabilities() for argument description. | |
int | can_sja1000_start (const struct device *dev) |
SJA1000 callback API upon starting CAN controller See can_start() for argument description. | |
int | can_sja1000_stop (const struct device *dev) |
SJA1000 callback API upon stopping CAN controller See can_stop() for argument description. | |
int | can_sja1000_set_mode (const struct device *dev, can_mode_t mode) |
SJA1000 callback API upon setting CAN controller mode See can_set_mode() for argument description. | |
int | can_sja1000_send (const struct device *dev, const struct can_frame *frame, k_timeout_t timeout, can_tx_callback_t callback, void *user_data) |
SJA1000 callback API upon sending a CAN frame See can_send() for argument description. | |
int | can_sja1000_add_rx_filter (const struct device *dev, can_rx_callback_t callback, void *user_data, const struct can_filter *filter) |
SJA1000 callback API upon adding an RX filter See can_add_rx_callback() for argument description. | |
void | can_sja1000_remove_rx_filter (const struct device *dev, int filter_id) |
SJA1000 callback API upon removing an RX filter See can_remove_rx_filter() for argument description. | |
int | can_sja1000_get_state (const struct device *dev, enum can_state *state, struct can_bus_err_cnt *err_cnt) |
SJA1000 callback API upon getting the CAN controller state See can_get_state() for argument description. | |
void | can_sja1000_set_state_change_callback (const struct device *dev, can_state_change_callback_t callback, void *user_data) |
SJA1000 callback API upon setting a state change callback See can_set_state_change_callback() for argument description. | |
int | can_sja1000_get_max_filters (const struct device *dev, bool ide) |
SJA1000 callback API upon getting the maximum number of concurrent CAN RX filters See can_get_max_filters() for argument description. | |
void | can_sja1000_isr (const struct device *dev) |
SJA1000 IRQ handler callback. | |
int | can_sja1000_init (const struct device *dev) |
SJA1000 driver initialization callback. | |
API for NXP SJA1000 (and compatible) CAN controller frontend drivers.
#define CAN_SJA1000_CDR_CAN_MODE BIT(7) |
#define CAN_SJA1000_CDR_CBP BIT(6) |
#define CAN_SJA1000_CDR_CD_DIV1 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 7U) |
#define CAN_SJA1000_CDR_CD_DIV10 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 4U) |
#define CAN_SJA1000_CDR_CD_DIV12 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 5U) |
#define CAN_SJA1000_CDR_CD_DIV14 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 6U) |
#define CAN_SJA1000_CDR_CD_DIV2 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 0U) |
#define CAN_SJA1000_CDR_CD_DIV4 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 1U) |
#define CAN_SJA1000_CDR_CD_DIV6 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 2U) |
#define CAN_SJA1000_CDR_CD_DIV8 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 3U) |
#define CAN_SJA1000_CDR_CD_MASK GENMASK(2, 0) |
#define CAN_SJA1000_CDR_CLOCK_OFF BIT(3) |
#define CAN_SJA1000_CDR_RXINTEN BIT(5) |
#define CAN_SJA1000_DATA_INITIALIZER | ( | _custom | ) |
Initializer for a can_sja1000_data struct.
_custom | Pointer to custom driver frontend data structure |
#define CAN_SJA1000_DT_CONFIG_GET | ( | node_id, | |
_custom, | |||
_read_reg, | |||
_write_reg, | |||
_ocr, | |||
_cdr, | |||
_min_bitrate ) |
Static initializer for can_sja1000_config
struct.
node_id | Devicetree node identifier |
_custom | Pointer to custom driver frontend configuration structure |
_read_reg | Driver frontend SJA100 register read function |
_write_reg | Driver frontend SJA100 register write function |
_ocr | Initial SJA1000 Output Control Register (OCR) value |
_cdr | Initial SJA1000 Clock Divider Register (CDR) value |
_min_bitrate | minimum bitrate supported by the CAN controller |
#define CAN_SJA1000_DT_CONFIG_INST_GET | ( | inst, | |
_custom, | |||
_read_reg, | |||
_write_reg, | |||
_ocr, | |||
_cdr, | |||
_min_bitrate ) |
Static initializer for can_sja1000_config
struct from a DT_DRV_COMPAT instance.
inst | DT_DRV_COMPAT instance number |
_custom | Pointer to custom driver frontend configuration structure |
_read_reg | Driver frontend SJA100 register read function |
_write_reg | Driver frontend SJA100 register write function |
_ocr | Initial SJA1000 Output Control Register (OCR) value |
_cdr | Initial SJA1000 Clock Divider Register (CDR) value |
_min_bitrate | minimum bitrate supported by the CAN controller |
#define CAN_SJA1000_OCR_OCMODE_BIPHASE FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 0U) |
#define CAN_SJA1000_OCR_OCMODE_CLOCK FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 3U) |
#define CAN_SJA1000_OCR_OCMODE_MASK GENMASK(1, 0) |
#define CAN_SJA1000_OCR_OCMODE_NORMAL FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 2U) |
#define CAN_SJA1000_OCR_OCMODE_TEST FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 1U) |
#define CAN_SJA1000_OCR_OCPOL0 BIT(2) |
#define CAN_SJA1000_OCR_OCPOL1 BIT(5) |
#define CAN_SJA1000_OCR_OCTN0 BIT(3) |
#define CAN_SJA1000_OCR_OCTN1 BIT(6) |
#define CAN_SJA1000_OCR_OCTP0 BIT(4) |
#define CAN_SJA1000_OCR_OCTP1 BIT(7) |
#define CAN_SJA1000_TIMING_MAX_INITIALIZER |
SJA1000 specific static initializer for a maximum can_timing
struct.
#define CAN_SJA1000_TIMING_MIN_INITIALIZER |
SJA1000 specific static initializer for a minimum can_timing
struct.
SJA1000 driver front-end callback for reading a register value.
dev | Pointer to the device structure for the driver instance. |
reg | Register offset |
Register | value |
SJA1000 driver front-end callback for writing a register value.
dev | Pointer to the device structure for the driver instance. |
reg | Register offset |
val | Register value |
int can_sja1000_add_rx_filter | ( | const struct device * | dev, |
can_rx_callback_t | callback, | ||
void * | user_data, | ||
const struct can_filter * | filter ) |
SJA1000 callback API upon adding an RX filter See can_add_rx_callback() for argument description.
int can_sja1000_get_capabilities | ( | const struct device * | dev, |
can_mode_t * | cap ) |
SJA1000 callback API upon getting CAN controller capabilities See can_get_capabilities() for argument description.
SJA1000 callback API upon getting the maximum number of concurrent CAN RX filters See can_get_max_filters() for argument description.
int can_sja1000_get_state | ( | const struct device * | dev, |
enum can_state * | state, | ||
struct can_bus_err_cnt * | err_cnt ) |
SJA1000 callback API upon getting the CAN controller state See can_get_state() for argument description.
int can_sja1000_init | ( | const struct device * | dev | ) |
SJA1000 driver initialization callback.
dev | Pointer to the device structure for the driver instance. |
void can_sja1000_isr | ( | const struct device * | dev | ) |
SJA1000 IRQ handler callback.
dev | Pointer to the device structure for the driver instance. |
void can_sja1000_remove_rx_filter | ( | const struct device * | dev, |
int | filter_id ) |
SJA1000 callback API upon removing an RX filter See can_remove_rx_filter() for argument description.
int can_sja1000_send | ( | const struct device * | dev, |
const struct can_frame * | frame, | ||
k_timeout_t | timeout, | ||
can_tx_callback_t | callback, | ||
void * | user_data ) |
SJA1000 callback API upon sending a CAN frame See can_send() for argument description.
int can_sja1000_set_mode | ( | const struct device * | dev, |
can_mode_t | mode ) |
SJA1000 callback API upon setting CAN controller mode See can_set_mode() for argument description.
void can_sja1000_set_state_change_callback | ( | const struct device * | dev, |
can_state_change_callback_t | callback, | ||
void * | user_data ) |
SJA1000 callback API upon setting a state change callback See can_set_state_change_callback() for argument description.
int can_sja1000_set_timing | ( | const struct device * | dev, |
const struct can_timing * | timing ) |
SJA1000 callback API upon setting CAN bus timing See can_set_timing() for argument description.
int can_sja1000_start | ( | const struct device * | dev | ) |
SJA1000 callback API upon starting CAN controller See can_start() for argument description.
int can_sja1000_stop | ( | const struct device * | dev | ) |
SJA1000 callback API upon stopping CAN controller See can_stop() for argument description.