drivers: can: add accessor functions for the CAN statistics
Add accessor functions for the individual CAN statistics. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
fd8f6bd7e6
commit
0cfca8be85
2 changed files with 218 additions and 0 deletions
|
|
@ -243,3 +243,63 @@ static inline int z_vrfy_can_recover(const struct device *dev, k_timeout_t timeo
|
||||||
}
|
}
|
||||||
#include <syscalls/can_recover_mrsh.c>
|
#include <syscalls/can_recover_mrsh.c>
|
||||||
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
|
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_bit0_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_bit0_errors(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_bit0_errors_mrsh.c>
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_bit1_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_bit1_errors(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_bit1_errors_mrsh.c>
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_stuff_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_stuff_errors(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_stuff_errors_mrsh.c>
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_crc_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_crc_errors(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_crc_errors_mrsh.c>
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_form_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_form_errors(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_form_errors_mrsh.c>
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_ack_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_ack_errors(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_ack_errors_mrsh.c>
|
||||||
|
|
||||||
|
static inline uint32_t z_vrfy_can_stats_get_rx_overruns(const struct device *dev)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN));
|
||||||
|
|
||||||
|
return z_impl_can_stats_get_rx_overruns(dev);
|
||||||
|
}
|
||||||
|
#include <syscalls/can_stats_get_rx_overruns_mrsh.c>
|
||||||
|
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
|
||||||
|
|
@ -971,6 +971,8 @@ static inline int z_impl_can_get_capabilities(const struct device *dev, can_mode
|
||||||
* enable the CAN controller to participate in CAN communication, and enable the CAN tranceiver, if
|
* enable the CAN controller to participate in CAN communication, and enable the CAN tranceiver, if
|
||||||
* supported.
|
* supported.
|
||||||
*
|
*
|
||||||
|
* Starting the CAN controller resets all the CAN controller statistics.
|
||||||
|
*
|
||||||
* @see can_stop()
|
* @see can_stop()
|
||||||
* @see can_transceiver_enable()
|
* @see can_transceiver_enable()
|
||||||
*
|
*
|
||||||
|
|
@ -1333,6 +1335,162 @@ static inline void can_set_state_change_callback(const struct device *dev,
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name CAN statistics
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the bit0 error counter for a CAN device
|
||||||
|
*
|
||||||
|
* The bit0 error counter is incremented when the CAN controller is unable to
|
||||||
|
* transmit a dominant bit.
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return bit0 error counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_bit0_errors(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_bit0_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).bit0_error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the bit1 error counter for a CAN device
|
||||||
|
*
|
||||||
|
* The bit1 error counter is incremented when the CAN controller is unable to
|
||||||
|
* transmit a recessive bit.
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return bit1 error counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_bit1_errors(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_bit1_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).bit1_error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the stuffing error counter for a CAN device
|
||||||
|
*
|
||||||
|
* The stuffing error counter is incremented when the CAN controller detects a
|
||||||
|
* bit stuffing error.
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return stuffing error counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_stuff_errors(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_stuff_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).stuff_error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the CRC error counter for a CAN device
|
||||||
|
*
|
||||||
|
* The CRC error counter is incremented when the CAN controller detects a frame
|
||||||
|
* with an invalid CRC.
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return CRC error counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_crc_errors(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_crc_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).crc_error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the form error counter for a CAN device
|
||||||
|
*
|
||||||
|
* The form error counter is incremented when the CAN controller detects a
|
||||||
|
* fixed-form bit field containing illegal bits.
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return form error counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_form_errors(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_form_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).form_error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the acknowledge error counter for a CAN device
|
||||||
|
*
|
||||||
|
* The acknowledge error counter is incremented when the CAN controller does not
|
||||||
|
* monitor a dominant bit in the ACK slot.
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return acknowledge error counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_ack_errors(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_ack_errors(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).ack_error;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the RX overrun counter for a CAN device
|
||||||
|
*
|
||||||
|
* The RX overrun counter is incremented when the CAN controller receives a CAN
|
||||||
|
* frame matching an installed filter but lacks the capacity to store it (either
|
||||||
|
* due to an already full RX mailbox or a full RX FIFO).
|
||||||
|
*
|
||||||
|
* @note @kconfig{CONFIG_CAN_STATS} must be selected for this function to be
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* @param dev Pointer to the device structure for the driver instance.
|
||||||
|
* @return RX overrun counter
|
||||||
|
*/
|
||||||
|
__syscall uint32_t can_stats_get_rx_overruns(const struct device *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_STATS
|
||||||
|
static inline uint32_t z_impl_can_stats_get_rx_overruns(const struct device *dev)
|
||||||
|
{
|
||||||
|
return Z_CAN_GET_STATS(dev).rx_overrun;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CAN_STATS */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name CAN utility functions
|
* @name CAN utility functions
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue