Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
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
9
#pragma once
10
27
28
#ifdef __cplusplus
29
extern
"C"
{
30
#endif
31
32
#include <stdint.h>
33
#include <
sys/uio.h
>
34
35
#include "
timex.h
"
36
#include "thread.h"
37
#ifdef MODULE_CAN_MBOX
38
#include "
mbox.h
"
39
#endif
40
44
#ifdef MODULE_FDCAN
45
#define DEFAULT_CAN_MAX_DLEN CANFD_MAX_DLEN
46
#else
47
#define DEFAULT_CAN_MAX_DLEN CAN_MAX_DLEN
48
#endif
49
53
typedef
enum
{
54
CANOPT_BITTIMING
,
55
CANOPT_RX_FILTERS
,
56
CANOPT_TEC
,
57
CANOPT_REC
,
58
CANOPT_LEC
,
59
CANOPT_CLOCK
,
60
CANOPT_BITTIMING_CONST
,
61
CANOPT_STATE
,
62
#ifdef MODULE_FDCAN
63
CANOPT_FD_BITTIMING,
64
CANOPT_FD_BITTIMING_CONST,
65
#endif
66
}
canopt_t
;
67
73
typedef
enum
{
74
CANOPT_STATE_OFF
,
75
CANOPT_STATE_SLEEP
,
76
CANOPT_STATE_LISTEN_ONLY
,
77
CANOPT_STATE_ON
,
78
CANOPT_STATE_LOOPBACK
,
79
}
canopt_state_t
;
80
84
typedef
struct
{
85
canopt_t
opt
;
86
uint16_t
context
;
87
void
*
data
;
88
uint16_t
data_len
;
89
}
can_opt_t
;
90
94
enum
can_msg
{
95
/* High level messages */
96
CAN_MSG_ACK
= 0x100,
97
CAN_MSG_SEND_FRAME
,
98
CAN_MSG_ABORT_FRAME
,
99
CAN_MSG_SET
,
100
CAN_MSG_GET
,
101
CAN_MSG_SET_FILTER
,
102
CAN_MSG_REMOVE_FILTER
,
103
CAN_MSG_POWER_UP
,
104
CAN_MSG_POWER_DOWN
,
105
#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
106
CAN_MSG_SET_TRX
,
107
#endif
108
/* candev internal messages */
109
CAN_MSG_EVENT
= 0x200,
110
CAN_MSG_WAKE_UP
,
111
CAN_MSG_TX_CONFIRMATION
,
112
CAN_MSG_RX_INDICATION
,
113
CAN_MSG_TX_ERROR
,
114
CAN_MSG_RX_ERROR
,
115
CAN_MSG_BUS_OFF
,
116
CAN_MSG_ERROR_PASSIVE
,
117
CAN_MSG_ERROR_WARNING
,
118
#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
119
CAN_MSG_PM
,
120
#endif
121
/* isotp messages */
122
#if defined(MODULE_CAN_ISOTP) || defined(DOXYGEN)
123
CAN_MSG_ISOTP_RX_TIMEOUT
= 0x400,
124
CAN_MSG_ISOTP_TX_TIMEOUT
,
125
#endif
126
};
127
134
typedef
struct
can_rx_data
{
135
struct
iovec
data
;
136
void
*
arg
;
137
}
can_rx_data_t
;
138
142
typedef
enum
{
143
CAN_TYPE_DEFAULT
= 0,
144
#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
145
CAN_TYPE_MBOX
,
146
#endif
147
}
can_reg_type_t
;
148
155
typedef
struct
can_reg_entry
{
156
struct
can_reg_entry
*
next
;
157
int
ifnum
;
158
union
{
159
kernel_pid_t
pid
;
160
#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
161
mbox_t
*
mbox
;
162
#endif
163
}
target
;
164
#if defined(MODULE_CAN_MBOX) || defined(DOXYGEN)
165
can_reg_type_t
type
;
166
#endif
167
}
can_reg_entry_t
;
168
169
#ifdef __cplusplus
170
}
171
#endif
172
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition
sched.h:138
canopt_state_t
canopt_state_t
CAN state options.
Definition
common.h:73
canopt_t
canopt_t
CAN options.
Definition
common.h:53
can_rx_data_t
struct can_rx_data can_rx_data_t
Received data structure.
can_msg
can_msg
Messages which can be sent through the CAN stack.
Definition
common.h:94
can_reg_type_t
can_reg_type_t
registry entry types
Definition
common.h:142
can_reg_entry_t
struct can_reg_entry can_reg_entry_t
registry entry
CANOPT_STATE_OFF
@ CANOPT_STATE_OFF
powered off
Definition
common.h:74
CANOPT_STATE_SLEEP
@ CANOPT_STATE_SLEEP
sleep mode
Definition
common.h:75
CANOPT_STATE_LOOPBACK
@ CANOPT_STATE_LOOPBACK
loopback mode
Definition
common.h:78
CANOPT_STATE_ON
@ CANOPT_STATE_ON
power on, rx / tx mode
Definition
common.h:77
CANOPT_STATE_LISTEN_ONLY
@ CANOPT_STATE_LISTEN_ONLY
listen only mode
Definition
common.h:76
CANOPT_STATE
@ CANOPT_STATE
set controller state canopt_state_t
Definition
common.h:61
CANOPT_RX_FILTERS
@ CANOPT_RX_FILTERS
rx filters
Definition
common.h:55
CANOPT_LEC
@ CANOPT_LEC
Last Error Code.
Definition
common.h:58
CANOPT_BITTIMING_CONST
@ CANOPT_BITTIMING_CONST
controller bittiming parameters
Definition
common.h:60
CANOPT_REC
@ CANOPT_REC
Receive Error Counter.
Definition
common.h:57
CANOPT_TEC
@ CANOPT_TEC
Transmit Error Counter.
Definition
common.h:56
CANOPT_CLOCK
@ CANOPT_CLOCK
controller main clock
Definition
common.h:59
CANOPT_BITTIMING
@ CANOPT_BITTIMING
bit timing parameter
Definition
common.h:54
CAN_MSG_SET_TRX
@ CAN_MSG_SET_TRX
set a transceiver
Definition
common.h:106
CAN_MSG_POWER_UP
@ CAN_MSG_POWER_UP
power up
Definition
common.h:103
CAN_MSG_ERROR_WARNING
@ CAN_MSG_ERROR_WARNING
driver reached error warning
Definition
common.h:117
CAN_MSG_ERROR_PASSIVE
@ CAN_MSG_ERROR_PASSIVE
driver switched in error passive
Definition
common.h:116
CAN_MSG_SET_FILTER
@ CAN_MSG_SET_FILTER
set a filter
Definition
common.h:101
CAN_MSG_POWER_DOWN
@ CAN_MSG_POWER_DOWN
power down
Definition
common.h:104
CAN_MSG_BUS_OFF
@ CAN_MSG_BUS_OFF
bus-off detected
Definition
common.h:115
CAN_MSG_EVENT
@ CAN_MSG_EVENT
driver event
Definition
common.h:109
CAN_MSG_ACK
@ CAN_MSG_ACK
acknowledgment
Definition
common.h:96
CAN_MSG_WAKE_UP
@ CAN_MSG_WAKE_UP
driver has been woken up by bus
Definition
common.h:110
CAN_MSG_TX_CONFIRMATION
@ CAN_MSG_TX_CONFIRMATION
a frame has been sent
Definition
common.h:111
CAN_MSG_RX_ERROR
@ CAN_MSG_RX_ERROR
there was an error when receiving
Definition
common.h:114
CAN_MSG_SEND_FRAME
@ CAN_MSG_SEND_FRAME
send a frame
Definition
common.h:97
CAN_MSG_SET
@ CAN_MSG_SET
set an option
Definition
common.h:99
CAN_MSG_ISOTP_RX_TIMEOUT
@ CAN_MSG_ISOTP_RX_TIMEOUT
isotp rx timeout
Definition
common.h:123
CAN_MSG_RX_INDICATION
@ CAN_MSG_RX_INDICATION
a frame has been received
Definition
common.h:112
CAN_MSG_ABORT_FRAME
@ CAN_MSG_ABORT_FRAME
abort a frame
Definition
common.h:98
CAN_MSG_REMOVE_FILTER
@ CAN_MSG_REMOVE_FILTER
remove a filter
Definition
common.h:102
CAN_MSG_PM
@ CAN_MSG_PM
power management event
Definition
common.h:119
CAN_MSG_GET
@ CAN_MSG_GET
get an option
Definition
common.h:100
CAN_MSG_ISOTP_TX_TIMEOUT
@ CAN_MSG_ISOTP_TX_TIMEOUT
isotp tx timeout
Definition
common.h:124
CAN_MSG_TX_ERROR
@ CAN_MSG_TX_ERROR
there was an error when transmitting
Definition
common.h:113
CAN_TYPE_DEFAULT
@ CAN_TYPE_DEFAULT
default entry (use msg)
Definition
common.h:143
CAN_TYPE_MBOX
@ CAN_TYPE_MBOX
mbox entry
Definition
common.h:145
mbox.h
Mailbox API.
can_opt_t
Structure to pass a CAN option.
Definition
common.h:84
can_opt_t::context
uint16_t context
(optional) context for that option
Definition
common.h:86
can_opt_t::data_len
uint16_t data_len
size of the data / the buffer
Definition
common.h:88
can_opt_t::opt
canopt_t opt
the option to get/set
Definition
common.h:85
can_opt_t::data
void * data
data to set or buffer to read into
Definition
common.h:87
can_reg_entry
registry entry
Definition
common.h:155
can_reg_entry::mbox
mbox_t * mbox
mbox pointer
Definition
common.h:161
can_reg_entry::pid
kernel_pid_t pid
pid of the thread when using msg
Definition
common.h:159
can_reg_entry::target
union can_reg_entry::@110065112330065052322137357235215311127371134047 target
entry target
can_reg_entry::type
can_reg_type_t type
entry type
Definition
common.h:165
can_reg_entry::ifnum
int ifnum
interface number for the entry
Definition
common.h:157
can_reg_entry::next
struct can_reg_entry * next
next for linked list
Definition
common.h:156
can_rx_data
Received data structure.
Definition
common.h:134
can_rx_data::arg
void * arg
upper layer private param
Definition
common.h:136
can_rx_data::data
struct iovec data
iovec containing received data
Definition
common.h:135
iovec
Structure for scatter/gather I/O.
Definition
uio.h:33
mbox_t
Mailbox struct definition.
Definition
mbox.h:40
timex.h
Utility library for comparing and computing timestamps.
uio.h
libc header for scatter/gather I/O
Generated on Thu Jul 3 2025 17:41:21 by
1.13.2