43#ifndef _DEV_CAN_CAN_HELPERS_H
44#define _DEV_CAN_CAN_HELPERS_H
53#define RTEMS_CAN_USER_MAGIC 0x05402033
56#define BIT(nr) (1UL << (nr))
59#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8 - 1 - (h))))
62#define __bf_shf(x) (__builtin_ffsll(x) - 1)
66#define FIELD_PREP(_mask, _val) \
68 ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
73#define FIELD_GET(_mask, _reg) \
75 (typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \
79static const uint8_t rtems_can_len2dlc[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8,
84 13, 13, 13, 13, 13, 13, 13, 13,
85 14, 14, 14, 14, 14, 14, 14, 14,
86 14, 14, 14, 14, 14, 14, 14, 14,
87 15, 15, 15, 15, 15, 15, 15, 15,
88 15, 15, 15, 15, 15, 15, 15, 15
98static inline uint8_t rtems_canfd_len2dlc( uint8_t len )
104 return rtems_can_len2dlc[len];
117static inline void rtems_can_set_bit(
int nr, atomic_uint *addr )
119 atomic_fetch_or( addr, 1 << nr );
132static inline void rtems_can_clear_bit(
int nr, atomic_uint *addr )
134 atomic_fetch_and( addr, ~( 1 << nr ) );
148static inline int rtems_can_test_bit(
int nr, atomic_uint *addr )
150 return ( atomic_load( addr ) ) & ( 1 << nr ) ? 1 : 0;
163static inline int rtems_can_test_and_set_bit(
int nr, atomic_uint *addr )
165 return ( atomic_fetch_or( addr, 1 << nr ) & ( 1 << nr ) ) ? 1 : 0;
This header file defines the RTEMS Classic API.