PicoLowLevel
can.h
Go to the documentation of this file.
1 #ifndef CAN_H_
2 #define CAN_H_
3 
4 #include <stdint.h>
5 
6 
7 typedef unsigned char __u8;
8 typedef unsigned short __u16;
9 typedef unsigned long __u32;
10 
11 
12 /* special address description flags for the CAN_ID */
13 #define CAN_EFF_FLAG 0x80000000UL /* EFF/SFF is set in the MSB */
14 #define CAN_RTR_FLAG 0x40000000UL /* remote transmission request */
15 #define CAN_ERR_FLAG 0x20000000UL /* error message frame */
16 
17 /* valid bits in CAN ID for frame formats */
18 #define CAN_SFF_MASK 0x000007FFUL /* standard frame format (SFF) */
19 #define CAN_EFF_MASK 0x1FFFFFFFUL /* extended frame format (EFF) */
20 #define CAN_ERR_MASK 0x1FFFFFFFUL /* omit EFF, RTR, ERR flags */
21 
22 /*
23  * Controller Area Network Identifier structure
24  *
25  * bit 0-28 : CAN identifier (11/29 bit)
26  * bit 29 : error message frame flag (0 = data frame, 1 = error message)
27  * bit 30 : remote transmission request flag (1 = rtr frame)
28  * bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
29  */
30 typedef __u32 canid_t;
31 
32 #define CAN_SFF_ID_BITS 11
33 #define CAN_EFF_ID_BITS 29
34 
35 /* CAN payload length and DLC definitions according to ISO 11898-1 */
36 #define CAN_MAX_DLC 8
37 #define CAN_MAX_DLEN 8
38 
39 struct can_frame {
40  canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
41  __u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
42  __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
43 };
44 
45 #endif /* CAN_H_ */
unsigned long __u32
Definition: can.h:9
unsigned char __u8
Definition: can.h:7
unsigned short __u16
Definition: can.h:8
#define CAN_MAX_DLEN
Definition: can.h:37
__u32 canid_t
Definition: can.h:30
Definition: can.h:39
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)))
canid_t can_id
Definition: can.h:40
__u8 can_dlc
Definition: can.h:41