12#ifndef ZEPHYR_INCLUDE_DRIVERS_CAN_CAN_SJA1000_H_
13#define ZEPHYR_INCLUDE_DRIVERS_CAN_CAN_SJA1000_H_
22#define CAN_SJA1000_OCR_OCMODE_MASK GENMASK(1, 0)
23#define CAN_SJA1000_OCR_OCPOL0 BIT(2)
24#define CAN_SJA1000_OCR_OCTN0 BIT(3)
25#define CAN_SJA1000_OCR_OCTP0 BIT(4)
26#define CAN_SJA1000_OCR_OCPOL1 BIT(5)
27#define CAN_SJA1000_OCR_OCTN1 BIT(6)
28#define CAN_SJA1000_OCR_OCTP1 BIT(7)
30#define CAN_SJA1000_OCR_OCMODE_BIPHASE FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 0U)
31#define CAN_SJA1000_OCR_OCMODE_TEST FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 1U)
32#define CAN_SJA1000_OCR_OCMODE_NORMAL FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 2U)
33#define CAN_SJA1000_OCR_OCMODE_CLOCK FIELD_PREP(CAN_SJA1000_OCR_OCMODE_MASK, 3U)
42#define CAN_SJA1000_CDR_CD_MASK GENMASK(2, 0)
43#define CAN_SJA1000_CDR_CLOCK_OFF BIT(3)
44#define CAN_SJA1000_CDR_RXINTEN BIT(5)
45#define CAN_SJA1000_CDR_CBP BIT(6)
46#define CAN_SJA1000_CDR_CAN_MODE BIT(7)
48#define CAN_SJA1000_CDR_CD_DIV1 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 7U)
49#define CAN_SJA1000_CDR_CD_DIV2 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 0U)
50#define CAN_SJA1000_CDR_CD_DIV4 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 1U)
51#define CAN_SJA1000_CDR_CD_DIV6 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 2U)
52#define CAN_SJA1000_CDR_CD_DIV8 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 3U)
53#define CAN_SJA1000_CDR_CD_DIV10 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 4U)
54#define CAN_SJA1000_CDR_CD_DIV12 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 5U)
55#define CAN_SJA1000_CDR_CD_DIV14 FIELD_PREP(CAN_SJA1000_CDR_CD_MASK, 6U)
62#define CAN_SJA1000_TIMING_MIN_INITIALIZER \
74#define CAN_SJA1000_TIMING_MAX_INITIALIZER \
124#define CAN_SJA1000_DT_CONFIG_GET(node_id, _custom, _read_reg, _write_reg, _ocr, _cdr, \
127 .common = CAN_DT_DRIVER_CONFIG_GET(node_id, _min_bitrate, 1000000), \
128 .read_reg = _read_reg, \
129 .write_reg = _write_reg, \
147#define CAN_SJA1000_DT_CONFIG_INST_GET(inst, _custom, _read_reg, _write_reg, _ocr, _cdr, \
149 CAN_SJA1000_DT_CONFIG_GET(DT_DRV_INST(inst), _custom, _read_reg, _write_reg, _ocr, _cdr, \
180#define CAN_SJA1000_DATA_INITIALIZER(_custom) \
235#ifdef CONFIG_CAN_MANUAL_RECOVERY_MODE
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_fil...
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 arg...
int can_sja1000_init(const struct device *dev)
SJA1000 driver initialization callback.
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_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.
uint8_t(* can_sja1000_read_reg_t)(const struct device *dev, uint8_t reg)
SJA1000 driver front-end callback for reading a register value.
Definition can_sja1000.h:99
void can_sja1000_isr(const struct device *dev)
SJA1000 IRQ handler callback.
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.
Definition can_sja1000.h:90
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...
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_stop(const struct device *dev)
SJA1000 callback API upon stopping CAN controller See can_stop() 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 descripti...
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_start(const struct device *dev)
SJA1000 callback API upon starting CAN controller See can_start() 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.
Controller Area Network (CAN) driver API.
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:111
void(* can_state_change_callback_t)(const struct device *dev, enum can_state state, struct can_bus_err_cnt err_cnt, void *user_data)
Defines the state change callback handler function signature.
Definition can.h:303
uint32_t can_mode_t
Provides a type to hold CAN controller configuration flags.
Definition can.h:116
void(* can_rx_callback_t)(const struct device *dev, struct can_frame *frame, void *user_data)
Defines the application callback handler function signature for receiving.
Definition can.h:292
void(* can_tx_callback_t)(const struct device *dev, int error, void *user_data)
Defines the application callback handler function signature.
Definition can.h:283
can_state
Defines the state of the CAN controller.
Definition can.h:121
state
Definition parser_state.h:29
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
CAN controller error counters.
Definition can.h:223
CAN filter structure.
Definition can.h:209
CAN frame structure.
Definition can.h:163
SJA1000 driver internal configuration structure.
Definition can_sja1000.h:104
const void * custom
Definition can_sja1000.h:110
const struct can_driver_config common
Definition can_sja1000.h:105
uint8_t cdr
Definition can_sja1000.h:109
uint8_t ocr
Definition can_sja1000.h:108
can_sja1000_read_reg_t read_reg
Definition can_sja1000.h:106
can_sja1000_write_reg_t write_reg
Definition can_sja1000.h:107
SJA1000 driver internal data structure.
Definition can_sja1000.h:164
void * custom
Definition can_sja1000.h:173
can_tx_callback_t tx_callback
Definition can_sja1000.h:171
struct k_sem tx_idle
Definition can_sja1000.h:170
struct can_driver_data common
Definition can_sja1000.h:165
enum can_state state
Definition can_sja1000.h:169
struct can_sja1000_rx_filter filters[CONFIG_CAN_MAX_FILTER]
Definition can_sja1000.h:167
void * tx_user_data
Definition can_sja1000.h:172
struct k_mutex mod_lock
Definition can_sja1000.h:168
atomic_t rx_allocs[ATOMIC_BITMAP_SIZE(CONFIG_CAN_MAX_FILTER)]
Definition can_sja1000.h:166
SJA1000 driver internal RX filter structure.
Definition can_sja1000.h:155
can_rx_callback_t callback
Definition can_sja1000.h:157
void * user_data
Definition can_sja1000.h:158
struct can_filter filter
Definition can_sja1000.h:156
CAN bus timing structure.
Definition can.h:262
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
Mutex Structure.
Definition kernel.h:3000
Kernel timeout type.
Definition sys_clock.h:65