drivers: can: add struct device argument to callback functions
Include a pointer to the CAN controller device for the CAN transmit, receive, and state change callback functions. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
9cc32af99e
commit
67ba9900f0
16 changed files with 137 additions and 105 deletions
|
@ -175,9 +175,9 @@ occurred. It does not block until the message is sent like the example above.
|
||||||
|
|
||||||
.. code-block:: C
|
.. code-block:: C
|
||||||
|
|
||||||
void tx_irq_callback(int error, void *arg)
|
void tx_callback(const struct device *dev, int error, void *user_data)
|
||||||
{
|
{
|
||||||
char *sender = (char *)arg;
|
char *sender = (char *)user_data;
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
LOG_ERR("Sending failed [%d]\nSender: %s\n", error, sender);
|
LOG_ERR("Sending failed [%d]\nSender: %s\n", error, sender);
|
||||||
|
@ -211,7 +211,7 @@ added.
|
||||||
|
|
||||||
.. code-block:: C
|
.. code-block:: C
|
||||||
|
|
||||||
void rx_callback_function(struct zcan_frame *frame, void *user_data)
|
void rx_callback_function(const struct device *dev, struct zcan_frame *frame, void *user_data)
|
||||||
{
|
{
|
||||||
... do something with the frame ...
|
... do something with the frame ...
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,16 +14,18 @@ LOG_MODULE_REGISTER(can_common, CONFIG_CAN_LOG_LEVEL);
|
||||||
/* CAN sync segment is always one time quantum */
|
/* CAN sync segment is always one time quantum */
|
||||||
#define CAN_SYNC_SEG 1
|
#define CAN_SYNC_SEG 1
|
||||||
|
|
||||||
static void can_msgq_put(struct zcan_frame *frame, void *arg)
|
static void can_msgq_put(const struct device *dev, struct zcan_frame *frame, void *user_data)
|
||||||
{
|
{
|
||||||
struct k_msgq *msgq = (struct k_msgq *)arg;
|
struct k_msgq *msgq = (struct k_msgq *)user_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
__ASSERT_NO_MSG(msgq);
|
__ASSERT_NO_MSG(msgq);
|
||||||
|
|
||||||
ret = k_msgq_put(msgq, frame, K_NO_WAIT);
|
ret = k_msgq_put(msgq, frame, K_NO_WAIT);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LOG_ERR("Msgq %p overflowed. Frame ID: 0x%x", arg, frame->id);
|
LOG_ERR("Msgq %p overflowed. Frame ID: 0x%x", msgq, frame->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ struct can_loopback_data {
|
||||||
CONFIG_CAN_LOOPBACK_TX_THREAD_STACK_SIZE);
|
CONFIG_CAN_LOOPBACK_TX_THREAD_STACK_SIZE);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void dispatch_frame(const struct zcan_frame *frame,
|
static void dispatch_frame(const struct device *dev,
|
||||||
|
const struct zcan_frame *frame,
|
||||||
struct can_loopback_filter *filter)
|
struct can_loopback_filter *filter)
|
||||||
{
|
{
|
||||||
struct zcan_frame frame_tmp = *frame;
|
struct zcan_frame frame_tmp = *frame;
|
||||||
|
@ -52,7 +53,7 @@ static void dispatch_frame(const struct zcan_frame *frame,
|
||||||
"standard" : "extended",
|
"standard" : "extended",
|
||||||
frame->rtr == CAN_DATAFRAME ? "" : ", RTR frame");
|
frame->rtr == CAN_DATAFRAME ? "" : ", RTR frame");
|
||||||
|
|
||||||
filter->rx_cb(&frame_tmp, filter->cb_arg);
|
filter->rx_cb(dev, &frame_tmp, filter->cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int check_filter_match(const struct zcan_frame *frame,
|
static inline int check_filter_match(const struct zcan_frame *frame,
|
||||||
|
@ -62,13 +63,15 @@ static inline int check_filter_match(const struct zcan_frame *frame,
|
||||||
(frame->id & filter->id_mask));
|
(frame->id & filter->id_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tx_thread(void *data_arg, void *arg2, void *arg3)
|
void tx_thread(void *arg1, void *arg2, void *arg3)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg2);
|
const struct device *dev = arg1;
|
||||||
ARG_UNUSED(arg3);
|
struct can_loopback_data *data = dev->data;
|
||||||
struct can_loopback_frame frame;
|
struct can_loopback_frame frame;
|
||||||
struct can_loopback_filter *filter;
|
struct can_loopback_filter *filter;
|
||||||
struct can_loopback_data *data = (struct can_loopback_data *)data_arg;
|
|
||||||
|
ARG_UNUSED(arg2);
|
||||||
|
ARG_UNUSED(arg3);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
k_msgq_get(&data->tx_msgq, &frame, K_FOREVER);
|
k_msgq_get(&data->tx_msgq, &frame, K_FOREVER);
|
||||||
|
@ -78,7 +81,7 @@ void tx_thread(void *data_arg, void *arg2, void *arg3)
|
||||||
filter = &data->filters[i];
|
filter = &data->filters[i];
|
||||||
if (filter->rx_cb &&
|
if (filter->rx_cb &&
|
||||||
check_filter_match(&frame.frame, &filter->filter)) {
|
check_filter_match(&frame.frame, &filter->filter)) {
|
||||||
dispatch_frame(&frame.frame, filter);
|
dispatch_frame(dev, &frame.frame, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +90,7 @@ void tx_thread(void *data_arg, void *arg2, void *arg3)
|
||||||
if (!frame.cb) {
|
if (!frame.cb) {
|
||||||
k_sem_give(frame.tx_compl);
|
k_sem_give(frame.tx_compl);
|
||||||
} else {
|
} else {
|
||||||
frame.cb(0, frame.cb_arg);
|
frame.cb(dev, 0, frame.cb_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +310,7 @@ static int can_loopback_init(const struct device *dev)
|
||||||
|
|
||||||
tx_tid = k_thread_create(&data->tx_thread_data, data->tx_thread_stack,
|
tx_tid = k_thread_create(&data->tx_thread_data, data->tx_thread_stack,
|
||||||
K_KERNEL_STACK_SIZEOF(data->tx_thread_stack),
|
K_KERNEL_STACK_SIZEOF(data->tx_thread_stack),
|
||||||
tx_thread, data, NULL, NULL,
|
tx_thread, (void *)dev, NULL, NULL,
|
||||||
CONFIG_CAN_LOOPBACK_TX_THREAD_PRIORITY,
|
CONFIG_CAN_LOOPBACK_TX_THREAD_PRIORITY,
|
||||||
0, K_NO_WAIT);
|
0, K_NO_WAIT);
|
||||||
if (!tx_tid) {
|
if (!tx_tid) {
|
||||||
|
|
|
@ -288,9 +288,11 @@ int can_mcan_init(const struct device *dev, const struct can_mcan_config *cfg,
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
data->dev = dev;
|
||||||
k_mutex_init(&data->inst_mutex);
|
k_mutex_init(&data->inst_mutex);
|
||||||
k_mutex_init(&data->tx_mtx);
|
k_mutex_init(&data->tx_mtx);
|
||||||
k_sem_init(&data->tx_sem, NUM_TX_BUF_ELEMENTS, NUM_TX_BUF_ELEMENTS);
|
k_sem_init(&data->tx_sem, NUM_TX_BUF_ELEMENTS, NUM_TX_BUF_ELEMENTS);
|
||||||
|
|
||||||
for (int i = 0; i < ARRAY_SIZE(data->tx_fin_sem); ++i) {
|
for (int i = 0; i < ARRAY_SIZE(data->tx_fin_sem); ++i) {
|
||||||
k_sem_init(&data->tx_fin_sem[i], 0, 1);
|
k_sem_init(&data->tx_fin_sem[i], 0, 1);
|
||||||
}
|
}
|
||||||
|
@ -502,7 +504,7 @@ static void can_mcan_state_change_handler(const struct can_mcan_config *cfg,
|
||||||
(void)can_mcan_get_state(cfg, &state, &err_cnt);
|
(void)can_mcan_get_state(cfg, &state, &err_cnt);
|
||||||
|
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
cb(state, err_cnt, cb_data);
|
cb(data->dev, state, err_cnt, cb_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +532,7 @@ static void can_mcan_tc_event_handler(struct can_mcan_reg *can,
|
||||||
if (tx_cb == NULL) {
|
if (tx_cb == NULL) {
|
||||||
k_sem_give(&data->tx_fin_sem[tx_idx]);
|
k_sem_give(&data->tx_fin_sem[tx_idx]);
|
||||||
} else {
|
} else {
|
||||||
tx_cb(0, data->tx_fin_cb_arg[tx_idx]);
|
tx_cb(data->dev, 0, data->tx_fin_cb_arg[tx_idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,7 +645,7 @@ static void can_mcan_get_message(struct can_mcan_data *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(&frame, cb_arg);
|
cb(data->dev, &frame, cb_arg);
|
||||||
} else {
|
} else {
|
||||||
LOG_DBG("cb missing");
|
LOG_DBG("cb missing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@ struct can_mcan_msg_sram {
|
||||||
} __packed __aligned(4);
|
} __packed __aligned(4);
|
||||||
|
|
||||||
struct can_mcan_data {
|
struct can_mcan_data {
|
||||||
|
const struct device *dev;
|
||||||
struct k_mutex inst_mutex;
|
struct k_mutex inst_mutex;
|
||||||
struct k_sem tx_sem;
|
struct k_sem tx_sem;
|
||||||
struct k_mutex tx_mtx;
|
struct k_mutex tx_mtx;
|
||||||
|
|
|
@ -635,7 +635,7 @@ static void mcp2515_rx_filter(const struct device *dev,
|
||||||
/*Make a temporary copy in case the user modifies the message*/
|
/*Make a temporary copy in case the user modifies the message*/
|
||||||
tmp_frame = *frame;
|
tmp_frame = *frame;
|
||||||
|
|
||||||
callback(&tmp_frame, dev_data->cb_arg[filter_id]);
|
callback(dev, &tmp_frame, dev_data->cb_arg[filter_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_unlock(&dev_data->mutex);
|
k_mutex_unlock(&dev_data->mutex);
|
||||||
|
@ -665,7 +665,7 @@ static void mcp2515_tx_done(const struct device *dev, uint8_t tx_idx)
|
||||||
if (dev_data->tx_cb[tx_idx].cb == NULL) {
|
if (dev_data->tx_cb[tx_idx].cb == NULL) {
|
||||||
k_sem_give(&dev_data->tx_cb[tx_idx].sem);
|
k_sem_give(&dev_data->tx_cb[tx_idx].sem);
|
||||||
} else {
|
} else {
|
||||||
dev_data->tx_cb[tx_idx].cb(0, dev_data->tx_cb[tx_idx].cb_arg);
|
dev_data->tx_cb[tx_idx].cb(dev, 0, dev_data->tx_cb[tx_idx].cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_lock(&dev_data->mutex, K_FOREVER);
|
k_mutex_lock(&dev_data->mutex, K_FOREVER);
|
||||||
|
@ -731,7 +731,7 @@ static void mcp2515_handle_errors(const struct device *dev)
|
||||||
|
|
||||||
if (state_change_cb && dev_data->old_state != state) {
|
if (state_change_cb && dev_data->old_state != state) {
|
||||||
dev_data->old_state = state;
|
dev_data->old_state = state;
|
||||||
state_change_cb(state, err_cnt, state_change_cb_data);
|
state_change_cb(dev, state, err_cnt, state_change_cb_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,7 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
|
||||||
data->state = state;
|
data->state = state;
|
||||||
|
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
cb(state, err_cnt, cb_data);
|
cb(dev, state, err_cnt, cb_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ static inline void mcux_flexcan_transfer_error_status(const struct device *dev,
|
||||||
FLEXCAN_TransferAbortSend(config->base, &data->handle,
|
FLEXCAN_TransferAbortSend(config->base, &data->handle,
|
||||||
ALLOC_IDX_TO_TXMB_IDX(alloc));
|
ALLOC_IDX_TO_TXMB_IDX(alloc));
|
||||||
if (function != NULL) {
|
if (function != NULL) {
|
||||||
function(-ENETDOWN, arg);
|
function(dev, -ENETDOWN, arg);
|
||||||
} else {
|
} else {
|
||||||
data->tx_cbs[alloc].status = -ENETDOWN;
|
data->tx_cbs[alloc].status = -ENETDOWN;
|
||||||
k_sem_give(&data->tx_cbs[alloc].done);
|
k_sem_give(&data->tx_cbs[alloc].done);
|
||||||
|
@ -590,7 +590,7 @@ static inline void mcux_flexcan_transfer_tx_idle(const struct device *dev,
|
||||||
|
|
||||||
if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) {
|
if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) {
|
||||||
if (function != NULL) {
|
if (function != NULL) {
|
||||||
function(0, arg);
|
function(dev, 0, arg);
|
||||||
} else {
|
} else {
|
||||||
data->tx_cbs[alloc].status = 0;
|
data->tx_cbs[alloc].status = 0;
|
||||||
k_sem_give(&data->tx_cbs[alloc].done);
|
k_sem_give(&data->tx_cbs[alloc].done);
|
||||||
|
@ -618,7 +618,7 @@ static inline void mcux_flexcan_transfer_rx_idle(const struct device *dev,
|
||||||
if (atomic_test_bit(data->rx_allocs, alloc)) {
|
if (atomic_test_bit(data->rx_allocs, alloc)) {
|
||||||
mcux_flexcan_copy_frame_to_zframe(&data->rx_cbs[alloc].frame,
|
mcux_flexcan_copy_frame_to_zframe(&data->rx_cbs[alloc].frame,
|
||||||
&frame);
|
&frame);
|
||||||
function(&frame, arg);
|
function(dev, &frame, arg);
|
||||||
|
|
||||||
/* Setup RX message buffer to receive next message */
|
/* Setup RX message buffer to receive next message */
|
||||||
FLEXCAN_SetRxMbConfig(config->base, mb,
|
FLEXCAN_SetRxMbConfig(config->base, mb,
|
||||||
|
|
|
@ -233,7 +233,7 @@ static void can_rcar_tx_done(const struct device *dev)
|
||||||
|
|
||||||
data->tx_unsent--;
|
data->tx_unsent--;
|
||||||
if (tx_cb->cb != NULL) {
|
if (tx_cb->cb != NULL) {
|
||||||
tx_cb->cb(0, tx_cb->cb_arg);
|
tx_cb->cb(dev, 0, tx_cb->cb_arg);
|
||||||
} else {
|
} else {
|
||||||
k_sem_give(&tx_cb->sem);
|
k_sem_give(&tx_cb->sem);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ static void can_rcar_state_change(const struct device *dev, uint32_t newstate)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
can_rcar_get_error_count(config, &err_cnt);
|
can_rcar_get_error_count(config, &err_cnt);
|
||||||
cb(newstate, err_cnt, state_change_cb_data);
|
cb(dev, newstate, err_cnt, state_change_cb_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void can_rcar_error(const struct device *dev)
|
static void can_rcar_error(const struct device *dev)
|
||||||
|
@ -366,7 +366,8 @@ static void can_rcar_error(const struct device *dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void can_rcar_rx_filter_isr(struct can_rcar_data *data,
|
static void can_rcar_rx_filter_isr(const struct device *dev,
|
||||||
|
struct can_rcar_data *data,
|
||||||
const struct zcan_frame *frame)
|
const struct zcan_frame *frame)
|
||||||
{
|
{
|
||||||
struct zcan_frame tmp_frame;
|
struct zcan_frame tmp_frame;
|
||||||
|
@ -385,7 +386,7 @@ static void can_rcar_rx_filter_isr(struct can_rcar_data *data,
|
||||||
* modifies the message.
|
* modifies the message.
|
||||||
*/
|
*/
|
||||||
tmp_frame = *frame;
|
tmp_frame = *frame;
|
||||||
data->rx_callback[i](&tmp_frame, data->rx_callback_arg[i]);
|
data->rx_callback[i](dev, &tmp_frame, data->rx_callback_arg[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +438,7 @@ static void can_rcar_rx_isr(const struct device *dev)
|
||||||
/* Increment CPU side pointer */
|
/* Increment CPU side pointer */
|
||||||
sys_write8(0xff, config->reg_addr + RCAR_CAN_RFPCR);
|
sys_write8(0xff, config->reg_addr + RCAR_CAN_RFPCR);
|
||||||
|
|
||||||
can_rcar_rx_filter_isr(data, &frame);
|
can_rcar_rx_filter_isr(dev, data, &frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void can_rcar_isr(const struct device *dev)
|
static void can_rcar_isr(const struct device *dev)
|
||||||
|
|
|
@ -55,10 +55,10 @@ LOG_MODULE_REGISTER(can_stm32, CONFIG_CAN_LOG_LEVEL);
|
||||||
static const uint8_t filter_in_bank[] = {2, 4, 1, 2};
|
static const uint8_t filter_in_bank[] = {2, 4, 1, 2};
|
||||||
static const uint8_t reg_demand[] = {2, 1, 4, 2};
|
static const uint8_t reg_demand[] = {2, 1, 4, 2};
|
||||||
|
|
||||||
static void can_stm32_signal_tx_complete(struct can_mailbox *mb)
|
static void can_stm32_signal_tx_complete(const struct device *dev, struct can_mailbox *mb)
|
||||||
{
|
{
|
||||||
if (mb->tx_callback) {
|
if (mb->tx_callback) {
|
||||||
mb->tx_callback(mb->error, mb->callback_arg);
|
mb->tx_callback(dev, mb->error, mb->callback_arg);
|
||||||
} else {
|
} else {
|
||||||
k_sem_give(&mb->tx_int_sem);
|
k_sem_give(&mb->tx_int_sem);
|
||||||
}
|
}
|
||||||
|
@ -85,8 +85,11 @@ static void can_stm32_get_msg_fifo(CAN_FIFOMailBox_TypeDef *mbox,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
void can_stm32_rx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
void can_stm32_rx_isr_handler(const struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct can_stm32_data *data = dev->data;
|
||||||
|
const struct can_stm32_config *cfg = dev->config;
|
||||||
|
CAN_TypeDef *can = cfg->can;
|
||||||
CAN_FIFOMailBox_TypeDef *mbox;
|
CAN_FIFOMailBox_TypeDef *mbox;
|
||||||
int filter_match_index;
|
int filter_match_index;
|
||||||
struct zcan_frame frame;
|
struct zcan_frame frame;
|
||||||
|
@ -107,7 +110,7 @@ void can_stm32_rx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||||
callback = data->rx_cb[filter_match_index];
|
callback = data->rx_cb[filter_match_index];
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(&frame, data->cb_arg[filter_match_index]);
|
callback(dev, &frame, data->cb_arg[filter_match_index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release message */
|
/* Release message */
|
||||||
|
@ -192,14 +195,17 @@ static inline void can_stm32_bus_state_change_isr(const struct device *dev)
|
||||||
data->state = state;
|
data->state = state;
|
||||||
|
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
cb(state, err_cnt, state_change_cb_data);
|
cb(dev, state, err_cnt, state_change_cb_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
void can_stm32_tx_isr_handler(const struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct can_stm32_data *data = dev->data;
|
||||||
|
const struct can_stm32_config *cfg = dev->config;
|
||||||
|
CAN_TypeDef *can = cfg->can;
|
||||||
uint32_t bus_off;
|
uint32_t bus_off;
|
||||||
|
|
||||||
bus_off = can->ESR & CAN_ESR_BOFF;
|
bus_off = can->ESR & CAN_ESR_BOFF;
|
||||||
|
@ -213,7 +219,7 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||||
-EIO;
|
-EIO;
|
||||||
/* clear the request. */
|
/* clear the request. */
|
||||||
can->TSR |= CAN_TSR_RQCP0;
|
can->TSR |= CAN_TSR_RQCP0;
|
||||||
can_stm32_signal_tx_complete(&data->mb0);
|
can_stm32_signal_tx_complete(dev, &data->mb0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((can->TSR & CAN_TSR_RQCP1) | bus_off) {
|
if ((can->TSR & CAN_TSR_RQCP1) | bus_off) {
|
||||||
|
@ -225,7 +231,7 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||||
-EIO;
|
-EIO;
|
||||||
/* clear the request. */
|
/* clear the request. */
|
||||||
can->TSR |= CAN_TSR_RQCP1;
|
can->TSR |= CAN_TSR_RQCP1;
|
||||||
can_stm32_signal_tx_complete(&data->mb1);
|
can_stm32_signal_tx_complete(dev, &data->mb1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((can->TSR & CAN_TSR_RQCP2) | bus_off) {
|
if ((can->TSR & CAN_TSR_RQCP2) | bus_off) {
|
||||||
|
@ -237,7 +243,7 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||||
-EIO;
|
-EIO;
|
||||||
/* clear the request. */
|
/* clear the request. */
|
||||||
can->TSR |= CAN_TSR_RQCP2;
|
can->TSR |= CAN_TSR_RQCP2;
|
||||||
can_stm32_signal_tx_complete(&data->mb2);
|
can_stm32_signal_tx_complete(dev, &data->mb2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can->TSR & CAN_TSR_TME) {
|
if (can->TSR & CAN_TSR_TME) {
|
||||||
|
@ -249,16 +255,12 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data)
|
||||||
|
|
||||||
static void can_stm32_isr(const struct device *dev)
|
static void can_stm32_isr(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct can_stm32_data *data;
|
const struct can_stm32_config *cfg = dev->config;
|
||||||
const struct can_stm32_config *cfg;
|
CAN_TypeDef *can = cfg->can;
|
||||||
CAN_TypeDef *can;
|
|
||||||
|
|
||||||
data = dev->data;
|
can_stm32_tx_isr_handler(dev);
|
||||||
cfg = dev->config;
|
can_stm32_rx_isr_handler(dev);
|
||||||
can = cfg->can;
|
|
||||||
|
|
||||||
can_stm32_tx_isr_handler(can, data);
|
|
||||||
can_stm32_rx_isr_handler(can, data);
|
|
||||||
if (can->MSR & CAN_MSR_ERRI) {
|
if (can->MSR & CAN_MSR_ERRI) {
|
||||||
can_stm32_bus_state_change_isr(dev);
|
can_stm32_bus_state_change_isr(dev);
|
||||||
can->MSR |= CAN_MSR_ERRI;
|
can->MSR |= CAN_MSR_ERRI;
|
||||||
|
@ -269,44 +271,22 @@ static void can_stm32_isr(const struct device *dev)
|
||||||
|
|
||||||
static void can_stm32_rx_isr(const struct device *dev)
|
static void can_stm32_rx_isr(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct can_stm32_data *data;
|
can_stm32_rx_isr_handler(dev);
|
||||||
const struct can_stm32_config *cfg;
|
|
||||||
CAN_TypeDef *can;
|
|
||||||
|
|
||||||
data = dev->data;
|
|
||||||
cfg = dev->config;
|
|
||||||
can = cfg->can;
|
|
||||||
|
|
||||||
can_stm32_rx_isr_handler(can, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void can_stm32_tx_isr(const struct device *dev)
|
static void can_stm32_tx_isr(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct can_stm32_data *data;
|
can_stm32_tx_isr_handler(dev);
|
||||||
const struct can_stm32_config *cfg;
|
|
||||||
CAN_TypeDef *can;
|
|
||||||
|
|
||||||
data = dev->data;
|
|
||||||
cfg = dev->config;
|
|
||||||
can = cfg->can;
|
|
||||||
|
|
||||||
can_stm32_tx_isr_handler(can, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void can_stm32_state_change_isr(const struct device *dev)
|
static void can_stm32_state_change_isr(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct can_stm32_data *data;
|
const struct can_stm32_config *cfg = dev->config;
|
||||||
const struct can_stm32_config *cfg;
|
CAN_TypeDef *can = cfg->can;
|
||||||
CAN_TypeDef *can;
|
|
||||||
|
|
||||||
data = dev->data;
|
|
||||||
cfg = dev->config;
|
|
||||||
can = cfg->can;
|
|
||||||
|
|
||||||
|
|
||||||
/* Signal bus-off to waiting tx */
|
/* Signal bus-off to waiting tx */
|
||||||
if (can->MSR & CAN_MSR_ERRI) {
|
if (can->MSR & CAN_MSR_ERRI) {
|
||||||
can_stm32_tx_isr_handler(can, data);
|
can_stm32_tx_isr_handler(dev);
|
||||||
can_stm32_bus_state_change_isr(dev);
|
can_stm32_bus_state_change_isr(dev);
|
||||||
can->MSR |= CAN_MSR_ERRI;
|
can->MSR |= CAN_MSR_ERRI;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,12 @@ static inline void socket_can_iface_init(struct net_if *iface)
|
||||||
LOG_DBG("Init CAN interface %p dev %p", iface, dev);
|
LOG_DBG("Init CAN interface %p dev %p", iface, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void tx_irq_callback(int error, void *arg)
|
static inline void tx_irq_callback(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
char *caller_str = (char *)arg;
|
char *caller_str = (char *)arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
LOG_DBG("TX error from %s! error-code: %d",
|
LOG_DBG("TX error from %s! error-code: %d",
|
||||||
caller_str, error);
|
caller_str, error);
|
||||||
|
|
|
@ -257,30 +257,35 @@ struct can_timing {
|
||||||
* @typedef can_tx_callback_t
|
* @typedef can_tx_callback_t
|
||||||
* @brief Defines the application callback handler function signature
|
* @brief Defines the application callback handler function signature
|
||||||
*
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
* @param error Status of the performed send operation. See the list of
|
* @param error Status of the performed send operation. See the list of
|
||||||
* return values for @a can_send() for value descriptions.
|
* return values for @a can_send() for value descriptions.
|
||||||
* @param user_data User data provided when the frame was sent.
|
* @param user_data User data provided when the frame was sent.
|
||||||
*/
|
*/
|
||||||
typedef void (*can_tx_callback_t)(int error, void *user_data);
|
typedef void (*can_tx_callback_t)(const struct device *dev, int error, void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef can_rx_callback_t
|
* @typedef can_rx_callback_t
|
||||||
* @brief Defines the application callback handler function signature for receiving.
|
* @brief Defines the application callback handler function signature for receiving.
|
||||||
*
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
* @param frame Received frame.
|
* @param frame Received frame.
|
||||||
* @param user_data User data provided when the filter was added.
|
* @param user_data User data provided when the filter was added.
|
||||||
*/
|
*/
|
||||||
typedef void (*can_rx_callback_t)(struct zcan_frame *frame, void *user_data);
|
typedef void (*can_rx_callback_t)(const struct device *dev, struct zcan_frame *frame,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef can_state_change_callback_t
|
* @typedef can_state_change_callback_t
|
||||||
* @brief Defines the state change callback handler function signature
|
* @brief Defines the state change callback handler function signature
|
||||||
*
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
* @param state State of the CAN controller.
|
* @param state State of the CAN controller.
|
||||||
* @param err_cnt CAN controller error counter values.
|
* @param err_cnt CAN controller error counter values.
|
||||||
* @param user_data User data provided the callback was set.
|
* @param user_data User data provided the callback was set.
|
||||||
*/
|
*/
|
||||||
typedef void (*can_state_change_callback_t)(enum can_state state,
|
typedef void (*can_state_change_callback_t)(const struct device *dev,
|
||||||
|
enum can_state state,
|
||||||
struct can_bus_err_cnt err_cnt,
|
struct can_bus_err_cnt err_cnt,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
|
|
@ -78,11 +78,13 @@ static void canopen_detach_all_rx_filters(CO_CANmodule_t *CANmodule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void canopen_rx_callback(struct zcan_frame *msg, void *arg)
|
static void canopen_rx_callback(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
CO_CANrx_t *buffer = (CO_CANrx_t *)arg;
|
CO_CANrx_t *buffer = (CO_CANrx_t *)arg;
|
||||||
CO_CANrxMsg_t rxMsg;
|
CO_CANrxMsg_t rxMsg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (!buffer || !buffer->pFunct) {
|
if (!buffer || !buffer->pFunct) {
|
||||||
LOG_ERR("failed to process CAN rx callback");
|
LOG_ERR("failed to process CAN rx callback");
|
||||||
return;
|
return;
|
||||||
|
@ -94,10 +96,12 @@ static void canopen_rx_callback(struct zcan_frame *msg, void *arg)
|
||||||
buffer->pFunct(buffer->object, &rxMsg);
|
buffer->pFunct(buffer->object, &rxMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void canopen_tx_callback(int error, void *arg)
|
static void canopen_tx_callback(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
CO_CANmodule_t *CANmodule = arg;
|
CO_CANmodule_t *CANmodule = arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (!CANmodule) {
|
if (!CANmodule) {
|
||||||
LOG_ERR("failed to process CAN tx callback");
|
LOG_ERR("failed to process CAN tx callback");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -44,10 +44,12 @@ static struct k_poll_event change_led_events[1] = {
|
||||||
&change_led_msgq, 0)
|
&change_led_msgq, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
void tx_irq_callback(int error, void *arg)
|
void tx_irq_callback(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
char *sender = (char *)arg;
|
char *sender = (char *)arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
printk("Callback! error-code: %d\nSender: %s\n",
|
printk("Callback! error-code: %d\nSender: %s\n",
|
||||||
error, sender);
|
error, sender);
|
||||||
|
@ -174,10 +176,13 @@ void state_change_work_handler(struct k_work *work)
|
||||||
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
|
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
|
||||||
}
|
}
|
||||||
|
|
||||||
void state_change_callback(enum can_state state, struct can_bus_err_cnt err_cnt, void *user_data)
|
void state_change_callback(const struct device *dev, enum can_state state,
|
||||||
|
struct can_bus_err_cnt err_cnt, void *user_data)
|
||||||
{
|
{
|
||||||
struct k_work *work = (struct k_work *)user_data;
|
struct k_work *work = (struct k_work *)user_data;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
current_state = state;
|
current_state = state;
|
||||||
current_err_cnt = err_cnt;
|
current_err_cnt = err_cnt;
|
||||||
k_work_submit(work);
|
k_work_submit(work);
|
||||||
|
|
|
@ -76,10 +76,12 @@ static inline void receive_report_error(struct isotp_recv_ctx *ctx, int err)
|
||||||
ctx->error_nr = err;
|
ctx->error_nr = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void receive_can_tx(int error, void *arg)
|
static void receive_can_tx(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
struct isotp_recv_ctx *ctx = (struct isotp_recv_ctx *)arg;
|
struct isotp_recv_ctx *ctx = (struct isotp_recv_ctx *)arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
LOG_ERR("Error sending FC frame (%d)", error);
|
LOG_ERR("Error sending FC frame (%d)", error);
|
||||||
receive_report_error(ctx, ISOTP_N_ERROR);
|
receive_report_error(ctx, ISOTP_N_ERROR);
|
||||||
|
@ -525,10 +527,12 @@ static void process_cf(struct isotp_recv_ctx *ctx, struct zcan_frame *frame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void receive_can_rx(struct zcan_frame *frame, void *arg)
|
static void receive_can_rx(const struct device *dev, struct zcan_frame *frame, void *arg)
|
||||||
{
|
{
|
||||||
struct isotp_recv_ctx *ctx = (struct isotp_recv_ctx *)arg;
|
struct isotp_recv_ctx *ctx = (struct isotp_recv_ctx *)arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
switch (ctx->state) {
|
switch (ctx->state) {
|
||||||
case ISOTP_RX_STATE_WAIT_FF_SF:
|
case ISOTP_RX_STATE_WAIT_FF_SF:
|
||||||
__ASSERT_NO_MSG(ctx->buf);
|
__ASSERT_NO_MSG(ctx->buf);
|
||||||
|
@ -723,10 +727,12 @@ static inline void send_report_error(struct isotp_send_ctx *ctx, uint32_t err)
|
||||||
ctx->error_nr = err;
|
ctx->error_nr = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_can_tx_cb(int error, void *arg)
|
static void send_can_tx_cb(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
struct isotp_send_ctx *ctx = (struct isotp_send_ctx *)arg;
|
struct isotp_send_ctx *ctx = (struct isotp_send_ctx *)arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
ctx->tx_backlog--;
|
ctx->tx_backlog--;
|
||||||
k_sem_give(&ctx->tx_sem);
|
k_sem_give(&ctx->tx_sem);
|
||||||
|
|
||||||
|
@ -816,10 +822,12 @@ static void send_process_fc(struct isotp_send_ctx *ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_can_rx_cb(struct zcan_frame *frame, void *arg)
|
static void send_can_rx_cb(const struct device *dev, struct zcan_frame *frame, void *arg)
|
||||||
{
|
{
|
||||||
struct isotp_send_ctx *ctx = (struct isotp_send_ctx *)arg;
|
struct isotp_send_ctx *ctx = (struct isotp_send_ctx *)arg;
|
||||||
|
|
||||||
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (ctx->state == ISOTP_TX_WAIT_FC) {
|
if (ctx->state == ISOTP_TX_WAIT_FC) {
|
||||||
z_abort_timeout(&ctx->timeout);
|
z_abort_timeout(&ctx->timeout);
|
||||||
send_process_fc(ctx, frame);
|
send_process_fc(ctx, frame);
|
||||||
|
|
|
@ -174,94 +174,106 @@ static inline void check_msg(const struct zcan_frame *msg1,
|
||||||
zassert_equal(cmp_res, 0, "Received data differ");
|
zassert_equal(cmp_res, 0, "Received data differ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_std_isr_1(int error, void *arg)
|
static void tx_std_isr_1(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
||||||
|
|
||||||
k_sem_give(&tx_cb_sem);
|
k_sem_give(&tx_cb_sem);
|
||||||
|
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal(msg->id, TEST_CAN_STD_ID_1, "Arg does not match");
|
zassert_equal(msg->id, TEST_CAN_STD_ID_1, "Arg does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_std_isr_2(int error, void *arg)
|
static void tx_std_isr_2(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
||||||
|
|
||||||
k_sem_give(&tx_cb_sem);
|
k_sem_give(&tx_cb_sem);
|
||||||
|
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal(msg->id, TEST_CAN_STD_ID_2, "Arg does not match");
|
zassert_equal(msg->id, TEST_CAN_STD_ID_2, "Arg does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_ext_isr_1(int error, void *arg)
|
static void tx_ext_isr_1(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
||||||
|
|
||||||
k_sem_give(&tx_cb_sem);
|
k_sem_give(&tx_cb_sem);
|
||||||
|
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal(msg->id, TEST_CAN_EXT_ID_1, "Arg does not match");
|
zassert_equal(msg->id, TEST_CAN_EXT_ID_1, "Arg does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_ext_isr_2(int error, void *arg)
|
static void tx_ext_isr_2(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
||||||
|
|
||||||
k_sem_give(&tx_cb_sem);
|
k_sem_give(&tx_cb_sem);
|
||||||
|
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal(msg->id, TEST_CAN_EXT_ID_2, "Arg does not match");
|
zassert_equal(msg->id, TEST_CAN_EXT_ID_2, "Arg does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_isr_1(struct zcan_frame *msg, void *arg)
|
static void rx_std_isr_1(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_1, 0);
|
check_msg(msg, &test_std_msg_1, 0);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_filter_1, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_filter_1, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_isr_2(struct zcan_frame *msg, void *arg)
|
static void rx_std_isr_2(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_2, 0);
|
check_msg(msg, &test_std_msg_2, 0);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_filter_2, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_filter_2, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_mask_isr_1(struct zcan_frame *msg, void *arg)
|
static void rx_std_mask_isr_1(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_1, 0x0F);
|
check_msg(msg, &test_std_msg_1, 0x0F);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_masked_filter_1, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_masked_filter_1, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_mask_isr_2(struct zcan_frame *msg, void *arg)
|
static void rx_std_mask_isr_2(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_2, 0x0F);
|
check_msg(msg, &test_std_msg_2, 0x0F);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_masked_filter_2, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_masked_filter_2, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_ext_isr_1(struct zcan_frame *msg, void *arg)
|
static void rx_ext_isr_1(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_ext_msg_1, 0);
|
check_msg(msg, &test_ext_msg_1, 0);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_ext_filter_1, "arg does not match");
|
zassert_equal_ptr(arg, &test_ext_filter_1, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_ext_isr_2(struct zcan_frame *msg, void *arg)
|
static void rx_ext_isr_2(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_ext_msg_2, 0);
|
check_msg(msg, &test_ext_msg_2, 0);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_ext_filter_2, "arg does not match");
|
zassert_equal_ptr(arg, &test_ext_filter_2, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_ext_mask_isr_1(struct zcan_frame *msg, void *arg)
|
static void rx_ext_mask_isr_1(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_ext_msg_1, 0x0F);
|
check_msg(msg, &test_ext_msg_1, 0x0F);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_ext_masked_filter_1, "arg does not match");
|
zassert_equal_ptr(arg, &test_ext_masked_filter_1, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_ext_mask_isr_2(struct zcan_frame *msg, void *arg)
|
static void rx_ext_mask_isr_2(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_ext_msg_2, 0x0F);
|
check_msg(msg, &test_ext_msg_2, 0x0F);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_ext_masked_filter_2, "arg does not match");
|
zassert_equal_ptr(arg, &test_ext_masked_filter_2, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,48 +112,54 @@ static inline void check_msg(const struct zcan_frame *msg1,
|
||||||
zassert_equal(cmp_res, 0, "Received data differ");
|
zassert_equal(cmp_res, 0, "Received data differ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_std_isr_1(int error, void *arg)
|
static void tx_std_isr_1(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
||||||
|
|
||||||
k_sem_give(&tx_cb_sem);
|
k_sem_give(&tx_cb_sem);
|
||||||
|
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal(msg->id, TEST_CAN_STD_ID_1, "Arg does not match");
|
zassert_equal(msg->id, TEST_CAN_STD_ID_1, "Arg does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tx_std_isr_2(int error, void *arg)
|
static void tx_std_isr_2(const struct device *dev, int error, void *arg)
|
||||||
{
|
{
|
||||||
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
const struct zcan_frame *msg = (const struct zcan_frame *)arg;
|
||||||
|
|
||||||
k_sem_give(&tx_cb_sem);
|
k_sem_give(&tx_cb_sem);
|
||||||
|
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal(msg->id, TEST_CAN_STD_ID_2, "Arg does not match");
|
zassert_equal(msg->id, TEST_CAN_STD_ID_2, "Arg does not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_isr_1(struct zcan_frame *msg, void *arg)
|
static void rx_std_isr_1(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_1);
|
check_msg(msg, &test_std_msg_1);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_filter_1, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_filter_1, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_isr_2(struct zcan_frame *msg, void *arg)
|
static void rx_std_isr_2(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_2);
|
check_msg(msg, &test_std_msg_2);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_filter_2, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_filter_2, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_isr_fd_1(struct zcan_frame *msg, void *arg)
|
static void rx_std_isr_fd_1(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_fd_1);
|
check_msg(msg, &test_std_msg_fd_1);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_filter_1, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_filter_1, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rx_std_isr_fd_2(struct zcan_frame *msg, void *arg)
|
static void rx_std_isr_fd_2(const struct device *dev, struct zcan_frame *msg, void *arg)
|
||||||
{
|
{
|
||||||
check_msg(msg, &test_std_msg_fd_2);
|
check_msg(msg, &test_std_msg_fd_2);
|
||||||
|
zassert_equal(dev, can_dev, "CAN device does not match");
|
||||||
zassert_equal_ptr(arg, &test_std_filter_2, "arg does not match");
|
zassert_equal_ptr(arg, &test_std_filter_2, "arg does not match");
|
||||||
k_sem_give(&rx_isr_sem);
|
k_sem_give(&rx_isr_sem);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue