Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 OTA keys S.A.
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
26#ifndef CAN_COMMON_H
27#define CAN_COMMON_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <stdint.h>
34#include <sys/uio.h>
35
36#include "timex.h"
37#include "thread.h"
38#ifdef MODULE_CAN_MBOX
39#include "mbox.h"
40#endif
41
45#ifdef MODULE_FDCAN
46#define DEFAULT_CAN_MAX_DLEN CANFD_MAX_DLEN
47#else
48#define DEFAULT_CAN_MAX_DLEN CAN_MAX_DLEN
49#endif
50
54typedef enum {
63#ifdef MODULE_FDCAN
64 CANOPT_FD_BITTIMING,
65 CANOPT_FD_BITTIMING_CONST,
66#endif
67} canopt_t;
68
81
85typedef struct {
87 uint16_t context;
88 void *data;
89 uint16_t data_len;
90} can_opt_t;
91
95enum can_msg {
96 /* High level messages */
97 CAN_MSG_ACK = 0x100,
106#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
108#endif
109 /* candev internal messages */
119#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
121#endif
122 /* isotp messages */
123#if defined(MODULE_CAN_ISOTP) || defined(DOXYGEN)
126#endif
127};
128
135typedef struct can_rx_data {
136 struct iovec data;
137 void *arg;
139
143typedef enum {
145#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
147#endif
149
156typedef struct can_reg_entry {
158 int ifnum;
159 union {
161#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
163#endif
165#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
167#endif
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif /* CAN_COMMON_H */
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:139
canopt_state_t
CAN state options.
Definition common.h:74
canopt_t
CAN options.
Definition common.h:54
struct can_rx_data can_rx_data_t
Received data structure.
can_msg
Messages which can be sent through the CAN stack.
Definition common.h:95
can_reg_type_t
registry entry types
Definition common.h:143
struct can_reg_entry can_reg_entry_t
registry entry
@ CANOPT_STATE_OFF
powered off
Definition common.h:75
@ CANOPT_STATE_SLEEP
sleep mode
Definition common.h:76
@ CANOPT_STATE_LOOPBACK
loopback mode
Definition common.h:79
@ CANOPT_STATE_ON
power on, rx / tx mode
Definition common.h:78
@ CANOPT_STATE_LISTEN_ONLY
listen only mode
Definition common.h:77
@ CANOPT_STATE
set controller state canopt_state_t
Definition common.h:62
@ CANOPT_RX_FILTERS
rx filters
Definition common.h:56
@ CANOPT_LEC
Last Error Code.
Definition common.h:59
@ CANOPT_BITTIMING_CONST
controller bittiming parameters
Definition common.h:61
@ CANOPT_REC
Receive Error Counter.
Definition common.h:58
@ CANOPT_TEC
Transmit Error Counter.
Definition common.h:57
@ CANOPT_CLOCK
controller main clock
Definition common.h:60
@ CANOPT_BITTIMING
bit timing parameter
Definition common.h:55
@ CAN_MSG_SET_TRX
set a transceiver
Definition common.h:107
@ CAN_MSG_POWER_UP
power up
Definition common.h:104
@ CAN_MSG_ERROR_WARNING
driver reached error warning
Definition common.h:118
@ CAN_MSG_ERROR_PASSIVE
driver switched in error passive
Definition common.h:117
@ CAN_MSG_SET_FILTER
set a filter
Definition common.h:102
@ CAN_MSG_POWER_DOWN
power down
Definition common.h:105
@ CAN_MSG_BUS_OFF
bus-off detected
Definition common.h:116
@ CAN_MSG_EVENT
driver event
Definition common.h:110
@ CAN_MSG_ACK
acknowledgment
Definition common.h:97
@ CAN_MSG_WAKE_UP
driver has been woken up by bus
Definition common.h:111
@ CAN_MSG_TX_CONFIRMATION
a frame has been sent
Definition common.h:112
@ CAN_MSG_RX_ERROR
there was an error when receiving
Definition common.h:115
@ CAN_MSG_SEND_FRAME
send a frame
Definition common.h:98
@ CAN_MSG_SET
set an option
Definition common.h:100
@ CAN_MSG_ISOTP_RX_TIMEOUT
isotp rx timeout
Definition common.h:124
@ CAN_MSG_RX_INDICATION
a frame has been received
Definition common.h:113
@ CAN_MSG_ABORT_FRAME
abort a frame
Definition common.h:99
@ CAN_MSG_REMOVE_FILTER
remove a filter
Definition common.h:103
@ CAN_MSG_PM
power management event
Definition common.h:120
@ CAN_MSG_GET
get an option
Definition common.h:101
@ CAN_MSG_ISOTP_TX_TIMEOUT
isotp tx timeout
Definition common.h:125
@ CAN_MSG_TX_ERROR
there was an error when transmitting
Definition common.h:114
@ CAN_TYPE_DEFAULT
default entry (use msg)
Definition common.h:144
@ CAN_TYPE_MBOX
mbox entry
Definition common.h:146
Mailbox API.
Structure to pass a CAN option.
Definition common.h:85
uint16_t context
(optional) context for that option
Definition common.h:87
uint16_t data_len
size of the data / the buffer
Definition common.h:89
canopt_t opt
the option to get/set
Definition common.h:86
void * data
data to set or buffer to read into
Definition common.h:88
registry entry
Definition common.h:156
union can_reg_entry::@329 target
entry target
mbox_t * mbox
mbox pointer
Definition common.h:162
kernel_pid_t pid
pid of the thread when using msg
Definition common.h:160
can_reg_type_t type
entry type
Definition common.h:166
int ifnum
interface number for the entry
Definition common.h:158
struct can_reg_entry * next
next for linked list
Definition common.h:157
Received data structure.
Definition common.h:135
void * arg
upper layer private param
Definition common.h:137
struct iovec data
iovec containing received data
Definition common.h:136
Structure for scatter/gather I/O.
Definition uio.h:33
Mailbox struct definition.
Definition mbox.h:41
Utility library for comparing and computing timestamps.
libc header for scatter/gather I/O