Zephyr Project API  3.3.0
A Scalable Open Source RTOS
can.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Vestas Wind Systems A/S
3 * Copyright (c) 2018 Alexander Wachter
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_DRIVERS_CAN_H_
9#define ZEPHYR_INCLUDE_DRIVERS_CAN_H_
10
11#include <errno.h>
12
13#include <zephyr/types.h>
14#include <zephyr/device.h>
15#include <zephyr/kernel.h>
16#include <string.h>
17#include <zephyr/sys_clock.h>
18#include <zephyr/sys/util.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
39#define CAN_STD_ID_MASK 0x7FFU
43#define CAN_MAX_STD_ID CAN_STD_ID_MASK
47#define CAN_EXT_ID_MASK 0x1FFFFFFFU
51#define CAN_MAX_EXT_ID CAN_EXT_ID_MASK
55#define CAN_MAX_DLC 8U
59#define CANFD_MAX_DLC 15U
60
65#ifndef CONFIG_CAN_FD_MODE
66#define CAN_MAX_DLEN 8U
67#else
68#define CAN_MAX_DLEN 64U
69#endif /* CONFIG_CAN_FD_MODE */
70
83#define CAN_MODE_NORMAL 0
84
86#define CAN_MODE_LOOPBACK BIT(0)
87
89#define CAN_MODE_LISTENONLY BIT(1)
90
92#define CAN_MODE_FD BIT(2)
93
95#define CAN_MODE_ONE_SHOT BIT(3)
96
98#define CAN_MODE_3_SAMPLES BIT(4)
99
111
126};
127
136#define CAN_FRAME_IDE BIT(0)
137
139#define CAN_FRAME_RTR BIT(1)
140
142#define CAN_FRAME_FDF BIT(2)
143
145#define CAN_FRAME_BRS BIT(3)
146
152struct can_frame {
156 uint8_t res0 : 3; /* reserved/padding. */
162#if defined(CONFIG_CAN_RX_TIMESTAMP) || defined(__DOXYGEN__)
171#else
173 uint16_t res1; /* reserved/padding. */
175#endif
177 union {
178 uint8_t data[CAN_MAX_DLEN];
179 uint32_t data_32[ceiling_fraction(CAN_MAX_DLEN, sizeof(uint32_t))];
180 };
181};
182
191#define CAN_FILTER_IDE BIT(0)
192
194#define CAN_FILTER_RTR BIT(1)
195
197#define CAN_FILTER_DATA BIT(2)
198
200#define CAN_FILTER_FDF BIT(3)
201
211 uint32_t res0 : 3;
219};
220
229};
230
274};
275
284typedef void (*can_tx_callback_t)(const struct device *dev, int error, void *user_data);
285
293typedef void (*can_rx_callback_t)(const struct device *dev, struct can_frame *frame,
294 void *user_data);
295
304typedef void (*can_state_change_callback_t)(const struct device *dev,
305 enum can_state state,
306 struct can_bus_err_cnt err_cnt,
307 void *user_data);
308
319typedef int (*can_set_timing_t)(const struct device *dev,
320 const struct can_timing *timing);
321
326typedef int (*can_set_timing_data_t)(const struct device *dev,
327 const struct can_timing *timing_data);
328
333typedef int (*can_get_capabilities_t)(const struct device *dev, can_mode_t *cap);
334
339typedef int (*can_start_t)(const struct device *dev);
340
345typedef int (*can_stop_t)(const struct device *dev);
346
351typedef int (*can_set_mode_t)(const struct device *dev, can_mode_t mode);
352
360typedef int (*can_send_t)(const struct device *dev,
361 const struct can_frame *frame,
363 void *user_data);
364
369typedef int (*can_add_rx_filter_t)(const struct device *dev,
370 can_rx_callback_t callback,
371 void *user_data,
372 const struct can_filter *filter);
373
378typedef void (*can_remove_rx_filter_t)(const struct device *dev, int filter_id);
379
384typedef int (*can_recover_t)(const struct device *dev, k_timeout_t timeout);
385
390typedef int (*can_get_state_t)(const struct device *dev, enum can_state *state,
391 struct can_bus_err_cnt *err_cnt);
392
397typedef void(*can_set_state_change_callback_t)(const struct device *dev,
399 void *user_data);
400
405typedef int (*can_get_core_clock_t)(const struct device *dev, uint32_t *rate);
406
411typedef int (*can_get_max_filters_t)(const struct device *dev, bool ide);
412
417typedef int (*can_get_max_bitrate_t)(const struct device *dev, uint32_t *max_bitrate);
418
419__subsystem struct can_driver_api {
420 can_get_capabilities_t get_capabilities;
421 can_start_t start;
422 can_stop_t stop;
423 can_set_mode_t set_mode;
424 can_set_timing_t set_timing;
425 can_send_t send;
426 can_add_rx_filter_t add_rx_filter;
427 can_remove_rx_filter_t remove_rx_filter;
428#if !defined(CONFIG_CAN_AUTO_BUS_OFF_RECOVERY) || defined(__DOXYGEN__)
429 can_recover_t recover;
430#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
431 can_get_state_t get_state;
432 can_set_state_change_callback_t set_state_change_callback;
433 can_get_core_clock_t get_core_clock;
434 can_get_max_filters_t get_max_filters;
435 can_get_max_bitrate_t get_max_bitrate;
436 /* Min values for the timing registers */
437 struct can_timing timing_min;
438 /* Max values for the timing registers */
439 struct can_timing timing_max;
440#if defined(CONFIG_CAN_FD_MODE) || defined(__DOXYGEN__)
441 can_set_timing_data_t set_timing_data;
442 /* Min values for the timing registers during the data phase */
443 struct can_timing timing_data_min;
444 /* Max values for the timing registers during the data phase */
445 struct can_timing timing_data_max;
446#endif /* CONFIG_CAN_FD_MODE */
447};
448
451#if defined(CONFIG_CAN_STATS) || defined(__DOXYGEN__)
452
453#include <zephyr/stats/stats.h>
454
458STATS_SECT_ENTRY32(bit0_error)
459STATS_SECT_ENTRY32(bit1_error)
460STATS_SECT_ENTRY32(stuff_error)
461STATS_SECT_ENTRY32(crc_error)
462STATS_SECT_ENTRY32(form_error)
463STATS_SECT_ENTRY32(ack_error)
464STATS_SECT_ENTRY32(rx_overrun)
466
468STATS_NAME(can, bit0_error)
469STATS_NAME(can, bit1_error)
470STATS_NAME(can, stuff_error)
471STATS_NAME(can, crc_error)
472STATS_NAME(can, form_error)
473STATS_NAME(can, ack_error)
474STATS_NAME(can, rx_overrun)
475STATS_NAME_END(can);
476
485 struct stats_can stats;
486};
487
493#define Z_CAN_GET_STATS(dev_) \
494 CONTAINER_OF(dev_->state, struct can_device_state, devstate)->stats
495
506#define CAN_STATS_BIT0_ERROR_INC(dev_) \
507 STATS_INC(Z_CAN_GET_STATS(dev_), bit0_error)
508
517#define CAN_STATS_BIT1_ERROR_INC(dev_) \
518 STATS_INC(Z_CAN_GET_STATS(dev_), bit1_error)
519
528#define CAN_STATS_STUFF_ERROR_INC(dev_) \
529 STATS_INC(Z_CAN_GET_STATS(dev_), stuff_error)
530
539#define CAN_STATS_CRC_ERROR_INC(dev_) \
540 STATS_INC(Z_CAN_GET_STATS(dev_), crc_error)
541
550#define CAN_STATS_FORM_ERROR_INC(dev_) \
551 STATS_INC(Z_CAN_GET_STATS(dev_), form_error)
552
561#define CAN_STATS_ACK_ERROR_INC(dev_) \
562 STATS_INC(Z_CAN_GET_STATS(dev_), ack_error)
563
573#define CAN_STATS_RX_OVERRUN_INC(dev_) \
574 STATS_INC(Z_CAN_GET_STATS(dev_), rx_overrun)
575
581#define Z_CAN_DEVICE_STATE_DEFINE(dev_id) \
582 static struct can_device_state Z_DEVICE_STATE_NAME(dev_id) \
583 __attribute__((__section__(".z_devstate")))
584
591#define Z_CAN_INIT_FN(dev_id, init_fn) \
592 static inline int UTIL_CAT(dev_id, _init)(const struct device *dev) \
593 { \
594 struct can_device_state *state = \
595 CONTAINER_OF(dev->state, struct can_device_state, devstate); \
596 stats_init(&state->stats.s_hdr, STATS_SIZE_32, 7, \
597 STATS_NAME_INIT_PARMS(can)); \
598 stats_register(dev->name, &(state->stats.s_hdr)); \
599 return init_fn(dev); \
600 }
601
624#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
625 prio, api, ...) \
626 Z_CAN_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
627 Z_CAN_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
628 Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
629 DEVICE_DT_NAME(node_id), \
630 &UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \
631 pm, data, config, level, prio, api, \
632 &(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
633 __VA_ARGS__)
634
635#else /* CONFIG_CAN_STATS */
636
637#define CAN_STATS_BIT0_ERROR_INC(dev_)
638#define CAN_STATS_BIT1_ERROR_INC(dev_)
639#define CAN_STATS_STUFF_ERROR_INC(dev_)
640#define CAN_STATS_CRC_ERROR_INC(dev_)
641#define CAN_STATS_FORM_ERROR_INC(dev_)
642#define CAN_STATS_ACK_ERROR_INC(dev_)
643#define CAN_STATS_RX_OVERRUN_INC(dev_)
644
645#define CAN_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
646 prio, api, ...) \
647 DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
648 prio, api, __VA_ARGS__)
649
650#endif /* CONFIG_CAN_STATS */
651
659#define CAN_DEVICE_DT_INST_DEFINE(inst, ...) \
660 CAN_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
661
678__syscall int can_get_core_clock(const struct device *dev, uint32_t *rate);
679
680static inline int z_impl_can_get_core_clock(const struct device *dev, uint32_t *rate)
681{
682 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
683
684 return api->get_core_clock(dev, rate);
685}
686
698__syscall int can_get_max_bitrate(const struct device *dev, uint32_t *max_bitrate);
699
700static inline int z_impl_can_get_max_bitrate(const struct device *dev, uint32_t *max_bitrate)
701{
702 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
703
704 if (api->get_max_bitrate == NULL) {
705 return -ENOSYS;
706 }
707
708 return api->get_max_bitrate(dev, max_bitrate);
709}
710
718__syscall const struct can_timing *can_get_timing_min(const struct device *dev);
719
720static inline const struct can_timing *z_impl_can_get_timing_min(const struct device *dev)
721{
722 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
723
724 return &api->timing_min;
725}
726
734__syscall const struct can_timing *can_get_timing_max(const struct device *dev);
735
736static inline const struct can_timing *z_impl_can_get_timing_max(const struct device *dev)
737{
738 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
739
740 return &api->timing_max;
741}
742
764__syscall int can_calc_timing(const struct device *dev, struct can_timing *res,
765 uint32_t bitrate, uint16_t sample_pnt);
766
780__syscall const struct can_timing *can_get_timing_data_min(const struct device *dev);
781
782#ifdef CONFIG_CAN_FD_MODE
783static inline const struct can_timing *z_impl_can_get_timing_data_min(const struct device *dev)
784{
785 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
786
787 return &api->timing_data_min;
788}
789#endif /* CONFIG_CAN_FD_MODE */
790
804__syscall const struct can_timing *can_get_timing_data_max(const struct device *dev);
805
806#ifdef CONFIG_CAN_FD_MODE
807static inline const struct can_timing *z_impl_can_get_timing_data_max(const struct device *dev)
808{
809 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
810
811 return &api->timing_data_max;
812}
813#endif /* CONFIG_CAN_FD_MODE */
814
834__syscall int can_calc_timing_data(const struct device *dev, struct can_timing *res,
835 uint32_t bitrate, uint16_t sample_pnt);
836
855__syscall int can_set_timing_data(const struct device *dev,
856 const struct can_timing *timing_data);
857
858#ifdef CONFIG_CAN_FD_MODE
859static inline int z_impl_can_set_timing_data(const struct device *dev,
860 const struct can_timing *timing_data)
861{
862 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
863
864 if (api->set_timing_data == NULL) {
865 return -ENOSYS;
866 }
867
868 return api->set_timing_data(dev, timing_data);
869}
870#endif /* CONFIG_CAN_FD_MODE */
871
900__syscall int can_set_bitrate_data(const struct device *dev, uint32_t bitrate_data);
901
918int can_calc_prescaler(const struct device *dev, struct can_timing *timing,
919 uint32_t bitrate);
920
924#define CAN_SJW_NO_CHANGE 0
925
940__syscall int can_set_timing(const struct device *dev,
941 const struct can_timing *timing);
942
943static inline int z_impl_can_set_timing(const struct device *dev,
944 const struct can_timing *timing)
945{
946 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
947
948 return api->set_timing(dev, timing);
949}
950
964__syscall int can_get_capabilities(const struct device *dev, can_mode_t *cap);
965
966static inline int z_impl_can_get_capabilities(const struct device *dev, can_mode_t *cap)
967{
968 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
969
970 return api->get_capabilities(dev, cap);
971}
972
988__syscall int can_start(const struct device *dev);
989
990static inline int z_impl_can_start(const struct device *dev)
991{
992 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
993
994 return api->start(dev);
995}
996
1012__syscall int can_stop(const struct device *dev);
1013
1014static inline int z_impl_can_stop(const struct device *dev)
1015{
1016 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1017
1018 return api->stop(dev);
1019}
1020
1031__syscall int can_set_mode(const struct device *dev, can_mode_t mode);
1032
1033static inline int z_impl_can_set_mode(const struct device *dev, can_mode_t mode)
1034{
1035 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1036
1037 return api->set_mode(dev, mode);
1038}
1039
1065__syscall int can_set_bitrate(const struct device *dev, uint32_t bitrate);
1066
1119__syscall int can_send(const struct device *dev, const struct can_frame *frame,
1121 void *user_data);
1122
1154static inline int can_add_rx_filter(const struct device *dev, can_rx_callback_t callback,
1155 void *user_data, const struct can_filter *filter)
1156{
1157 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1158
1159 if (filter == NULL || (filter->flags & (CAN_FILTER_DATA | CAN_FILTER_RTR)) == 0) {
1160 return -EINVAL;
1161 }
1162
1163 return api->add_rx_filter(dev, callback, user_data, filter);
1164}
1165
1176#define CAN_MSGQ_DEFINE(name, max_frames) \
1177 K_MSGQ_DEFINE(name, sizeof(struct can_frame), max_frames, 4)
1178
1205__syscall int can_add_rx_filter_msgq(const struct device *dev, struct k_msgq *msgq,
1206 const struct can_filter *filter);
1207
1217__syscall void can_remove_rx_filter(const struct device *dev, int filter_id);
1218
1219static inline void z_impl_can_remove_rx_filter(const struct device *dev, int filter_id)
1220{
1221 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1222
1223 return api->remove_rx_filter(dev, filter_id);
1224}
1225
1239__syscall int can_get_max_filters(const struct device *dev, bool ide);
1240
1241static inline int z_impl_can_get_max_filters(const struct device *dev, bool ide)
1242{
1243 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1244
1245 if (api->get_max_filters == NULL) {
1246 return -ENOSYS;
1247 }
1248
1249 return api->get_max_filters(dev, ide);
1250}
1251
1273__syscall int can_get_state(const struct device *dev, enum can_state *state,
1274 struct can_bus_err_cnt *err_cnt);
1275
1276static inline int z_impl_can_get_state(const struct device *dev, enum can_state *state,
1277 struct can_bus_err_cnt *err_cnt)
1278{
1279 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1280
1281 return api->get_state(dev, state, err_cnt);
1282}
1283
1299#if !defined(CONFIG_CAN_AUTO_BUS_OFF_RECOVERY) || defined(__DOXYGEN__)
1300__syscall int can_recover(const struct device *dev, k_timeout_t timeout);
1301
1302static inline int z_impl_can_recover(const struct device *dev, k_timeout_t timeout)
1303{
1304 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1305
1306 return api->recover(dev, timeout);
1307}
1308#else /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
1309/* This implementation prevents inking errors for auto recovery */
1310static inline int z_impl_can_recover(const struct device *dev, k_timeout_t timeout)
1311{
1312 ARG_UNUSED(dev);
1313 ARG_UNUSED(timeout);
1314 return 0;
1315}
1316#endif /* !CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
1317
1331static inline void can_set_state_change_callback(const struct device *dev,
1333 void *user_data)
1334{
1335 const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
1336
1337 api->set_state_change_callback(dev, callback, user_data);
1338}
1339
1356{
1357 static const uint8_t dlc_table[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 12,
1358 16, 20, 24, 32, 48, 64};
1359
1360 return dlc > 0x0F ? 64 : dlc_table[dlc];
1361}
1362
1370static inline uint8_t can_bytes_to_dlc(uint8_t num_bytes)
1371{
1372 return num_bytes <= 8 ? num_bytes :
1373 num_bytes <= 12 ? 9 :
1374 num_bytes <= 16 ? 10 :
1375 num_bytes <= 20 ? 11 :
1376 num_bytes <= 24 ? 12 :
1377 num_bytes <= 32 ? 13 :
1378 num_bytes <= 48 ? 14 :
1379 15;
1380}
1381
1388#ifdef __cplusplus
1389}
1390#endif
1391
1392#include <syscalls/can.h>
1393
1394#endif /* ZEPHYR_INCLUDE_DRIVERS_CAN_H_ */
ZTEST_BMEM int timeout
Definition: main.c:31
System error numbers.
static ssize_t send(int sock, const void *buf, size_t len, int flags)
Definition: socket.h:738
void(* can_state_change_callback_t)(const struct device *dev, enum can_state state, struct can_bus_err_cnt err_cnt, void *user_data)
Defines the state change callback handler function signature.
Definition: can.h:304
int can_set_bitrate(const struct device *dev, uint32_t bitrate)
Set the bitrate of the CAN controller.
int can_set_bitrate_data(const struct device *dev, uint32_t bitrate_data)
Set the bitrate for the data phase of the CAN-FD controller.
uint32_t can_mode_t
Provides a type to hold CAN controller configuration flags.
Definition: can.h:110
static int can_add_rx_filter(const struct device *dev, can_rx_callback_t callback, void *user_data, const struct can_filter *filter)
Add a callback function for a given CAN filter.
Definition: can.h:1154
int can_stop(const struct device *dev)
Stop the CAN controller.
int can_set_timing(const struct device *dev, const struct can_timing *timing)
Configure the bus timing of a CAN controller.
int can_calc_timing_data(const struct device *dev, struct can_timing *res, uint32_t bitrate, uint16_t sample_pnt)
Calculate timing parameters for the data phase.
int can_send(const struct device *dev, const struct can_frame *frame, k_timeout_t timeout, can_tx_callback_t callback, void *user_data)
Queue a CAN frame for transmission on the CAN bus.
const struct can_timing * can_get_timing_data_max(const struct device *dev)
Get the maximum supported timing parameter values for the data phase.
int can_get_core_clock(const struct device *dev, uint32_t *rate)
Get the CAN core clock rate.
int can_get_capabilities(const struct device *dev, can_mode_t *cap)
Get the supported modes of the CAN controller.
int can_get_max_filters(const struct device *dev, bool ide)
Get maximum number of RX filters.
const struct can_timing * can_get_timing_min(const struct device *dev)
Get the minimum supported timing parameter values.
int can_set_timing_data(const struct device *dev, const struct can_timing *timing_data)
Configure the bus timing for the data phase of a CAN-FD controller.
const struct can_timing * can_get_timing_data_min(const struct device *dev)
Get the minimum supported timing parameter values for the data phase.
int can_calc_prescaler(const struct device *dev, struct can_timing *timing, uint32_t bitrate)
Fill in the prescaler value for a given bitrate and timing.
void can_remove_rx_filter(const struct device *dev, int filter_id)
Remove a CAN RX filter.
static uint8_t can_bytes_to_dlc(uint8_t num_bytes)
Convert from number of bytes to Data Length Code (DLC)
Definition: can.h:1370
int can_get_max_bitrate(const struct device *dev, uint32_t *max_bitrate)
Get maximum supported bitrate.
#define CAN_FILTER_RTR
Definition: can.h:194
static uint8_t can_dlc_to_bytes(uint8_t dlc)
Convert from Data Length Code (DLC) to the number of data bytes.
Definition: can.h:1355
#define CAN_FILTER_DATA
Definition: can.h:197
int can_add_rx_filter_msgq(const struct device *dev, struct k_msgq *msgq, const struct can_filter *filter)
Simple wrapper function for adding a message queue for a given filter.
void(* can_rx_callback_t)(const struct device *dev, struct can_frame *frame, void *user_data)
Defines the application callback handler function signature for receiving.
Definition: can.h:293
void(* can_tx_callback_t)(const struct device *dev, int error, void *user_data)
Defines the application callback handler function signature.
Definition: can.h:284
int can_get_state(const struct device *dev, enum can_state *state, struct can_bus_err_cnt *err_cnt)
Get current CAN controller state.
const struct can_timing * can_get_timing_max(const struct device *dev)
Get the maximum supported timing parameter values.
int can_calc_timing(const struct device *dev, struct can_timing *res, uint32_t bitrate, uint16_t sample_pnt)
Calculate timing parameters from bitrate and sample point.
int can_recover(const struct device *dev, k_timeout_t timeout)
Recover from bus-off state.
can_state
Defines the state of the CAN controller.
Definition: can.h:115
static void can_set_state_change_callback(const struct device *dev, can_state_change_callback_t callback, void *user_data)
Set a callback for CAN controller state change events.
Definition: can.h:1331
int can_set_mode(const struct device *dev, can_mode_t mode)
Set the CAN controller to the given operation mode.
int can_start(const struct device *dev)
Start the CAN controller.
@ CAN_STATE_ERROR_ACTIVE
Definition: can.h:117
@ CAN_STATE_ERROR_WARNING
Definition: can.h:119
@ CAN_STATE_STOPPED
Definition: can.h:125
@ CAN_STATE_BUS_OFF
Definition: can.h:123
@ CAN_STATE_ERROR_PASSIVE
Definition: can.h:121
#define ceiling_fraction(numerator, divider)
Ceiling function applied to numerator / divider as a fraction.
Definition: util.h:247
#define EINVAL
Definition: errno.h:61
#define ENOSYS
Definition: errno.h:83
Public kernel APIs.
Variables needed for system clock.
struct k_msgq msgq
Definition: test_msgq_contexts.c:12
state
Definition: parser_state.h:29
Statistics.
#define STATS_NAME_END(name__)
Definition: stats.h:391
#define STATS_NAME(name__, entry__)
Definition: stats.h:390
#define STATS_SECT_END
Ends a stats group struct definition.
Definition: stats.h:89
#define STATS_SECT_ENTRY32(var__)
Definition: stats.h:359
#define STATS_NAME_START(name__)
Definition: stats.h:389
#define STATS_SECT_START(group__)
Definition: stats.h:354
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
CAN controller error counters.
Definition: can.h:224
uint8_t tx_err_cnt
Definition: can.h:226
uint8_t rx_err_cnt
Definition: can.h:228
CAN specific device state which allows for CAN device class specific additions.
Definition: can.h:483
struct device_state devstate
Definition: can.h:484
struct stats_can stats
Definition: can.h:485
CAN filter structure.
Definition: can.h:207
uint32_t mask
Definition: can.h:216
uint8_t flags
Definition: can.h:218
uint32_t id
Definition: can.h:209
CAN frame structure.
Definition: can.h:152
uint8_t dlc
Definition: can.h:159
uint8_t flags
Definition: can.h:161
uint32_t data_32[ceiling_fraction(CAN_MAX_DLEN, sizeof(uint32_t))]
Definition: can.h:179
uint32_t id
Definition: can.h:154
uint8_t data[CAN_MAX_DLEN]
Definition: can.h:178
uint16_t timestamp
Definition: can.h:170
CAN bus timing structure.
Definition: can.h:263
uint16_t sjw
Definition: can.h:265
uint16_t phase_seg2
Definition: can.h:271
uint16_t prescaler
Definition: can.h:273
uint16_t phase_seg1
Definition: can.h:269
uint16_t prop_seg
Definition: can.h:267
Runtime device dynamic structure (in RAM) per driver instance.
Definition: device.h:351
Runtime device structure (in ROM) per driver instance.
Definition: device.h:378
const void * api
Definition: device.h:384
Message Queue Structure.
Definition: kernel.h:4248
Kernel timeout type.
Definition: sys_clock.h:65
static const intptr_t user_data[5]
Definition: main.c:588
Misc utilities.