📄 can.h.svn-base
字号:
//****************************************************************************//// File: can.h //// Description: //// Author: Uwe Koppe //// e-mail: koppe@microcontrol.net //// ////============================================================================//// This program is free software; you can redistribute it and/or modify //// it under the terms of the GNU Lesser General Public License as published //// by the Free Software Foundation; either version 2.1 of the License, or //// (at your option) any later version. ////============================================================================//// //// Date History //// ---------- -------------------------------------------------------------- //// 05.07.2004 Initial version //// ////****************************************************************************//#ifndef _CAN_H_#define _CAN_H_//------------------------------------------------------------------------------// CVS version information:// $Id: can.h,v 1.3 2005/06/17 13:46:31 microcontrol Exp $//------------------------------------------------------------------------------/*----------------------------------------------------------------------------*\** Include files **** **\*----------------------------------------------------------------------------*/#ifdef __KERNEL__#include <linux/types.h> // data types uint8_t ... uint32_t, kernel space#else#include <stdint.h> // data types uint8_t ... uint32_t, user space#include <sys/ioctl.h> // definition of SIOCPROTOPRIVATE#endif//-----------------------------------------------------------------------------/*! \file can.h*****//*----------------------------------------------------------------------------*\** Definitions **** **\*----------------------------------------------------------------------------*/#define AF_CAN 28 // this definition needs to be moved into socket.h!#define CAN_FRAME_CTRL_EXT 0x01#define CAN_FRAME_CTRL_RTR 0x02enum SIOC_CAN { SIOC_CAN_FIRST = SIOCPROTOPRIVATE, SIOC_CAN_SET_BITRATE = SIOC_CAN_FIRST, SIOC_CAN_GET_BITRATE, SIOC_CAN_SET_MODE, SIOC_CAN_GET_STATE, SIOC_CAN_SET_TRMFIFOSIZE, SIOC_CAN_SET_RCVFIFOSIZE, SIOC_CAN_LAST = SIOC_CAN_SET_RCVFIFOSIZE};/*----------------------------------------------------------------------------*\** Structures **** **\*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//*!** \struct can_frame can.h** \brief CAN message structure**** For transmission and reception of CAN messages a structure which holds** all necessary informations is used. The structure has the following** fields:*/struct can_frame { /*! The identifier field may have 11 bits for standard frames ** (CAN specification 2.0A) or 29 bits for extended frames ** (CAN specification 2.0B). The three most significant bits ** are reserved (always read 0). */ union { uint16_t uwStd; uint32_t ulExt; } id; /*! The data field has up to 8 bytes (64 bit) of message data. ** The number of used bytes is described via the structure ** member 'dlc'. */ union { uint8_t aubByte[8]; uint16_t auwWord[4]; uint32_t aulLong[2]; } data; /*! The data length code denotes the number of data bytes ** which are transmitted by a message. ** The possible value range for the data length code is ** from 0 to 8 (bytes). */ uint8_t dlc; /*! The structure member 'ctrl' defines the ** different data frames (2.0A / 2.0B) and the RTR frames. ** See definitions CAN_FRAME_CTRL_XXX. ** Bit 0: Extended Frame if set to 1, else Standard Frame ** Bit 1: Remote Frame if set to 1, else Data Frame */ uint8_t ctrl; };struct sockaddr_can { /*! ** address family (AF_CAN) */ sa_family_t can_family; /*! ** logical CAN interface number, compliant to CANpie ** first CAN interface number starts at 0 */ uint16_t can_if; /* CAN_PROTO_RAW-specific */ int32_t can_id;};/*----------------------------------------------------------------------------*//*!** \struct can_bit_timing can.h** \brief Bit timing structure** */struct can_bit_timing { /*! holds the value from enum CP_BAUD */ uint8_t ubBaudSel; /*! Bit timing register 0 */ uint8_t ubBtr0; /*! Bit timing register 1 */ uint8_t ubBtr1; /*! Syncronisation jump width */ uint8_t ubSjw;};/*----------------------------------------------------------------------------*\** Function prototypes **** **\*----------------------------------------------------------------------------*/#endif /* _CAN_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -