Lines Matching +full:rx +full:- +full:mask
4 * SPDX-License-Identifier: Apache-2.0
75 if (!CANmodule || !CANmodule->rx_array || !CANmodule->configured) { in canopen_detach_all_rx_filters()
79 for (i = 0U; i < CANmodule->rx_size; i++) { in canopen_detach_all_rx_filters()
80 if (CANmodule->rx_array[i].filter_id != -ENOSPC) { in canopen_detach_all_rx_filters()
81 can_remove_rx_filter(CANmodule->dev, in canopen_detach_all_rx_filters()
82 CANmodule->rx_array[i].filter_id); in canopen_detach_all_rx_filters()
83 CANmodule->rx_array[i].filter_id = -ENOSPC; in canopen_detach_all_rx_filters()
98 /* Loop through registered rx buffers in priority order */ in canopen_rx_callback()
99 for (i = 0; i < CANmodule->rx_size; i++) { in canopen_rx_callback()
100 buffer = &CANmodule->rx_array[i]; in canopen_rx_callback()
102 if (buffer->filter_id == -ENOSPC || buffer->pFunct == NULL) { in canopen_rx_callback()
106 if (((frame->id ^ buffer->ident) & buffer->mask) == 0U) { in canopen_rx_callback()
108 if (buffer->rtr && ((frame->flags & CAN_FRAME_RTR) == 0U)) { in canopen_rx_callback()
112 rxMsg.ident = frame->id; in canopen_rx_callback()
113 rxMsg.DLC = frame->dlc; in canopen_rx_callback()
114 memcpy(rxMsg.data, frame->data, frame->dlc); in canopen_rx_callback()
115 buffer->pFunct(buffer->object, &rxMsg); in canopen_rx_callback()
136 CANmodule->first_tx_msg = false; in canopen_tx_callback()
146 CO_CANmodule_t *CANmodule = container->CANmodule; in canopen_tx_retry()
156 for (i = 0; i < CANmodule->tx_size; i++) { in canopen_tx_retry()
157 buffer = &CANmodule->tx_array[i]; in canopen_tx_retry()
158 if (buffer->bufferFull) { in canopen_tx_retry()
159 frame.id = buffer->ident; in canopen_tx_retry()
160 frame.dlc = buffer->DLC; in canopen_tx_retry()
161 frame.flags |= (buffer->rtr ? CAN_FRAME_RTR : 0); in canopen_tx_retry()
162 memcpy(frame.data, buffer->data, buffer->DLC); in canopen_tx_retry()
164 err = can_send(CANmodule->dev, &frame, K_NO_WAIT, in canopen_tx_retry()
166 if (err == -EAGAIN) { in canopen_tx_retry()
171 CO_errorReport(CANmodule->em, in canopen_tx_retry()
177 buffer->bufferFull = false; in canopen_tx_retry()
189 err = can_stop(ctx->dev); in CO_CANsetConfigurationMode()
190 if (err != 0 && err != -EALREADY) { in CO_CANsetConfigurationMode()
199 err = can_start(CANmodule->dev); in CO_CANsetNormalMode()
200 if (err != 0 && err != -EALREADY) { in CO_CANsetNormalMode()
205 CANmodule->CANnormal = true; in CO_CANsetNormalMode()
226 max_filters = can_get_max_filters(ctx->dev, false); in CO_CANmodule_init()
227 if (max_filters != -ENOSYS) { in CO_CANmodule_init()
229 LOG_ERR("unable to determine number of CAN RX filters"); in CO_CANmodule_init()
234 LOG_ERR("insufficient number of concurrent CAN RX filters" in CO_CANmodule_init()
238 LOG_DBG("excessive number of concurrent CAN RX filters enabled" in CO_CANmodule_init()
246 CANmodule->dev = ctx->dev; in CO_CANmodule_init()
247 CANmodule->rx_array = rxArray; in CO_CANmodule_init()
248 CANmodule->rx_size = rxSize; in CO_CANmodule_init()
249 CANmodule->tx_array = txArray; in CO_CANmodule_init()
250 CANmodule->tx_size = txSize; in CO_CANmodule_init()
251 CANmodule->CANnormal = false; in CO_CANmodule_init()
252 CANmodule->first_tx_msg = true; in CO_CANmodule_init()
253 CANmodule->errors = 0; in CO_CANmodule_init()
254 CANmodule->em = NULL; in CO_CANmodule_init()
259 rxArray[i].filter_id = -ENOSPC; in CO_CANmodule_init()
266 err = can_set_bitrate(CANmodule->dev, KHZ(CANbitRate)); in CO_CANmodule_init()
272 err = can_set_mode(CANmodule->dev, CAN_MODE_NORMAL); in CO_CANmodule_init()
278 CANmodule->configured = true; in CO_CANmodule_init()
287 if (!CANmodule || !CANmodule->dev) { in CO_CANmodule_disable()
293 err = can_stop(CANmodule->dev); in CO_CANmodule_disable()
294 if (err != 0 && err != -EALREADY) { in CO_CANmodule_disable()
301 return rxMsg->ident; in CO_CANrxMsg_readIdent()
305 uint16_t ident, uint16_t mask, bool_t rtr, in CO_CANrxBufferInit() argument
316 if (!pFunct || (index >= CANmodule->rx_size)) { in CO_CANrxBufferInit()
317 LOG_ERR("failed to initialize CAN rx buffer, illegal argument"); in CO_CANrxBufferInit()
318 CO_errorReport(CANmodule->em, CO_EM_GENERIC_SOFTWARE_ERROR, in CO_CANrxBufferInit()
323 buffer = &CANmodule->rx_array[index]; in CO_CANrxBufferInit()
324 buffer->object = object; in CO_CANrxBufferInit()
325 buffer->pFunct = pFunct; in CO_CANrxBufferInit()
326 buffer->ident = ident; in CO_CANrxBufferInit()
327 buffer->mask = mask; in CO_CANrxBufferInit()
332 CO_errorReport(CANmodule->em, CO_EM_GENERIC_SOFTWARE_ERROR, in CO_CANrxBufferInit()
337 buffer->rtr = rtr; in CO_CANrxBufferInit()
342 filter.mask = mask; in CO_CANrxBufferInit()
344 if (buffer->filter_id != -ENOSPC) { in CO_CANrxBufferInit()
345 can_remove_rx_filter(CANmodule->dev, buffer->filter_id); in CO_CANrxBufferInit()
348 buffer->filter_id = can_add_rx_filter(CANmodule->dev, in CO_CANrxBufferInit()
351 if (buffer->filter_id == -ENOSPC) { in CO_CANrxBufferInit()
352 LOG_ERR("failed to add CAN rx callback, no free filter"); in CO_CANrxBufferInit()
353 CO_errorReport(CANmodule->em, CO_EM_MEMORY_ALLOCATION_ERROR, in CO_CANrxBufferInit()
371 if (index >= CANmodule->tx_size) { in CO_CANtxBufferInit()
372 LOG_ERR("failed to initialize CAN rx buffer, illegal argument"); in CO_CANtxBufferInit()
373 CO_errorReport(CANmodule->em, CO_EM_GENERIC_SOFTWARE_ERROR, in CO_CANtxBufferInit()
378 buffer = &CANmodule->tx_array[index]; in CO_CANtxBufferInit()
379 buffer->ident = ident; in CO_CANtxBufferInit()
380 buffer->rtr = rtr; in CO_CANtxBufferInit()
381 buffer->DLC = noOfBytes; in CO_CANtxBufferInit()
382 buffer->bufferFull = false; in CO_CANtxBufferInit()
383 buffer->syncFlag = syncFlag; in CO_CANtxBufferInit()
394 if (!CANmodule || !CANmodule->dev || !buffer) { in CO_CANsend()
402 if (buffer->bufferFull) { in CO_CANsend()
403 if (!CANmodule->first_tx_msg) { in CO_CANsend()
404 CO_errorReport(CANmodule->em, CO_EM_CAN_TX_OVERFLOW, in CO_CANsend()
405 CO_EMC_CAN_OVERRUN, buffer->ident); in CO_CANsend()
407 buffer->bufferFull = false; in CO_CANsend()
411 frame.id = buffer->ident; in CO_CANsend()
412 frame.dlc = buffer->DLC; in CO_CANsend()
413 frame.flags = (buffer->rtr ? CAN_FRAME_RTR : 0); in CO_CANsend()
414 memcpy(frame.data, buffer->data, buffer->DLC); in CO_CANsend()
416 err = can_send(CANmodule->dev, &frame, K_NO_WAIT, canopen_tx_callback, in CO_CANsend()
418 if (err == -EAGAIN) { in CO_CANsend()
419 buffer->bufferFull = true; in CO_CANsend()
422 CO_errorReport(CANmodule->em, CO_EM_GENERIC_SOFTWARE_ERROR, in CO_CANsend()
444 for (i = 0; i < CANmodule->tx_size; i++) { in CO_CANclearPendingSyncPDOs()
445 buffer = &CANmodule->tx_array[i]; in CO_CANclearPendingSyncPDOs()
446 if (buffer->bufferFull && buffer->syncFlag) { in CO_CANclearPendingSyncPDOs()
447 buffer->bufferFull = false; in CO_CANclearPendingSyncPDOs()
455 CO_errorReport(CANmodule->em, CO_EM_TPDO_OUTSIDE_WINDOW, in CO_CANclearPendingSyncPDOs()
462 CO_EM_t *em = (CO_EM_t *)CANmodule->em; in CO_CANverifyErrors()
470 * TODO: Zephyr lacks an API for reading the rx mailbox in CO_CANverifyErrors()
475 err = can_get_state(CANmodule->dev, &state, &err_cnt); in CO_CANverifyErrors()
485 if (errors != CANmodule->errors) { in CO_CANverifyErrors()
486 CANmodule->errors = errors; in CO_CANverifyErrors()
508 /* Bus rx passive */ in CO_CANverifyErrors()
512 /* Bus not rx passive */ in CO_CANverifyErrors()
518 !CANmodule->first_tx_msg) { in CO_CANverifyErrors()