Lines Matching +full:sample +full:- +full:point +full:- +full:data

6  * SPDX-License-Identifier: Apache-2.0
45 * @brief Bit mask for a standard (11-bit) CAN identifier.
50 * @brief Bit mask for an extended (29-bit) CAN identifier.
55 * @brief Maximum data length code for CAN 2.0A/2.0B.
60 * @brief Maximum data length code for CAN FD.
66 * Internally calculated maximum data length
103 /** Controller requires manual recovery after entering bus-off state */
122 /** Error-active state (RX/TX error count < 96). */
124 /** Error-warning state (RX/TX error count < 128). */
126 /** Error-passive state (RX/TX error count < 256). */
128 /** Bus-off state (RX/TX error count >= 256). */
141 /** Frame uses extended (29-bit) CAN ID */
153 /** CAN FD Error State Indicator (ESI). Indicates that the transmitting node is in error-passive
164 /** Standard (11-bit) or extended (29-bit) CAN identifier. */
166 /** Data Length Code (DLC) indicating data length in bytes. */
171 /** Captured value of the free-running timer in the CAN controller when
185 /** The frame payload data. */
187 /** Payload data accessed as unsigned 8 bit values. */
188 uint8_t data[CAN_MAX_DLEN]; member
189 /** Payload data accessed as unsigned 32 bit values. */
201 /** Filter matches frames with extended (29-bit) CAN IDs */
237 * segment 1 and phase segment 2 define the sampling point. The ``prop_seg`` and
238 * ``phase_seg1`` values affect the sampling point in the same way and some
244 * +---------+----------+------------+------------+
246 * +---------+----------+------------+------------+
248 * Sampling-Point
259 * sample point can be moved. The sample point is moved when resynchronization
281 * @param user_data User data provided when the frame was sent.
290 * @param user_data User data provided when the filter was added.
301 * @param user_data User data provided the callback was set.
315 * @brief Calculate Transmitter Delay Compensation Offset from data phase timing parameters.
317 * Calculates the TDC Offset in minimum time quanta (mtq) using the sample point and CAN core clock
318 * prescaler specified by a set of data phase timing parameters.
322 * @param _timing_data Pointer to data phase timing parameters.
328 CLAMP((1U + _timing_data->prop_seg + _timing_data->phase_seg1) * _timing_data->prescaler, \
346 /** Initial CAN classic/CAN FD arbitration phase sample point in permille. */
349 /** Initial CAN FD data phase sample point in permille. */
351 /** Initial CAN FD data phase bitrate. */
389 * @brief Common CAN controller driver data.
401 /** State change callback user data pointer or NULL. */
413 * @brief Optional callback API upon setting CAN FD bus timing for the data phase.
471 * @brief Optional callback API upon manually recovering the CAN controller from bus-off state
525 /* Min values for the timing registers during the data phase */
527 /* Max values for the timing registers during the data phase */
581 CONTAINER_OF(dev_->state, struct can_device_state, devstate)->stats
664 * fixed-form bit field containing illegal bits.
717 * This does device instance specific initialization of common data (such as stats)
724 CONTAINER_OF(dev->state, struct can_device_state, devstate); \
725 stats_init(&state->stats.s_hdr, STATS_SIZE_32, 8, \
727 stats_register(dev->name, &(state->stats.s_hdr)); \
747 * @param data Pointer to the device's private data.
757 #define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \ argument
764 pm, data, config, level, prio, api, \
780 #define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \ argument
782 DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
819 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_core_clock()
821 return api->get_core_clock(dev, rate); in z_impl_can_get_core_clock()
844 const struct can_driver_config *common = (const struct can_driver_config *)dev->config; in z_impl_can_get_bitrate_min()
846 return common->min_bitrate; in z_impl_can_get_bitrate_min()
869 const struct can_driver_config *common = (const struct can_driver_config *)dev->config; in z_impl_can_get_bitrate_max()
871 return common->max_bitrate; in z_impl_can_get_bitrate_max()
885 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_timing_min()
887 return &api->timing_min; in z_impl_can_get_timing_min()
901 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_timing_max()
903 return &api->timing_max; in z_impl_can_get_timing_max()
907 * @brief Calculate timing parameters from bitrate and sample point
910 * sampling point in permill (1/1000) of the entire bit time. The bitrate must
912 * -EINVAL is returned.
914 * If the sample point is set to 0, this function defaults to a sample point of 75.0%
924 * @param sample_pnt Sample point in permille of the entire bit time or 0 for
925 * automatic sample point location.
927 * @retval 0 or positive sample point error on success.
928 * @retval -EINVAL if the requested bitrate or sample point is out of range.
929 * @retval -ENOTSUP if the requested bitrate is not supported.
930 * @retval -EIO if @a can_get_core_clock() is not available.
936 * @brief Get the minimum supported timing parameter values for the data phase.
938 * Same as @a can_get_timing_min() but for the minimum values for the data phase.
953 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_timing_data_min()
955 return &api->timing_data_min; in z_impl_can_get_timing_data_min()
960 * @brief Get the maximum supported timing parameter values for the data phase.
962 * Same as @a can_get_timing_max() but for the maximum values for the data phase.
977 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_timing_data_max()
979 return &api->timing_data_max; in z_impl_can_get_timing_data_max()
984 * @brief Calculate timing parameters for the data phase
987 * data phase.
994 * @param bitrate Target bitrate for the data phase in bits/s
995 * @param sample_pnt Sample point for the data phase in permille of the entire bit
996 * time or 0 for automatic sample point location.
998 * @retval 0 or positive sample point error on success.
999 * @retval -EINVAL if the requested bitrate or sample point is out of range.
1000 * @retval -ENOTSUP if the requested bitrate is not supported.
1001 * @retval -EIO if @a can_get_core_clock() is not available.
1007 * @brief Configure the bus timing for the data phase of a CAN FD controller.
1015 * @param timing_data Bus timings for data phase
1018 * @retval -EBUSY if the CAN controller is not in stopped state.
1019 * @retval -EIO General input/output error, failed to configure device.
1020 * @retval -ENOTSUP if the timing parameters are not supported by the driver.
1021 * @retval -ENOSYS if CAN FD support is not implemented by the driver.
1027 * @brief Set the bitrate for the data phase of the CAN FD controller
1029 * CAN in Automation (CiA) 301 v4.2.0 recommends a sample point location of
1033 * This function defaults to using a sample point of 75.0% for bitrates over 800
1035 * bitrates. This is in line with the sample point locations used by the Linux
1044 * @param bitrate_data Desired data phase bitrate.
1047 * @retval -EBUSY if the CAN controller is not in stopped state.
1048 * @retval -EINVAL if the requested bitrate is out of range.
1049 * @retval -ENOTSUP if the requested bitrate not supported by the CAN controller/transceiver
1051 * @retval -ERANGE if the resulting sample point is off by more than +/- 5%.
1052 * @retval -EIO General input/output error, failed to set bitrate.
1065 * @retval -EBUSY if the CAN controller is not in stopped state.
1066 * @retval -ENOTSUP if the timing parameters are not supported by the driver.
1067 * @retval -EIO General input/output error, failed to configure device.
1083 * @retval -EIO General input/output error, failed to get capabilities.
1089 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_capabilities()
1091 return api->get_capabilities(dev, cap); in z_impl_can_get_capabilities()
1107 const struct can_driver_config *common = (const struct can_driver_config *)dev->config; in z_impl_can_get_transceiver()
1109 return common->phy; in z_impl_can_get_transceiver()
1126 * @retval -EALREADY if the device is already started.
1127 * @retval -EIO General input/output error, failed to start device.
1133 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_start()
1135 return api->start(dev); in z_impl_can_start()
1150 * @retval -EALREADY if the device is already stopped.
1151 * @retval -EIO General input/output error, failed to stop device.
1157 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_stop()
1159 return api->stop(dev); in z_impl_can_stop()
1169 * @retval -EBUSY if the CAN controller is not in stopped state.
1170 * @retval -EIO General input/output error, failed to configure device.
1176 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_set_mode()
1178 return api->set_mode(dev, mode); in z_impl_can_set_mode()
1192 const struct can_driver_data *common = (const struct can_driver_data *)dev->data; in z_impl_can_get_mode()
1194 return common->mode; in z_impl_can_get_mode()
1200 * CAN in Automation (CiA) 301 v4.2.0 recommends a sample point location of
1204 * This function defaults to using a sample point of 75.0% for bitrates over 800
1206 * bitrates. This is in line with the sample point locations used by the Linux
1215 * @retval -EBUSY if the CAN controller is not in stopped state.
1216 * @retval -EINVAL if the requested bitrate is out of range.
1217 * @retval -ENOTSUP if the requested bitrate not supported by the CAN controller/transceiver
1219 * @retval -ERANGE if the resulting sample point is off by more than +/- 5%.
1220 * @retval -EIO General input/output error, failed to set bitrate.
1239 * - The lower the CAN-ID, the higher the priority.
1240 * - Data frames have higher priority than Remote Transmission Request (RTR)
1241 * frames with identical CAN-IDs.
1242 * - Frames with standard (11-bit) identifiers have higher priority than frames
1243 * with extended (29-bit) identifiers with identical base IDs (the higher 11
1245 * - Transmission order for queued frames with the same priority is hardware
1249 * identical CAN-IDs, the sender must ensure to only queue one frame at a time
1263 * @param user_data User data to pass to callback function.
1266 * @retval -EINVAL if an invalid parameter was passed to the function.
1267 * @retval -ENOTSUP if an unsupported parameter was passed to the function.
1268 * @retval -ENETDOWN if the CAN controller is in stopped state.
1269 * @retval -ENETUNREACH if the CAN controller is in bus-off state.
1270 * @retval -EBUSY if CAN bus arbitration was lost (only applicable if automatic
1272 * @retval -EIO if a general transmit error occurred (e.g. missing ACK if
1274 * @retval -EAGAIN on timeout.
1303 * @param user_data User data to pass to callback function.
1307 * @retval -ENOSPC if there are no free filters.
1308 * @retval -EINVAL if the requested filter type is invalid.
1309 * @retval -ENOTSUP if the requested filter type is not supported.
1350 * @retval -ENOSPC if there are no free filters.
1351 * @retval -ENOTSUP if the requested filter type is not supported.
1369 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_remove_rx_filter()
1371 api->remove_rx_filter(dev, filter_id); in z_impl_can_remove_rx_filter()
1380 * @param ide Get the maximum standard (11-bit) CAN ID filters if false, or extended (29-bit) CAN ID
1384 * @retval -EIO General input/output error.
1385 * @retval -ENOSYS If this function is not implemented by the driver.
1391 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_max_filters()
1393 if (api->get_max_filters == NULL) { in z_impl_can_get_max_filters()
1394 return -ENOSYS; in z_impl_can_get_max_filters()
1397 return api->get_max_filters(dev, ide); in z_impl_can_get_max_filters()
1419 * @retval -EIO General input/output error, failed to get state.
1427 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_get_state()
1429 return api->get_state(dev, state, err_cnt); in z_impl_can_get_state()
1433 * @brief Recover from bus-off state
1435 * Recover the CAN controller from bus-off state to error-active state.
1444 * @retval -ENOTSUP if the CAN controller is not in manual recovery mode.
1445 * @retval -ENETDOWN if the CAN controller is in stopped state.
1446 * @retval -EAGAIN on timeout.
1447 * @retval -ENOSYS If this function is not implemented by the driver.
1454 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in z_impl_can_recover()
1456 if (api->recover == NULL) { in z_impl_can_recover()
1457 return -ENOSYS; in z_impl_can_recover()
1460 return api->recover(dev, timeout); in z_impl_can_recover()
1475 * @param user_data User data to pass to callback function.
1481 const struct can_driver_api *api = (const struct can_driver_api *)dev->api; in can_set_state_change_callback()
1483 api->set_state_change_callback(dev, callback, user_data); in can_set_state_change_callback()
1607 * fixed-form bit field containing illegal bits.
1676 * @brief Convert from Data Length Code (DLC) to the number of data bytes
1678 * @param dlc Data Length Code (DLC).
1687 return dlc_table[MIN(dlc, ARRAY_SIZE(dlc_table) - 1)]; in can_dlc_to_bytes()
1691 * @brief Convert from number of bytes to Data Length Code (DLC)
1695 * @retval Data Length Code (DLC).
1719 if ((frame->flags & CAN_FRAME_IDE) != 0 && (filter->flags & CAN_FILTER_IDE) == 0) { in can_frame_matches_filter()
1720 /* Extended (29-bit) ID frame, standard (11-bit) filter */ in can_frame_matches_filter()
1724 if ((frame->flags & CAN_FRAME_IDE) == 0 && (filter->flags & CAN_FILTER_IDE) != 0) { in can_frame_matches_filter()
1725 /* Standard (11-bit) ID frame, extended (29-bit) filter */ in can_frame_matches_filter()
1729 if ((frame->id ^ filter->id) & filter->mask) { in can_frame_matches_filter()