RTEMS 7.0-rc1
Loading...
Searching...
No Matches
can.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0 OR GPL-2.0-or-later */
2
16/*
17 * Copyright (C) 2023-2024 Michal Lenc <michallenc@seznam.cz>
18 * Copyright (C) 2002-2009 DCE FEE CTU Prague
19 * Copyright (C) 2002-2024 Pavel Pisa <pisa@cmp.felk.cvut.cz>
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
41 */
42
43#ifndef _DEV_CAN_CAN_H
44#define _DEV_CAN_CAN_H
45
46#include <sys/queue.h>
47
48#include <stdatomic.h>
49#include <rtems.h>
50#include <rtems/seterr.h>
51#include <rtems/thread.h>
52#include <sys/ioccom.h>
53
54#include <dev/can/can-stats.h>
56#include <dev/can/can-frame.h>
57#include <dev/can/can-filter.h>
58
59#define CAN_IOC_MAGIC 'd'
60
79#define RTEMS_CAN_CHIP_CONFIGURED ( 0 )
84#define RTEMS_CAN_CHIP_RUNNING ( 1 )
85
96#define RTEMS_CAN_CHIP_CAPABILITIES_FD ( 1 << 0 )
101#define RTEMS_CAN_CHIP_CAPABILITIES_TX_TIMESTAMP ( 1 << 1 )
106#define RTEMS_CAN_CHIP_CAPABILITIES_RX_TIMESTAMP ( 1 << 2 )
107
122#define RTEMS_CAN_CHIP_BITRATE ( 1 )
127#define RTEMS_CAN_CHIP_DBITRATE ( 2 )
132#define RTEMS_CAN_CHIP_NUSERS ( 3 )
138#define RTEMS_CAN_CHIP_FLAGS ( 4 )
143#define RTEMS_CAN_CHIP_MODE ( 5 )
148#define RTEMS_CAN_CHIP_MODE_SUPPORTED ( 6 )
149
163#define RTEMS_CAN_QUEUE_RX ( 1 << 0 )
168#define RTEMS_CAN_QUEUE_TX ( 1 << 1 )
169
184#define CAN_CTRLMODE_LOOPBACK ( 1 << 0 )
189#define CAN_CTRLMODE_LISTENONLY ( 1 << 1 )
194#define CAN_CTRLMODE_3_SAMPLES ( 1 << 2 )
199#define CAN_CTRLMODE_ONE_SHOT ( 1 << 3 )
204#define CAN_CTRLMODE_BERR_REPORTING ( 1 << 4 )
209#define CAN_CTRLMODE_FD ( 1 << 5 )
214#define CAN_CTRLMODE_PRESUME_ACK ( 1 << 6 )
219#define CAN_CTRLMODE_FD_NON_ISO ( 1 << 7 )
224#define CAN_CTRLMODE_CC_LEN8_DLC ( 1 << 8 )
229#define CAN_CTRLMODE_TDC_AUTO ( 1 << 9 )
234#define CAN_CTRLMODE_TDC_MANUAL ( 1 << 10 )
235#define CAN_CTRLMODE_MASK ( CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY | \
236 CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_ONE_SHOT | \
237 CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_FD | \
238 CAN_CTRLMODE_PRESUME_ACK | CAN_CTRLMODE_FD_NON_ISO | \
239 CAN_CTRLMODE_CC_LEN8_DLC | CAN_CTRLMODE_TDC_AUTO | \
240 CAN_CTRLMODE_TDC_MANUAL)
241
263#define RTEMS_CAN_CHIP_START _IO( CAN_IOC_MAGIC, 1 )
268#define RTEMS_CAN_CHIP_STOP _IOW( CAN_IOC_MAGIC, 2, struct timespec )
273#define RTEMS_CAN_CLOSE_NONBLOCK _IO( CAN_IOC_MAGIC, 3 )
279#define RTEMS_CAN_DISCARD_QUEUES _IO( CAN_IOC_MAGIC, 4 )
285#define RTEMS_CAN_FLUSH_QUEUES _IO( CAN_IOC_MAGIC, 5 )
291#define RTEMS_CAN_CHIP_SET_MODE _IO( CAN_IOC_MAGIC, 6 )
296#define RTEMS_CAN_CHIP_GET_INFO _IO( CAN_IOC_MAGIC, 7 )
303#define RTEMS_CAN_WAIT_TX_DONE _IOW( CAN_IOC_MAGIC, 8, struct timespec )
310#define RTEMS_CAN_POLL_TX_READY _IOW( CAN_IOC_MAGIC, 9, struct timespec )
317#define RTEMS_CAN_POLL_RX_AVAIL _IOW( CAN_IOC_MAGIC, 10, struct timespec )
322#define RTEMS_CAN_CREATE_QUEUE _IOW( CAN_IOC_MAGIC, 11, struct rtems_can_queue_param )
327#define RTEMS_CAN_SET_BITRATE _IOW( CAN_IOC_MAGIC, 12, struct rtems_can_set_bittiming )
331#define RTEMS_CAN_CHIP_GET_TIMESTAMP _IOR( CAN_IOC_MAGIC, 13, uint64_t )
336#define RTEMS_CAN_CHIP_STATISTICS _IOR( CAN_IOC_MAGIC, 14, struct rtems_can_stats )
341#define RTEMS_CAN_GET_BITTIMING _IOWR( CAN_IOC_MAGIC, 15, struct rtems_can_get_bittiming )
342
354 uint8_t direction;
360 uint8_t priority;
366 uint8_t dlen_max;
371 uint8_t buffer_size;
377};
378
381#endif
This header file is part of CAN/CAN FD bus common support. It defines structures used for bit timing ...
This header file is part of CAN/CAN FD bus common support. It implements structure that represents fi...
This header file is part of CAN/CAN FD bus common support. It implements CAN frame structure and rela...
This header file is part of CAN/CAN FD bus common support. It implements controller's statistics.
This header file defines the RTEMS Classic API.
This header file defines macros to set errno and return minus one.
This structure is used to represent CAN ID and flags in one unified structure.
Definition: can-filter.h:50
This structure represents parameters of FIFO queue. It is used to setup new queues via RTEMS_CAN_CREA...
Definition: can.h:349
uint8_t direction
This member specifies queue's direction. Use RTEMS_CAN_QUEUE_RX or RTEMS_CAN_QUEUE_TX.
Definition: can.h:354
struct rtems_can_filter filter
This member holds a queue's filter. Refer to rtems_can_filter for more information.
Definition: can.h:376
uint8_t buffer_size
This member specifies queue's buffer size. Passing 0 applies default RTEMS_CAN_FIFO_SIZE value.
Definition: can.h:371
uint8_t priority
This member specifies queue's priority. Maximum priority value is available from RTEMS_CAN_QUEUE_PRIO...
Definition: can.h:360
uint8_t dlen_max
This member specifies queue's maximum data length. Passing 0 applies default value: CAN_FRAME_STANDAR...
Definition: can.h:366
This header file provides the API of Self-Contained Objects.