drivers: can: drop DEV_DATA/DEV_CFG usage
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and dev->config instead. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
224958c537
commit
6378fcd0be
6 changed files with 84 additions and 76 deletions
|
@ -37,6 +37,8 @@ LOG_MODULE_REGISTER(mcp2515_can);
|
|||
|
||||
static int mcp2515_cmd_soft_reset(const struct device *dev)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_RESET };
|
||||
|
||||
const struct spi_buf tx_buf = {
|
||||
|
@ -46,13 +48,15 @@ static int mcp2515_cmd_soft_reset(const struct device *dev)
|
|||
.buffers = &tx_buf, .count = 1U
|
||||
};
|
||||
|
||||
return spi_write_dt(&DEV_CFG(dev)->bus, &tx);
|
||||
return spi_write_dt(&dev_cfg->bus, &tx);
|
||||
}
|
||||
|
||||
static int mcp2515_cmd_bit_modify(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t mask,
|
||||
uint8_t data)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_BIT_MODIFY, reg_addr, mask, data };
|
||||
|
||||
const struct spi_buf tx_buf = {
|
||||
|
@ -62,12 +66,14 @@ static int mcp2515_cmd_bit_modify(const struct device *dev, uint8_t reg_addr,
|
|||
.buffers = &tx_buf, .count = 1U
|
||||
};
|
||||
|
||||
return spi_write_dt(&DEV_CFG(dev)->bus, &tx);
|
||||
return spi_write_dt(&dev_cfg->bus, &tx);
|
||||
}
|
||||
|
||||
static int mcp2515_cmd_write_reg(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t *buf_data, uint8_t buf_len)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_WRITE, reg_addr };
|
||||
|
||||
struct spi_buf tx_buf[] = {
|
||||
|
@ -78,7 +84,7 @@ static int mcp2515_cmd_write_reg(const struct device *dev, uint8_t reg_addr,
|
|||
.buffers = tx_buf, .count = ARRAY_SIZE(tx_buf)
|
||||
};
|
||||
|
||||
return spi_write_dt(&DEV_CFG(dev)->bus, &tx);
|
||||
return spi_write_dt(&dev_cfg->bus, &tx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -98,6 +104,8 @@ static int mcp2515_cmd_write_reg(const struct device *dev, uint8_t reg_addr,
|
|||
static int mcp2515_cmd_load_tx_buffer(const struct device *dev, uint8_t abc,
|
||||
uint8_t *buf_data, uint8_t buf_len)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
__ASSERT(abc <= 5, "abc <= 5");
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_LOAD_TX_BUFFER | abc };
|
||||
|
@ -110,7 +118,7 @@ static int mcp2515_cmd_load_tx_buffer(const struct device *dev, uint8_t abc,
|
|||
.buffers = tx_buf, .count = ARRAY_SIZE(tx_buf)
|
||||
};
|
||||
|
||||
return spi_write_dt(&DEV_CFG(dev)->bus, &tx);
|
||||
return spi_write_dt(&dev_cfg->bus, &tx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -122,6 +130,8 @@ static int mcp2515_cmd_load_tx_buffer(const struct device *dev, uint8_t abc,
|
|||
*/
|
||||
static int mcp2515_cmd_rts(const struct device *dev, uint8_t nnn)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
__ASSERT(nnn < BIT(MCP2515_TX_CNT), "nnn < BIT(MCP2515_TX_CNT)");
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_RTS | nnn };
|
||||
|
@ -133,12 +143,14 @@ static int mcp2515_cmd_rts(const struct device *dev, uint8_t nnn)
|
|||
.buffers = tx_buf, .count = ARRAY_SIZE(tx_buf)
|
||||
};
|
||||
|
||||
return spi_write_dt(&DEV_CFG(dev)->bus, &tx);
|
||||
return spi_write_dt(&dev_cfg->bus, &tx);
|
||||
}
|
||||
|
||||
static int mcp2515_cmd_read_reg(const struct device *dev, uint8_t reg_addr,
|
||||
uint8_t *buf_data, uint8_t buf_len)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_READ, reg_addr };
|
||||
|
||||
struct spi_buf tx_buf[] = {
|
||||
|
@ -156,7 +168,7 @@ static int mcp2515_cmd_read_reg(const struct device *dev, uint8_t reg_addr,
|
|||
.buffers = rx_buf, .count = ARRAY_SIZE(rx_buf)
|
||||
};
|
||||
|
||||
return spi_transceive_dt(&DEV_CFG(dev)->bus, &tx, &rx);
|
||||
return spi_transceive_dt(&dev_cfg->bus, &tx, &rx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -173,6 +185,8 @@ static int mcp2515_cmd_read_reg(const struct device *dev, uint8_t reg_addr,
|
|||
static int mcp2515_cmd_read_rx_buffer(const struct device *dev, uint8_t nm,
|
||||
uint8_t *buf_data, uint8_t buf_len)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
__ASSERT(nm <= 0x03, "nm <= 0x03");
|
||||
|
||||
uint8_t cmd_buf[] = { MCP2515_OPCODE_READ_RX_BUFFER | (nm << 1) };
|
||||
|
@ -192,7 +206,7 @@ static int mcp2515_cmd_read_rx_buffer(const struct device *dev, uint8_t nm,
|
|||
.buffers = rx_buf, .count = ARRAY_SIZE(rx_buf)
|
||||
};
|
||||
|
||||
return spi_transceive_dt(&DEV_CFG(dev)->bus, &tx, &rx);
|
||||
return spi_transceive_dt(&dev_cfg->bus, &tx, &rx);
|
||||
}
|
||||
|
||||
static uint8_t mcp2515_convert_canmode_to_mcp2515mode(enum can_mode mode)
|
||||
|
@ -308,7 +322,7 @@ static int mcp2515_get_mode(const struct device *dev, uint8_t *mode)
|
|||
|
||||
static int mcp2515_get_core_clock(const struct device *dev, uint32_t *rate)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = DEV_CFG(dev);
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
|
||||
*rate = dev_cfg->osc_freq / 2;
|
||||
return 0;
|
||||
|
@ -326,7 +340,7 @@ static int mcp2515_set_timing(const struct device *dev,
|
|||
const struct can_timing *timing_data)
|
||||
{
|
||||
ARG_UNUSED(timing_data);
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
int ret;
|
||||
|
||||
if (!timing) {
|
||||
|
@ -439,7 +453,7 @@ done:
|
|||
|
||||
static int mcp2515_set_mode(const struct device *dev, enum can_mode mode)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
int ret;
|
||||
|
||||
k_mutex_lock(&dev_data->mutex, K_FOREVER);
|
||||
|
@ -460,7 +474,7 @@ static int mcp2515_send(const struct device *dev,
|
|||
k_timeout_t timeout, can_tx_callback_t callback,
|
||||
void *user_data)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
uint8_t tx_idx = 0U;
|
||||
uint8_t abc;
|
||||
uint8_t nnn;
|
||||
|
@ -523,7 +537,7 @@ static int mcp2515_add_rx_filter(const struct device *dev,
|
|||
void *cb_arg,
|
||||
const struct zcan_filter *filter)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
int filter_id = 0;
|
||||
|
||||
__ASSERT(rx_cb != NULL, "response_ptr can not be null");
|
||||
|
@ -555,7 +569,7 @@ static int mcp2515_add_rx_filter(const struct device *dev,
|
|||
|
||||
static void mcp2515_remove_rx_filter(const struct device *dev, int filter_id)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
|
||||
k_mutex_lock(&dev_data->mutex, K_FOREVER);
|
||||
dev_data->filter_usage &= ~BIT(filter_id);
|
||||
|
@ -566,7 +580,7 @@ static void mcp2515_set_state_change_callback(const struct device *dev,
|
|||
can_state_change_callback_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
|
||||
dev_data->state_change_cb = cb;
|
||||
dev_data->state_change_cb_data = user_data;
|
||||
|
@ -575,7 +589,7 @@ static void mcp2515_set_state_change_callback(const struct device *dev,
|
|||
static void mcp2515_rx_filter(const struct device *dev,
|
||||
struct zcan_frame *frame)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
uint8_t filter_id = 0U;
|
||||
can_rx_callback_t callback;
|
||||
struct zcan_frame tmp_frame;
|
||||
|
@ -621,7 +635,7 @@ static void mcp2515_rx(const struct device *dev, uint8_t rx_idx)
|
|||
|
||||
static void mcp2515_tx_done(const struct device *dev, uint8_t tx_idx)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
|
||||
if (dev_data->tx_cb[tx_idx].cb == NULL) {
|
||||
k_sem_give(&dev_data->tx_cb[tx_idx].sem);
|
||||
|
@ -673,7 +687,7 @@ static enum can_state mcp2515_get_state(const struct device *dev,
|
|||
|
||||
static void mcp2515_handle_errors(const struct device *dev)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
can_state_change_callback_t state_change_cb = dev_data->state_change_cb;
|
||||
void *state_change_cb_data = dev_data->state_change_cb_data;
|
||||
enum can_state state;
|
||||
|
@ -697,8 +711,8 @@ static void mcp2515_recover(const struct device *dev, k_timeout_t timeout)
|
|||
|
||||
static void mcp2515_handle_interrupts(const struct device *dev)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = DEV_CFG(dev);
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
int ret;
|
||||
uint8_t canintf;
|
||||
|
||||
|
@ -765,7 +779,7 @@ static void mcp2515_handle_interrupts(const struct device *dev)
|
|||
|
||||
static void mcp2515_int_thread(const struct device *dev)
|
||||
{
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
|
||||
while (1) {
|
||||
k_sem_take(&dev_data->int_sem, K_FOREVER);
|
||||
|
@ -814,8 +828,8 @@ static const struct can_driver_api can_api_funcs = {
|
|||
|
||||
static int mcp2515_init(const struct device *dev)
|
||||
{
|
||||
const struct mcp2515_config *dev_cfg = DEV_CFG(dev);
|
||||
struct mcp2515_data *dev_data = DEV_DATA(dev);
|
||||
const struct mcp2515_config *dev_cfg = dev->config;
|
||||
struct mcp2515_data *dev_data = dev->data;
|
||||
int ret;
|
||||
struct can_timing timing;
|
||||
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
#define MCP2515_TX_CNT 3
|
||||
#define MCP2515_FRAME_LEN 13
|
||||
|
||||
#define DEV_CFG(dev) \
|
||||
((const struct mcp2515_config *const)(dev)->config)
|
||||
#define DEV_DATA(dev) ((struct mcp2515_data *const)(dev)->data)
|
||||
|
||||
struct mcp2515_tx_cb {
|
||||
struct k_sem sem;
|
||||
can_tx_callback_t cb;
|
||||
|
|
|
@ -201,8 +201,8 @@ static void can_stm32_isr(const struct device *dev)
|
|||
const struct can_stm32_config *cfg;
|
||||
CAN_TypeDef *can;
|
||||
|
||||
data = DEV_DATA(dev);
|
||||
cfg = DEV_CFG(dev);
|
||||
data = dev->data;
|
||||
cfg = dev->config;
|
||||
can = cfg->can;
|
||||
|
||||
can_stm32_tx_isr_handler(can, data);
|
||||
|
@ -221,8 +221,8 @@ static void can_stm32_rx_isr(const struct device *dev)
|
|||
const struct can_stm32_config *cfg;
|
||||
CAN_TypeDef *can;
|
||||
|
||||
data = DEV_DATA(dev);
|
||||
cfg = DEV_CFG(dev);
|
||||
data = dev->data;
|
||||
cfg = dev->config;
|
||||
can = cfg->can;
|
||||
|
||||
can_stm32_rx_isr_handler(can, data);
|
||||
|
@ -234,8 +234,8 @@ static void can_stm32_tx_isr(const struct device *dev)
|
|||
const struct can_stm32_config *cfg;
|
||||
CAN_TypeDef *can;
|
||||
|
||||
data = DEV_DATA(dev);
|
||||
cfg = DEV_CFG(dev);
|
||||
data = dev->data;
|
||||
cfg = dev->config;
|
||||
can = cfg->can;
|
||||
|
||||
can_stm32_tx_isr_handler(can, data);
|
||||
|
@ -247,8 +247,8 @@ static void can_stm32_state_change_isr(const struct device *dev)
|
|||
const struct can_stm32_config *cfg;
|
||||
CAN_TypeDef *can;
|
||||
|
||||
data = DEV_DATA(dev);
|
||||
cfg = DEV_CFG(dev);
|
||||
data = dev->data;
|
||||
cfg = dev->config;
|
||||
can = cfg->can;
|
||||
|
||||
|
||||
|
@ -313,9 +313,9 @@ static int can_leave_sleep_mode(CAN_TypeDef *can)
|
|||
|
||||
int can_stm32_set_mode(const struct device *dev, enum can_mode mode)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
struct can_stm32_data *data = dev->data;
|
||||
int ret;
|
||||
|
||||
LOG_DBG("Set mode %d", mode);
|
||||
|
@ -359,9 +359,9 @@ int can_stm32_set_timing(const struct device *dev,
|
|||
const struct can_timing *timing,
|
||||
const struct can_timing *timing_data)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
struct can_stm32_data *data = dev->data;
|
||||
int ret = -EIO;
|
||||
|
||||
ARG_UNUSED(timing_data);
|
||||
|
@ -397,7 +397,7 @@ done:
|
|||
|
||||
int can_stm32_get_core_clock(const struct device *dev, uint32_t *rate)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
const struct device *clock;
|
||||
int ret;
|
||||
|
||||
|
@ -423,8 +423,8 @@ int can_stm32_get_max_filters(const struct device *dev, enum can_ide id_type)
|
|||
|
||||
static int can_stm32_init(const struct device *dev)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
struct can_stm32_data *data = dev->data;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
struct can_timing timing;
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can2), okay)
|
||||
|
@ -534,8 +534,8 @@ static void can_stm32_set_state_change_callback(const struct device *dev,
|
|||
can_state_change_callback_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
struct can_stm32_data *data = dev->data;
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
|
||||
data->state_change_cb = cb;
|
||||
|
@ -551,7 +551,7 @@ static void can_stm32_set_state_change_callback(const struct device *dev,
|
|||
static enum can_state can_stm32_get_state(const struct device *dev,
|
||||
struct can_bus_err_cnt *err_cnt)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
|
||||
if (err_cnt) {
|
||||
|
@ -576,8 +576,8 @@ static enum can_state can_stm32_get_state(const struct device *dev,
|
|||
#ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
|
||||
int can_stm32_recover(const struct device *dev, k_timeout_t timeout)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
struct can_stm32_data *data = dev->data;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
int ret = -EAGAIN;
|
||||
int64_t start_time;
|
||||
|
@ -619,8 +619,8 @@ int can_stm32_send(const struct device *dev, const struct zcan_frame *frame,
|
|||
k_timeout_t timeout, can_tx_callback_t callback,
|
||||
void *user_data)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
struct can_stm32_data *data = dev->data;
|
||||
CAN_TypeDef *can = cfg->can;
|
||||
uint32_t transmit_status_register = can->TSR;
|
||||
CAN_TxMailBox_TypeDef *mailbox = NULL;
|
||||
|
@ -1029,8 +1029,8 @@ static inline int can_stm32_add_rx_filter_unlocked(const struct device *dev,
|
|||
void *cb_arg,
|
||||
const struct zcan_filter *filter)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
struct can_stm32_data *data = dev->data;
|
||||
CAN_TypeDef *can = cfg->master_can;
|
||||
int filter_index = 0;
|
||||
int filter_id;
|
||||
|
@ -1048,7 +1048,7 @@ int can_stm32_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
|
|||
void *cb_arg,
|
||||
const struct zcan_filter *filter)
|
||||
{
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
struct can_stm32_data *data = dev->data;
|
||||
int filter_id;
|
||||
|
||||
k_mutex_lock(&data->inst_mutex, K_FOREVER);
|
||||
|
@ -1060,8 +1060,8 @@ int can_stm32_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
|
|||
|
||||
void can_stm32_remove_rx_filter(const struct device *dev, int filter_id)
|
||||
{
|
||||
const struct can_stm32_config *cfg = DEV_CFG(dev);
|
||||
struct can_stm32_data *data = DEV_DATA(dev);
|
||||
const struct can_stm32_config *cfg = dev->config;
|
||||
struct can_stm32_data *data = dev->data;
|
||||
CAN_TypeDef *can = cfg->master_can;
|
||||
int bank_nr;
|
||||
int filter_index;
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
|
||||
#include <drivers/can.h>
|
||||
|
||||
#define DEV_DATA(dev) ((struct can_stm32_data *const)(dev)->data)
|
||||
#define DEV_CFG(dev) \
|
||||
((const struct can_stm32_config *const)(dev)->config)
|
||||
|
||||
#define BIT_SEG_LENGTH(cfg) ((cfg)->prop_ts1 + (cfg)->ts2 + 1)
|
||||
|
||||
#define CAN_NUMBER_OF_FILTER_BANKS (14)
|
||||
|
|
|
@ -57,7 +57,7 @@ void can_stm32fd_set_state_change_callback(const struct device *dev,
|
|||
can_state_change_callback_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
struct can_stm32fd_data *data = DEV_DATA(dev);
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
|
||||
data->mcan_data.state_change_cb = cb;
|
||||
data->mcan_data.state_change_cb_data = user_data;
|
||||
|
@ -65,9 +65,10 @@ void can_stm32fd_set_state_change_callback(const struct device *dev,
|
|||
|
||||
static int can_stm32fd_init(const struct device *dev)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
struct can_mcan_data *mcan_data = &DEV_DATA(dev)->mcan_data;
|
||||
struct can_mcan_data *mcan_data = &data->mcan_data;
|
||||
struct can_mcan_msg_sram *msg_ram = cfg->msg_sram;
|
||||
int ret;
|
||||
|
||||
|
@ -92,7 +93,7 @@ static int can_stm32fd_init(const struct device *dev)
|
|||
enum can_state can_stm32fd_get_state(const struct device *dev,
|
||||
struct can_bus_err_cnt *err_cnt)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
|
||||
return can_mcan_get_state(mcan_cfg, err_cnt);
|
||||
|
@ -102,9 +103,10 @@ int can_stm32fd_send(const struct device *dev, const struct zcan_frame *frame,
|
|||
k_timeout_t timeout, can_tx_callback_t callback,
|
||||
void *user_data)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
struct can_mcan_data *mcan_data = &DEV_DATA(dev)->mcan_data;
|
||||
struct can_mcan_data *mcan_data = &data->mcan_data;
|
||||
struct can_mcan_msg_sram *msg_ram = cfg->msg_sram;
|
||||
|
||||
return can_mcan_send(mcan_cfg, mcan_data, msg_ram, frame, timeout,
|
||||
|
@ -114,8 +116,9 @@ int can_stm32fd_send(const struct device *dev, const struct zcan_frame *frame,
|
|||
int can_stm32fd_add_rx_filter(const struct device *dev, can_rx_callback_t callback,
|
||||
void *user_data, const struct zcan_filter *filter)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
struct can_mcan_data *mcan_data = &DEV_DATA(dev)->mcan_data;
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
struct can_mcan_data *mcan_data = &data->mcan_data;
|
||||
struct can_mcan_msg_sram *msg_ram = cfg->msg_sram;
|
||||
|
||||
return can_mcan_add_rx_filter(mcan_data, msg_ram, callback, user_data, filter);
|
||||
|
@ -123,8 +126,9 @@ int can_stm32fd_add_rx_filter(const struct device *dev, can_rx_callback_t callba
|
|||
|
||||
void can_stm32fd_remove_rx_filter(const struct device *dev, int filter_id)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
struct can_mcan_data *mcan_data = &DEV_DATA(dev)->mcan_data;
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
struct can_mcan_data *mcan_data = &data->mcan_data;
|
||||
struct can_mcan_msg_sram *msg_ram = cfg->msg_sram;
|
||||
|
||||
can_mcan_remove_rx_filter(mcan_data, msg_ram, filter_id);
|
||||
|
@ -132,7 +136,7 @@ void can_stm32fd_remove_rx_filter(const struct device *dev, int filter_id)
|
|||
|
||||
int can_stm32fd_set_mode(const struct device *dev, enum can_mode mode)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
|
||||
return can_mcan_set_mode(mcan_cfg, mode);
|
||||
|
@ -142,7 +146,7 @@ int can_stm32fd_set_timing(const struct device *dev,
|
|||
const struct can_timing *timing,
|
||||
const struct can_timing *timing_data)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
|
||||
return can_mcan_set_timing(mcan_cfg, timing, timing_data);
|
||||
|
@ -151,9 +155,9 @@ int can_stm32fd_set_timing(const struct device *dev,
|
|||
void can_stm32fd_line_0_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
struct can_stm32fd_data *data = DEV_DATA(dev);
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
struct can_mcan_data *mcan_data = &data->mcan_data;
|
||||
struct can_mcan_msg_sram *msg_ram = cfg->msg_sram;
|
||||
|
||||
|
@ -163,9 +167,10 @@ void can_stm32fd_line_0_isr(void *arg)
|
|||
void can_stm32fd_line_1_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct can_stm32fd_config *cfg = DEV_CFG(dev);
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
struct can_stm32fd_data *data = dev->data;
|
||||
const struct can_mcan_config *mcan_cfg = &cfg->mcan_cfg;
|
||||
struct can_mcan_data *mcan_data = &DEV_DATA(dev)->mcan_data;
|
||||
struct can_mcan_data *mcan_data = &data->mcan_data;
|
||||
struct can_mcan_msg_sram *msg_ram = cfg->msg_sram;
|
||||
|
||||
can_mcan_line_1_isr(mcan_cfg, msg_ram, mcan_data);
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
|
||||
#include "can_mcan.h"
|
||||
|
||||
#define DEV_DATA(dev) ((struct can_stm32fd_data *)(dev)->data)
|
||||
#define DEV_CFG(dev) ((const struct can_stm32fd_config *)(dev)->config)
|
||||
|
||||
struct can_stm32fd_config {
|
||||
struct can_mcan_msg_sram *msg_sram;
|
||||
void (*config_irq)(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue