📄 canopen.h.svn-base
字号:
//****************************************************************************//
// File: canopen.h //
// Description: General definitions for CANopen //
// Author: Uwe Koppe //
// e-mail: koppe@microcontrol.net //
// //
// Copyright (C) MicroControl GmbH & Co. KG //
// Josef-Kitz-Str. 9 //
// 53840 Troisdorf //
// Germany //
// Tel: +49-2241-978493 //
// Fax: +49-2241-978495 //
// //
// The copyright to the computer program(s) herein is the property of //
// MicroControl GmbH & Co. KG, Germany. The program(s) may be used //
// and/or copied only with the written permission of MicroControl GmbH & //
// Co. KG or in accordance with the terms and conditions stipulated in //
// the agreement/contract under which the program(s) have been supplied. //
//----------------------------------------------------------------------------//
// //
// Date History //
// ---------- -------------------------------------------------------------- //
// 26.06.2000 Initial version //
// 06.11.2000 Added Online-Documentation for Doxygen //
// //
//****************************************************************************//
//------------------------------------------------------------------------------
// CVS version information:
// $Id: canopen.h,v 1.2 2005/06/01 21:22:00 microcontrol Exp $
//------------------------------------------------------------------------------
#ifndef _CANOPEN_H_
#define _CANOPEN_H_
/*----------------------------------------------------------------------------*\
** Include files **
** **
\*----------------------------------------------------------------------------*/
#include "compiler.h" // datatype definitions
//-----------------------------------------------------------------------------
/*!
** \file canopen.h
** \brief General CANopen definitions
** \version \$Revision: 1.2 $
**
** The file canopen.h holds all definitions and structures that are
** necessary for a CANopen protocol stack.
*/
//-------------------------------------------------------------------
// identifier values for the pre-defined connection set
// the value used by the device is ID_BASE_XXX + node id
// direction has to be seen from the devices point of view
//
#define ID_BASE_SYNC 0x080
#define ID_BASE_EMCY 0x080
#define ID_BASE_PDO1_TX 0x180
#define ID_BASE_PDO1_RX 0x200
#define ID_BASE_PDO2_TX 0x280
#define ID_BASE_PDO2_RX 0x300
#define ID_BASE_SDO_TX 0x580
#define ID_BASE_SDO_RX 0x600
#define ID_BASE_NMT_ERR 0x700
//-------------------------------------------------------------------
/*!
** \enum SdoCmd_e
** \brief Command values for SDO transfer
**
*/
enum SdoCmd_e {
eSDO_WRITE_REQ_SEG = 0x21, /*! segmented write request */
eSDO_WRITE_REQ_0 = 0x22, /*! write request, unspecified length */
eSDO_WRITE_REQ_4 = 0x23, /*! write request, 4 bytes data */
eSDO_WRITE_REQ_3 = 0x27, /*! write request, 3 bytes data */
eSDO_WRITE_REQ_2 = 0x2B, /*! write request, 2 bytes data */
eSDO_WRITE_REQ_1 = 0x2F, /*! write request, 1 byte data */
eSDO_WRITE_RESP = 0x60, /*! response to write request */
eSDO_READ_REQ = 0x40, /*! read request */
eSDO_READ_RESP_SEG = 0x41, /*! read response, segmented data */
eSDO_READ_RESP_0 = 0x42, /*! read response, unspecified length */
eSDO_READ_RESP_4 = 0x43, /*! read response, 4 bytes data */
eSDO_READ_RESP_3 = 0x47, /*! read response, 3 bytes data */
eSDO_READ_RESP_2 = 0x4B, /*! read response, 2 bytes data */
eSDO_READ_RESP_1 = 0x4F, /*! read response, 1 byte data */
eSDO_READ_REQ_SEG_0 = 0x60, /*! read request, segmented data */
eSDO_READ_REQ_SEG_1 = 0x70, /*! read request, segmented data */
eSDO_BLK_UP_REQ_0 = 0xA0, /*! Init Block upload */
eSDO_BLK_UP_REQ_1 = 0xA4, /*! Init Block upload, CRC Info */
eSDO_BLK_DOWN_REQ_0 = 0xC0, /*! Initiate Block download */
eSDO_BLK_DOWN_REQ_1 = 0xC2, /*! Initiate Block download, size info */
eSDO_BLK_DOWN_REQ_2 = 0xC4, /*! Initiate Block download, CRC info */
eSDO_BLK_DOWN_REQ_3 = 0xC6, /*! Initiate Block download, CRC & size */
eSDO_ABORT = 0x80 /*! abort transmission */
};
/*----------------------------------------------------------------------------*\
** SDO abort codes **
** **
\*----------------------------------------------------------------------------*/
//-------------------------------------------------------------------
/*!
** \def SDO_ERR_TOGGLE_BIT
** \brief SDO Abort Code
**
** Toggle bit not altered.
*/
#define SDO_ERR_TOGGLE_BIT 0x05030000
//-------------------------------------------------------------------
/*!
** \def SDO_ERR_TIMEOUT
** \brief SDO Abort Code
**
** SDO protocol timed out.
*/
#define SDO_ERR_TIMEOUT 0x05040000
//-------------------------------------------------------------------
/*!
** \def SDO_ERR_COMMAND
** \brief SDO Abort Code
**
** Client/server command specifier not valid or unknown.
*/
#define SDO_ERR_COMMAND 0x05040001
//-------------------------------------------------------------------
/*!
** \def SDO_ERR_BLOCK_SIZE
** \brief SDO Abort Code
**
** Invalid block size (block mode only).
*/
#define SDO_ERR_BLOCK_SIZE 0x05040002
//-------------------------------------------------------------------
/*!
** \def SDO_ERR_BLOCK_SEQUENCE
** \brief SDO Abort Code
**
** Invalid block sequence number (block mode only).
*/
#define SDO_ERR_BLOCK_SEQUENCE 0x05040003
//-------------------------------------------------------------------
/*!
** \def SDO_ERR_BLOCK_CRC
** \brief SDO Abort Code
**
** Invalid block CRC value (block mode only).
*/
#define SDO_ERR_BLOCK_CRC 0x05040004
#define SDO_ERR_MEMORY 0x05040005
#define SDO_ERR_ACCESS_UNSUPPORTED 0x06010000
#define SDO_ERR_ACCESS_WO 0x06010001
#define SDO_ERR_ACCESS_RO 0x06010002
#define SDO_ERR_NO_OBJECT 0x06020000
#define SDO_ERR_MAPPING_OBJECT 0x06040041
#define SDO_ERR_MAPPING_LENGTH 0x06040042
#define SDO_ERR_GENERAL_PARAMETER 0x06040043
#define SDO_ERR_GENERAL_DEVICE 0x06040047
#define SDO_ERR_HARDWARE 0x06060000
#define SDO_ERR_DATATYPE 0x06070010
#define SDO_ERR_DATATYPE_HIGH 0x06070012
#define SDO_ERR_DATATYPE_LOW 0x06070013
#define SDO_ERR_NO_SUB_INDEX 0x06090011
#define SDO_ERR_VALUE_RANGE 0x06090030
#define SDO_ERR_VALUE_HIGH 0x06090031
#define SDO_ERR_VALUE_LOW 0x06090032
#define SDO_ERR_VALUE_MIN_MAX 0x06090036
#define SDO_ERR_GENERAL 0x08000000
#define SDO_ERR_DATA_STORE 0x08000020
#define SDO_ERR_DATA_STORE_LOCAL 0x08000021
#define SDO_ERR_DATA_STORE_STATE 0x08000022
#define SDO_ERR_OBJECT_DICTIONARY 0x08000023
//-----------------------------------------------------------------------------
/*!
** \enum CoATTR
** \brief Access Attributes for objects in dictionary
**
** Each object within the object dictionary can have the following access
** attributes:
** \li Read/Write
** \li Write Only
** \li Read Only
** \li Constant (value is Read Only)
**
** The member ubAttribute of the structure CosDicEntry_s is used for
** that purpose. By this enumeration the possible attributes are defined.
*/
enum CoATTR {
CoATTR_ACC_RO = 0x01, /*! object is read-only */
CoATTR_ACC_WO = 0x02, /*! object is write-only */
CoATTR_ACC_RW = 0x03, /*! object supports read-write access */
CoATTR_ACC_CONST = 0x05, /*! object is constant */
CoATTR_PDO_MAP = 0x10,
CoATTR_RES_1 = 0x20,
CoATTR_RES_2 = 0x40,
CoATTR_FUNCTION = 0x80 /*! function callback */
};
//-----------------------------------------------------------------------------
// attributes for the object dictionary
//
//-----------------------------------------------------------------------------
/*!
** \enum CoDT
** \brief Data Type definitions for objects in dictionary
**
** Each object within the object dictionary has a specific data type.
** The member ubDataType of the structure CoStruct_DicEntry is used for
** that purpose. By this enumeration the possible data types are defined.
**
*/
enum CoDT {
/*!
** data type: boolean value
*/
CoDT_BOOLEAN = 1,
/*!
** data type: Signed Integer, 1 byte
*/
CoDT_INTEGER8,
/*!
** data type: Signed Integer, 2 bytes
*/
CoDT_INTEGER16,
/*!
** data type: Signed Integer, 4 bytes
*/
CoDT_INTEGER32,
/*!
** data type: Unsigned Integer, 1 byte
*/
CoDT_UNSIGNED8,
/*!
** data type: Unsigned Integer, 2 bytes
*/
CoDT_UNSIGNED16,
/*!
** data type: Unsigned Integer, 4 bytes
*/
CoDT_UNSIGNED32,
/*!
** data type: Float, 32 bit according to IEEE
*/
CoDT_REAL32,
/*!
** data type: character string
*/
CoDT_VISIBLE_STRING,
/*!
** data type: octet string
*/
CoDT_OCTET_STRING,
/*!
** data type: unicode string
*/
CoDT_UNICODE_STRING,
/*!
** data type: time of day value
*/
CoDT_TIME_OF_DAY,
/*!
** data type: time difference value
*/
CoDT_TIME_DIFFERENCE
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -