Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:9509fece98da, committed 2016-05-12
- Comitter:
- wkane
- Date:
- Thu May 12 19:04:45 2016 +0000
- Commit message:
- ver1.0
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,1756 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** ABP - Anybus-CC Protocol Definitions.
+**
+** This software component contains protocol definitions used by Anybus-CC
+** modules as well as applications designed to use such modules.
+**
+** This file contains the generic portion used by all Anybus-CC modules.
+**
+** Network specific definitions that may be required by some applications are
+** published in the corresponding abp_xxx.h file(s).
+**
+********************************************************************************
+********************************************************************************
+**
+** Services List
+** -------------
+**
+** Public Services:
+**
+** ABP_SetMsgErrorResponse() - Convert message command to an error response.
+** ABP_SetMsgResponse() - Convert message command to a response.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2009 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_H_
+#define ABP_H_
+
+
+
+/*******************************************************************************
+**
+** ABCC operating mode constants
+**
+********************************************************************************
+*/
+
+#define ABP_OP_MODE_SPI 1
+#define ABP_OP_MODE_SHIFT_REGISTER 2
+#define ABP_OP_MODE_16_BIT_PARALLEL 7
+#define ABP_OP_MODE_8_BIT_PARALLEL 8
+#define ABP_OP_MODE_SERIAL_19_2 9
+#define ABP_OP_MODE_SERIAL_57_6 10
+#define ABP_OP_MODE_SERIAL_115_2 11
+#define ABP_OP_MODE_SERIAL_625 12
+
+
+/*******************************************************************************
+**
+** Common telegram and message constants
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** Control register bitmasks.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_CTRL_T_BIT 0x80
+#define ABP_CTRL_M_BIT 0x40
+#define ABP_CTRL_R_BIT 0x20
+#define ABP_CTRL_A_BIT 0x10
+#define ABP_CTRL_G_BIT 0x01
+
+
+/*------------------------------------------------------------------------------
+**
+** Status register bitmasks.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_STAT_T_BIT 0x80
+#define ABP_STAT_M_BIT 0x40
+#define ABP_STAT_R_BIT 0x20
+#define ABP_STAT_A_BIT 0x10
+#define ABP_STAT_SUP_BIT 0x08
+#define ABP_STAT_S_BITS 0x07
+
+
+/*------------------------------------------------------------------------------
+**
+** The maximum amount of process data in a telegram (in bytes).
+** Note: Used for ping-pong protocol on both NP30 and NP40.
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_MAX_PROCESS_DATA 256
+
+
+/*------------------------------------------------------------------------------
+**
+** The maximum amount of data in a message data field (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_MAX_MSG_255_DATA_BYTES 255
+#define ABP_MAX_MSG_DATA_BYTES 1524
+
+
+/*------------------------------------------------------------------------------
+**
+** Message header bitmasks.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_MSG_HEADER_C_BIT 0x40
+#define ABP_MSG_HEADER_E_BIT 0x80
+#define ABP_MSG_HEADER_CMD_BITS 0x3F
+
+
+/*------------------------------------------------------------------------------
+**
+** Message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_MsgCmdType
+{
+ ABP_CMD_GET_ATTR = 0x01, /* Get attribute */
+ ABP_CMD_SET_ATTR = 0x02, /* Set attribute */
+ ABP_CMD_CREATE = 0x03, /* Create */
+ ABP_CMD_DELETE = 0x04, /* Delete */
+ ABP_CMD_RESET = 0x05, /* Reset */
+ ABP_CMD_GET_ENUM_STR = 0x06, /* Get enumeration string */
+ ABP_CMD_GET_INDEXED_ATTR = 0x07, /* Get indexed attribute */
+ ABP_CMD_SET_INDEXED_ATTR = 0x08 /* Set indexed attribute */
+}
+ABP_MsgCmdType;
+
+
+/*------------------------------------------------------------------------------
+**
+** Reset command types.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_ResetType
+{
+ ABP_RESET_POWER_ON = 0x00, /* Power-on reset */
+ ABP_RESET_FACTORY_DEFAULT = 0x01, /* Factory default reset */
+ ABP_RESET_POWER_ON_FACTORY_DEFAULT = 0x02 /* Power-on + Factory reset */
+}
+ABP_ResetType;
+
+
+/*------------------------------------------------------------------------------
+**
+** Message error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_MsgErrorCodeType
+{
+ ABP_ERR_NO_ERROR = 0x00, /* No error */
+
+ ABP_ERR_INV_MSG_FORMAT = 0x02, /* Invalid message format */
+ ABP_ERR_UNSUP_OBJ = 0x03, /* Unsupported object */
+ ABP_ERR_UNSUP_INST = 0x04, /* Unsupported instance */
+ ABP_ERR_UNSUP_CMD = 0x05, /* Unsupported command */
+ ABP_ERR_INV_CMD_EXT_0 = 0x06, /* Invalid CmdExt[ 0 ] */
+ ABP_ERR_INV_CMD_EXT_1 = 0x07, /* Invalid CmdExt[ 1 ] */
+ ABP_ERR_ATTR_NOT_SETABLE = 0x08, /* Attribute access is not set-able */
+ ABP_ERR_ATTR_NOT_GETABLE = 0x09, /* Attribute access is not get-able */
+ ABP_ERR_TOO_MUCH_DATA = 0x0A, /* Too much data in msg data field */
+ ABP_ERR_NOT_ENOUGH_DATA = 0x0B, /* Not enough data in msg data field*/
+ ABP_ERR_OUT_OF_RANGE = 0x0C, /* Out of range */
+ ABP_ERR_INV_STATE = 0x0D, /* Invalid state */
+ ABP_ERR_NO_RESOURCES = 0x0E, /* Out of resources */
+ ABP_ERR_SEG_FAILURE = 0x0F, /* Segmentation failure */
+ ABP_ERR_SEG_BUF_OVERFLOW = 0x10, /* Segmentation buffer overflow */
+ ABP_ERR_VAL_TOO_HIGH = 0x11, /* Written data value is too high (ABCC40) */
+ ABP_ERR_VAL_TOO_LOW = 0x12, /* Written data value is too low (ABCC40) */
+ ABP_ERR_CONTROLLED_FROM_OTHER_CHANNEL = 0x13, /* NAK writes to "read process data" mapped attr. (ABCC40) */
+ ABP_ERR_MSG_CHANNEL_TOO_SMALL = 0x14, /* Response does not fit (ABCC40) */
+ ABP_ERR_GENERAL_ERROR = 0x15, /* General error (ABCC40) */
+ ABP_ERR_OBJ_SPECIFIC = 0xFF /* Object specific error */
+}
+ABP_MsgErrorCodeType;
+
+
+/*------------------------------------------------------------------------------
+**
+** Application status data type.
+**
+**------------------------------------------------------------------------------
+*/
+typedef enum ABP_AppStatusType
+{
+ ABP_APPSTAT_NO_ERROR = 0x0000,
+ ABP_APPSTAT_NOT_SYNCED = 0x0001,
+ ABP_APPSTAT_SYNC_CFG_ERR = 0x0002,
+ ABP_APPSTAT_READ_PD_CFG_ERR = 0x0003,
+ ABP_APPSTAT_WRITE_PD_CFG_ERR = 0x0004,
+ ABP_APPSTAT_SYNC_LOSS = 0x0005,
+ ABP_APPSTAT_PD_DATA_LOSS = 0x0006,
+ ABP_APPSTAT_OUTPUT_ERR = 0x0007
+}
+ABP_AppStatusType;
+
+
+/*******************************************************************************
+**
+** Anybus interface constants
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** Address memory offsets.
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_WRPD_ADR_OFFSET 0x0000
+#define ABP_RDPD_ADR_OFFSET 0x1000
+#define ABP_WRMSG_ADR_OFFSET 0x2000
+#define ABP_RDMSG_ADR_OFFSET 0x3000
+#define ABP_WRPDM_ADR_OFFSET 0x3800
+#define ABP_RDPDM_ADR_OFFSET 0x3900
+#define ABP_WRMSG_LEGACY_ADR_OFFSET 0x3B00
+#define ABP_RDMSG_LEGACY_ADR_OFFSET 0x3D00
+
+#define ABP_MODCAP_ADR_OFFSET 0x3FF0
+#define ABP_LEDSTATUS_ADR_OFFSET 0x3FF2
+#define ABP_APPSTATUS_ADR_OFFSET 0x3FF4
+#define ABP_ANBSTATUS_ADR_OFFSET 0x3FF6
+#define ABP_BUFCTRL_ADR_OFFSET 0x3FF8
+#define ABP_INTMASK_ADR_OFFSET 0x3FFA
+#define ABP_INTSTATUS_ADR_OFFSET 0x3FFC
+#define ABP_CONTROL_ADR_OFFSET 0x3FFE
+#define ABP_STATUS_ADR_OFFSET 0x3FFF
+
+
+/*------------------------------------------------------------------------------
+**
+** BUFCTRL Register.
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_BUFCTRL_WRPD 0x01
+#define ABP_BUFCTRL_RDPD 0x02
+#define ABP_BUFCTRL_WRMSG 0x04
+#define ABP_BUFCTRL_RDMSG 0x08
+#define ABP_BUFCTRL_ANBR 0x10
+#define ABP_BUFCTRL_APPR 0x20
+#define ABP_BUFCTRL_APPRCLR 0x40
+
+
+/*------------------------------------------------------------------------------
+**
+** INT STATUS Register.
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_INTSTATUS_RDPDI 0x01
+#define ABP_INTSTATUS_RDMSGI 0x02
+#define ABP_INTSTATUS_WRMSGI 0x04
+#define ABP_INTSTATUS_ANBRI 0x08
+#define ABP_INTSTATUS_STATUSI 0x10
+#define ABP_INTSTATUS_PWRI 0x20
+#define ABP_INTSTATUS_SYNCI 0x40
+
+
+/*------------------------------------------------------------------------------
+**
+** INT MASK Register.
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_INTMASK_RDPDIEN 0x01
+#define ABP_INTMASK_RDMSGIEN 0x02
+#define ABP_INTMASK_WRMSGIEN 0x04
+#define ABP_INTMASK_ANBRIEN 0x08
+#define ABP_INTMASK_STATUSIEN 0x10
+#define ABP_INTMASK_SYNCIEN 0x40
+
+
+/*------------------------------------------------------------------------------
+**
+** SPI control word in MOSI frame
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_SPI_CTRL_WRPD_VALID 0x01
+#define ABP_SPI_CTRL_CMDCNT 0x06
+#define ABP_SPI_CTRL_M 0x08
+#define ABP_SPI_CTRL_LAST_FRAG 0x10
+#define ABP_SPI_CTRL_T 0x80
+
+
+
+/*------------------------------------------------------------------------------
+**
+** SPI status word in MISO frame
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_SPI_STATUS_WRMSG_FULL 0x01
+#define ABP_SPI_STATUS_CMDCNT 0x06
+#define ABP_SPI_STATUS_M 0x08
+#define ABP_SPI_STATUS_LAST_FRAG 0x10
+#define ABP_SPI_STATUS_NEW_PD 0x20
+
+
+/*******************************************************************************
+**
+** ABCC module type constants
+**
+********************************************************************************
+*/
+#define ABP_MODULE_TYPE_ABCC 0x0401 /* ABCC30 */
+#define ABP_MODULE_TYPE_ABCC_DRIVE_PROFILE 0x0402
+#define ABP_MODULE_TYPE_ABCC_40 0x0403
+
+
+/*******************************************************************************
+**
+** ABCC module id constants
+** MI1 MI0
+** 0 0 ( 0) Active CompactCom 30-series
+** 0 1 ( 1 ) Passive CompactCom
+** 1 0 ( 2 ) Active CompactCom 40-series
+** 1 1 ( 3 ) Customer specific
+********************************************************************************
+*/
+#define ABP_MODULE_ID_ACTIVE_ABCC30 0
+#define ABP_MODULE_ID_PASSIVE_ABCC 1
+#define ABP_MODULE_ID_ACTIVE_ABCC40 2
+#define ABP_MODULE_ID_CUSTOMER_SPECIFIC 3
+
+/*******************************************************************************
+**
+** ABCC network types
+**
+********************************************************************************
+*/
+
+#define ABP_NW_TYPE_PDPV0 0x0001 /* PROFIBUS DP-V0 */
+#define ABP_NW_TYPE_PDPV1 0x0005 /* PROFIBUS DP-V1 */
+#define ABP_NW_TYPE_COP 0x0020 /* CANopen */
+#define ABP_NW_TYPE_DEV 0x0025 /* DeviceNet */
+#define ABP_NW_TYPE_CNT 0x0065 /* ControlNet */
+#define ABP_NW_TYPE_PRT 0x0084 /* PROFINET RT */
+#define ABP_NW_TYPE_EIP_1P 0x0085 /* EtherNet/IP */
+#define ABP_NW_TYPE_ECT 0x0087 /* EtherCAT */
+#define ABP_NW_TYPE_PIR 0x0089 /* PROFINET IRT */
+#define ABP_NW_TYPE_CCL 0x0090 /* CC-Link */
+#define ABP_NW_TYPE_CPN 0x0095 /* CompoNet */
+#define ABP_NW_TYPE_PRT_2P 0x0096 /* PROFINET RT 2-port */
+#define ABP_NW_TYPE_EIP_2P_BB 0x009B /* EtherNet/IP 2-Port BB DLR */
+#define ABP_NW_TYPE_EIP_2P 0x009C /* EtherNet/IP 2-Port */
+#define ABP_NW_TYPE_EPL 0x009F /* POWERLINK */
+
+
+
+
+
+
+/*******************************************************************************
+**
+** Anybus-CC data types.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Anybus-CC data type numbers.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_BOOL 0 /* Boolean */
+#define ABP_SINT8 1 /* Signed 8 bit integer */
+#define ABP_SINT16 2 /* Signed 16 bit integer */
+#define ABP_SINT32 3 /* Signed 32 bit integer */
+#define ABP_UINT8 4 /* Unsigned 8 bit integer */
+#define ABP_UINT16 5 /* Unsigned 16 bit integer */
+#define ABP_UINT32 6 /* Unsigned 32 bit integer */
+#define ABP_CHAR 7 /* Character */
+#define ABP_ENUM 8 /* Enumeration */
+#define ABP_BITS8 9 /* 8 bit bitfield (ABCC40) */
+#define ABP_BITS16 10 /* 16 bit bitfield (ABCC40) */
+#define ABP_BITS32 11 /* 32 bit bitfield (ABCC40) */
+#define ABP_OCTET 12 /* 8 bit data (ABCC40) */
+
+#define ABP_SINT64 16 /* Signed 64 bit integer */
+#define ABP_UINT64 17 /* Unsigned 64 bit integer */
+#define ABP_FLOAT 18 /* Floating point/real number */
+
+#define ABP_PAD0 32 /* Padding bitfield (ABCC40) */
+#define ABP_PAD1 33 /* Padding bitfield (ABCC40) */
+#define ABP_PAD2 34 /* Padding bitfield (ABCC40) */
+#define ABP_PAD3 35 /* Padding bitfield (ABCC40) */
+#define ABP_PAD4 36 /* Padding bitfield (ABCC40) */
+#define ABP_PAD5 37 /* Padding bitfield (ABCC40) */
+#define ABP_PAD6 38 /* Padding bitfield (ABCC40) */
+#define ABP_PAD7 39 /* Padding bitfield (ABCC40) */
+#define ABP_PAD8 40 /* Padding bitfield (ABCC40) */
+#define ABP_PAD9 41 /* Padding bitfield (ABCC40) */
+#define ABP_PAD10 42 /* Padding bitfield (ABCC40) */
+#define ABP_PAD11 43 /* Padding bitfield (ABCC40) */
+#define ABP_PAD12 44 /* Padding bitfield (ABCC40) */
+#define ABP_PAD13 45 /* Padding bitfield (ABCC40) */
+#define ABP_PAD14 46 /* Padding bitfield (ABCC40) */
+#define ABP_PAD15 47 /* Padding bitfield (ABCC40) */
+#define ABP_PAD16 48 /* Padding bitfield (ABCC40) */
+
+#define ABP_BIT1 65 /* 1 bit bitfield (ABCC40) */
+#define ABP_BIT2 66 /* 2 bit bitfield (ABCC40) */
+#define ABP_BIT3 67 /* 3 bit bitfield (ABCC40) */
+#define ABP_BIT4 68 /* 4 bit bitfield (ABCC40) */
+#define ABP_BIT5 69 /* 5 bit bitfield (ABCC40) */
+#define ABP_BIT6 70 /* 6 bit bitfield (ABCC40) */
+#define ABP_BIT7 71 /* 7 bit bitfield (ABCC40) */
+
+
+/*------------------------------------------------------------------------------
+**
+** The size of the Anybus-CC data types (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_BOOL_SIZEOF 1 /* Boolean */
+#define ABP_SINT8_SIZEOF 1 /* Signed 8 bit integer */
+#define ABP_SINT16_SIZEOF 2 /* Signed 16 bit integer */
+#define ABP_SINT32_SIZEOF 4 /* Signed 32 bit integer */
+#define ABP_UINT8_SIZEOF 1 /* Unsigned 8 bit integer */
+#define ABP_UINT16_SIZEOF 2 /* Unsigned 16 bit integer */
+#define ABP_UINT32_SIZEOF 4 /* Unsigned 32 bit integer */
+#define ABP_CHAR_SIZEOF 1 /* Character */
+#define ABP_ENUM_SIZEOF 1 /* Enumeration */
+#define ABP_BITS8_SIZEOF 1 /* 8 bit bitfield (ABCC40) */
+#define ABP_BITS16_SIZEOF 2 /* 16 bit bitfield (ABCC40) */
+#define ABP_BITS32_SIZEOF 4 /* 32 bit bitfield (ABCC40) */
+#define ABP_OCTET_SIZEOF 1 /* 8 bit data (ABCC40) */
+
+#define ABP_SINT64_SIZEOF 8 /* Signed 64 bit integer */
+#define ABP_UINT64_SIZEOF 8 /* Unsigned 64 bit integer */
+#define ABP_FLOAT_SIZEOF 4 /* Floating point/real number */
+
+
+/*------------------------------------------------------------------------------
+**
+** The Anybus-CC data type maximum values.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_BOOL_MAX !0
+#define ABP_SINT8_MAX 0x7F
+#define ABP_SINT16_MAX 0x7FFF
+#define ABP_SINT32_MAX 0x7FFFFFFFL
+#define ABP_UINT8_MAX 0xFFU
+#define ABP_UINT16_MAX 0xFFFFU
+#define ABP_UINT32_MAX 0xFFFFFFFFLU
+#define ABP_CHAR_MAX 0xFFU
+#define ABP_ENUM_MAX 0xFFU
+#define ABP_BITS8_MAX 0xFFU /* ABCC40 */
+#define ABP_BITS16_MAX 0xFFFFU /* ABCC40 */
+#define ABP_BITS32_MAX 0xFFFFFFFFLU /* ABCC40 */
+#define ABP_OCTET_MAX 0xFFU /* ABCC40 */
+
+#define ABP_SINT64_MAX 0x7FFFFFFFFFFFFFFFL
+#define ABP_UINT64_MAX 0xFFFFFFFFFFFFFFFFLU
+#define ABP_FLOAT_MAX 3.40282347E+38F
+
+#define ABP_BITS1_MAX 0x1 /* ABCC40 */
+#define ABP_BITS2_MAX 0x3 /* ABCC40 */
+#define ABP_BITS3_MAX 0x7 /* ABCC40 */
+#define ABP_BITS4_MAX 0xF /* ABCC40 */
+#define ABP_BITS5_MAX 0x1F /* ABCC40 */
+#define ABP_BITS6_MAX 0x3F /* ABCC40 */
+#define ABP_BITS7_MAX 0x7F /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The Anybus-CC data type minimum values.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_BOOL_MIN 0
+#define ABP_SINT8_MIN ( - ABP_SINT8_MAX - 1 )
+#define ABP_SINT16_MIN ( - ABP_SINT16_MAX - 1 )
+#define ABP_SINT32_MIN ( - ABP_SINT32_MAX - 1L )
+#define ABP_UINT8_MIN 0
+#define ABP_UINT16_MIN 0
+#define ABP_UINT32_MIN 0
+#define ABP_CHAR_MIN 0
+#define ABP_ENUM_MIN 0
+#define ABP_BITS8_MIN 0 /* ABCC40 */
+#define ABP_BITS16_MIN 0 /* ABCC40 */
+#define ABP_BITS32_MIN 0 /* ABCC40 */
+#define ABP_OCTET_MIN 0 /* ABCC40 */
+
+#define ABP_SINT64_MIN ( - ABP_SINT64_MAX - 1 )
+#define ABP_UINT64_MIN 0
+#define ABP_FLOAT_MIN 1.17549435E-38F
+
+#define ABP_BITS1_MIN 0 /* ABCC40 */
+#define ABP_BITS2_MIN 0 /* ABCC40 */
+#define ABP_BITS3_MIN 0 /* ABCC40 */
+#define ABP_BITS4_MIN 0 /* ABCC40 */
+#define ABP_BITS5_MIN 0 /* ABCC40 */
+#define ABP_BITS6_MIN 0 /* ABCC40 */
+#define ABP_BITS7_MIN 0 /* ABCC40 */
+
+
+/*******************************************************************************
+**
+** The languages supported by multilingual objects.
+**
+********************************************************************************
+*/
+
+typedef enum ABP_LangType
+{
+ ABP_LANG_ENG, /* English */
+ ABP_LANG_DEU, /* German */
+ ABP_LANG_SPA, /* Spanish */
+ ABP_LANG_ITA, /* Italian */
+ ABP_LANG_FRA, /* French */
+
+ ABP_LANG_NUM_LANG /* Number of supported languages */
+}
+ABP_LangType;
+
+
+/*******************************************************************************
+**
+** Anybus-CC protocol object number pool.
+**
+** Each object, whether its a network specific or a common object, an Anybus
+** module or a host application object, must have a unique object number. This
+** number list is therefore common to both the application and the Anybus.
+**
+** Anybus objects are numbered from 1 and up while application objects
+** are numbered from 255 and down.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Anybus module objects
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_OBJ_NUM_ANB 1 /* Anybus */
+#define ABP_OBJ_NUM_DI 2 /* Diagnostic */
+#define ABP_OBJ_NUM_NW 3 /* Network */
+#define ABP_OBJ_NUM_NC 4 /* Network Configuration */
+#define ABP_OBJ_NUM_ADD 5 /* PROFIBUS DP-V1 Additional Diag */
+#define ABP_OBJ_NUM_RSV1 6 /* Reserved */
+#define ABP_OBJ_NUM_SOC 7 /* Socket Interface */
+#define ABP_OBJ_NUM_NWCCL 8 /* Network CC-Link */
+#define ABP_OBJ_NUM_SMTP 9 /* SMTP Client */
+#define ABP_OBJ_NUM_FSI 10 /* File System Interface */
+#define ABP_OBJ_NUM_NWDPV1 11 /* Network PROFIBUS DP-V1 */
+#define ABP_OBJ_NUM_NWETN 12 /* Network Ethernet */
+#define ABP_OBJ_NUM_CPC 13 /* CIP Port Configuration */
+#define ABP_OBJ_NUM_NWPNIO 14 /* Network PROFINET IO */
+#define ABP_OBJ_NUM_PNIOADD 15 /* PROFINET IO Additional Diag */
+#define ABP_OBJ_NUM_DPV0DI 16 /* PROFIBUS DP-V0 Diagnostic */
+#define ABP_OBJ_NUM_FUSM 17 /* Functional Safety Module */
+
+
+/*------------------------------------------------------------------------------
+** Host application objects
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_OBJ_NUM_ER 231 /* Energy Reporting */
+#define ABP_OBJ_NUM_SAFE 232 /* Functional Safety */
+#define ABP_OBJ_NUM_EPL 233 /* POWERLINK */
+#define ABP_OBJ_NUM_AFSI 234 /* Application File System Interface*/
+#define ABP_OBJ_NUM_ASM 235 /* Assembly mapping object */
+#define ABP_OBJ_NUM_MDD 236 /* Modular device */
+#define ABP_OBJ_NUM_CIPID 237 /* CIP Identity */
+#define ABP_OBJ_NUM_SYNC 238 /* Sync */
+#define ABP_OBJ_NUM_BAC 239 /* BACnet */
+#define ABP_OBJ_NUM_ECO 240 /* Energy Control */
+#define ABP_OBJ_NUM_SRC3 241 /* SERCOS III */
+#define ABP_OBJ_NUM_PRD 242 /* PROFIdrive */
+#define ABP_OBJ_NUM_CNT 243 /* ControlNet */
+#define ABP_OBJ_NUM_CPN 244 /* CompoNet */
+#define ABP_OBJ_NUM_ECT 245 /* EtherCAT */
+#define ABP_OBJ_NUM_PNIO 246 /* PROFINET IO */
+#define ABP_OBJ_NUM_CCL 247 /* CC-Link */
+#define ABP_OBJ_NUM_EIP 248 /* EtherNet/IP */
+#define ABP_OBJ_NUM_ETN 249 /* Ethernet */
+#define ABP_OBJ_NUM_MOD 250 /* Modbus */
+#define ABP_OBJ_NUM_COP 251 /* CANopen */
+#define ABP_OBJ_NUM_DEV 252 /* DeviceNet */
+#define ABP_OBJ_NUM_DPV1 253 /* PROFIBUS DP-V1 */
+#define ABP_OBJ_NUM_APPD 254 /* Application Data */
+#define ABP_OBJ_NUM_APP 255 /* Application */
+
+
+/*******************************************************************************
+**
+** Common object constants.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The object standard attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_OA_NAME 1 /* Object name */
+#define ABP_OA_REV 2 /* Object revision */
+#define ABP_OA_NUM_INST 3 /* Current number of instances */
+#define ABP_OA_HIGHEST_INST 4 /* Current highest instance number */
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the object standard attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_OA_REV_DS ABP_UINT8_SIZEOF
+#define ABP_OA_NUM_INST_DS ABP_UINT16_SIZEOF
+#define ABP_OA_HIGHEST_INST_DS ABP_UINT16_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** The object instance number.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_INST_OBJ 0
+
+
+/*******************************************************************************
+**
+** Anybus object constants.
+**
+** Object revision: 4.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Anybus instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ANB_IA_MODULE_TYPE 1
+#define ABP_ANB_IA_FW_VERSION 2
+#define ABP_ANB_IA_SERIAL_NUM 3
+#define ABP_ANB_IA_WD_TIMEOUT 4
+#define ABP_ANB_IA_SETUP_COMPLETE 5
+#define ABP_ANB_IA_EXCEPTION 6
+#define ABP_ANB_IA_FATAL_EVENT 7
+#define ABP_ANB_IA_ERROR_CNTRS 8
+#define ABP_ANB_IA_LANG 9
+#define ABP_ANB_IA_PROVIDER_ID 10
+#define ABP_ANB_IA_PROVIDER_INFO 11
+#define ABP_ANB_IA_LED_COLOURS 12
+#define ABP_ANB_IA_LED_STATUS 13
+#define ABP_ANB_IA_SWITCH_STATUS 14
+#define ABP_ANB_IA_AUX_BIT_FUNC 15
+#define ABP_ANB_IA_GPIO_CONFIG 16
+#define ABP_ANB_IA_VIRTUAL_ATTRS 17 /* ABCC40 */
+#define ABP_ANB_IA_BLACK_WHITE_LIST 18 /* ABCC40 */
+#define ABP_ANB_IA_NETWORK_TIME 19 /* ABCC40 */
+#define ABP_ANB_IA_FW_CUST_VERSION 20 /* ABCC40 */
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Anybus instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ANB_IA_MODULE_TYPE_DS ABP_UINT16_SIZEOF
+#define ABP_ANB_IA_FW_VERSION_DS ( 3 * ABP_UINT8_SIZEOF )
+#define ABP_ANB_IA_SERIAL_NUM_DS ABP_UINT32_SIZEOF
+#define ABP_ANB_IA_WD_TIMEOUT_DS ABP_UINT16_SIZEOF
+#define ABP_ANB_IA_SETUP_COMPLETE_DS ABP_BOOL_SIZEOF
+#define ABP_ANB_IA_EXCEPTION_DS ABP_ENUM_SIZEOF
+#define ABP_ANB_IA_ERROR_CNTRS_DS ( 4 * ABP_UINT16_SIZEOF )
+#define ABP_ANB_IA_LANG_DS ABP_ENUM_SIZEOF
+#define ABP_ANB_IA_PROVIDER_ID_DS ABP_UINT16_SIZEOF
+#define ABP_ANB_IA_PROVIDER_INFO_DS ABP_UINT16_SIZEOF
+#define ABP_ANB_IA_LED_COLOURS_DS ( 4 * ABP_UINT8_SIZEOF )
+#define ABP_ANB_IA_LED_STATUS_DS ABP_UINT8_SIZEOF
+#define ABP_ANB_IA_SWITCH_STATUS_DS ( 2 * ABP_UINT8_SIZEOF )
+#define ABP_ANB_IA_AUX_BIT_FUNC_DS ABP_UINT8_SIZEOF
+#define ABP_ANB_IA_GPIO_CONFIG_DS ABP_UINT16_SIZEOF
+#define ABP_ANB_IA_VIRTUAL_ATTRS_DS 1524 /* ABCC40 */
+#define ABP_ANB_IA_BLACK_WHITE_LIST_DS ( 12 * ABP_UINT16_SIZEOF ) /* ABCC40 */
+#define ABP_ANB_IA_NETWORK_TIME_DS ABP_UINT64_SIZEOF /* ABCC40 */
+#define ABP_ANB_IA_FW_CUST_VERSION_DS ABP_UINT8_SIZEOF /* ABCC40 */
+
+/*------------------------------------------------------------------------------
+**
+** The Anybus object specific error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ANB_ERR_INV_PRD_CFG 0x01 /* Invalid process data config */
+#define ABP_ANB_ERR_INV_DEV_ADDR 0x02 /* Invalid device address */
+#define ABP_ANB_ERR_INV_COM_SETTINGS 0x03 /* Invalid communication settings */
+
+
+/*------------------------------------------------------------------------------
+**
+** Anybus state.
+**
+** The current Anybus state is presented by status bits S[0..2] of the
+** status register, transferred to the application in each telegram.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_AnbStateType
+{
+ ABP_ANB_STATE_SETUP = 0x00,
+ ABP_ANB_STATE_NW_INIT = 0x01,
+ ABP_ANB_STATE_WAIT_PROCESS = 0x02,
+ ABP_ANB_STATE_IDLE = 0x03,
+ ABP_ANB_STATE_PROCESS_ACTIVE = 0x04,
+ ABP_ANB_STATE_ERROR = 0x05,
+ ABP_ANB_STATE_EXCEPTION = 0x07
+}
+ABP_AnbStateType;
+
+
+/*------------------------------------------------------------------------------
+**
+** Anybus exception codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_AnbExceptionCodeType
+{
+ ABP_ANB_EXCPT_NONE = 0x00, /* No exception */
+ ABP_ANB_EXCPT_APP_TO = 0x01, /* Application timeout */
+ ABP_ANB_EXCPT_INV_DEV_ADDR = 0x02, /* Invalid device address */
+ ABP_ANB_EXCPT_INV_COM_SETTINGS = 0x03, /* Invalid communication settings */
+ ABP_ANB_EXCPT_MAJ_UNREC_APP_EVNT = 0x04, /* Major unrecoverable app event */
+ ABP_ANB_EXCPT_WAIT_APP_RESET = 0x05, /* Waiting for application reset */
+ ABP_ANB_EXCPT_INV_PRD_CFG = 0x06, /* Invalid process data config */
+ ABP_ANB_EXCPT_INV_APP_RESPONSE = 0x07, /* Invalid application response */
+ ABP_ANB_EXCPT_NVS_CHECKSUM_ERROR = 0x08, /* NVS memory checksum error */
+ ABP_ANB_EXCPT_FUSM_ERROR = 0x09, /* Functional Safety Module error */
+ ABP_ANB_EXCPT_INSUFF_APPL_IMPL = 0x0A, /* Insufficient application impl. */
+ ABP_ANB_EXCPT_MISSING_SERIAL_NUM = 0x0B, /* Missing serial number */
+
+ ABP_ANB_EXCPT_NUM_CODES /* Number of exception codes */
+}
+ABP_AnbExceptionCodeType;
+
+
+/*------------------------------------------------------------------------------
+**
+** LED colour codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ANB_LED_COLOUR_NONE 0x00
+#define ABP_ANB_LED_COLOUR_GREEN 0x01
+#define ABP_ANB_LED_COLOUR_RED 0x02
+#define ABP_ANB_LED_COLOUR_YELLOW 0x03
+#define ABP_ANB_LED_COLOUR_ORANGE 0x04
+#define ABP_ANB_LED_COLOUR_BLUE 0x05
+#define ABP_ANB_LED_COLOUR_WHITE 0x06
+
+
+/*------------------------------------------------------------------------------
+**
+** Auxiliary bit functionality codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ANB_AUX_BIT_FUNC_NONE 0x00 /* Not used */
+#define ABP_ANB_AUX_BIT_FUNC_CDI 0x01 /* Changed data indication */
+
+
+/*------------------------------------------------------------------------------
+**
+** GPIO configuration codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ANB_GPIO_CONFIG_STD 0x00 /* Standard GPIO */
+#define ABP_ANB_GPIO_CONFIG_EXT_LED 0x01 /* Extended LED functionality */
+#define ABP_ANB_GPIO_CONFIG_RMII 0x02 /* RMII functionality */
+
+
+/*******************************************************************************
+**
+** Diagnostic object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Diagnostic object specific object attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DI_OA_MAX_INST 11 /* Max number of instances */
+#define ABP_DI_OA_SUPPORT_FUNC 12 /* Supported functionality (ABCC40) */
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Diagnostic object specific attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DI_OA_MAX_INST_DS ABP_UINT16_SIZEOF
+#define ABP_DI_OA_SUPPORT_FUNC_DS ABP_BITS32_SIZEOF /* ABCC40 */
+
+/*------------------------------------------------------------------------------
+**
+** Supported functionality bit masks
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DI_OA_SUPPORT_FUNC_LATCH_EVENT_BIT 1
+
+/*------------------------------------------------------------------------------
+**
+** The Diagnostic instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DI_IA_SEVERITY 1
+#define ABP_DI_IA_EVENT_CODE 2
+#define ABP_DI_IA_NW_SPEC_EVENT_INFO 3
+#define ABP_DI_IA_SLOT 4 /* ABCC40 */
+#define ABP_DI_IA_ADI 5 /* ABCC40 */
+#define ABP_DI_IA_ELEMENT 6 /* ABCC40 */
+#define ABP_DI_IA_BIT 7 /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Diagnostic instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DI_IA_SEVERITY_DS ABP_UINT8_SIZEOF
+#define ABP_DI_IA_EVENT_CODE_DS ABP_UINT8_SIZEOF
+#define ABP_DI_IA_SLOT_DS ABP_UINT16_SIZEOF /* ABCC40 */
+#define ABP_DI_IA_ADI_DS ABP_UINT16_SIZEOF /* ABCC40 */
+#define ABP_DI_IA_ELEMENT_DS ABP_UINT8_SIZEOF /* ABCC40 */
+#define ABP_DI_IA_BIT_DS ABP_UINT8_SIZEOF /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The Diagnostic object specific error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DI_ERR_NOT_REMOVED 0x01 /* Event could not be removed */
+#define ABP_DI_LATCH_NOT_SUPPORTED 0x02 /* Latching events not supported */
+#define ABP_DI_ERR_NW_SPECIFIC 0xFF /* Network specific error */
+
+
+/*------------------------------------------------------------------------------
+**
+** Diagnostic object event severity.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_DiEventSeverityType
+{
+ ABP_DI_EVENT_SEVERITY_MINOR_REC = 0x00, /* Minor, recoverable */
+ ABP_DI_EVENT_SEVERITY_MINOR_UNREC = 0x10, /* Minor, unrecoverable */
+ ABP_DI_EVENT_SEVERITY_MAJOR_REC = 0x20, /* Major, recoverable */
+ ABP_DI_EVENT_SEVERITY_MAJOR_UNREC = 0x30, /* Major, unrecoverable */
+ ABP_DI_EVENT_SEVERITY_MINOR_LATCH = 0x50, /* Minor, recoverable latching (ABCC40) */
+ ABP_DI_EVENT_SEVERITY_MAJOR_LATCH = 0x60 /* Major, recoverable latching (ABCC40) */
+}
+ABP_DiEventSeverityType;
+
+/*------------------------------------------------------------------------------
+**
+** Diagnostic object Create CmdExt0 bit masks
+**
+**------------------------------------------------------------------------------
+*/
+#define ABP_DI_CREATE_CMDEXT0_SEVERITY_BITS 0x70
+#define ABP_DI_CREATE_CMDEXT0_EXT_DIAG_BIT 0x01
+
+/*------------------------------------------------------------------------------
+**
+** Diagnostic object event codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_DiEventCodeType
+{
+ ABP_DI_EVENT_NONE = 0x00, /* No event */
+ ABP_DI_EVENT_GENERIC_ERROR = 0x10, /* Generic Error */
+ ABP_DI_EVENT_CURRENT = 0x20, /* Current */
+ ABP_DI_EVENT_CURRENT_DEVICE_INPUT = 0x21, /* Current, device input side */
+ ABP_DI_EVENT_CURRENT_INSIDE = 0x22, /* Current, inside the device */
+ ABP_DI_EVENT_CURRENT_DEVICE_OUTPUT = 0x23, /* Current, device output side */
+ ABP_DI_EVENT_VOLTAGE = 0x30, /* Voltage */
+ ABP_DI_EVENT_MAINS_VOLTAGE = 0x31, /* Mains Voltage */
+ ABP_DI_EVENT_VOLTAGE_INSIDE_DEVICE = 0x32, /* Voltage inside the device */
+ ABP_DI_EVENT_OUTPUT_VOLTAGE = 0x33, /* Output Voltage */
+ ABP_DI_EVENT_TEMPERATURE = 0x40, /* Temperature */
+ ABP_DI_EVENT_AMBIENT_TEMPERATURE = 0x41, /* Ambient Temperature */
+ ABP_DI_EVENT_DEVICE_TEMPERATURE = 0x42, /* Device Temperature */
+ ABP_DI_EVENT_DEVICE_HARDWARE = 0x50, /* Device Hardware */
+ ABP_DI_EVENT_DEVICE_SOFTWARE = 0x60, /* Device Software */
+ ABP_DI_EVENT_INTERNAL_SOFTWARE = 0x61, /* Internal Software */
+ ABP_DI_EVENT_USER_SOFTWARE = 0x62, /* User Software */
+ ABP_DI_EVENT_DATA_SET = 0x63, /* Data Set */
+ ABP_DI_EVENT_ADDITIONAL_MODULES = 0x70, /* Additional Modules */
+ ABP_DI_EVENT_MONITORING = 0x80, /* Monitoring */
+ ABP_DI_EVENT_COMMUNICATION = 0x81, /* Communication */
+ ABP_DI_EVENT_PROTOCOL_ERROR = 0x82, /* Protocol Error */
+ ABP_DI_EVENT_EXTERNAL_ERROR = 0x90, /* External Error */
+ ABP_DI_EVENT_ADDITIONAL_FUNCTIONS = 0xF0, /* Additional Functions */
+ ABP_DI_EVENT_NW_SPECIFIC = 0xFF /* Network specific */
+}
+ABP_DiEventCodeType;
+
+
+/*******************************************************************************
+**
+** Network object constants.
+**
+** Object revision: 2.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Network instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NW_IA_NW_TYPE 1
+#define ABP_NW_IA_NW_TYPE_STR 2
+#define ABP_NW_IA_DATA_FORMAT 3
+#define ABP_NW_IA_PARAM_SUPPORT 4
+#define ABP_NW_IA_WRITE_PD_SIZE 5
+#define ABP_NW_IA_READ_PD_SIZE 6
+#define ABP_NW_IA_EXCEPTION_INFO 7
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Network instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NW_IA_NW_TYPE_DS ABP_UINT16_SIZEOF
+#define ABP_NW_IA_DATA_FORMAT_DS ABP_ENUM_SIZEOF
+#define ABP_NW_IA_PARAM_SUPPORT_DS ABP_BOOL_SIZEOF
+#define ABP_NW_IA_WRITE_PD_SIZE_DS ABP_UINT16_SIZEOF
+#define ABP_NW_IA_READ_PD_SIZE_DS ABP_UINT16_SIZEOF
+#define ABP_NW_IA_EXCEPTION_INFO_DS ABP_UINT8_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** The Network object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NW_CMD_MAP_ADI_WRITE_AREA 0x10
+#define ABP_NW_CMD_MAP_ADI_READ_AREA 0x11
+#define ABP_NW_CMD_MAP_ADI_WRITE_EXT_AREA 0x12
+#define ABP_NW_CMD_MAP_ADI_READ_EXT_AREA 0x13
+
+
+/*------------------------------------------------------------------------------
+**
+** The Network object specific error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NW_ERR_INVALID_ADI_DATA_TYPE 0x01 /* Invalid ADI data type */
+#define ABP_NW_ERR_INVALID_NUM_ELEMENTS 0x02 /* Invalid number of elements */
+#define ABP_NW_ERR_INVALID_TOTAL_SIZE 0x03 /* Invalid total size */
+#define ABP_NW_ERR_MULTIPLE_MAPPING 0x04 /* Multiple mapping */
+#define ABP_NW_ERR_INVALID_ORDER_NUM 0x05 /* Invalid ADI order number */
+#define ABP_NW_ERR_INVALID_MAP_CMD_SEQ 0x06 /* Invalid mapp cmd sequence */
+#define ABP_NW_ERR_INVALID_MAP_CMD 0x07 /* Command impossible to parse */
+#define ABP_NW_ERR_BAD_ALIGNMENT 0x08 /* Invalid data alignment */
+#define ABP_NW_ERR_INVALID_ADI_0 0x09 /* Invalid use of ADI 0 */
+#define ABP_NW_ERR_NW_SPEC_RESTRICTION 0xFF /* Network specific restriction */
+
+
+/*------------------------------------------------------------------------------
+**
+** Common Network specific exception information codes.
+**
+** Please see the network specific header file for the remaining codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NW_EXCPT_INFO_NONE 0x00 /* No information */
+
+
+/*******************************************************************************
+**
+** Network configuration object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Network configuration instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NC_VAR_IA_NAME 1
+#define ABP_NC_VAR_IA_DATA_TYPE 2
+#define ABP_NC_VAR_IA_NUM_ELEM 3
+#define ABP_NC_VAR_IA_DESCRIPTOR 4
+#define ABP_NC_VAR_IA_VALUE 5
+#define ABP_NC_VAR_IA_CONFIG_VALUE 6 /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Network configuration instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NC_VAR_IA_DATA_TYPE_DS ABP_UINT8_SIZEOF
+#define ABP_NC_VAR_IA_NUM_ELEM_DS ABP_UINT8_SIZEOF
+#define ABP_NC_VAR_IA_DESCRIPTOR_DS ABP_UINT8_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** The Network configuration instance attribute descriptor bits.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NC_DESCR_GET_ACCESS 0x01
+#define ABP_NC_DESCR_SET_ACCESS 0x02
+#define ABP_NC_DESCR_SHARED_ACCESS 0x04
+
+
+/*------------------------------------------------------------------------------
+**
+** The Network configuration instances common to most Anybus-CC modules.
+**
+** Note:
+** 1. Although all Network configuration instances are network specific,
+** the instances listed here are meant to offer some degree of ANY
+** functionality in that they are always of an eight-bit data type and
+** that they may be set by the application during setup.
+**
+** 2. In case the values of these instances originate from input devices
+** controlled by the end user (DIP switches or similar), the application
+** shall keep these instances updated at all times because some networks
+** require that a changed switch is indicated by the LEDs.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NC_INST_NUM_SW1 0x01
+#define ABP_NC_INST_NUM_SW2 0x02
+
+
+/*******************************************************************************
+**
+** Application data object constants.
+**
+** Object revision: 3.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** Application data object specific attributes (ABCC40)
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_OA_NR_READ_PD_MAPPABLE_INSTANCES 11
+#define ABP_APPD_OA_NR_WRITE_PD_MAPPABLE_INSTANCES 12
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Diagnostic object specific attrs, in bytes. (ABCC40)
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_OA_NR_READ_PD_MAPPABLE_INSTANCES_DS ABP_UINT16_SIZEOF
+#define ABP_APPD_OA_NR_WRITE_PD_MAPPABLE_INSTANCES_DS ABP_UINT16_SIZEOF
+
+/*------------------------------------------------------------------------------
+**
+** The Application data object instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_IA_NAME 1
+#define ABP_APPD_IA_DATA_TYPE 2
+#define ABP_APPD_IA_NUM_ELEM 3
+#define ABP_APPD_IA_DESCRIPTOR 4
+#define ABP_APPD_IA_VALUE 5
+#define ABP_APPD_IA_MAX_VALUE 6
+#define ABP_APPD_IA_MIN_VALUE 7
+#define ABP_APPD_IA_DFLT_VALUE 8
+#define ABP_APPD_IA_NUM_SUB_ELEM 9
+
+
+/*------------------------------------------------------------------------------
+**
+** The Application data object attribute data sizes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_IA_DATA_TYPE_DS ABP_UINT8_SIZEOF
+#define ABP_APPD_IA_NUM_ELEM_DS ABP_UINT8_SIZEOF
+#define ABP_APPD_IA_DESCRIPTOR_DS ABP_UINT8_SIZEOF
+#define ABP_APPD_IA_NUM_SUB_ELEM_DS ABP_UINT16_SIZEOF
+
+/*------------------------------------------------------------------------------
+**
+** The Application data instance attribute descriptor bits.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_DESCR_GET_ACCESS 0x01
+#define ABP_APPD_DESCR_SET_ACCESS 0x02
+#define ABP_APPD_DESCR_MAPPABLE_WRITE_PD 0x08
+#define ABP_APPD_DESCR_MAPPABLE_READ_PD 0x10
+
+
+/*------------------------------------------------------------------------------
+**
+** The Application data object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_CMD_GET_INST_BY_ORDER 0x10
+#define ABP_APPD_GET_PROFILE_INST_NUMBERS 0x11
+#define ABP_APPD_GET_ADI_INFO 0x12 /* ABCC40 deprecated shall not be used */
+#define ABP_APPD_REMAP_ADI_WRITE_AREA 0x13
+#define ABP_APPD_REMAP_ADI_READ_AREA 0x14
+#define ABP_APPD_GET_INSTANCE_NUMBERS 0x15 /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The Application data object specific error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_ERR_MAPPING_ITEM_NAK 0x01 /* Mapping item NAK */
+#define ABP_APPD_ERR_INVALID_TOTAL_SIZE 0x02 /* Invalid total size */
+#define ABP_APPD_ERR_ATTR_CTRL_FROM_OTHER_CHANNEL 0x03 /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** Definitions for the different lists that can be fetched with the
+** Get_Instance_Numbers command towards the Application Data Object.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APPD_LIST_TYPE_ALL 0x01
+#define ABP_APPD_LIST_TYPE_RD_PD_MAPPABLE 0x02
+#define ABP_APPD_LIST_TYPE_WR_PD_MAPPABLE 0x03
+
+/*******************************************************************************
+**
+** Application object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Application instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APP_IA_CONFIGURED 1
+#define ABP_APP_IA_SUP_LANG 2
+#define ABP_APP_IA_SER_NUM 3 /* ABCC40 */
+#define ABP_APP_IA_PAR_CRTL_SUM 4 /* ABCC40 */
+#define ABP_APP_IA_FW_AVAILABLE 5 /* ABCC40 */
+#define ABP_APP_IA_HW_CONF_ADDR 6 /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Application instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APP_IA_CONFIGURED_DS ABP_BOOL_SIZEOF
+#define ABP_APP_IA_SER_NUM_DS ABP_UINT32_SIZEOF /* ABCC40 */
+#define ABP_APP_IA_PAR_CRTL_SUM_DS ( 16 * ABP_UINT8_SIZEOF ) /* ABCC40 */
+#define ABP_APP_IA_FW_AVAILABLE_DS ABP_BOOL_SIZEOF /* ABCC40 */
+#define ABP_APP_IA_HW_CONF_ADDR_DS ABP_BOOL_SIZEOF /* ABCC40 */
+
+
+/*------------------------------------------------------------------------------
+**
+** The Application object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_APP_CMD_RESET_REQUEST 0x10
+#define ABP_APP_CMD_CHANGE_LANG_REQUEST 0x11
+#define ABP_APP_CMD_RESET_DIAGNOSTIC 0x12 /* ABCC40 */
+
+/*******************************************************************************
+**
+** Typedefs
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** PACKED_STRUCT
+**
+** Compiler independent symbols to pack structures for compilers that
+** need an in-line directive.
+**
+**------------------------------------------------------------------------------
+*/
+
+#ifndef PACKED_STRUCT
+ #if defined( __GNUC__ )
+ #define PACKED_STRUCT __attribute__ ((packed))
+ #else
+ #define PACKED_STRUCT
+ #endif
+#endif
+
+/*------------------------------------------------------------------------------
+**
+** ABP_Msg255HeaderType
+**
+** Structure describing a message header .
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef struct ABP_Msg255HeaderType
+{
+ UINT8 bSourceId;
+ UINT8 bDestObj;
+ UINT16 iInstance;
+ UINT8 bCmd;
+ UINT8 bDataSize;
+ UINT8 bCmdExt0;
+ UINT8 bCmdExt1;
+}
+PACKED_STRUCT ABP_Msg255HeaderType;
+
+/*------------------------------------------------------------------------------
+**
+** ABP_Msg255Type
+**
+** Structure describing a message.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef struct ABP_Msg255Type
+{
+ /*
+ ** The message header part.
+ */
+
+ ABP_Msg255HeaderType sHeader;
+
+ /*
+ ** The message data.
+ */
+
+ UINT8 abData[ ABP_MAX_MSG_255_DATA_BYTES ];
+}
+PACKED_STRUCT ABP_Msg255Type;
+
+/*------------------------------------------------------------------------------
+**
+** ABP_MsgHeaderType
+**
+** Structure describing a message header for an 8 bit char platform
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef struct ABP_MsgHeaderType
+{
+ UINT16 iDataSize;
+ UINT16 iReserved;
+ UINT8 bSourceId;
+ UINT8 bDestObj;
+ UINT16 iInstance;
+ UINT8 bCmd;
+ UINT8 bReserved;
+ UINT8 bCmdExt0;
+ UINT8 bCmdExt1;
+}
+PACKED_STRUCT ABP_MsgHeaderType;
+
+
+/*------------------------------------------------------------------------------
+**
+** ABP_MsgHeaderType16
+**
+** Structure describing a message header for a 16 bit char platform
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef struct ABP_MsgHeaderType16
+{
+ UINT16 iDataSize;
+ UINT16 iReserved;
+ UINT16 iSourceIdDestObj;
+ UINT16 iInstance;
+ UINT16 iCmdReserved;
+ UINT16 iCmdExt0CmdExt1;
+}
+PACKED_STRUCT ABP_MsgHeaderType16;
+
+
+
+/*------------------------------------------------------------------------------
+**
+** ABP_MsgType8
+**
+** Structure describing a message for an 8 bit char platform
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef struct ABP_MsgType8
+{
+ /*
+ ** The message header part.
+ */
+
+ ABP_MsgHeaderType sHeader;
+
+ /*
+ ** The message data.
+ */
+
+ UINT8 abData[ ABP_MAX_MSG_DATA_BYTES ];
+}
+PACKED_STRUCT ABP_MsgType8;
+
+
+/*------------------------------------------------------------------------------
+**
+** ABP_MsgType16
+**
+** Structure describing a message for a 16 bit char platform
+**
+**------------------------------------------------------------------------------
+*/
+typedef struct ABP_MsgType16
+{
+ /*
+ ** The message header part.
+ */
+
+ ABP_MsgHeaderType16 sHeader;
+
+ /*
+ ** The message data.
+ */
+
+ UINT16 aiData[ ( ABP_MAX_MSG_DATA_BYTES + 1 ) >> 1 ];
+}
+PACKED_STRUCT ABP_MsgType16;
+
+/*------------------------------------------------------------------------------
+**
+** ABP_MsgType
+**
+** Typedef to ABP_MsgType8 or ABP_MsgType16 depending on platform.
+**
+**------------------------------------------------------------------------------
+*/
+
+#ifdef ABCC_SYS_16_BIT_CHAR
+typedef struct ABP_MsgType16 ABP_MsgType;
+#else
+typedef struct ABP_MsgType8 ABP_MsgType;
+#endif
+
+/*******************************************************************************
+**
+** Public Services
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** ABP_BitSize_PADx()
+** ABP_BitSize_BITx()
+**
+** Returns the number of bits occupied by the supplied type.
+** NOTE: The macro does not check that the supplied type is of the specific type
+** class. The type class has to be verified separately.
+**
+**------------------------------------------------------------------------------
+**
+** Inputs:
+** bType - Type code
+**
+** Outputs:
+** Returns the number of bits occupied by the supplied type.
+**
+** Usage:
+** if( ABP_Is_PADx( bType ) )
+** bOccupiedBits = ABP_BitSize_PADx( bType );
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_BitSize_PADx( bType ) ( (bType) & 0x1F )
+#define ABP_BitSize_BITx( bType ) ( (bType) & 0x07 )
+
+/*------------------------------------------------------------------------------
+**
+** ABP_Is_PADx()
+** ABP_Is_BITx()
+**
+** Check if the supplied type is of the specific type class (PADx or BITx).
+** Returns logical true if so, and false if not.
+**
+**------------------------------------------------------------------------------
+**
+** Inputs:
+** bType - Type code
+**
+** Outputs:
+** Returns logical true if supplied type code is of the specific type class.
+**
+** Usage:
+** if( ABP_Is_PADx( bType ) )
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_Is_BITx( bType ) ( ( (bType) >= ABP_BIT1 ) && ( (bType) <= ABP_BIT7 ) )
+#define ABP_Is_PADx( bType ) ( ( (bType) >= ABP_PAD0 ) && ( (bType) <= ABP_PAD16 ) )
+
+/*------------------------------------------------------------------------------
+**
+** ABP_SetMsg255ErrorResponse()
+**
+** Converts a message command header into an error response header.
+** It clears the C-bit, sets the E-bit and enters the submitted error code.
+**
+**------------------------------------------------------------------------------
+**
+** Inputs:
+** psMsg - Pointer to the message command to convert.
+** bMsgDataSize - The number of valid message data field bytes.
+** eErr - The requested error code (ABP_MsgErrorCodeType).
+**
+** Outputs:
+** None
+**
+** Usage:
+** ABP_SetMsg255ErrorResponse( psMsg, bMsgDataSize, eErr );
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_SetMsg255ErrorResponse( psMsg, bMsgDataSize, eErr ) \
+{ \
+ (psMsg)->sHeader.bCmd &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.bCmd |= ABP_MSG_HEADER_E_BIT; \
+ (psMsg)->sHeader.bDataSize = (bMsgDataSize); \
+ (psMsg)->abData[ 0 ] = (UINT8)(eErr); \
+ \
+} /* end of ABP_SetMsg255ErrorResponse() */
+
+/*------------------------------------------------------------------------------
+**
+** ABP_SetMsgErrorResponse()
+**
+** Converts a message command header into an error response header.
+** It clears the C-bit, sets the E-bit and enters the submitted error code.
+**
+**------------------------------------------------------------------------------
+**
+** Inputs:
+** psMsg - Pointer to the message command to convert.
+** iMsgDataSize - The number of valid message data field bytes.
+** eErr - The requested error code (ABP_MsgErrorCodeType).
+**
+** Outputs:
+** None
+**
+** Usage:
+** ABP_SetMsgErrorResponse( psMsg, iMsgDataSize, eErr );
+**
+**------------------------------------------------------------------------------
+*/
+
+#ifdef ABCC_SYS_BIG_ENDIAN
+#define ABP_SetMsgErrorResponse16( psMsg, iMsgDataSize, eErr ) \
+{ \
+ (psMsg)->sHeader.iCmdReserved &= ~( (UINT16)ABP_MSG_HEADER_C_BIT << 8 ); \
+ (psMsg)->sHeader.iCmdReserved |= (UINT16)ABP_MSG_HEADER_E_BIT << 8; \
+ (psMsg)->sHeader.iDataSize = ( (UINT16)(iMsgDataSize) << 8 ) | ( (UINT16)(iMsgDataSize) >> 8 ); \
+ (psMsg)->aiData[ 0 ] = ( (UINT16)(eErr) << 8 ) | ( (UINT16)(eErr) >> 8 ); \
+ \
+} /* end of ABP_SetMsgErrorResponse() */
+#else
+#define ABP_SetMsgErrorResponse16( psMsg, iMsgDataSize, eErr ) \
+{ \
+ (psMsg)->sHeader.iCmdReserved &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.iCmdReserved |= ABP_MSG_HEADER_E_BIT; \
+ (psMsg)->sHeader.iDataSize = (iMsgDataSize); \
+ (psMsg)->aiData[ 0 ] = (UINT16)(eErr); \
+ \
+} /* end of ABP_SetMsgErrorResponse() */
+#endif
+
+#ifdef ABCC_SYS_BIG_ENDIAN
+#define ABP_SetMsgErrorResponse8( psMsg, iMsgDataSize, eErr ) \
+{ \
+ (psMsg)->sHeader.bCmd &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.bCmd |= ABP_MSG_HEADER_E_BIT; \
+ (psMsg)->sHeader.iDataSize = ( (UINT16)(iMsgDataSize) << 8 ) | ( (UINT16)(iMsgDataSize) >> 8 ); \
+ (psMsg)->abData[ 0 ] = (UINT8)(eErr); \
+ \
+} /* end of ABP_SetMsgErrorResponse() */
+#else
+#define ABP_SetMsgErrorResponse8( psMsg, iMsgDataSize, eErr ) \
+{ \
+ (psMsg)->sHeader.bCmd &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.bCmd |= ABP_MSG_HEADER_E_BIT; \
+ (psMsg)->sHeader.iDataSize = (iMsgDataSize); \
+ (psMsg)->abData[ 0 ] = (UINT8)(eErr); \
+ \
+} /* end of ABP_SetMsgErrorResponse() */
+#endif
+
+
+#ifdef ABCC_SYS_16_BIT_CHAR
+#define ABP_SetMsgErrorResponse( psMsg, iMsgDataSize, eErr ) ABP_SetMsgErrorResponse16( psMsg, iMsgDataSize, eErr )
+#else
+#define ABP_SetMsgErrorResponse( psMsg, iMsgDataSize, eErr ) ABP_SetMsgErrorResponse8( psMsg, iMsgDataSize, eErr )
+#endif
+
+
+
+
+
+/*------------------------------------------------------------------------------
+**
+** ABP_SetMsg255Response()
+**
+** Converts a message command header into a response header.
+** It clears the C-bit and enters the submitted data size.
+**
+**------------------------------------------------------------------------------
+**
+** Inputs:
+** psMsg - Pointer to the message command to convert.
+** bMsgDataSize - The number of valid message data field bytes.
+**
+** Outputs:
+** None
+**
+** Usage:
+** ABP_SetMsg255Response( psMsg, bMsgDataSize );
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_SetMsg255Response( psMsg, bMsgDataSize ) \
+{ \
+ (psMsg)->sHeader.bCmd &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.bDataSize = (bMsgDataSize); \
+ \
+} /* end of ABP_SetMsg255Response() */
+
+/*------------------------------------------------------------------------------
+**
+** ABP_SetMsgResponse()
+**
+** Converts a message command header into a response header.
+** It clears the C-bit and enters the submitted data size.
+**
+**------------------------------------------------------------------------------
+**
+** Inputs:
+** psMsg - Pointer to the message command to convert.
+** iMsgDataSize - The number of valid message data field bytes.
+**
+** Outputs:
+** None
+**
+** Usage:
+** ABP_SetMsgResponse( psMsg, iMsgDataSize );
+**
+**------------------------------------------------------------------------------
+*/
+
+#ifdef ABCC_SYS_BIG_ENDIAN
+#define ABP_SetMsgResponse16( psMsg, iMsgDataSize ) \
+{ \
+ (psMsg)->sHeader.iCmdReserved &= ~( (UINT16)ABP_MSG_HEADER_C_BIT << 8 ); \
+ (psMsg)->sHeader.iDataSize = ( (UINT16)(iMsgDataSize) << 8 ) | ( (UINT16)(iMsgDataSize) >> 8 ); \
+ \
+} /* end of ABP_SetMsgResponse() */
+#else
+#define ABP_SetMsgResponse16( psMsg, iMsgDataSize ) \
+{ \
+ (psMsg)->sHeader.iCmdReserved &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.iDataSize = (iMsgDataSize); \
+ \
+} /* end of ABP_SetMsgResponse() */
+#endif
+
+#ifdef ABCC_SYS_BIG_ENDIAN
+#define ABP_SetMsgResponse8( psMsg, iMsgDataSize ) \
+{ \
+ (psMsg)->sHeader.bCmd &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.iDataSize = ( (UINT16)(iMsgDataSize) << 8 ) | ( (UINT16)(iMsgDataSize) >> 8 ); \
+ \
+} /* end of ABP_SetMsgResponse() */
+#else
+#define ABP_SetMsgResponse8( psMsg, iMsgDataSize ) \
+{ \
+ (psMsg)->sHeader.bCmd &= ~ABP_MSG_HEADER_C_BIT; \
+ (psMsg)->sHeader.iDataSize = (iMsgDataSize); \
+ \
+} /* end of ABP_SetMsgResponse() */
+#endif
+
+
+#ifdef ABCC_SYS_16_BIT_CHAR
+#define ABP_SetMsgResponse( psMsg, iMsgDataSize ) ABP_SetMsgResponse16( psMsg, iMsgDataSize )
+#else
+#define ABP_SetMsgResponse( psMsg, iMsgDataSize ) ABP_SetMsgResponse8( psMsg, iMsgDataSize )
+#endif
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** End of abp.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_add.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,303 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_add.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** abp_add - Anybus-CC Protocol - Additional Diagnostic object definitions
+** PROFIBUS specific constants for the Diagnostic object
+**
+** This file contains network specific definitions used by the Anybus-CC
+** PROFIBUS module as well as applications designed to use such module.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_ADD_H
+#define ABP_ADD_H
+
+
+/*******************************************************************************
+**
+** Anybus-CC Additional Diagnostic object constants (ABCC30 only)
+**
+** Object revision: 2.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Additional diagnostic object specific object attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_OA_MAX_INST = 11,
+ ABP_ADD_OA_EXT_DIAG_OVERFLOW = 12,
+ ABP_ADD_OA_STATIC_DIAG = 13
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Additional diagnostic object specific object
+** attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ADD_OA_MAX_INST_DS ABP_UINT16_SIZEOF
+#define ABP_ADD_OA_EXT_DIAG_OVERFLOW_DS ABP_UINT8_SIZEOF
+#define ABP_ADD_OA_STATIC_DIAG_DS ABP_UINT8_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** Additional Diagnostic instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_IA_MODULE_NUMBER = 1,
+ ABP_ADD_IA_IO_TYPE = 2,
+ ABP_ADD_IA_CHANNEL_NUMBER = 3,
+ ABP_ADD_IA_CHANNEL_TYPE = 4,
+ ABP_ADD_IA_ERROR_TYPE = 5
+};
+
+/*------------------------------------------------------------------------------
+**
+** The max value of the module number
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ADD_MODULE_NUMBER_MAX 0x3F
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Additional Diagnostic instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ADD_IA_MODULE_NUMBER_DS ABP_UINT8_SIZEOF
+#define ABP_ADD_IA_IO_TYPE_DS ABP_UINT8_SIZEOF
+#define ABP_ADD_IA_CHANNEL_NUMBER_DS ABP_UINT8_SIZEOF
+#define ABP_ADD_IA_CHANNEL_TYPE_DS ABP_UINT8_SIZEOF
+#define ABP_ADD_IA_ERROR_TYPE_DS ABP_UINT8_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** The Additional Diagnostic object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_CMD_ALARM_NOTIFICATION = 0x10
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Additional Diagnostic object specific error codes and network specific
+** error codes for the Diagnostic object
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_ERR_NO_ERROR = 0x00,
+ ABP_ADD_ERR_INVALID_SLOT_NUMBER = 0x01,
+ ABP_ADD_ERR_INVALID_IO_TYPE = 0x02,
+ ABP_ADD_ERR_INVALID_CHANNEL_NUMBER = 0x03,
+ ABP_ADD_ERR_INVALID_CHANNEL_TYPE = 0x04,
+ ABP_ADD_ERR_INVALID_ERROR_TYPE = 0x05,
+ ABP_ADD_ERR_INVALID_ALARM_SPECIFIER = 0x06,
+ ABP_ADD_ERR_ALARM_TYPE_DISABLED = 0x07,
+ ABP_ADD_ERR_TOO_MANY_ACTIVE_ALARMS = 0x08,
+ ABP_ADD_ERR_ALARM_TYPE_ALREADY_ACTIVE = 0x09
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Value range of slot number (instance attribute and parameter in
+** Alarm Notification command)
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_SLOT_NUMBER_MIN = 0x00,
+ ABP_ADD_SLOT_NUMBER_MAX = 0xFE
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of IO type attribute
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_IO_TYPE_INPUT = 0x01,
+ ABP_ADD_IO_TYPE_OUTPUT = 0x02,
+ ABP_ADD_IO_TYPE_INPUT_OUTPUT = 0x03
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Value range of channel number attribute
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_CHANNEL_NUMBER_MIN = 0x00,
+ ABP_ADD_CHANNEL_NUMBER_MAX = 0x3F
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of Channel type attribute
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_CHANNEL_TYPE_BIT = 0x01,
+ ABP_ADD_CHANNEL_TYPE_2_BITS = 0x02,
+ ABP_ADD_CHANNEL_TYPE_4_BITS = 0x03,
+ ABP_ADD_CHANNEL_TYPE_BYTE = 0x04,
+ ABP_ADD_CHANNEL_TYPE_WORD = 0x05,
+ ABP_ADD_CHANNEL_TYPE_2_WORDS = 0x06
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of Error type attribute
+**
+** 0x00 : Reserved
+** 0x01 - 0x09: Defined error codes in PROFIBUS specification
+** 0x0A - 0x0F: Reserved
+** 0x10 - 0x1F: Manufacturer specific
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_ERROR_TYPE_SHORT_CIRCUIT = 0x01,
+ ABP_ADD_ERROR_TYPE_UNDER_VOLTAGE = 0x02,
+ ABP_ADD_ERROR_TYPE_OVER_VOLTAGE = 0x03,
+ ABP_ADD_ERROR_TYPE_OVERLOAD = 0x04,
+ ABP_ADD_ERROR_TYPE_OVER_TEMPERATURE = 0x05,
+ ABP_ADD_ERROR_TYPE_WIRE_BREAK = 0x06,
+ ABP_ADD_ERROR_TYPE_UPPER_LIMIT_EXCEEDED = 0x07,
+ ABP_ADD_ERROR_TYPE_LOWER_LIMIT_EXCEEDED = 0x08,
+ ABP_ADD_ERROR_TYPE_ERROR_GENERAL = 0x09,
+
+ ABP_ADD_ERROR_TYPE_MANUF_MIN = 0x10,
+ ABP_ADD_ERROR_TYPE_MANUF_MAX = 0x1F
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of Alarm type (part of Alarm Notification command)
+**
+** 0x00 : Reserved
+** 0x01 - 0x06: Defined alarm types in PROFIBUS specification
+** 0x07 - 0x1F: Reserved
+** 0x20 - 0x7E: Manufacturer specific
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_ALARM_TYPE_DIAGNOSIS = 0x01,
+ ABP_ADD_ALARM_TYPE_PROCESS = 0x02,
+ ABP_ADD_ALARM_TYPE_PULL = 0x03,
+ ABP_ADD_ALARM_TYPE_PLUG = 0x04,
+ ABP_ADD_ALARM_TYPE_STATUS = 0x05,
+ ABP_ADD_ALARM_TYPE_UPDATE = 0x06,
+
+ ABP_ADD_ALARM_TYPE_MANUF_MIN = 0x20,
+ ABP_ADD_ALARM_TYPE_MANUF_MAX = 0x7E
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of Alarm specifier (part of Alarm Notification command)
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_ADD_SPEC_NO_FURTHER_DIFF = 0x00,
+ ABP_ADD_SPEC_ERROR_APPEARS = 0x01,
+ ABP_ADD_SPEC_ERROR_DISAPPEARS_SLOT_OK = 0x02,
+ ABP_ADD_SPEC_ERROR_DISAPPEARS_SLOT_NOT_OK = 0x03
+};
+
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** End of abp_add.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_asm.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,89 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This program is the property of HMS Industrial Networks AB. ** +** It may not be reproduced, distributed, or used without permission ** +** of an authorized company official. ** +******************************************************************************** +******************************************************************************** +** This file contains Assembly Mapping Object specific definitions used by +** ABCC modules as well as applications designed to use such modules. +******************************************************************************** +******************************************************************************** +** Services: +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_ASM_H_ +#define ABP_ASM_H_ + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** The Assembly Mapping object specific object attributes. +** +** ABP_ASM_OA_WRITE_PD_INST_LIST - Array of Assembly instances that can be +** mapped to write process data. +** ABP_ASM_OA_READ_PD_INST_LIST - Array of Assembly instances that can be +** mapped to read process data +**------------------------------------------------------------------------------ +*/ +#define ABP_ASM_OA_WRITE_PD_INST_LIST 11 +#define ABP_ASM_OA_READ_PD_INST_LIST 12 + +/*------------------------------------------------------------------------------ +** The data size of the Assembly Mapping object specific attributes +** (in bytes). +**------------------------------------------------------------------------------ +*/ +#define ABP_ASM_OA_WRITE_PD_INST_LIST_DS ( 127 * ABP_UINT16_SIZEOF ) +#define ABP_ASM_OA_READ_PD_INST_LIST_DS ( 127 * ABP_UINT16_SIZEOF ) + + +/*------------------------------------------------------------------------------ +** The Assembly Mapping Object specific instance attributes. +**------------------------------------------------------------------------------ +*/ +#define ABP_ASM_IA_DESCRIPTOR 1 /* Descriptor */ +#define ABP_ASM_IA_ADI_MAP_XX 2 /* Attributes 2-12 are valid */ + +/*------------------------------------------------------------------------------ +** The data size of the Assembly Mapping object specific instance attributes +** (in bytes). +**------------------------------------------------------------------------------ +*/ +#define ABP_ASM_IA_DESCRIPTOR_DS ABP_UINT32_SIZEOF + +/*------------------------------------------------------------------------------ +** The Assembly Mapping object specific message commands. +**------------------------------------------------------------------------------ +*/ +#define ABP_ASM_CMD_WRITE_ASSEMBLY_DATA 0x10 +#define ABP_ASM_CMD_READ_ASSEMBLY_DATA 0x11 + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_bac.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,128 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_bac.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for BACnet Object. +** +** This file contains network specific definitions used by the Anybus-CC +** BACnet modules as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2010 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_BAC_H +#define ABP_BAC_H + + +/******************************************************************************* +** +** Anybus-CC BACnet object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC BACnet Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_BAC_IA_OBJECT_NAME 1 +#define ABP_BAC_IA_VENDOR_NAME 2 +#define ABP_BAC_IA_VENDOR_IDENTIFIER 3 +#define ABP_BAC_IA_MODEL_NAME 4 +#define ABP_BAC_IA_FIRMWARE_REVISION 5 +#define ABP_BAC_IA_APP_SOFTWARE_VERSION 6 +#define ABP_BAC_IA_SUPPORT_ADV_MAPPING 7 +#define ABP_BAC_IA_CURRENT_DATE_AND_TIME 8 +#define ABP_BAC_IA_PASSWORD 9 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC BACnet Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_BAC_IA_OBJECT_NAME_MAX_DS ( 64 * ABP_UINT8_SIZEOF ) +#define ABP_BAC_IA_VENDOR_NAME_MAX_DS ( 64 * ABP_UINT8_SIZEOF ) +#define ABP_BAC_IA_VENDOR_IDENTIFIER_DS ABP_UINT16_SIZEOF +#define ABP_BAC_IA_MODEL_NAME_MAX_DS ( 64 * ABP_UINT8_SIZEOF ) +#define ABP_BAC_IA_FIRMWARE_REVISION_MAX_DS ( 16 * ABP_UINT8_SIZEOF ) +#define ABP_BAC_IA_APP_SOFTWARE_VERSION_MAX_DS ( 16 * ABP_UINT8_SIZEOF ) +#define ABP_BAC_IA_SUPPORT_ADV_MAPPING_DS ABP_BOOL_SIZEOF +#define ABP_BAC_IA_CURRENT_DATE_AND_TIME_DS 7 +#define ABP_BAC_IA_PASSWORD_MAX_DS ( 20 * ABP_UINT8_SIZEOF ) + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC BACnet Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_BAC_CMD_GET_ADI_BY_BACNET_OBJ_INST 0x10 +#define ABP_BAC_CMD_GET_ADI_BY_BACNET_OBJ_INST_NAME 0x11 +#define ABP_BAC_CMD_GET_ALL_BACNET_OBJ_INSTANCES 0x12 +#define ABP_BAC_CMD_GET_BACNET_OBJ_INST_BY_ADI 0x13 + + +/*------------------------------------------------------------------------------ +** +** BACnet specific exception information codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_BAC_EXCPT_INFO_COULD_NOT_READ_OBJ_INST_AV 0x01 +#define ABP_BAC_EXCPT_INFO_COULD_NOT_READ_OBJ_INST_BV 0x02 +#define ABP_BAC_EXCPT_INFO_COULD_NOT_READ_OBJ_INST_MSV 0x03 +#define ABP_BAC_EXCPT_INFO_COULD_NOT_READ_OBJ_INST_BY_ADI 0x04 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_bac.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_ccl.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,124 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_ccl.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** abp_ccl - Anybus-CC Protocol - CC-Link Definitions.
+**
+** This software component contains protocol definitions used by the CC-Link
+** Anybus-CC module as well as applications designed to use such modules.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_CCL_H
+#define ABP_CCL_H
+
+
+/*******************************************************************************
+**
+** Anybus-CC CC-Link object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** CC-Link object instance number
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_CCL_OI_ID 1
+
+
+/*------------------------------------------------------------------------------
+**
+** CC-Link object instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_CCL_IA_VENDOR_CODE = 1,
+ ABP_CCL_IA_SOFTWARE_VERSION = 2,
+ ABP_CCL_IA_MODEL_CODE = 3,
+ ABP_CCL_IA_NETWORK_SETTINGS = 4,
+ ABP_CCL_IA_SYS_AREA_HANDLER = 5,
+ ABP_CCL_IA_HOLD_CLEAR_SETTING = 6
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the CC-Link object instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_CCL_IA_VENDOR_CODE_DS ABP_UINT16_SIZEOF
+#define ABP_CCL_IA_SOFTWARE_VERSION_DS ABP_UINT8_SIZEOF
+#define ABP_CCL_IA_MODEL_CODE_DS ABP_UINT8_SIZEOF
+#define ABP_CCL_IA_NETWORK_SETTINGS_DS ( ABP_UINT8_SIZEOF + \
+ ABP_UINT8_SIZEOF + \
+ ABP_UINT8_SIZEOF )
+#define ABP_CCL_IA_SYS_AREA_HANDLER_DS ABP_SINT16_SIZEOF
+#define ABP_CCL_IA_HOLD_CLEAR_SETTING_DS ABP_UINT8_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** CC-Link object specific commands
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_CCL_CMD_INITIAL_DATA_SETTING_NOTIFICATION = 0x10,
+ ABP_CCL_CMD_INITIAL_DATA_PROCESSING_COMPLETED_NOTIFICATION
+};
+
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** end of abp_ccl.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_cipid.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,109 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_cipid.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for CIP Identity Object. +** +** This file contains CIP identity specific definitions used by Anybus-CC CIP +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2012 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_CIPID_H +#define ABP_CIPID_H + + +/******************************************************************************* +** +** Anybus-CC CIP Identity Object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC CIP Identity Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CIPID_IA_VENDOR_ID 1 +#define ABP_CIPID_IA_DEVICE_TYPE 2 +#define ABP_CIPID_IA_PRODUCT_CODE 3 +#define ABP_CIPID_IA_REVISION 4 +#define ABP_CIPID_IA_STATUS 5 +#define ABP_CIPID_IA_SERIAL_NUMBER 6 +#define ABP_CIPID_IA_PRODUCT_NAME 7 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC CIP Identity Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CIPID_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_CIPID_IA_DEVICE_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_CIPID_IA_PRODUCT_CODE_DS ABP_UINT16_SIZEOF +#define ABP_CIPID_IA_REVISION_DS ( 2 * ABP_UINT8_SIZEOF ) +#define ABP_CIPID_IA_STATUS_DS ABP_UINT16_SIZEOF +#define ABP_CIPID_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_CIPID_IA_PRODUCT_NAME_MAX_DS 32 + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC CIP Identity Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CIPID_CMD_GET_ATTRIBUTE_ALL 0x10 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_cipid.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_cnt.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,127 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_cnt.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for ControlNet. +** +** This file contains network specific definitions used by the Anybus-CC +** ControlNet module as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_CNT_H +#define ABP_CNT_H + + +/******************************************************************************* +** +** Anybus-CC ControlNet object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC ControlNet Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CNT_IA_VENDOR_ID 1 +#define ABP_CNT_IA_DEVICE_TYPE 2 +#define ABP_CNT_IA_PRODUCT_CODE 3 +#define ABP_CNT_IA_REVISION 4 +#define ABP_CNT_IA_SERIAL_NUMBER 5 +#define ABP_CNT_IA_PRODUCT_NAME 6 +#define ABP_CNT_IA_PROD_INSTANCE 7 +#define ABP_CNT_IA_CONS_INSTANCE 8 +#define ABP_CNT_IA_ENABLE_APP_CIP_OBJECTS 11 +#define ABP_CNT_IA_ENABLE_PARAM_OBJECT 12 +#define ABP_CNT_IA_CONFIG_INSTANCE 15 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC ControlNet Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CNT_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_CNT_IA_DEVICE_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_CNT_IA_PRODUCT_CODE_DS ABP_UINT16_SIZEOF +#define ABP_CNT_IA_REVISION_DS ( 2 * ABP_UINT8_SIZEOF ) +#define ABP_CNT_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_CNT_IA_PROD_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_CNT_IA_CONS_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_CNT_IA_ENABLE_APP_CIP_OBJECTS_DS ABP_BOOL_SIZEOF +#define ABP_CNT_IA_ENABLE_PARAM_OBJECT_DS ABP_BOOL_SIZEOF +#define ABP_CNT_IA_CONFIG_INSTANCE_DS ABP_UINT16_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC ControlNet Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CNT_CMD_PROCESS_CIP_OBJ_REQUEST 0x10 +#define ABP_CNT_CMD_SET_CONFIG_DATA 0x11 +#define ABP_CNT_CMD_GET_CONFIG_DATA 0x13 + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC ControlNet Object specific exception codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CNT_NW_EXCPT_INFO_INVALID_SY_INST 0x01 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_cnt.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_cop.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,153 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_cop.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_cop - Anybus-CC Protocol - CANopen Definitions. +** +** This software component contains protocol definitions used by the CANopen +** Anybus-CC module as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_COP_H +#define ABP_COP_H + + +/******************************************************************************* +** +** Anybus-CC CANopen object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** CANopen object instance number +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_COP_OI_ID 1 + + +/*------------------------------------------------------------------------------ +** +** CANopen object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_COP_IA_VENDOR_ID 1 +#define ABP_COP_IA_PRODUCT_CODE 2 +#define ABP_COP_IA_MAJOR_REV 3 +#define ABP_COP_IA_MINOR_REV 4 +#define ABP_COP_IA_SERIAL_NUMBER 5 +#define ABP_COP_IA_MANF_DEV_NAME 6 +#define ABP_COP_IA_MANF_HW_VER 7 +#define ABP_COP_IA_MANF_SW_VER 8 + + +/*------------------------------------------------------------------------------ +** +** The data size of the CANopen object instance attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_COP_CFG_STR_LEN 24 + +#define ABP_COP_IA_VENDOR_ID_DS ABP_UINT32_SIZEOF +#define ABP_COP_IA_PRODUCT_CODE_DS ABP_UINT32_SIZEOF +#define ABP_COP_IA_MAJOR_REV_DS ABP_UINT16_SIZEOF +#define ABP_COP_IA_MINOR_REV_DS ABP_UINT16_SIZEOF +#define ABP_COP_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_COP_IA_MANF_DEV_NAME_MAX_DS ( ABP_CHAR_SIZEOF * ABP_COP_CFG_STR_LEN ) +#define ABP_COP_IA_MANF_HW_VER_MAX_DS ( ABP_CHAR_SIZEOF * ABP_COP_CFG_STR_LEN ) +#define ABP_COP_IA_MANF_SW_VER_MAX_DS ( ABP_CHAR_SIZEOF * ABP_COP_CFG_STR_LEN ) + + +/******************************************************************************* +** +** Network object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** Network object instance attribute # 7 information +** CANopen specific exception constants +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_COP_NW_EXCPT_ILLEGAL_DATA_TYPE 1 + + +/******************************************************************************* +** +** Diagnostic object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** Device specific emergency (EMCY) error codes. +** These should be used in combination with the ABP_DI_EVENT_NW_SPECIFIC +** diagnostic code. +** +**------------------------------------------------------------------------------ +*/ + +/* +** The mappings stored in NV memory does not correspond to the ADI's currently +** mapped by the application. +*/ + +#define ABP_COP_ECY_NO_PD_MAP 0xFF01 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_cop.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_cpc.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,117 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_cpc.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC CIP Port Configuration Object Protocol Definitions. +** +** This software component contains CPC definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_CPC_H +#define ABP_CPC_H + + +/******************************************************************************* +** +** CIP Port Configuration object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The CIP Port Configuration object specific object attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPC_OA_MAX_INST 11 /* Max number of instances */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC CIP Port Configuration object specific +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPC_OA_MAX_INST_DS ABP_UINT16_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The CIP Port Configuration instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPC_IA_PORT_TYPE 1 /* Port type */ +#define ABP_CPC_IA_PORT_NUMBER 2 /* Port number */ +#define ABP_CPC_IA_LINK_PATH 3 /* Link path */ +#define ABP_CPC_IA_PORT_NAME 4 /* Port name */ +#define ABP_CPC_IA_NODE_ADDRESS 7 /* Node address */ +#define ABP_CPC_IA_PORT_NODE_RANGE 8 /* Port node range */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC CIP Port Configuration object instance +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPC_IA_PORT_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_CPC_IA_PORT_NUMBER_DS ABP_UINT16_SIZEOF +#define ABP_CPC_IA_LINK_PATH_MAX_DS 12 +#define ABP_CPC_IA_PORT_NAME_MAX_DS 64 +#define ABP_CPC_IA_NODE_ADDRESS_MAX_DS 64 +#define ABP_CPC_IA_PORT_NODE_RANGE_DS ( 2 * ABP_UINT16_SIZEOF ) + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_cpc.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_cpn.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,136 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_cpn.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for CompoNet Object. +** +** This file contains network specific definitions used by the Anybus-CC +** CompoNet module as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2009 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +** +** Company: HMS Industrial Networks AB +** Stationsgatan 37 +** S-302 45 Halmstad +** SWEDEN +** Tel: +46 (0)35 - 17 29 00 +** Fax: +46 (0)35 - 17 29 09 +** e-mail: info@hms.se +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_CPN_H +#define ABP_CPN_H + + +/******************************************************************************* +** +** Anybus-CC CompoNet object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC CompoNet Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPN_IA_VENDOR_ID 1 +#define ABP_CPN_IA_DEVICE_TYPE 2 +#define ABP_CPN_IA_PRODUCT_CODE 3 +#define ABP_CPN_IA_REVISION 4 +#define ABP_CPN_IA_SERIAL_NUMBER 5 +#define ABP_CPN_IA_PRODUCT_NAME 6 +#define ABP_CPN_IA_PROD_INSTANCE 7 +#define ABP_CPN_IA_CONS_INSTANCE 8 +#define ABP_CPN_IA_ENABLE_APP_CIP_OBJECTS 11 +#define ABP_CPN_IA_ENABLE_PARAM_OBJECT 12 +#define ABP_CPN_IA_BIT_SLAVE 13 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC CompoNet Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPN_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_CPN_IA_DEVICE_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_CPN_IA_PRODUCT_CODE_DS ABP_UINT16_SIZEOF +#define ABP_CPN_IA_REVISION_DS ( 2 * ABP_UINT8_SIZEOF ) +#define ABP_CPN_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_CPN_IA_PROD_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_CPN_IA_CONS_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_CPN_IA_ENABLE_APP_CIP_OBJECTS_DS ABP_BOOL_SIZEOF +#define ABP_CPN_IA_ENABLE_PARAM_OBJECT_DS ABP_BOOL_SIZEOF +#define ABP_CPN_IA_BIT_SLAVE_DS ABP_BOOL_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC CompoNet Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPN_CMD_PROCESS_CIP_OBJ_REQUEST 0x10 + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC CompoNet Object specific exception codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_CPN_NW_EXCPT_INFO_INVALID_SY_INST 0x01 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_cpn.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_dev.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,137 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_dev.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for DeviceNet. +** +** This file contains network specific definitions used by the Anybus-CC +** DeviceNet module as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_DEV_H +#define ABP_DEV_H + + +/******************************************************************************* +** +** Anybus-CC DeviceNet object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC DeviceNet Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_DEV_IA_VENDOR_ID 1 +#define ABP_DEV_IA_DEVICE_TYPE 2 +#define ABP_DEV_IA_PRODUCT_CODE 3 +#define ABP_DEV_IA_REVISION 4 +#define ABP_DEV_IA_SERIAL_NUMBER 5 +#define ABP_DEV_IA_PRODUCT_NAME 6 +#define ABP_DEV_IA_PROD_INSTANCE 7 +#define ABP_DEV_IA_CONS_INSTANCE 8 +#define ABP_DEV_IA_ADDRESS_FROM_NET 9 +#define ABP_DEV_IA_BAUD_RATE_FROM_NET 10 +#define ABP_DEV_IA_ENABLE_APP_CIP_OBJECTS 11 +#define ABP_DEV_IA_ENABLE_PARAM_OBJECT 12 +#define ABP_DEV_IA_ENABLE_QUICK_CONNECT 13 + +#define ABP_DEV_IA_PREPEND_PRODUCING 18 +#define ABP_DEV_IA_PREPEND_CONSUMING 19 +#define ABP_DEV_IA_ABCC_ADI_OBJECT 20 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC DeviceNet Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_DEV_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_DEVICE_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_PRODUCT_CODE_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_REVISION_DS ( 2 * ABP_UINT8_SIZEOF ) +#define ABP_DEV_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_DEV_IA_PROD_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_CONS_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_ADDRESS_FROM_NET_DS ABP_BOOL_SIZEOF +#define ABP_DEV_IA_BAUD_RATE_FROM_NET_DS ABP_BOOL_SIZEOF +#define ABP_DEV_IA_ENABLE_APP_CIP_OBJECTS_DS ABP_BOOL_SIZEOF +#define ABP_DEV_IA_ENABLE_PARAM_OBJECT_DS ABP_BOOL_SIZEOF +#define ABP_DEV_IA_ENABLE_QUICK_CONNECT_DS ABP_BOOL_SIZEOF + +#define ABP_DEV_IA_PREPEND_PRODUCING_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_PREPEND_CONSUMING_DS ABP_UINT16_SIZEOF +#define ABP_DEV_IA_ABCC_ADI_OBJECT_DS ABP_UINT16_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC DeviceNet Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_DEV_CMD_PROCESS_CIP_OBJ_REQUEST 0x10 + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC DeviceNet Object specific exception codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_DEV_NW_EXCPT_INFO_INVALID_SY_INST 0x01 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_dev.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_dpv0di.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,136 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_dpv0di.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** abp_dpv0di - Anybus-CC Protocol - PROFIBUS DP-V0 Diagnostic object definitions
+**
+** This file contains network specific definitions used by the Anybus-CC
+** PROFIBUS DP-V0 module as well as applications designed to use such module.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_DPV0DI_H
+#define ABP_DPV0DI_H
+
+
+/*******************************************************************************
+**
+** Anybus-CC PROFIBUS DP-V0 Diagnostic object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The PROFIBUS DP-V0 Diagnostic diagnostic object specific object attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV0DI_OA_EXT_DIAG_OVERFLOW = 12,
+ ABP_DPV0DI_OA_STATIC_DIAG = 13
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the PROFIBUS DP-V0 Diagnostic diagnostic object specific object
+** attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DPV0DI_OA_MAX_INST_DS ABP_UINT16_SIZEOF
+#define ABP_DPV0DI_OA_EXT_DIAG_OVERFLOW_DS ABP_UINT8_SIZEOF
+#define ABP_DPV0DI_OA_STATIC_DIAG_DS ABP_UINT8_SIZEOF
+
+
+/*------------------------------------------------------------------------------
+**
+** PROFIBUS DP-V0 Diagnostic Diagnostic instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV0DI_IA_DIAG_DATA = 1
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** PROFIBUS DP-V0 Diagnostic Diagnostic object specific error codes
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV0DI_ERR_NO_ERROR = 0x00,
+ ABP_DPV0DI_ERR_STD_DIAG_OBJ_USED = 0x01,
+ ABP_DPV0DI_ERR_INVALID_EXT_DIAG_FLAG = 0x02,
+ ABP_DPV0DI_ERR_ADD_DIAG_OBJ_USED = 0x03
+};
+
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of Extended Diagnostic Flag attribute
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV0DI_EXT_DIAG_FLAG_DISABLE = 0x00,
+ ABP_DPV0DI_EXT_DIAG_FLAG_ENABLE = 0x01
+};
+
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** End of abp_dpv0di.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_dpv1.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,265 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_dpv1.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** abp_dpv1 - Anybus-CC Protocol - PROFIBUS DP-V1 application object definitions
+**
+** This software component contains protocol definitions used by Anybus-CC
+** modules as well as applications designed to use such modules.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_DPV1_H
+#define ABP_DPV1_H
+
+
+/*******************************************************************************
+**
+** PROFIBUS DP-V1 application object constants and PROFIBUS specific constants
+** for the Network object.
+**
+** Object revision: 4.
+**
+********************************************************************************
+*/
+
+/*******************************************************************************
+**
+** Network object constants.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** Network object instance attribute # 7 information
+** PROFIBUS specific exception constants
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_NW_EXCPT_DPV1_TOO_MUCH_DEFAULT_CFG_DATA = 0x01,
+ ABP_NW_EXCPT_DPV1_CFG_DATA_ATTR_TOO_BIG = 0x02,
+ ABP_NW_EXCPT_DPV1_CFG_DATA_MISMATCH_ADI_MAP = 0x03,
+ ABP_NW_EXCPT_DPV1_TOO_MUCH_PROCESS_DATA = 0x04,
+ ABP_NW_EXCPT_DPV1_CFG_DATA_AND_ADI_MAP_SPEC = 0x05,
+ ABP_NW_EXCPT_DPV1_SSA_DISABLED = 0x06,
+ ABP_NW_EXCPT_DPV1_INV_BUFFER_MODE_ATTR = 0x07,
+ ABP_NW_EXCPT_DPV1_CFG_DATA_ATTR_INVALID = 0x08,
+ ABP_NW_EXCPT_DPV1_CFG_DATA_ATTR_TOO_MUCH_IO_DATA = 0x09,
+ ABP_NW_EXCPT_DPV1_UNABLE_TO_GET_ABCCDP_PARAM_LIST = 0x0A,
+ ABP_NW_EXCPT_DPV1_INVALID_APPL_REMAP_CMD_RSP = 0x0B,
+ ABP_NW_EXCPT_DPV1_INVALID_MAP_SLOT_0 = 0x0C,
+ ABP_NW_EXCPT_DPV1_INVALID_MAP_EMPTY_SLOT = 0x0D
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** PROFIBUS DP-V1 instance attributes
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV1_IA_IDENT_NUMBER = 1,
+ ABP_DPV1_IA_PRM_DATA = 2,
+ ABP_DPV1_IA_EXPECTED_CFG_DATA = 3,
+ ABP_DPV1_IA_SSA_ENABLED = 4,
+ ABP_DPV1_IA_SIZEOF_ID_REL_DIAG = 5,
+ ABP_DPV1_IA_BUFFER_MODE = 6,
+ ABP_DPV1_IA_ALARM_SETTINGS = 7,
+ ABP_DPV1_IA_MANUFACTURER_ID = 8,
+ ABP_DPV1_IA_ORDER_ID = 9,
+ ABP_DPV1_IA_SERIAL_NO = 10,
+ ABP_DPV1_IA_HW_REV = 11,
+ ABP_DPV1_IA_SW_REV = 12,
+ ABP_DPV1_IA_REV_COUNTER = 13,
+ ABP_DPV1_IA_PROFILE_ID = 14,
+ ABP_DPV1_IA_PROFILE_SPEC_TYPE = 15,
+ ABP_DPV1_IA_IM_VERSION = 16,
+ ABP_DPV1_IA_IM_SUPPORTED = 17,
+ ABP_DPV1_IA_IM_HEADER = 18,
+ ABP_DPV1_IA_CHK_CFG_BEHAVIOR = 19,
+ ABP_DPV1_IA_RESERVED = 20
+};
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the PROFIBUS DP-V1 instance attributes
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_DPV1_IA_IDENT_NUMBER_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_PRM_DATA_MAX_DS ( ABP_UINT8_SIZEOF * 244 )
+#define ABP_DPV1_IA_CFG_DATA_MAX_DS ( ABP_UINT8_SIZEOF * 244 )
+#define ABP_DPV1_IA_SSA_ENABLED_DS ( ABP_BOOL_SIZEOF )
+#define ABP_DPV1_IA_SIZEOF_ID_REL_DIAG_DS ( ABP_UINT8_SIZEOF )
+#define ABP_DPV1_IA_BUFFER_MODE_DS ( ABP_UINT8_SIZEOF )
+#define ABP_DPV1_IA_ALARM_SETTINGS_DS ( ABP_UINT8_SIZEOF + \
+ ABP_UINT8_SIZEOF + \
+ ABP_BOOL_SIZEOF )
+#define ABP_DPV1_IA_MANUFACTURER_ID_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_ORDER_ID_DS ( ABP_CHAR_SIZEOF * 20 )
+#define ABP_DPV1_IA_SERIAL_NO_DS ( ABP_CHAR_SIZEOF * 16 )
+#define ABP_DPV1_IA_HW_REV_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_SW_REV_DS ( ABP_CHAR_SIZEOF + \
+ ( ABP_UINT8_SIZEOF * 3 ) )
+#define ABP_DPV1_IA_REV_COUNTER_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_PROFILE_ID_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_PROFILE_SPEC_TYPE_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_IM_VERSION_DS ( ABP_UINT8_SIZEOF * 2 )
+#define ABP_DPV1_IA_IM_SUPPORTED_DS ( ABP_UINT16_SIZEOF )
+#define ABP_DPV1_IA_IM_HEADER_DS ( ABP_UINT8_SIZEOF * 10 )
+#define ABP_DPV1_IA_CHK_CFG_BEHAVIOR_DS ( ABP_UINT8_SIZEOF )
+#define ABP_DPV1_IA_SKIP_ADI_DS ( ABP_BOOL_SIZEOF )
+
+
+/*------------------------------------------------------------------------------
+**
+** Values of Buffer mode attribute
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV1_DEF_BUFFER_MODE = 0,
+ ABP_DPV1_PRM_BUFFER_MODE,
+ ABP_DPV1_PD_BUFFER_MODE,
+ ABP_DPV1_ALARM_BUFFER_MODE,
+ ABP_DPV1_PDIM_BUFFER_MODE,
+ ABP_DPV1_DEF_BUFFER_MODE_2,
+ ABP_DPV1_PRM_BUFFER_MODE_2,
+ ABP_DPV1_PD_BUFFER_MODE_2,
+
+ /*
+ ** The buffer modes below are for ABCC-DPV0 only.
+ */
+
+ ABP_DPV1_V0_MODE1 = 200,
+ ABP_DPV1_V0_MODE2,
+ ABP_DPV1_V0_MODE3,
+ ABP_DPV1_V0_MODE4
+};
+
+/*------------------------------------------------------------------------------
+**
+** Values of Profile ID attribute
+** Note! This is not a complete list. The Profile ID's is defined by the
+** PROFIBUS/PROFINET International organization.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV1_PROFILE_ID_NONE = 0x0000,
+ ABP_DPV1_PROFILE_ID_PROFIDRIVE = 0x3A00,
+ ABP_DPV1_PROFILE_ID_ROBOT = 0x3B00,
+ ABP_DPV1_PROFILE_ID_DISPLAY = 0x3C00,
+ ABP_DPV1_PROFILE_ID_ENCODER = 0x3D00,
+ ABP_DPV1_PROFILE_ID_FLUID_POWER = 0x3F00,
+ ABP_DPV1_PROFILE_ID_WATER_TREATMENT = 0x4900,
+ ABP_DPV1_PROFILE_ID_IOLINK_MASTER = 0x4E00,
+ ABP_DPV1_PROFILE_ID_IDENTIFICATION = 0x5B00,
+ ABP_DPV1_PROFILE_ID_WEIGHING_DOSAGE = 0x5C00,
+ ABP_DPV1_PROFILE_ID_PUMPS = 0x5D00,
+ ABP_DPV1_PROFILE_ID_SWITCHGEAR = 0x5E00,
+ ABP_DPV1_PROFILE_ID_REMOTE_IO = 0x5F00,
+ ABP_DPV1_PROFILE_ID_LABORATORY = 0x6200,
+ ABP_DPV1_PROFILE_ID_PA = 0x9700,
+ ABP_DPV1_PROFILE_ID_GENERIC_DEVICE = 0xF600
+};
+
+/*------------------------------------------------------------------------------
+**
+** Values of Check Cfg Behavior attribute (Only in ABCC30 series)
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV1_CHK_CFG_BEHAVIOR_0 = 0,
+ ABP_DPV1_CHK_CFG_BEHAVIOR_1 = 1
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** The PROFIBUS DP-V1 object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV1_CMD_GET_IM_RECORD = 0x10,
+ ABP_DPV1_CMD_SET_IM_RECORD = 0x11,
+ ABP_DPV1_CMD_ALARM_ACK = 0x12, /* Only for ABCC30 */
+ ABP_DPV1_CMD_GET_RECORD = 0x13, /* Only for ABCC40 */
+ ABP_DPV1_CMD_SET_RECORD = 0x14 /* Only for ABCC40 */
+};
+
+/*------------------------------------------------------------------------------
+**
+** The data sizes of the PROFIBUS DP-V1 object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_DPV1_CMD_GET_IM_RECORD_DS = 4,
+ ABP_DPV1_CMD_SET_IM_RECORD_DS = 68,
+ ABP_DPV1_CMD_GET_RECORD_DS = 12,
+ ABP_DPV1_CMD_GET_RECORD_RSP_MAX_DS = 240,
+ ABP_DPV1_CMD_SET_RECORD_MAX_DS = 251
+};
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** End of abp_dpv1.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_eco.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,143 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_eco.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_eco.h - Anybus-CC Energy Control Object Protocol Definitions. +** +** This software component contains Energy Control definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2011 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_ECO_H +#define ABP_ECO_H + + +/******************************************************************************* +** +** Anybus-CC Energy Control Object constants. +** +** Object revision: 2. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Energy Control object specific attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECO_OA_CURRENT_ENERGY_SAVING_MODE 11 +#define ABP_ECO_OA_REMAINING_TIME_TO_DEST 12 +#define ABP_ECO_OA_ENERGY_CONSUMP_TO_DEST 13 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Energy Control object specific +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECO_OA_CURRENT_ENERGY_SAVING_MODE_DS ABP_UINT16_SIZEOF +#define ABP_ECO_OA_REMAINING_TIME_TO_DEST_DS ABP_UINT32_SIZEOF +#define ABP_ECO_OA_ENERGY_CONSUMP_TO_DEST_DS ABP_FLOAT_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Energy Control object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECO_IA_MODE_ATTRIBUTES 1 +#define ABP_ECO_IA_TIME_MIN_PAUSE 2 +#define ABP_ECO_IA_TIME_TO_PAUSE 3 +#define ABP_ECO_IA_TIME_TO_OPERATE 4 +#define ABP_ECO_IA_TIME_MIN_LENGTH_OF_STAY 5 +#define ABP_ECO_IA_TIME_MAX_LENGTH_OF_STAY 6 +#define ABP_ECO_IA_MODE_POWER_CONSUMP 7 +#define ABP_ECO_IA_ENERGY_CONSUMP_TO_PAUSE 8 +#define ABP_ECO_IA_ENERGY_CONSUMP_TO_OPERATE 9 +#define ABP_ECO_IA_AVAILABILITY 10 +#define ABP_ECO_IA_POWER_CONSUMPTION 11 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Energy Control object instance attributes +** (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECO_IA_MODE_ATTRIBUTES_DS ABP_UINT16_SIZEOF +#define ABP_ECO_IA_TIME_MIN_PAUSE_DS ABP_UINT32_SIZEOF +#define ABP_ECO_IA_TIME_TO_PAUSE_DS ABP_UINT32_SIZEOF +#define ABP_ECO_IA_TIME_TO_OPERATE_DS ABP_UINT32_SIZEOF +#define ABP_ECO_IA_TIME_MIN_LENGTH_OF_STAY_DS ABP_UINT32_SIZEOF +#define ABP_ECO_IA_TIME_MAX_LENGTH_OF_STAY_DS ABP_UINT32_SIZEOF +#define ABP_ECO_IA_MODE_POWER_CONSUMP_DS ABP_FLOAT_SIZEOF +#define ABP_ECO_IA_ENERGY_CONSUMP_TO_PAUSE_DS ABP_FLOAT_SIZEOF +#define ABP_ECO_IA_ENERGY_CONSUMP_TO_OPERATE_DS ABP_FLOAT_SIZEOF +#define ABP_ECO_IA_AVAILABILITY_DS ABP_BOOL_SIZEOF +#define ABP_ECO_IA_POWER_CONSUMPTION_DS ABP_UINT32_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Energy Control object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECO_CMD_START_PAUSE 0x10 +#define ABP_ECO_CMD_END_PAUSE 0x11 +#define ABP_ECO_CMD_PREVIEW_PAUSE_TIME 0x12 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_eco.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_ect.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,200 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_ect.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_ect - Anybus-CC Protocol - EtherCAT Definitions. +** +** This software component contains protocol definitions used by the EtherCAT +** Anybus-CC module as well as applications designed to use such modules. +** +** The generic portion used by all Anybus-CC modules is available in the file +** ABP.H. +** +******************************************************************************** +******************************************************************************** +** +** Services List +** ------------- +** +** Public Services: +** +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_ECT_H +#define ABP_ECT_H + + +/******************************************************************************* +** +** Anybus-CC EtherCAT object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** Instance number where the attributes reside on the EtherCAT object. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECT_OI_ID 1 + + +/*------------------------------------------------------------------------------ +** +** EtherCAT object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECT_IA_VENDOR_ID 1 +#define ABP_ECT_IA_PRODUCT_CODE 2 +#define ABP_ECT_IA_MAJOR_REV 3 +#define ABP_ECT_IA_MINOR_REV 4 +#define ABP_ECT_IA_SERIAL_NUMBER 5 +#define ABP_ECT_IA_MANF_DEV_NAME 6 +#define ABP_ECT_IA_MANF_HW_VER 7 +#define ABP_ECT_IA_MANF_SW_VER 8 +#define ABP_ECT_IA_ENUM_ADIS 9 +#define ABP_ECT_IA_DEVICE_TYPE 10 +#define ABP_ECT_IA_WR_PD_ASSY_INST_TRANS 11 +#define ABP_ECT_IA_RD_PD_ASSY_INST_TRANS 12 +#define ABP_ECT_IA_ADI_TRANS 13 + +#define ABP_ECT_IA_OBJ_SUB_TRANS 15 +#define ABP_ECT_IA_ENABLE_FOE 16 + + +/*------------------------------------------------------------------------------ +** +** The data size of the EtherCAT object instance attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECT_CFG_STR_LEN 64 + +#define ABP_ECT_IA_VENDOR_ID_DS ABP_UINT32_SIZEOF +#define ABP_ECT_IA_PRODUCT_CODE_DS ABP_UINT32_SIZEOF +#define ABP_ECT_IA_MAJOR_REV_DS ABP_UINT16_SIZEOF +#define ABP_ECT_IA_MINOR_REV_DS ABP_UINT16_SIZEOF +#define ABP_ECT_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_ECT_IA_MANF_DEV_NAME_MAX_DS ( ABP_CHAR_SIZEOF * ABP_ECT_CFG_STR_LEN ) +#define ABP_ECT_IA_MANF_HW_VER_MAX_DS ( ABP_CHAR_SIZEOF * ABP_ECT_CFG_STR_LEN ) +#define ABP_ECT_IA_MANF_SW_VER_MAX_DS ( ABP_CHAR_SIZEOF * ABP_ECT_CFG_STR_LEN ) +#define ABP_ECT_IA_ENUM_ADIS_MAX_DS 1524 +#define ABP_ECT_IA_DEVICE_TYPE_DS ABP_UINT32_SIZEOF +#define ABP_ECT_IA_WR_PD_ASSY_INST_TRANS_MAX_DS 1524 +#define ABP_ECT_IA_RD_PD_ASSY_INST_TRANS_MAX_DS 1524 +#define ABP_ECT_IA_ADI_TRANS_MAX_DS 1524 +#define ABP_ECT_IA_OBJ_SUB_TRANS_MAX_DS 1524 +#define ABP_ECT_IA_ENABLE_FOE_DS ABP_BOOL_SIZEOF + + +/******************************************************************************* +** +** Network object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** Network object instance attribute # 7 information +** EtherCAT specific exception constants +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ECT_NW_EXCPT_ILLEGAL_DATA_TYPE 1 +#define ABP_ECT_NW_EXCPT_INSTANCE_BY_ORDER_ERROR 2 +#define ABP_ECT_NW_EXCPT_HIGHEST_INSTANCE_ERROR 3 +#define ABP_ECT_NW_EXCPT_NUMBER_OF_INSTANCES_ERROR 4 +#define ABP_ECT_NW_EXCPT_HIGHEST_INSTANCE_LOWER_THAN_NUMBER_OF_INSTANCES 5 +#define ABP_ECT_NW_EXCPT_ASM_MAP_ERROR 6 +#define ABP_ECT_NW_EXCPT_GET_INST_NUMBERS_ERROR 7 +#define ABP_ECT_NW_EXCPT_MDD_ERROR 8 + +/******************************************************************************* +** +** Network configuration object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Network configuration instances common to most Anybus-CC modules. +** +** Note: +** In case the values of these instances originate from input devices +** controlled by the end user (DIP switches or similar), the application +** shall keep these instances updated at all times because some networks +** require that a changed switch is indicated by the LEDs. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NC_INST_NUM_DEVICE_ID 0x01 + +/******************************************************************************* +** +** Diagnostic object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** Device specific emergency (EMCY) error codes. +** These should be used in combination with the ABP_DI_EVENT_NW_SPECIFIC +** diagnostic code. +** +**------------------------------------------------------------------------------ +*/ + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_ect.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_eip.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,182 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_eip.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for EtherNet/IP Object. +** +** This file contains network specific definitions used by the Anybus-CC +** EtherNet/IP module as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_EIP_H +#define ABP_EIP_H + + +/******************************************************************************* +** +** Anybus-CC EtherNet/IP object constants. +** +** Object revision: 2. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC EtherNet/IP Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EIP_IA_VENDOR_ID 1 +#define ABP_EIP_IA_DEVICE_TYPE 2 +#define ABP_EIP_IA_PRODUCT_CODE 3 +#define ABP_EIP_IA_REVISION 4 +#define ABP_EIP_IA_SERIAL_NUMBER 5 +#define ABP_EIP_IA_PRODUCT_NAME 6 +#define ABP_EIP_IA_PROD_INSTANCE 7 +#define ABP_EIP_IA_CONS_INSTANCE 8 +#define ABP_EIP_IA_COMM_SETTINGS_FROM_NET 9 +#define ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS 11 +#define ABP_EIP_IA_ENABLE_PARAM_OBJECT 12 +#define ABP_EIP_IA_INPUT_INSTANCE_OBJECT 13 +#define ABP_EIP_IA_LISTEN_INSTANCE_OBJECT 14 +#define ABP_EIP_IA_CONFIG_INSTANCE 15 +#define ABP_EIP_IA_DISABLE_STRICT_IO_MATCH 16 +#define ABP_EIP_IA_ENABLE_UNCONNECTED_SEND 17 +#define ABP_EIP_IA_INPUT_EXT_INSTANCE_OBJECT 18 +#define ABP_EIP_IA_LISTEN_EXT_INSTANCE_OBJECT 19 +#define ABP_EIP_IA_IF_LABEL_PORT_1 20 +#define ABP_EIP_IA_IF_LABEL_PORT_2 21 +#define ABP_EIP_IA_IF_LABEL_PORT_INT 22 +#define ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT 23 +#define ABP_EIP_IA_PREPEND_PRODUCING 24 +#define ABP_EIP_IA_PREPEND_CONSUMING 25 +#define ABP_EIP_IA_ENABLE_EIP_QC 26 +#define ABP_EIP_IA_PROD_INSTANCE_MAP 27 +#define ABP_EIP_IA_CONS_INSTANCE_MAP 28 +#define ABP_EIP_IA_IGNORE_SEQ_COUNT_CHECK 29 +#define ABP_EIP_IA_ABCC_ADI_OBJECT 30 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC EtherNet/IP Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EIP_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_DEVICE_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_PRODUCT_CODE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_REVISION_DS ( 2 * ABP_UINT8_SIZEOF ) +#define ABP_EIP_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_EIP_IA_PRODUCT_NAME_MAX_DS ( 32 * ABP_UINT8_SIZEOF ) +#define ABP_EIP_IA_PROD_INSTANCE_DS ( 6 * ABP_UINT16_SIZEOF ) +#define ABP_EIP_IA_CONS_INSTANCE_DS ( 6 * ABP_UINT16_SIZEOF ) +#define ABP_EIP_IA_COMM_SETTINGS_FROM_NET_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_ENABLE_PARAM_OBJECT_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_INPUT_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_LISTEN_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_CONFIG_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_DISABLE_STRICT_IO_MATCH_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_ENABLE_UNCONNECTED_SEND_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_INPUT_EXT_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_LISTEN_EXT_INSTANCE_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_IF_LABEL_PORT_1_MAX_DS ( 64 * ABP_UINT8_SIZEOF ) +#define ABP_EIP_IA_IF_LABEL_PORT_2_MAX_DS ( 64 * ABP_UINT8_SIZEOF ) +#define ABP_EIP_IA_IF_LABEL_PORT_INT_MAX_DS ( 64 * ABP_UINT8_SIZEOF ) +#define ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_PREPEND_PRODUCING_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_PREPEND_CONSUMING_DS ABP_UINT16_SIZEOF +#define ABP_EIP_IA_ENABLE_EIP_QC_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_PROD_INSTANCE_MAP_DS ( 6 * 2 * ABP_UINT16_SIZEOF ) +#define ABP_EIP_IA_CONS_INSTANCE_MAP_DS ( 6 * 2 * ABP_UINT16_SIZEOF ) +#define ABP_EIP_IA_IGNORE_SEQ_COUNT_CHECK_DS ABP_BOOL_SIZEOF +#define ABP_EIP_IA_ABCC_ADI_OBJECT_DS ABP_UINT16_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC EtherNet/IP Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EIP_CMD_PROCESS_CIP_OBJ_REQUEST 0x10 +#define ABP_EIP_CMD_SET_CONFIG_DATA 0x11 +#define ABP_EIP_CMD_PROCESS_CIP_ROUTING_REQUEST 0x12 +#define ABP_EIP_CMD_GET_CONFIG_DATA 0x13 +#define ABP_EIP_CMD_PROCESS_CIP_OBJ_REQUEST_EXT 0x14 + + +/*------------------------------------------------------------------------------ +** +** Object specific error codes. +** Defines the second byte in a response from the application if the first byte +** is 0xFF (object specific error). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EIP_ERR_OWNERSHIP_CONFLICT 0x01 /* Ownership conflict */ +#define ABP_EIP_ERR_INVALID_CONFIG 0x02 /* Invalid configuration */ + + +/*------------------------------------------------------------------------------ +** +** Exception information codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EIP_NW_EXCPT_INFO_INVALID_SY_INST 0x01 +#define ABP_EIP_NW_EXCPT_INFO_INVALID_PROD_MAP_SIZE 0x02 +#define ABP_EIP_NW_EXCPT_INFO_INVALID_CONS_MAP_SIZE 0x03 +#define ABP_EIP_NW_EXCPT_INFO_MISSING_MAC_ADDRESS 0x04 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_eip.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_epl.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,135 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This program is the property of HMS Industrial Networks AB. ** +** It may not be reproduced, distributed, or used without permission ** +** of an authorized company official. ** +******************************************************************************** +******************************************************************************** +** Anybus-CC Protocol - POWERLINK Definitions. +** +** This software component contains protocol definitions used by the POWERLINK +** Anybus-CC module as well as applications designed to use such modules. +** +** The generic portion used by all Anybus-CC modules is available in the file +** ABP.H. +******************************************************************************** +******************************************************************************** +** Services: +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_EPL_H +#define ABP_EPL_H + + +/******************************************************************************* +** +** Anybus-CC POWERLINK object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** POWERLINK object instance number +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EPL_OI_ID 1 + + +/*------------------------------------------------------------------------------ +** +** POWERLINK object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EPL_IA_VENDOR_ID 1 +#define ABP_EPL_IA_PRODUCT_CODE 2 +#define ABP_EPL_IA_MAJOR_REV 3 +#define ABP_EPL_IA_MINOR_REV 4 +#define ABP_EPL_IA_SERIAL_NUMBER 5 +#define ABP_EPL_IA_MANF_DEV_NAME 6 +#define ABP_EPL_IA_MANF_HW_VER 7 +#define ABP_EPL_IA_MANF_SW_VER 8 + +#define ABP_EPL_IA_DEVICE_TYPE 10 + +#define ABP_EPL_IA_MANF_NAME 14 + + +/*------------------------------------------------------------------------------ +** +** The data size of the POWERLINK object instance attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EPL_CFG_STR_LEN 64 + +#define ABP_EPL_IA_VENDOR_ID_DS ABP_UINT32_SIZEOF +#define ABP_EPL_IA_PRODUCT_CODE_DS ABP_UINT32_SIZEOF +#define ABP_EPL_IA_MAJOR_REV_DS ABP_UINT16_SIZEOF +#define ABP_EPL_IA_MINOR_REV_DS ABP_UINT16_SIZEOF +#define ABP_EPL_IA_SERIAL_NUMBER_DS ABP_UINT32_SIZEOF +#define ABP_EPL_IA_MANF_DEV_NAME_MAX_DS ( ABP_CHAR_SIZEOF * ABP_EPL_CFG_STR_LEN ) +#define ABP_EPL_IA_MANF_HW_VER_MAX_DS ( ABP_CHAR_SIZEOF * ABP_EPL_CFG_STR_LEN ) +#define ABP_EPL_IA_MANF_SW_VER_MAX_DS ( ABP_CHAR_SIZEOF * ABP_EPL_CFG_STR_LEN ) + +#define ABP_EPL_IA_DEVICE_TYPE_DS ABP_UINT32_SIZEOF +#define ABP_EPL_IA_MANF_NAME_MAX_DS ( ABP_CHAR_SIZEOF * ABP_EPL_CFG_STR_LEN ) + +/******************************************************************************* +** +** Network object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** Network object instance attribute # 7 information +** POWERLINK specific exception constants +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EPL_NW_EXCPT_GET_INST_NUMBERS_ERROR 7 + + +/******************************************************************************* +** +** Network configuration object constants. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Network configuration instances common to most Anybus-CC modules. +** +** Note: +** In case the values of these instances originate from input devices +** controlled by the end user (DIP switches or similar), the application +** shall keep these instances updated at all times because some networks +** require that a changed switch is indicated by the LEDs. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_EPL_NC_INST_NUM_NODE_ID 0x01 + + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_er.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,94 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_er.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_er.h - Anybus-CC Energy Reporting Object Protocol Definitions. +** +** This software component contains Energy Reporting definitions used by +** Anybus-CC modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2014 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_ER_H +#define ABP_ER_H + + +/******************************************************************************* +** +** Anybus-CC Energy Reporting Object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Energy Reporting object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ER_IA_ENERGY_READING 1 +#define ABP_ER_IA_DIRECTION 2 +#define ABP_ER_IA_ACCURACY 3 +#define ABP_ER_IA_CURRENT_POWER_CONSUMPTION 4 +#define ABP_ER_IA_NOMINAL_POWER_CONSUMPTION 5 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Energy Reporting object instance attributes +** (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_ER_IA_ENERGY_READING_DS ( 2 * ABP_UINT32_SIZEOF ) +#define ABP_ER_IA_DIRECTION_DS ABP_BOOL_SIZEOF +#define ABP_ER_IA_ACCURACY_DS ABP_UINT16_SIZEOF +#define ABP_ER_IA_CURRENT_POWER_CONSUMPTION_DS ABP_UINT16_SIZEOF +#define ABP_ER_IA_NOMINAL_POWER_CONSUMPTION_DS ABP_UINT32_SIZEOF + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_er.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_etn.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,147 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_etn.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** ABP - Anybus-CC Protocol Definitions for Ethernet Object.
+**
+** This file contains network specific definitions used by the Anybus-CC
+** Ethernet module as well as applications designed to use such module.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_ETN_H
+#define ABP_ETN_H
+
+
+/*******************************************************************************
+**
+** Anybus-CC Ethernet object constants.
+**
+** Object revision: 2.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Anybus-CC Ethernet Object instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ETN_IA_MAC_ADDRESS 1
+#define ABP_ETN_IA_ENABLE_HICP 2
+#define ABP_ETN_IA_ENABLE_WEB 3
+#define ABP_ETN_IA_ENABLE_MOD_TCP 4
+#define ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS 5
+#define ABP_ETN_IA_ENABLE_FTP 6
+#define ABP_ETN_IA_ENABLE_ADMIN_MODE 7
+#define ABP_ETN_IA_NETWORK_STATUS 8
+#define ABP_ETN_IA_PORT1_MAC_ADDRESS 9
+#define ABP_ETN_IA_PORT2_MAC_ADDRESS 10
+#define ABP_ETN_IA_ENABLE_ACD 11
+#define ABP_ETN_IA_PORT1_STATE 12
+#define ABP_ETN_IA_PORT2_STATE 13
+#define ABP_ETN_IA_ENABLE_WEB_UPDATE 14
+#define ABP_ETN_IA_ENABLE_HICP_RESET 15
+#define ABP_ETN_IA_IP_CONFIGURATION 16
+#define ABP_ETN_IA_IP_ADDRESS_BYTE_0_2 17
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Anybus-CC Ethernet Object instance attributes (in
+** bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ETN_IA_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF )
+#define ABP_ETN_IA_ENABLE_HICP_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_ENABLE_WEB_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_ENABLE_MOD_TCP_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_ENABLE_FTP_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_ENABLE_ADMIN_MODE_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_NETWORK_STATUS_DS ABP_UINT16_SIZEOF
+#define ABP_ETN_IA_PORT1_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF )
+#define ABP_ETN_IA_PORT2_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF )
+#define ABP_ETN_IA_ENABLE_ACD_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_PORT1_STATE_DS ABP_ENUM_SIZEOF
+#define ABP_ETN_IA_PORT2_STATE_DS ABP_ENUM_SIZEOF
+#define ABP_ETN_IA_ENABLE_WEB_UPDATE_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_ENABLE_HICP_RESET_DS ABP_BOOL_SIZEOF
+#define ABP_ETN_IA_IP_CONFIGURATION_DS ( 3 * ABP_UINT32_SIZEOF )
+#define ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS ( 3 * ABP_UINT8_SIZEOF )
+
+
+/*------------------------------------------------------------------------------
+**
+** Network status attribute bit definitions.
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_ETN_IA_NETWORK_STATUS_LINK 0x0001
+#define ABP_ETN_IA_NETWORK_STATUS_IP_INUSE 0x0002
+#define ABP_ETN_IA_NETWORK_STATUS_IP_CONFLICT 0x0004
+#define ABP_ETN_IA_NETWORK_STATUS_LINK_PORT1 0x0008
+#define ABP_ETN_IA_NETWORK_STATUS_LINK_PORT2 0x0010
+
+
+/*------------------------------------------------------------------------------
+**
+** Port 1 and Port 2 state attribute values
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_EtnPortStateType
+{
+ ABP_ETN_IA_PORT_STATE_ENABLE = 0x00, /* Enable Ethernet port */
+ ABP_ETN_IA_PORT_STATE_DISABLE = 0x01, /* Disable Ethernet port */
+
+ ABP_ETN_IA_PORT_STATE_NUM_VALUES /* Number of port states */
+}
+ABP_EtnPortStateType;
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** End of abp_etn.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_fsi.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,209 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_fsi.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC File System Interface Object Protocol Definitions. +** +** This software component contains FSI definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_FSI_H +#define ABP_FSI_H + + +/******************************************************************************* +** +** File System Interface object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The File System Interface object specific object attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_OA_MAX_INST 11 /* Max number of instances */ +#define ABP_FSI_OA_DISABLE_VFS 12 /* Disables VFS */ +#define ABP_FSI_OA_TOTAL_DISC_SIZE 13 /* Total size for discs */ +#define ABP_FSI_OA_FREE_DISC_SIZE 14 /* Free size for discs */ +#define ABP_FSI_OA_DISC_CRC 15 /* CRC of disc content */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC File System Interface object specific +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_OA_MAX_INST_DS ABP_UINT16_SIZEOF +#define ABP_FSI_OA_DISABLE_VFS_DS ABP_BOOL_SIZEOF +#define ABP_FSI_OA_TOTAL_DISC_SIZE_DS ABP_UINT32_SIZEOF +#define ABP_FSI_OA_FREE_DISC_SIZE_DS ABP_UINT32_SIZEOF +#define ABP_FSI_OA_DISC_CRC_SIZE_DS ABP_UINT32_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The File System Interface instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_IA_TYPE 1 /* Instance type */ +#define ABP_FSI_IA_FILE_SIZE 2 /* File size */ +#define ABP_FSI_IA_PATH 3 /* Current instance path */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC File System Interface object instance +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_IA_TYPE_DS ABP_UINT8_SIZEOF +#define ABP_FSI_IA_FILE_SIZE_DS ABP_UINT32_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The File System Interface object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_CMD_FILE_OPEN 0x10 +#define ABP_FSI_CMD_FILE_CLOSE 0x11 +#define ABP_FSI_CMD_FILE_DELETE 0x12 +#define ABP_FSI_CMD_FILE_COPY 0x13 +#define ABP_FSI_CMD_FILE_RENAME 0x14 +#define ABP_FSI_CMD_FILE_READ 0x15 +#define ABP_FSI_CMD_FILE_WRITE 0x16 +#define ABP_FSI_CMD_DIRECTORY_OPEN 0x20 +#define ABP_FSI_CMD_DIRECTORY_CLOSE 0x21 +#define ABP_FSI_CMD_DIRECTORY_DELETE 0x22 +#define ABP_FSI_CMD_DIRECTORY_READ 0x23 +#define ABP_FSI_CMD_DIRECTORY_CREATE 0x24 +#define ABP_FSI_CMD_DIRECTORY_CHANGE 0x25 +#define ABP_FSI_CMD_FORMAT_DISC 0x30 + + +/*------------------------------------------------------------------------------ +** +** Max number of characters in the path. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_MAX_PATH_LENGTH 126 + + +/*------------------------------------------------------------------------------ +** +** Instance types. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_TYPE_NONE 0 /* Instance holds nothing */ +#define ABP_FSI_TYPE_FILE 1 /* Instance holds a file */ +#define ABP_FSI_TYPE_DIRECTORY 2 /* Instance holds a directory */ + + +/*------------------------------------------------------------------------------ +** +** File open command modes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_FILE_OPEN_READ_MODE 0x00 +#define ABP_FSI_FILE_OPEN_WRITE_MODE 0x01 +#define ABP_FSI_FILE_OPEN_APPEND_MODE 0x02 + + +/*------------------------------------------------------------------------------ +** +** Directory read object flags. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_DIRECTORY_READ_DIRECTORY 0x01 +#define ABP_FSI_DIRECTORY_READ_READ_ONLY 0x02 +#define ABP_FSI_DIRECTORY_READ_HIDDEN 0x04 +#define ABP_FSI_DIRECTORY_READ_SYSTEM 0x08 + + +/*------------------------------------------------------------------------------ +** +** File System Interface object specific error codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FSI_ERR_FILE_OPEN_FAILED 1 +#define ABP_FSI_ERR_FILE_CLOSE_FAILED 2 +#define ABP_FSI_ERR_FILE_DELETE_FAILED 3 +#define ABP_FSI_ERR_DIRECTORY_OPEN_FAILED 4 +#define ABP_FSI_ERR_DIRECTORY_CLOSE_FAILED 5 +#define ABP_FSI_ERR_DIRECTORY_CREATE_FAILED 6 +#define ABP_FSI_ERR_DIRECTORY_DELETE_FAILED 7 +#define ABP_FSI_ERR_DIRECTORY_CHANGE_FAILED 8 +#define ABP_FSI_ERR_FILE_COPY_OPEN_READ_FAILED 9 +#define ABP_FSI_ERR_FILE_COPY_OPEN_WRITE_FAILED 10 +#define ABP_FSI_ERR_FILE_COPY_WRITE_FAILED 11 +#define ABP_FSI_ERR_FILE_RENAME_FAILED 12 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_fsi.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_fusm.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,189 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_fusm.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_fusm.h - Anybus-CC Functional Safety Objects Protocol Definitions. +** +** This software component contains FUSM definitions used by Anybus-CC +** modules as well as applications designed to use Functional Safety. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2012 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_FUSM_H +#define ABP_FUSM_H + + +/*------------------------------------------------------------------------------ +** +** The Functional Safety instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SAFE_IA_SAFETY_ENABLE 1 +#define ABP_SAFE_IA_BAUD_RATE 2 +#define ABP_SAFE_IA_IO_CONFIG 3 +#define ABP_SAFE_IA_CYCLE_TIME 4 /* ABCC40 */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Functional Safety instance attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SAFE_IA_SAFETY_ENABLE_DS ABP_BOOL_SIZEOF +#define ABP_SAFE_IA_BAUD_RATE_DS ABP_UINT32_SIZEOF +#define ABP_SAFE_IA_CYCLE_TIME_DS ABP_UINT8_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Functional Safety Module instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FUSM_IA_STATE 1 +#define ABP_FUSM_IA_VENDOR_ID 2 +#define ABP_FUSM_IA_MODULE_ID 3 +#define ABP_FUSM_IA_FW_VERSION 4 +#define ABP_FUSM_IA_SERIAL_NUM 5 +#define ABP_FUSM_IA_DATA_OUT 6 +#define ABP_FUSM_IA_DATA_IN 7 +#define ABP_FUSM_IA_ERROR_CNTRS 8 +#define ABP_FUSM_IA_FATAL_EVENT 9 +#define ABP_FUSM_IA_EXCPT_INFO 10 +#define ABP_FUSM_IA_BL_VERSION 11 + + +/*------------------------------------------------------------------------------ +** +** The data size of the instance attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FUSM_IA_STATE_DS ABP_UINT8_SIZEOF +#define ABP_FUSM_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_FUSM_IA_MODULE_ID_DS ABP_UINT16_SIZEOF +#define ABP_FUSM_IA_FW_VERSION_DS ( 3 * ABP_UINT8_SIZEOF ) +#define ABP_FUSM_IA_SERIAL_NUM_DS ABP_UINT32_SIZEOF +#define ABP_FUSM_IA_ERROR_CNTRS_DS ( 4 * ABP_UINT16_SIZEOF ) +#define ABP_FUSM_IA_EXCPT_INFO_DS ABP_UINT8_SIZEOF +#define ABP_FUSM_IA_BL_VERSION_DS ( 2 * ABP_UINT8_SIZEOF ) + + +/*------------------------------------------------------------------------------ +** +** Object specific error codes +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FUSM_ERR_REJECT_BY_MODULE 0x01 +#define ABP_FUSM_ERR_MODULE_RSP_FAULTY 0x02 + +#define ABP_FUSM_ERR_OBJ_SPEC_DS 2 +#define ABP_FUSM_ERR_REJECT_BY_MODULE_DS 4 + + +/*----------------------------------------------------------------------- +** +** ABP_FUSM_IA_ERROR_CNTRS_IDX_... +** +** Index for the different counters in the Error Counters attribute +** (array of UINT16) +** +**----------------------------------------------------------------------- +*/ + +#define ABP_FUSM_IA_ERROR_CNTRS_IDX_ABCC_DR 0 +#define ABP_FUSM_IA_ERROR_CNTRS_IDX_ABCC_SE 1 +#define ABP_FUSM_IA_ERROR_CNTRS_IDX_SAFE_DR 2 +#define ABP_FUSM_IA_ERROR_CNTRS_IDX_SAFE_SE 3 + + +/*------------------------------------------------------------------------------ +** +** Values of the Exception Info attribute +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FUSM_EXCPT_INFO_NONE 0 +#define ABP_FUSM_EXCPT_INFO_BAUDRATE_NOT_SUPP 1 +#define ABP_FUSM_EXCPT_INFO_NO_START_MSG 2 +#define ABP_FUSM_EXCPT_INFO_UNEXP_MSG_LENGTH 3 +#define ABP_FUSM_EXCPT_INFO_UNEXP_CMD_IN_RSP 4 +#define ABP_FUSM_EXCPT_INFO_UNEXP_ERR_CODE 5 +#define ABP_FUSM_EXCPT_INFO_APPL_NOT_FOUND 6 +#define ABP_FUSM_EXCPT_INFO_INV_APPL_CRC 7 +#define ABP_FUSM_EXCPT_INFO_NO_FLASH_ACCESS 8 +#define ABP_FUSM_EXCPT_INFO_WRONG_UC_IN_RSP 9 +#define ABP_FUSM_EXCPT_INFO_BL_TIMEOUT 10 +#define ABP_FUSM_EXCPT_INFO_NW_SPEC_PRM_ERR 11 +#define ABP_FUSM_EXCPT_INFO_INV_CFG_STRING 12 +#define ABP_FUSM_EXCPT_INFO_UC_RSP_DIFFERS 13 +#define ABP_FUSM_EXCPT_INFO_INCOMPAT_MODULE 14 +#define ABP_FUSM_EXCPT_INFO_MAX_RETRANSMISSIONS 15 +#define ABP_FUSM_EXCPT_INFO_FW_FILE_ERROR 16 +#define ABP_FUSM_EXCPT_INFO_INV_CYCLE_TIME 17 +#define ABP_FUSM_EXCPT_INFO_INV_SPDU_IN_SIZE 18 +#define ABP_FUSM_EXCPT_INFO_INV_SPDU_OUT_SIZE 19 +#define ABP_FUSM_EXCPT_INFO_BAD_FORMAT_IN_SPDU 20 +#define ABP_FUSM_EXCPT_INFO_SAFE_MOD_INIT_FAIL 21 + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Functional Safety object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_FUSM_CMD_ERROR_CONFIRMATION 0x10 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** end of abp_fusm.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_mdd.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,65 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2014 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** + +******************************************************************************** +******************************************************************************** +** This file contains Modular Device Object specific definitions used by +** ABCC modules as well as applications designed to use such modules. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_MDD_H_ +#define ABP_MDD_H_ + +#include "abp.h" + +/*------------------------------------------------------------------------------ +** The Modular Device object specific object attributes. +** +** ABP_MDD_OA_NUM_SLOTS - Number of available slots in the backplane, +** including the coupler. +** ABP_MDD_OA_NUM_ADIS_PER_SLOT - Number of ADIs each slot occupies. +**------------------------------------------------------------------------------ +*/ +#define ABP_MDD_OA_NUM_SLOTS 11 +#define ABP_MDD_OA_NUM_ADIS_PER_SLOT 12 + +/*------------------------------------------------------------------------------ +** The data size of the Modular Device object specific attributes +** (in bytes). +**------------------------------------------------------------------------------ +*/ +#define ABP_MDD_OA_NUM_SLOTS_DS ABP_UINT16_SIZEOF +#define ABP_MDD_OA_NUM_ADIS_PER_SLOT_DS ABP_UINT16_SIZEOF + +/*------------------------------------------------------------------------------ +** The Modular Device object specific message commands. +**------------------------------------------------------------------------------ +*/ +#define ABP_MDD_CMD_GET_LIST 0x15 + +/*------------------------------------------------------------------------------ +** Valid list types for the Get_List command. +**------------------------------------------------------------------------------ +*/ +#define ABP_MDD_LIST_TYPE_ALL_MODULE_IDS 0x01 + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_mod.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,115 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_mod.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Protocol Definitions for Modbus. +** +** This file contains network specific definitions used by the Anybus-CC +** Modbus module as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_MOD_H +#define ABP_MOD_H + + +/******************************************************************************* +** +** Anybus-CC Modbus object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Modbus Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_MOD_IA_VENDOR_NAME 1 +#define ABP_MOD_IA_PRODUCT_CODE 2 +#define ABP_MOD_IA_REVISION 3 +#define ABP_MOD_IA_VENDOR_URL 4 +#define ABP_MOD_IA_PRODUCT_NAME 5 +#define ABP_MOD_IA_MODEL_NAME 6 +#define ABP_MOD_IA_USER_APP_NAME 7 +#define ABP_MOD_IA_DEVICE_ID 8 +#define ABP_MOD_IA_ADI_INDEXING_BITS 9 +#define ABP_MOD_IA_MESSAGE_FORWARDING 10 +#define ABP_MOD_IA_RW_OFFSET 11 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Modbus Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_MOD_IA_ADI_INDEXING_BITS_DS ABP_UINT8_SIZEOF +#define ABP_MOD_IA_MESSAGE_FORWARDING_DS ABP_BOOL_SIZEOF +#define ABP_MOD_IA_RW_OFFSET_DS ( 2 * ABP_SINT16_SIZEOF ) + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Modbus Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_MOD_CMD_PROCESS_MODBUS_MESSAGE 0x10 + +/*------------------------------------------------------------------------------ +** +** Exception information codes. +** +**------------------------------------------------------------------------------ +*/ +#define ABP_MOD_NW_EXCPT_MISSING_MAC_ADDRESS 1 + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_mod.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_nwccl.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,145 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_nwccl.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** abp_nwccl - Anybus-CC Protocol - Network CC-Link object definitions
+**
+** This software component contains protocol definitions used by the CC-Link
+** Anybus-CC module as well as applications designed to use such modules.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_NWCCL_H
+#define ABP_NWCCL_H
+
+
+/*******************************************************************************
+**
+** Anybus-CC Network CC-Link object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** Network CC-Link object instance number
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NWCCL_OI_ID 1
+
+
+/*------------------------------------------------------------------------------
+**
+** Network CC-Link object instance attributes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_NWCCL_IA_NETWORK_SETTINGS = 1,
+ ABP_NWCCL_IA_SYSTEM_AREA_HANDLER = 2,
+ ABP_NWCCL_IA_ERROR_CODE_POSITION = 3,
+ ABP_NWCCL_IA_LAST_MAPPING_INFO = 4,
+ ABP_NWCCL_IA_CCL_CONF_TEST_MODE = 5,
+ ABP_NWCCL_IA_ERROR_INFO = 6
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** The data size of the Network CC-Link object instance attributes (in bytes).
+**
+**------------------------------------------------------------------------------
+*/
+
+#define ABP_NWCCL_IA_NETWORK_SETTINGS_DS ABP_CCL_IA_NETWORK_SETTINGS_DS
+#define ABP_NWCCL_IA_SYSTEM_AREA_HANDLER_DS ABP_SINT16_SIZEOF
+#define ABP_NWCCL_IA_ERROR_CODE_POSITION_DS ABP_SINT8_SIZEOF
+#define ABP_NWCCL_IA_LAST_MAPPING_INFO_DS ( ABP_UINT8_SIZEOF + \
+ ABP_UINT16_SIZEOF + \
+ ABP_UINT16_SIZEOF )
+#define ABP_NWCCL_IA_CCL_CONF_TEST_MODE_DS ABP_BOOL_SIZEOF
+#define ABP_NWCCL_IA_ERROR_INFO_DS ( ABP_UINT8_SIZEOF + \
+ ABP_UINT8_SIZEOF + \
+ ABP_UINT8_SIZEOF )
+
+/*------------------------------------------------------------------------------
+**
+** Network CC-Link object specific commands
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_NWCCL_MsgCmdType
+{
+ ABP_NWCCL_CMD_MAP_ADI_SPEC_WRITE_AREA = 0x10,
+ ABP_NWCCL_CMD_MAP_ADI_SPEC_READ_AREA = 0x11,
+ ABP_NWCCL_CMD_CCL_CONF_TEST_MODE = 0x12
+}ABP_NWCCL_MsgCmdType;
+
+
+/*------------------------------------------------------------------------------
+**
+** The Network CC-Link object specific error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+typedef enum ABP_NWCCL_MsgErrorCodeType
+{
+ ABP_NWCCL_ERR_INVALID_ADI_DATA_TYPE = 0x01,
+ ABP_NWCCL_ERR_INVALID_NUM_ELEMENTS = 0x02,
+ ABP_NWCCL_ERR_INVALID_TOTAL_SIZE = 0x03,
+ ABP_NWCCL_ERR_INVALID_ORDER_NUM = 0x04,
+ ABP_NWCCL_ERR_INVALID_MAP_CMD_SEQ = 0x05,
+ ABP_NWCCL_ERR_INVALID_CCL_AREA = 0x06,
+ ABP_NWCCL_ERR_INVALID_OFFSET = 0x07,
+ ABP_NWCCL_ERR_DATA_OVERLAPPING = 0x08
+}ABP_NWCCL_MsgErrorCodeType;
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** end of abp_nwccl.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_abp/abp_nwdpv1.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,98 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABP version 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+**
+** File Name
+** ---------
+**
+** abp_nwdpv1.h
+**
+********************************************************************************
+********************************************************************************
+**
+** Description
+** -----------
+**
+** abp_nwdpv1 - Anybus-CC Protocol - Network PROFIBUS DP-V1 object definitions
+**
+** This file contains network specific definitions used by the Anybus-CC
+** PROFIBUS module as well as applications designed to use such module.
+**
+********************************************************************************
+********************************************************************************
+** **
+** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, this code can be **
+** modified, reproduced and distributed in binary form without any **
+** restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+** **
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABP_NWDPV1_H
+#define ABP_NWDPV1_H
+
+
+/*******************************************************************************
+**
+** Anybus-CC Network PROFIBUS DP-V1 object constants.
+**
+** Object revision: 1.
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+**
+** The Network PROFIBUS DP-V1 object specific message commands.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_NWDPV1_CMD_MAP_ADI_WRITE_AREA = 0x10,
+ ABP_NWDPV1_CMD_MAP_ADI_READ_AREA = 0x11
+};
+
+
+/*------------------------------------------------------------------------------
+**
+** The Network PROFIBUS DP-V1 object specific error codes.
+**
+**------------------------------------------------------------------------------
+*/
+
+enum
+{
+ ABP_NWDPV1_ERR_INVALID_ADI_DATA_TYPE = 0x01,
+ ABP_NWDPV1_ERR_INVALID_NUM_ELEMENTS = 0x02,
+ ABP_NWDPV1_ERR_INVALID_TOTAL_SIZE = 0x03,
+ ABP_NWDPV1_ERR_INVALID_ORDER_NUM = 0x04,
+ ABP_NWDPV1_ERR_INVALID_MAP_CMD_SEQ = 0x05,
+ ABP_NWDPV1_ERR_INVALID_CFG_DATA = 0x06,
+ ABP_NWDPV1_ERR_TOO_MUCH_TOTAL_CFG_DATA = 0x07
+};
+
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+**
+** End of abp_nwdpv1.h
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_nwetn.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,89 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_nwetn.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Network Ethernet Object Protocol Definitions. +** +** This software component contains NWETN definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_NWETN_H +#define ABP_NWETN_H + + +/******************************************************************************* +** +** Network Ethernet Interface object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Network Ethernet Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWETN_IA_MAC_ID 1 +#define ABP_NWETN_IA_PORT1_MAC_ID 2 +#define ABP_NWETN_IA_PORT2_MAC_ID 3 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Network Ethernet Object instance attributes +** (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWETN_IA_MAC_ID_DS ( 6 * ABP_UINT8_SIZEOF ) +#define ABP_NWETN_IA_PORT1_MAC_ID_DS ( 6 * ABP_UINT8_SIZEOF ) +#define ABP_NWETN_IA_PORT2_MAC_ID_DS ( 6 * ABP_UINT8_SIZEOF ) + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_nwetn.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_nwpnio.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,178 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_nwpnio.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_nwpnio.h - Anybus-CC Network PROFINET Object Protocol Definitions. +** +** This software component contains NWPNIO definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_NWPNIO_H +#define ABP_NWPNIO_H + + +/******************************************************************************* +** +** Anybus-CC Network PROFINET Interface object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Network PROFINET Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWPNIO_IA_ONLINE_TRANS 1 /* Number of on-line transitions */ +#define ABP_NWPNIO_IA_OFFLINE_TRANS 2 /* Number of off-line transitions */ +#define ABP_NWPNIO_IA_OFFLINE_REASON_CODE 3 /* Reason code of last off-line */ +#define ABP_NWPNIO_IA_ABORT_REASON_CODE 4 /* Last abort reason code */ +#define ABP_NWPNIO_IA_ADDED_APIS 5 /* Number of added apis */ +#define ABP_NWPNIO_IA_API_LIST 6 /* List of the added APIs */ +#define ABP_NWPNIO_IA_EST_ARS 7 /* Number of established ARs */ +#define ABP_NWPNIO_IA_AR_LIST 8 /* List of established ARs (handles)*/ +#define ABP_NWPNIO_IA_PNIO_INIT_ERR_CODE 9 /* Error code PROFINET IO stack init*/ +#define ABP_NWPNIO_IA_PORT1_MAC_ADDRESS 10 /* PROFINET IO port 1 MAC address */ +#define ABP_NWPNIO_IA_PORT2_MAC_ADDRESS 11 /* PROFINET IO port 2 MAC address */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Network PROFINET Object instance attributes +** (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWPNIO_IA_ONLINE_TRANS_DS ( ABP_UINT32_SIZEOF ) +#define ABP_NWPNIO_IA_OFFLINE_TRANS_DS ( ABP_UINT32_SIZEOF ) +#define ABP_NWPNIO_IA_OFFLINE_REASON_CODE_DS ( ABP_UINT16_SIZEOF ) +#define ABP_NWPNIO_IA_ABORT_REASON_CODE_DS ( ABP_UINT16_SIZEOF ) +#define ABP_NWPNIO_IA_ADDED_APIS_DS ( ABP_UINT16_SIZEOF ) +#define ABP_NWPNIO_IA_API_LIST_DS ( 2 * ABP_UINT32_SIZEOF ) +#define ABP_NWPNIO_IA_EST_ARS_DS ( ABP_UINT16_SIZEOF ) +#define ABP_NWPNIO_IA_AR_LIST_DS ( 3 * ABP_UINT16_SIZEOF ) +#define ABP_NWPNIO_IA_PNIO_INIT_ERR_CODE_DS ( ABP_UINT16_SIZEOF ) +#define ABP_NWPNIO_IA_PORT1_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF ) +#define ABP_NWPNIO_IA_PORT2_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF ) + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Network PROFINET Object Interface object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWPNIO_CMD_PLUG_MODULE 0x10 +#define ABP_NWPNIO_CMD_PLUG_SUB_MODULE 0x11 +#define ABP_NWPNIO_CMD_PULL_MODULE 0x12 +#define ABP_NWPNIO_CMD_PULL_SUB_MODULE 0x13 +#define ABP_NWPNIO_CMD_API_ADD 0x14 +#define ABP_NWPNIO_CMD_APPL_STATE_READY 0x15 +#define ABP_NWPNIO_CMD_AR_ABORT 0x16 +#define ABP_NWPNIO_CMD_ADD_SAFETY_MODULE 0x17 +#define ABP_NWPNIO_CMD_IM_OPTIONS 0x18 +#define ABP_NWPNIO_CMD_PLUG_SUB_MODULE_EXT 0x19 +#define ABP_NWPNIO_CMD_IDENT_CHANGE_DONE 0x1A + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Network PROFINET Object Interface object +** specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWPNIO_CMD_PLUG_MODULE_DS 10 +#define ABP_NWPNIO_CMD_PLUG_SUB_MODULE_DS 18 +#define ABP_NWPNIO_CMD_PULL_MODULE_DS 6 +#define ABP_NWPNIO_CMD_PULL_SUB_MODULE_DS 8 +#define ABP_NWPNIO_CMD_API_ADD_DS 8 +#define ABP_NWPNIO_CMD_APPL_STATE_READY_DS 0 +#define ABP_NWPNIO_CMD_AR_ABORT_DS 0 +#define ABP_NWPNIO_CMD_ADD_SAFETY_MODULE_DS 4 +#define ABP_NWPNIO_CMD_IM_OPTIONS_DS 255 +#define ABP_NWPNIO_CMD_PLUG_SUB_MODULE_EXT_DS 20 +#define ABP_NWPNIO_CMD_IDENT_CHANGE_DONE_DS 0 + + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC Network PROFINET Object Interface object specific error codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_NWPNIO_ERR_ADI_WRITE_NOT_MAPPED 0x01 +#define ABP_NWPNIO_ERR_ADI_READ_NOT_MAPPED 0x02 +#define ABP_NWPNIO_ERR_ADI_ELEM_NOT_PRESENT 0x03 +#define ABP_NWPNIO_ERR_ADI_ALREADY_MAPPED 0x04 +#define ABP_NWPNIO_ERR_API_0_NOT_ADDED 0x05 +#define ABP_NWPNIO_ERR_API_NOT_PRESENT 0x06 +#define ABP_NWPNIO_ERR_API_ALREADY_PRESENT 0x07 +#define ABP_NWPNIO_ERR_API_CANNOT_BE_ADDED 0x08 +#define ABP_NWPNIO_ERR_NO_IO_IN_SLOT_0 0x09 +#define ABP_NWPNIO_ERR_SLOT_0_NOT_PROP_PLUGGED 0x0A +#define ABP_NWPNIO_ERR_SLOT_OCCUPIED 0x0B +#define ABP_NWPNIO_ERR_SUBSLOT_OCCUPIED 0x0C +#define ABP_NWPNIO_ERR_NO_MODULE_SPECIFIED_SLOT 0x0D +#define ABP_NWPNIO_ERR_NO_SUBMOD_SPECIFIED_SLOT 0x0E +#define ABP_NWPNIO_ERR_SLOT_OUT_OF_RANGE 0x0F +#define ABP_NWPNIO_ERR_SUBSLOT_OUT_OF_RANGE 0x10 +#define ABP_NWPNIO_ERR_AR_NOT_VALID 0x11 +#define ABP_NWPNIO_ERR_NO_PEND_APPL_READY 0x12 +#define ABP_NWPNIO_ERR_UNKNOWN_STACK_ERROR 0x13 +#define ABP_NWPNIO_ERR_MAX_NBR_OF_PLUGGED_SUBMOD 0x14 +#define ABP_NWPNIO_ERR_SAFETY_NOT_ENABLED 0x15 +#define ABP_NWPNIO_ERR_ADI_DATATYPE_CONSTRAINT 0x16 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** end of abp_nwpnio.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_pnio.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,190 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_pnio.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_pnio.h - Anybus-CC Protocol Definitions for PROFINET Object. +** +** This file contains network specific definitions used by the Anybus-CC +** PROFINET module as well as applications designed to use such module. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_PNIO_H +#define ABP_PNIO_H + + +/******************************************************************************* +** +** Anybus-CC PROFINET object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Anybus-CC PROFINET Object instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_PNIO_IA_DEVICE_ID 1 +#define ABP_PNIO_IA_VENDOR_ID 2 +#define ABP_PNIO_IA_STATION_TYPE 3 +#define ABP_PNIO_IA_MAX_AR 4 +/* +** Instance attributes 5-6 are reserved +*/ +#define ABP_PNIO_IA_RTM 7 +#define ABP_PNIO_IA_IM_ORDER_ID 8 +#define ABP_PNIO_IA_IM_SERIAL_NBR 9 +#define ABP_PNIO_IA_IM_HW_REV 10 +#define ABP_PNIO_IA_IM_SW_REV 11 +#define ABP_PNIO_IA_IM_REV_CNT 12 +#define ABP_PNIO_IA_IM_PROFILE_ID 13 +#define ABP_PNIO_IA_IM_PROFILE_SPEC_TYPE 14 +#define ABP_PNIO_IA_IM_VER 15 +#define ABP_PNIO_IA_IM_SUPPORTED 16 +#define ABP_PNIO_IA_PORT1_MAC_ADDRESS 17 +#define ABP_PNIO_IA_PORT2_MAC_ADDRESS 18 +#define ABP_PNIO_IA_SYSTEM_DESCRIPTION 19 +#define ABP_PNIO_IA_INTERFACE_DESCRIPTION 20 +#define ABP_PNIO_IA_MOD_ID_ASSIGN_MODE 21 +#define ABP_PNIO_IA_SYSTEM_CONTACT 22 +#define ABP_PNIO_IA_PROFIENERGY_FUNC 23 + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC PROFINET Object instance attributes (in +** bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_PNIO_IA_DEVICE_ID_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_VENDOR_ID_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_STATION_TYPE_DS ( 25 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_MAX_AR_DS ABP_UINT32_SIZEOF +#define ABP_PNIO_IA_RTM_DS ABP_UINT8_SIZEOF +#define ABP_PNIO_IA_IM_ORDER_ID_DS ( 20 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_IM_SERIAL_NBR_DS ( 16 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_IM_HW_REV_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_IM_SW_REV_DS ( 4 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_IM_REV_CNT_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_IM_PROFILE_ID_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_IM_PROFILE_SPEC_TYPE_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_IM_VER_DS ( 2 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_IM_SUPPORTED_DS ABP_UINT16_SIZEOF +#define ABP_PNIO_IA_PORT1_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_PORT2_MAC_ADDRESS_DS ( 6 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_SYSTEM_DESCRIPTION_DS ( 255 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_INTERFACE_DESCRIPTION_DS ( 255 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_MOD_ID_ASSIGN_MODE_DS ( ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_SYSTEM_CONTACT_DS ( 255 * ABP_UINT8_SIZEOF ) +#define ABP_PNIO_IA_PROFIENERGY_FUNC_DS ( ABP_UINT8_SIZEOF ) + +/*------------------------------------------------------------------------------ +** +** The PROFINET IO object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_PNIO_CMD_GET_RECORD 0x10 +#define ABP_PNIO_CMD_SET_RECORD 0x11 +#define ABP_PNIO_CMD_GET_IM_RECORD 0x12 +#define ABP_PNIO_CMD_SET_IM_RECORD 0x13 +#define ABP_PNIO_CMD_AR_CHECK_IND 0x14 +#define ABP_PNIO_CMD_CFG_MISMATCH_IND 0x15 +#define ABP_PNIO_CMD_AR_INFO_IND 0x16 +#define ABP_PNIO_CMD_END_OF_PRM_IND 0x17 +#define ABP_PNIO_CMD_AR_ABORT_IND 0x19 +#define ABP_PNIO_CMD_PLUG_SUB_FAILED 0x1A +#define ABP_PNIO_CMD_EXPECTED_IDENT_IND 0x1B +#define ABP_PNIO_CMD_SAVE_IP_SUITE 0x1C +#define ABP_PNIO_CMD_SAVE_STATION_NAME 0x1D + +/*------------------------------------------------------------------------------ +** +** The data size of the PROFINET Object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_PNIO_CMD_GET_RECORD_DS 11 +#define ABP_PNIO_CMD_SET_RECORD_DS 255 +#define ABP_PNIO_CMD_GET_IM_RECORD_DS 4 +#define ABP_PNIO_CMD_SET_IM_RECORD_DS 255 +#define ABP_PNIO_CMD_AR_CHECK_IND_DS 255 +#define ABP_PNIO_CMD_CFG_MISMATCH_IND_DS 16 +#define ABP_PNIO_CMD_AR_INFO_IND_DS 255 +#define ABP_PNIO_CMD_END_OF_PRM_IND_DS 8 +#define ABP_PNIO_CMD_AR_ABORT_IND_DS 2 +#define ABP_PNIO_CMD_PLUG_SUB_FAILED_DS 8 +#define ABP_PNIO_CMD_EXPECTED_IDENT_IND_DS 255 + +/*------------------------------------------------------------------------------ +** +** Response codes for Expected_Ident_Ind +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_PNIO_RSP_EXPECTED_IDENT_IND_CONT 0 +#define ABP_PNIO_RSP_EXPECTED_IDENT_IND_BLOCK 1 + +/*------------------------------------------------------------------------------ +** +** PROFINET IO specific exception information codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_PNIO_NW_EXCPT_ILLEGAL_VALUE 1 +#define ABP_PNIO_NW_EXCPT_WRONG_DATA_SIZE 2 +#define ABP_PNIO_NW_EXCPT_ILLEGAL_RSP 3 +#define ABP_PNIO_NW_EXCPT_MISSING_MAC_ADDRESS 4 +#define ABP_PNIO_NW_EXCPT_CMD_TIMEOUT 5 + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** end of abp_pnio.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_safe.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,78 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_safe.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** abp_safe.h - Anybus-CC Functional Safety Object Protocol Definitions. +** +** This software component contains definitions used by Anybus-CC +** modules as well as applications designed to use Functional Safety. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_SAFE_H_ +#define ABP_SAFE_H_ + + +/*------------------------------------------------------------------------------ +** +** The Functional Safety instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SAFE_IA_SAFETY_ENABLE 1 +#define ABP_SAFE_IA_BAUD_RATE 2 + + +/*------------------------------------------------------------------------------ +** +** The data size of the Functional Safety instance attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SAFE_IA_SAFETY_ENABLE_DS ABP_BOOL_SIZEOF +#define ABP_SAFE_IA_BAUD_RATE_DS ABP_UINT32_SIZEOF + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_safe.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_smtp.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,144 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_smtp.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC SMTP Client Interface Object Protocol Definitions. +** +** This software component contains SMTP definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_SMTP_H +#define ABP_SMTP_H + + +/******************************************************************************* +** +** SMTP Client Interface object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The SMTP Client Interface object specific object attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SMTP_OA_MAX_INST 11 /* Max number of instances */ +#define ABP_SMTP_OA_EMAILS_SENT 12 /* Emails sent */ +#define ABP_SMTP_OA_EMAIL_FAILED 13 /* Emails failed to send */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC SMTP Client Interface object specific +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SMTP_OA_MAX_INST_DS ABP_UINT16_SIZEOF +#define ABP_SMTP_OA_EMAILS_SENT_DS ABP_UINT16_SIZEOF +#define ABP_SMTP_OA_EMAIL_FAILED_DS ABP_UINT16_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The SMTP Client Interface instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SMTP_IA_FROM 1 /* From address */ +#define ABP_SMTP_IA_TO 2 /* To address */ +#define ABP_SMTP_IA_SUBJECT 3 /* Message subject */ +#define ABP_SMTP_IA_MESSAGE 4 /* Message body */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC SMTP Client Interface object instance +** attributes (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SMTP_IA_FROM_DS ( 255 * ABP_UINT8_SIZEOF ) +#define ABP_SMTP_IA_TO_DS ( 255 * ABP_UINT8_SIZEOF ) +#define ABP_SMTP_IA_SUBJECT_DS ( 255 * ABP_UINT8_SIZEOF ) +#define ABP_SMTP_IA_MESSAGE_DS ( 255 * ABP_UINT8_SIZEOF ) + + +/*------------------------------------------------------------------------------ +** +** The SMTP Client Interface object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SMTP_CMD_SEND_EMAIL 0x10 +#define ABP_SMTP_CMD_SEND_EMAIL_FROM_FILE 0x11 + + +/*------------------------------------------------------------------------------ +** +** SMTP Client Interface object specific error codes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SMTP_NO_EMAIL_SERVER 1 +#define ABP_SMTP_SERVER_NOT_READY 2 +#define ABP_SMTP_AUTHENTICATION_ERROR 3 +#define ABP_SMTP_SOCKET_ERROR 4 +#define ABP_SMTP_SSI_SCAN_ERROR 5 +#define ABP_SMTP_FILE_ERROR 6 +#define ABP_SMTP_OTHER 255 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_smtp.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_soc.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,241 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** +** File Name +** --------- +** +** abp_soc.h +** +******************************************************************************** +******************************************************************************** +** +** Description +** ----------- +** +** ABP - Anybus-CC Socket Interface Object Protocol Definitions. +** +** This software component contains SOC definitions used by Anybus-CC +** modules as well as applications designed to use such modules. +** +******************************************************************************** +******************************************************************************** +** ** +** COPYRIGHT NOTIFICATION (c) 2008 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +** ** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_SOC_H +#define ABP_SOC_H + + +/******************************************************************************* +** +** Socket Interface object constants. +** +** Object revision: 1. +** +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** +** The Socket Interface object specific object attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SOC_OA_MAX_INST 11 /* Max number of instances */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Socket Interface object specific attributes +** (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SOC_OA_MAX_INST_DS ABP_UINT16_SIZEOF + + +/*------------------------------------------------------------------------------ +** +** The Socket Interface instance attributes. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SOC_IA_SOCK_TYPE 1 /* Socket type */ +#define ABP_SOC_IA_LOCAL_PORT 2 /* Local port */ +#define ABP_SOC_IA_HOST_IP 3 /* Host IP address */ +#define ABP_SOC_IA_HOST_PORT 4 /* Host port */ +#define ABP_SOC_IA_TCP_STATE 5 /* TCP state */ +#define ABP_SOC_IA_RX_BYTES 6 /* Bytes in RX buffer */ +#define ABP_SOC_IA_TX_BYTES 7 /* Bytes in TX buffer */ +#define ABP_SOC_IA_SO_REUSE_ADDR 8 /* Reuse address option */ +#define ABP_SOC_IA_SO_KEEP_ALIVE 9 /* Keep alive option */ +#define ABP_SOC_IA_IP_MULT_TTL 10 /* Multicast time-to-live */ +#define ABP_SOC_IA_IP_MULT_LOOP 11 /* Multicast loopback */ +#define ABP_SOC_IA_TCP_ACKDELAYTIME 12 /* TCP acknowledge delay time */ +#define ABP_SOC_IA_TCP_NODELAY 13 /* Disable Nagle's algorithm */ +#define ABP_SOC_IA_TCP_CONNTIMEO 14 /* Connect timeout */ + + +/*------------------------------------------------------------------------------ +** +** The data size of the Anybus-CC Socket Interface object instance attributes +** (in bytes). +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SOC_IA_SOCK_TYPE_DS ABP_UINT8_SIZEOF +#define ABP_SOC_IA_LOCAL_PORT_DS ABP_UINT16_SIZEOF +#define ABP_SOC_IA_HOST_IP_DS ABP_UINT32_SIZEOF +#define ABP_SOC_IA_HOST_PORT_DS ABP_UINT16_SIZEOF +#define ABP_SOC_IA_TCP_STATE_DS ABP_UINT8_SIZEOF +#define ABP_SOC_IA_RX_BYTES_DS ABP_UINT16_SIZEOF +#define ABP_SOC_IA_TX_BYTES_DS ABP_UINT16_SIZEOF +#define ABP_SOC_IA_SO_REUSE_ADDR_DS ABP_BOOL_SIZEOF +#define ABP_SOC_IA_SO_KEEP_ALIVE_DS ABP_BOOL_SIZEOF +#define ABP_SOC_IA_IP_MULT_TTL_DS ABP_UINT8_SIZEOF +#define ABP_SOC_IA_IP_MULT_LOOP_DS ABP_BOOL_SIZEOF +#define ABP_SOC_IA_TCP_ACKDELAYTIME_DS ABP_UINT16_SIZEOF +#define ABP_SOC_IA_TCP_NODELAY_DS ABP_BOOL_SIZEOF +#define ABP_SOC_IA_TCP_CONNTIMEO_DS ABP_UINT16_SIZEOF + +/*------------------------------------------------------------------------------ +** +** The Socket Interface object specific message commands. +** +**------------------------------------------------------------------------------ +*/ + +#define ABP_SOC_CMD_BIND 0x10 +#define ABP_SOC_CMD_SHUTDOWN 0x11 +#define ABP_SOC_CMD_LISTEN 0x12 +#define ABP_SOC_CMD_ACCEPT 0x13 +#define ABP_SOC_CMD_CONNECT 0x14 +#define ABP_SOC_CMD_RECEIVE 0x15 +#define ABP_SOC_CMD_RECEIVE_FROM 0x16 +#define ABP_SOC_CMD_SEND 0x17 +#define ABP_SOC_CMD_SEND_TO 0x18 +#define ABP_SOC_CMD_ADD_MULTICAST_MEMBERSHIP 0x19 +#define ABP_SOC_CMD_DROP_MULTICAST_MEMBERSHIP 0x1A +#define ABP_SOC_CMD_DNS_LOOKUP 0x1B + + +/*------------------------------------------------------------------------------ +** +** Socket types. +** +**------------------------------------------------------------------------------ +*/ + +#define SOC_TYPE_NB_TCP_SOCKET 0 /* Non-blocking TCP */ +#define SOC_TYPE_B_TCP_SOCKET 1 /* Blocking TCP */ +#define SOC_TYPE_NB_UDP_SOCKET 2 /* Non-blocking UDP */ +#define SOC_TYPE_B_UDP_SOCKET 3 /* Blocking UDP */ +#define SOC_TYPE_RESERVED 4 /* Reserved socket type. */ + /* This type is used to reserve */ + /* an instance for later use. */ + + + +/*------------------------------------------------------------------------------ +** +** TCP socket states. +** For more information see TCP statemachine (RFC 793) +** +**------------------------------------------------------------------------------ +*/ + +#define SOC_TCP_STATE_CLOSED 0 +#define SOC_TCP_STATE_LISTEN 1 +#define SOC_TCP_STATE_SYN_SENT 2 +#define SOC_TCP_STATE_SYN_RECEIVED 3 +#define SOC_TCP_STATE_ESTABLISHED 4 +#define SOC_TCP_STATE_CLOSE_WAIT 5 +#define SOC_TCP_STATE_FIN_WAIT_1 6 +#define SOC_TCP_STATE_CLOSING 7 +#define SOC_TCP_STATE_LAST_ACK 8 +#define SOC_TCP_STATE_FIN_WAIT_2 9 +#define SOC_TCP_STATE_TIME_WAIT 10 + + +/*------------------------------------------------------------------------------ +** +** Shutdown "how" types. +** +**------------------------------------------------------------------------------ +*/ + +#define SOC_SHUTDOWN_RECV 0 +#define SOC_SHUTDOWN_SEND 1 +#define SOC_SHUTDOWN_BOTH 2 + + +/*------------------------------------------------------------------------------ +** +** Socket object specific error codes. +** +**------------------------------------------------------------------------------ +*/ + +#define SOC_ERR_ENOBUFS 1 +#define SOC_ERR_ETIMEDOUT 2 +#define SOC_ERR_EISCONN 3 +#define SOC_ERR_EOPNOTSUPP 4 +#define SOC_ERR_ECONNABORTED 5 +#define SOC_ERR_EWOULDBLOCK 6 +#define SOC_ERR_ECONNREFUSED 7 +#define SOC_ERR_ECONNRESET 8 +#define SOC_ERR_ENOTCONN 9 +#define SOC_ERR_EALREADY 10 +#define SOC_ERR_EINVAL 11 +#define SOC_ERR_EMSGSIZE 12 +#define SOC_ERR_EPIPE 13 +#define SOC_ERR_EDESTADDRREQ 14 +#define SOC_ERR_ESHUTDOWN 15 + +#define SOC_ERR_EHAVEOOB 17 +#define SOC_ERR_ENOMEM 18 +#define SOC_ERR_EADDRNOTAVAIL 19 +#define SOC_ERR_EADDRINUSE 20 + +#define SOC_ERR_EINPROGRESS 22 + +#define SOC_ERR_ETOOMANYREFS 28 + +#define SOC_ERR_CMD_ABORTED 101 +#define SOC_ERR_DNS_NAME 102 +#define SOC_ERR_DNS_TIMEOUT 103 +#define SOC_ERR_DNS_CMD_FAILED 104 + + +#endif /* inclusion lock */ + +/******************************************************************************* +** +** End of abp_soc.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_abp/abp_sync.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,61 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABP version 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2014 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** + +******************************************************************************** +******************************************************************************** +** This file contains Sync Object specific definitions used by +** ABCC modules as well as applications designed to use the Sync Object.. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABP_SYNC_H_ +#define ABP_SYNC_H_ + +#include "abp.h" + +/*------------------------------------------------------------------------------ +** The Sync Object specific instance attributes. +**------------------------------------------------------------------------------ +*/ +#define ABP_SYNC_IA_CYCLE_TIME 1 /* Cycle time */ +#define ABP_SYNC_IA_OUTPUT_VALID 2 /* Output valid */ +#define ABP_SYNC_IA_INPUT_CAPTURE 3 /* Input capture */ +#define ABP_SYNC_IA_OUTPUT_PROCESSING 4 /* Output processing */ +#define ABP_SYNC_IA_INPUT_PROCESSING 5 /* Input processing */ +#define ABP_SYNC_IA_MIN_CYCLE_TIME 6 /* Min cycle time */ +#define ABP_SYNC_IA_SYNC_MODE 7 /* Sync mode */ +#define ABP_SYNC_IA_SUPPORTED_SYNC_MODES 8 /* Supported sync modes */ + +/*------------------------------------------------------------------------------ +** The data size of the sync object specific instance attributes +** (in bytes). +**------------------------------------------------------------------------------ +*/ +#define ABP_SYNC_IA_CYCLE_TIME_DS ABP_UINT32_SIZEOF +#define ABP_SYNC_IA_OUTPUT_VALID_DS ABP_UINT32_SIZEOF +#define ABP_SYNC_IA_INPUT_CAPTURE_DS ABP_UINT32_SIZEOF +#define ABP_SYNC_IA_OUTPUT_PROCESSING_DS ABP_UINT32_SIZEOF +#define ABP_SYNC_IA_INPUT_PROCESSING_DS ABP_UINT32_SIZEOF +#define ABP_SYNC_IA_MIN_CYCLE_TIME_DS ABP_UINT32_SIZEOF +#define ABP_SYNC_IA_SYNC_MODE_DS ABP_UINT16_SIZEOF +#define ABP_SYNC_IA_SUPPORTED_SYNC_MODES_DS ABP_UINT16_SIZEOF + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_adapt/abcc_drv_cfg.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,153 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** User configuration of the ABCC driver. The configuration parameters are +** documented in the driver's public interface abcc_cfg.h. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_DRV_CFG_H_ +#define ABCC_DRV_CFG_H_ + +#include "abcc_td.h" +#include "abp.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** All operating modes are supported +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_DRV_PARALLEL ( TRUE ) +#define ABCC_CFG_DRV_SPI ( TRUE ) +#define ABCC_CFG_DRV_SERIAL ( TRUE ) +#define ABCC_CFG_DRV_PARALLEL_30 ( TRUE ) + +/*------------------------------------------------------------------------------ +** The software can both get the operating mode from external resource and set +** the selected operating mode to the ABCC host connector. +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_OP_MODE_GETTABLE ( TRUE ) +#define ABCC_CFG_OP_MODE_SETTABLE ( TRUE ) + +#if( !ABCC_CFG_OP_MODE_GETTABLE ) +#define ABCC_CFG_ABCC_OP_MODE_30 ABP_OP_MODE_8_BIT_PARALLEL +#define ABCC_CFG_ABCC_OP_MODE_40 ABP_OP_MODE_8_BIT_PARALLEL +#endif + +/*------------------------------------------------------------------------------ +** SPI frame configuration +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_DRV_SPI ) +#define ABCC_CFG_SPI_MSG_FRAG_LEN ( 16 ) +#endif + +/*------------------------------------------------------------------------------ +** ABCC memory access configuration for parallel operation modes +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_MEMORY_MAPPED_ACCESS ( FALSE ) +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_CFG_PARALLEL_BASE_ADR ( 0x00000000 ) +#endif + +/*------------------------------------------------------------------------------ +** Module id is read from host connector. No softconfiguration is done. +**------------------------------------------------------------------------------ +*/ +/* #define ABCC_CFG_ABCC_MODULE_ID ABP_MODULE_ID_ACTIVE_ABCC40 */ + +/*------------------------------------------------------------------------------ +** Module detection configuration +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_MOD_DETECT_PINS_CONN ( TRUE ) + +/*------------------------------------------------------------------------------ +** Configuration of message handling +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_MAX_NUM_APPL_CMDS ( 2 ) +#define ABCC_CFG_MAX_NUM_ABCC_CMDS ( 2 ) +#define ABCC_CFG_MAX_MSG_SIZE ( 255 ) +#define ABCC_CFG_MAX_PROCESS_DATA_SIZE ( 512 ) + +/*------------------------------------------------------------------------------ +** Sync configuration +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_SYNC_ENABLE ( FALSE ) +#if( ABCC_CFG_SYNC_ENABLE ) +#define ABCC_CFG_USE_ABCC_SYNC_SIGNAL ( TRUE ) +#endif + +/*------------------------------------------------------------------------------ +** Interrupt configuration excluding sync +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_POLL_ABCC_IRQ_PIN ( FALSE ) +#define ABCC_CFG_INT_ENABLED ( FALSE ) +#if( ABCC_CFG_INT_ENABLED ) + #define ABCC_CFG_INT_ENABLE_MASK_PAR ( ABP_INTMASK_RDPDIEN | ABP_INTMASK_STATUSIEN | ABP_INTMASK_RDMSGIEN | ABP_INTMASK_WRMSGIEN | ABP_INTMASK_ANBRIEN ) + #define ABCC_CFG_INT_ENABLE_MASK_SPI ( 0 ) + #define ABCC_CFG_HANDLE_INT_IN_ISR_MASK ( ABP_INTMASK_RDPDIEN ) +#endif + +/*------------------------------------------------------------------------------ +** Watchdog configuration +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_WD_TIMEOUT_MS ( 1000 ) + +/*------------------------------------------------------------------------------ +** Remap support configuration +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_REMAP_SUPPORT_ENABLED ( FALSE ) + +/*------------------------------------------------------------------------------ +** The Application data object ADI support configuration +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_STRUCT_DATA_TYPE ( FALSE ) +#define ABCC_CFG_ADI_GET_SET_CALLBACK ( FALSE ) +#define ABCC_CFG_64BIT_ADI_SUPPORT ( FALSE ) + +/*------------------------------------------------------------------------------ +** Debug event print functions +**------------------------------------------------------------------------------ +*/ +#define ABCC_CFG_ERR_REPORTING_ENABLED ( TRUE ) +#define ABCC_CFG_DEBUG_EVENT_ENABLED ( TRUE ) +#define ABCC_CFG_DEBUG_ERR_ENABLED ( TRUE ) +#define ABCC_CFG_DEBUG_MESSAGING ( FALSE ) + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_adapt/abcc_identification.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,643 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** User configuration to set the identification parameters of an ABCC module
+**
+** All configurations in this file should be possible to override if defined
+** in abcc_platform_cfg.h. This allows the target platform to adapt the
+** configuration to realize its implementation for specific needs.
+********************************************************************************
+********************************************************************************
+** Services:
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABCC_IDENTIFICATION_H_
+#define ABCC_IDENTIFICATION_H_
+
+#include "abcc_platform_cfg.h"
+
+#ifndef ABCC_OBJ_CFG_H_
+#error Do not include abcc_identification.h, include abcc_obj_cfg.h instead.
+#endif
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Ethernet Powerlink (0xE9)
+**------------------------------------------------------------------------------
+*/
+#if EPL_OBJ_ENABLE
+/*
+** Attribute 1: Vendor ID (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef EPL_IA_VENDOR_ID_ENABLE
+ #define EPL_IA_VENDOR_ID_ENABLE TRUE
+ #define EPL_IA_VENDOR_ID_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 2: Product Code type (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef EPL_IA_PRODUCT_CODE_ENABLE
+ #define EPL_IA_PRODUCT_CODE_ENABLE TRUE
+ #define EPL_IA_PRODUCT_CODE_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 3: Revision High Word (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EPL_IA_REVISION_HW_ENABLE
+ #define EPL_IA_REVISION_HW_ENABLE TRUE
+ #define EPL_IA_REVISION_HW_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 4: Revision Low Word (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EPL_IA_REVISION_LW_ENABLE
+ #define EPL_IA_REVISION_LW_ENABLE TRUE
+ #define EPL_IA_REVISION_LW_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 5: Serial number (UINT32 - function/variable/0x00000000-0xFFFFFFFF)
+*/
+#ifndef EPL_IA_SERIAL_NUMBER_ENABLE
+ #define EPL_IA_SERIAL_NUMBER_ENABLE TRUE
+ #define EPL_IA_SERIAL_NUMBER_VALUE 0x12345678
+#endif
+
+/*
+** Attribute 6: Manufacturer device name (Array of CHAR)
+*/
+#ifndef EPL_IA_MANF_DEVICE_NAME_ENABLE
+ #define EPL_IA_MANF_DEVICE_NAME_ENABLE TRUE
+ #define EPL_IA_MANF_DEVICE_NAME_VALUE "Manufacturer device name"
+#endif
+
+/*
+** Attribute 7: Manufacturer hardware version (Array of CHAR)
+*/
+#ifndef EPL_IA_MANF_HW_VERSION_ENABLE
+ #define EPL_IA_MANF_HW_VERSION_ENABLE TRUE
+ #define EPL_IA_MANF_HW_VERSION_VALUE "01"
+#endif
+
+/*
+** Attribute 8: Manufacturer software version (Array of CHAR)
+*/
+#ifndef EPL_IA_MANF_SW_VERSION_ENABLE
+ #define EPL_IA_MANF_SW_VERSION_ENABLE TRUE
+ #define EPL_IA_MANF_SW_VERSION_VALUE "01"
+#endif
+
+/*
+** Attribute 10: Device type (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef EPL_IA_DEVICE_TYPE_ENABLE
+ #define EPL_IA_DEVICE_TYPE_ENABLE TRUE
+ #define EPL_IA_DEVICE_TYPE_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 14: Manufacturer name (Array of CHAR)
+*/
+#ifndef EPL_IA_MANF_NAME_ENABLE
+ #define EPL_IA_MANF_NAME_ENABLE TRUE
+ #define EPL_IA_MANF_NAME_VALUE "Manufacturer name"
+#endif
+
+#endif /* #if EPL_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** EtherCAT (0xF5)
+**------------------------------------------------------------------------------
+*/
+#if ECT_OBJ_ENABLE
+/*
+** Attribute 1: Vendor ID (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef ECT_IA_VENDOR_ID_ENABLE
+ #define ECT_IA_VENDOR_ID_ENABLE TRUE
+ #define ECT_IA_VENDOR_ID_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 2: Product Code type (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef ECT_IA_PRODUCT_CODE_ENABLE
+ #define ECT_IA_PRODUCT_CODE_ENABLE TRUE
+ #define ECT_IA_PRODUCT_CODE_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 3: Revision High Word (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef ECT_IA_MAJOR_REV_ENABLE
+ #define ECT_IA_MAJOR_REV_ENABLE TRUE
+ #define ECT_IA_REVISION_HW_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 4: Revision Low Word (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef ECT_IA_MINOR_REV_ENABLE
+ #define ECT_IA_MINOR_REV_ENABLE TRUE
+ #define ECT_IA_REVISION_LW_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 5: Serial number (UINT32 - function/variable/0x00000000-0xFFFFFFFF)
+*/
+#ifndef ECT_IA_SERIAL_NUMBER_ENABLE
+ #define ECT_IA_SERIAL_NUMBER_ENABLE TRUE
+ #define ECT_IA_SERIAL_NUMBER_VALUE 0x12345678
+#endif
+
+/*
+** Attribute 6: Manufacturer device name (Array of CHAR)
+*/
+#ifndef ECT_IA_MANF_DEVICE_NAME_ENABLE
+ #define ECT_IA_MANF_DEVICE_NAME_ENABLE TRUE
+ #define ECT_IA_MANF_DEVICE_NAME_VALUE "Manufacturer device name"
+#endif
+
+/*
+** Attribute 7: Manufacturer hardware version (Array of CHAR)
+*/
+#ifndef ECT_IA_MANF_HW_VERSION_ENABLE
+ #define ECT_IA_MANF_HW_VERSION_ENABLE TRUE
+ #define ECT_IA_MANF_HW_VERSION_VALUE "FF"
+#endif
+
+/*
+** Attribute 8: Manufacturer software version (Array of CHAR)
+*/
+#ifndef ECT_IA_MANF_SW_VERSION_ENABLE
+ #define ECT_IA_MANF_SW_VERSION_ENABLE TRUE
+ #define ECT_IA_MANF_SW_VERSION_VALUE "FF"
+#endif
+
+/*
+** Attribute 10: Device type (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef ECT_IA_DEVICE_TYPE_ENABLE
+ #define ECT_IA_DEVICE_TYPE_ENABLE TRUE
+ #define ECT_IA_DEVICE_TYPE_VALUE 0xFFFFFFFF
+#endif
+
+#endif /* #if ECT_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** PROFINET IO Object (0xF6)
+**------------------------------------------------------------------------------
+*/
+#if PRT_OBJ_ENABLE
+/*
+** Attribute 1: Device ID (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef PRT_IA_DEVICE_ID_ENABLE
+ #define PRT_IA_DEVICE_ID_ENABLE TRUE
+ #define PRT_IA_DEVICE_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 2: Vendor ID (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef PRT_IA_VENDOR_ID_ENABLE
+ #define PRT_IA_VENDOR_ID_ENABLE TRUE
+ #define PRT_IA_VENDOR_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 3: Station Type (Array of CHAR)
+*/
+#ifndef PRT_IA_STATION_TYPE_ENABLE
+ #define PRT_IA_STATION_TYPE_ENABLE TRUE
+ #define PRT_IA_STATION_TYPE_VALUE "Station Type"
+#endif
+
+/*
+** Attribute 8: IM Order ID (Array of CHAR)
+*/
+#ifndef PRT_IA_IM_ORDER_ID_ENABLE
+ #define PRT_IA_IM_ORDER_ID_ENABLE TRUE
+ #define PRT_IA_IM_ORDER_ID_VALUE "Order ID"
+#endif
+
+/*
+** Attribute 9: IM Serial Number (Array of CHAR)
+*/
+#ifndef PRT_IA_IM_SERIAL_NBR_ENABLE
+ #define PRT_IA_IM_SERIAL_NBR_ENABLE TRUE
+ #define PRT_IA_IM_SERIAL_NBR_VALUE "0123456789ABCDEF"
+#endif
+
+/*
+** Attribute 10: IM Hardware revision (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef PRT_IA_IM_HW_REV_ENABLE
+ #define PRT_IA_IM_HW_REV_ENABLE TRUE
+ #define PRT_IA_IM_HW_REV_VALUE 0x0000
+#endif
+
+/*
+** Attribute 11: IM Software revision (CHAR, 3 * UINT8)
+*/
+#ifndef PRT_IA_IM_SW_REV_ENABLE
+ #define PRT_IA_IM_SW_REV_ENABLE TRUE
+ #define PRT_IA_IM_SW_REV_SYMBOL_VALUE 'V'
+ #define PRT_IA_IM_SW_REV_MAJOR_VALUE 99
+ #define PRT_IA_IM_SW_REV_MINOR_VALUE 99
+ #define PRT_IA_IM_SW_REV_BUILD_VALUE 99
+#endif
+
+/*
+** Attribute 19: System Description (Array of CHAR)
+*/
+#ifndef PRT_IA_SYSTEM_DESCRIPTION_ENABLE
+ #define PRT_IA_SYSTEM_DESCRIPTION_ENABLE TRUE
+ #define PRT_IA_SYSTEM_DESCRIPTION_VALUE "System Description"
+#endif
+
+/*
+** Attribute 22: System Contact (Array of CHAR)
+*/
+#ifndef PRT_IA_SYSTEM_CONTACT_ENABLE
+ #define PRT_IA_SYSTEM_CONTACT_ENABLE TRUE
+ #define PRT_IA_SYSTEM_CONTACT_VALUE "System Contact"
+#endif
+
+#endif /* #if PRT_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** EtherNet/IP (0xF8)
+**------------------------------------------------------------------------------
+*/
+#if EIP_OBJ_ENABLE
+/*
+** Attribute 1: Vendor ID (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_VENDOR_ID_ENABLE
+ #define EIP_IA_VENDOR_ID_ENABLE TRUE
+ #define EIP_IA_VENDOR_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 2: Device type (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_DEVICE_TYPE_ENABLE
+ #define EIP_IA_DEVICE_TYPE_ENABLE TRUE
+ #define EIP_IA_DEVICE_TYPE_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 3: Product code (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_PRODUCT_CODE_ENABLE
+ #define EIP_IA_PRODUCT_CODE_ENABLE TRUE
+ #define EIP_IA_PRODUCT_CODE_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 4: Revision (Array of UINT8 - {0x01-0xFF})
+*/
+#ifndef EIP_IA_REVISION_ENABLE
+ #define EIP_IA_REVISION_ENABLE TRUE
+ #define EIP_IA_REVISION_MAJOR_VALUE 99
+ #define EIP_IA_REVISION_MINOR_VALUE 99
+#endif
+
+/*
+** Attribute 5: Serial number (UINT32 - function/variable/0x00000000-0xFFFFFFFF)
+*/
+#ifndef EIP_IA_SERIAL_NUMBER_ENABLE
+ #define EIP_IA_SERIAL_NUMBER_ENABLE TRUE
+ #define EIP_IA_SERIAL_NUMBER_VALUE 0x12345678
+#endif
+
+/*
+** Attribute 6: Product name (Array of CHAR)
+*/
+#ifndef EIP_IA_PRODUCT_NAME_ENABLE
+ #define EIP_IA_PRODUCT_NAME_ENABLE TRUE
+ #define EIP_IA_PRODUCT_NAME_VALUE "Product Name"
+#endif
+
+#endif /* #if EIP_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** Ethernet Object (0xF9)
+**------------------------------------------------------------------------------
+*/
+#if ETN_OBJ_ENABLE
+/*
+** Attribute 1: MAC Address (Array[6] of UINT8)
+*/
+#ifndef ETN_IA_MAC_ADDRESS_ENABLE
+ #define ETN_IA_MAC_ADDRESS_ENABLE TRUE
+ #define ETN_IA_MAC_ADDRESS_VALUE "\x00\x30\x11\x11\xFF\xFF"
+#endif
+
+#endif /* #if ETN_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** Modbus (0xFA)
+**------------------------------------------------------------------------------
+*/
+#if MOD_OBJ_ENABLE
+/*
+** Attribute 1: Vendor Name (Array of CHAR)
+*/
+#ifndef MOD_IA_VENDOR_NAME_ENABLE
+ #define MOD_IA_VENDOR_NAME_ENABLE TRUE
+ #define MOD_IA_VENDOR_NAME_VALUE "Vendor Name"
+#endif
+
+/*
+** Attribute 2: Product Code (Array of CHAR)
+*/
+#ifndef MOD_IA_PRODUCT_CODE_ENABLE
+ #define MOD_IA_PRODUCT_CODE_ENABLE TRUE
+ #define MOD_IA_PRODUCT_CODE_VALUE "Product Code"
+#endif
+
+/*
+** Attribute 3: Revision (Array of CHAR)
+*/
+#ifndef MOD_IA_REVISION_ENABLE
+ #define MOD_IA_REVISION_ENABLE TRUE
+ #define MOD_IA_REVISION_VALUE "99.99"
+#endif
+
+/*
+** Attribute 4: Vendor URL (Array of CHAR)
+*/
+#ifndef MOD_IA_VENDOR_URL_ENABLE
+ #define MOD_IA_VENDOR_URL_ENABLE TRUE
+ #define MOD_IA_VENDOR_URL_VALUE "www.vendor.url"
+#endif
+
+/*
+** Attribute 5: Product Name (Array of CHAR)
+*/
+#ifndef MOD_IA_PRODUCT_NAME_ENABLE
+ #define MOD_IA_PRODUCT_NAME_ENABLE TRUE
+ #define MOD_IA_PRODUCT_NAME_VALUE "Product Name"
+#endif
+
+/*
+** Attribute 6: Model Name (Array of CHAR)
+*/
+#ifndef MOD_IA_MODEL_NAME_ENABLE
+ #define MOD_IA_MODEL_NAME_ENABLE TRUE
+ #define MOD_IA_MODEL_NAME_VALUE "Model Name"
+#endif
+
+/*
+** Attribute 7: User Application Name (Array of CHAR)
+*/
+#ifndef MOD_IA_USER_APP_NAME_ENABLE
+ #define MOD_IA_USER_APP_NAME_ENABLE TRUE
+ #define MOD_IA_USER_APP_NAME_VALUE "User Application Name"
+#endif
+
+/*
+** Attribute 8: Device ID (Array of UINT8)
+*/
+#ifndef MOD_IA_DEVICE_ID_ENABLE
+ #define MOD_IA_DEVICE_ID_ENABLE TRUE
+ #define MOD_IA_DEVICE_ID_VALUE "\x00\x01\x02\x03"
+ #define MOD_IA_DEVICE_ID_ARRAY_SIZE 4
+#endif
+
+#endif /* #if MOD_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** COP Object (0xFB)
+**------------------------------------------------------------------------------
+*/
+#if COP_OBJ_ENABLE
+/*
+** Attribute 1: Vendor ID (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef COP_IA_VENDOR_ID_ENABLE
+ #define COP_IA_VENDOR_ID_ENABLE TRUE
+ #define COP_IA_VENDOR_ID_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 2: Product Code (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef COP_IA_PRODUCT_CODE_ENABLE
+ #define COP_IA_PRODUCT_CODE_ENABLE TRUE
+ #define COP_IA_PRODUCT_CODE_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 3: Major Revision (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef COP_IA_REV_MAJOR_ENABLE
+ #define COP_IA_REV_MAJOR_ENABLE TRUE
+ #define COP_IA_REV_MAJOR_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 4: Minor Revision (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef COP_IA_REV_MINOR_ENABLE
+ #define COP_IA_REV_MINOR_ENABLE TRUE
+ #define COP_IA_REV_MINOR_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 5: Serial Number (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef COP_IA_SERIAL_NUMBER_ENABLE
+ #define COP_IA_SERIAL_NUMBER_ENABLE TRUE
+ #define COP_IA_SERIAL_NUMBER_VALUE 0xFFFFFFFF
+#endif
+
+/*
+** Attribute 6: Manufacturer Device Name (Array of CHAR)
+*/
+#ifndef COP_IA_MANF_DEV_NAME_ENABLE
+ #define COP_IA_MANF_DEV_NAME_ENABLE TRUE
+ #define COP_IA_MANF_DEV_NAME_VALUE "Device Name"
+#endif
+
+/*
+** Attribute 7: Manufacturer Hardware Version (Array of CHAR)
+*/
+#ifndef COP_IA_MANF_HW_VER_ENABLE
+ #define COP_IA_MANF_HW_VER_ENABLE TRUE
+ #define COP_IA_MANF_HW_VER_VALUE "Hardware Version"
+#endif
+
+/*
+** Attribute 8: Manufacturer Software Version (Array of CHAR)
+*/
+#ifndef COP_IA_MANF_SW_VER_ENABLE
+ #define COP_IA_MANF_SW_VER_ENABLE TRUE
+ #define COP_IA_MANF_SW_VER_VALUE "Software Version"
+#endif
+
+#endif /* #if COP_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** DeviceNet (0xFC)
+**------------------------------------------------------------------------------
+*/
+#if DEV_OBJ_ENABLE
+/*
+** Attribute 1: Vendor ID (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DEV_IA_VENDOR_ID_ENABLE
+ #define DEV_IA_VENDOR_ID_ENABLE TRUE
+ #define DEV_IA_VENDOR_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 2: Device type (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DEV_IA_DEVICE_TYPE_ENABLE
+ #define DEV_IA_DEVICE_TYPE_ENABLE TRUE
+ #define DEV_IA_DEVICE_TYPE_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 3: Product code (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DEV_IA_PRODUCT_CODE_ENABLE
+ #define DEV_IA_PRODUCT_CODE_ENABLE TRUE
+ #define DEV_IA_PRODUCT_CODE_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 4: Revision (Array of UINT8 - {0x01-0xFF})
+*/
+#ifndef DEV_IA_REVISION_ENABLE
+ #define DEV_IA_REVISION_ENABLE TRUE
+ #define DEV_IA_REVISION_MAJOR_VALUE 99
+ #define DEV_IA_REVISION_MINOR_VALUE 99
+#endif
+
+/*
+** Attribute 5: Serial number (UINT32 - function/variable/0x00000000-0xFFFFFFFF)
+*/
+#ifndef DEV_IA_SERIAL_NUMBER_ENABLE
+ #define DEV_IA_SERIAL_NUMBER_ENABLE TRUE
+ #define DEV_IA_SERIAL_NUMBER_VALUE 0x12345678
+#endif
+
+/*
+** Attribute 6: Product name (Array of CHAR)
+*/
+#ifndef DEV_IA_PRODUCT_NAME_ENABLE
+ #define DEV_IA_PRODUCT_NAME_ENABLE TRUE
+ #define DEV_IA_PRODUCT_NAME_VALUE "Product Name"
+#endif
+
+#endif /* #if DEV_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** DPV1 Object (0xFD)
+**------------------------------------------------------------------------------
+*/
+#if DPV1_OBJ_ENABLE
+/*
+** Attribute 1: PNO Ident number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DPV1_IA_IDENT_NUMBER_ENABLE
+ #define DPV1_IA_IDENT_NUMBER_ENABLE TRUE
+ #define DPV1_IA_IDENT_NUMBER_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 8: Manufacturer Ident number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DPV1_IA_MANUFACTURER_ID_ENABLE
+ #define DPV1_IA_MANUFACTURER_ID_ENABLE TRUE
+ #define DPV1_IA_MANUFACTURER_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 9: IM Order ID (Array of CHAR)
+*/
+#ifndef DPV1_IA_ORDER_ID_ENABLE
+ #define DPV1_IA_ORDER_ID_ENABLE TRUE
+ #define DPV1_IA_ORDER_ID_VALUE "Order ID"
+#endif
+
+/*
+** Attribute 10: IM Serial Number (Array of CHAR)
+*/
+#ifndef DPV1_IA_SERIAL_NO_ENABLE
+ #define DPV1_IA_SERIAL_NO_ENABLE TRUE
+ #define DPV1_IA_SERIAL_NO_VALUE "0123456789ABCDEF"
+#endif
+
+/*
+** Attribute 11: IM Hardware revision (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DPV1_IA_HW_REV_ENABLE
+ #define DPV1_IA_HW_REV_ENABLE TRUE
+ #define DPV1_IA_HW_REV_VALUE 0x0000
+#endif
+
+/*
+** Attribute 12: IM Software revision (CHAR, 3 * UINT8)
+*/
+#ifndef DPV1_IA_SW_REV_ENABLE
+ #define DPV1_IA_SW_REV_ENABLE TRUE
+ #define DPV1_IA_SW_REV_SYMBOL_VALUE 'V'
+ #define DPV1_IA_SW_REV_MAJOR_VALUE 99
+ #define DPV1_IA_SW_REV_MINOR_VALUE 99
+ #define DPV1_IA_SW_REV_BUILD_VALUE 99
+#endif
+
+#endif /* DPV1_OBJ_ENABLE */
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_adapt/abcc_obj_cfg.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,951 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** User configuration of the Anybus objects implementation.
+**
+** All configurations in this file should be possible to override if defined
+** in abcc_platform_cfg.h. This allows the target platform to adapt the
+** product configuration to realize its implementation for specific needs.
+********************************************************************************
+********************************************************************************
+** Services:
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABCC_OBJ_CFG_H_
+#define ABCC_OBJ_CFG_H_
+
+#include "abcc_platform_cfg.h"
+#include "abcc_drv_cfg.h"
+
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Supported networks - Set to TRUE to enable a network
+**------------------------------------------------------------------------------
+*/
+#ifndef ECT_OBJ_ENABLE
+ #define ECT_OBJ_ENABLE FALSE
+#endif
+#ifndef PRT_OBJ_ENABLE
+ #define PRT_OBJ_ENABLE FALSE
+#endif
+#ifndef EIP_OBJ_ENABLE
+ #define EIP_OBJ_ENABLE FALSE
+#endif
+#ifndef EPL_OBJ_ENABLE
+ #define EPL_OBJ_ENABLE FALSE
+#endif
+#ifndef MOD_OBJ_ENABLE
+ #define MOD_OBJ_ENABLE FALSE
+#endif
+#ifndef COP_OBJ_ENABLE
+ #define COP_OBJ_ENABLE FALSE
+#endif
+#ifndef DEV_OBJ_ENABLE
+ #define DEV_OBJ_ENABLE FALSE
+#endif
+#ifndef DPV1_OBJ_ENABLE
+ #define DPV1_OBJ_ENABLE FALSE
+#endif
+
+
+/*------------------------------------------------------------------------------
+** Supported host object - Set to TRUE to enable
+**------------------------------------------------------------------------------
+*/
+#ifndef ETN_OBJ_ENABLE
+ #define ETN_OBJ_ENABLE FALSE
+#endif
+#ifndef SYNC_OBJ_ENABLE
+ #define SYNC_OBJ_ENABLE ABCC_CFG_SYNC_ENABLE
+#endif
+
+/*------------------------------------------------------------------------------
+** Sync Object (0xEE)
+**------------------------------------------------------------------------------
+*/
+
+#if SYNC_OBJ_ENABLE
+/*
+** Attribute 1: Cycle time (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef SYNC_IA_CYCLE_TIME_ENABLE
+ #define SYNC_IA_CYCLE_TIME_ENABLE TRUE
+ #define SYNC_IA_CYCLE_TIME_VALUE 0L
+#endif
+
+/*
+** Attribute 2: Output valid (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef SYNC_IA_OUTPUT_VALID_ENABLE
+ #define SYNC_IA_OUTPUT_VALID_ENABLE TRUE
+ #define SYNC_IA_OUTPUT_VALID_VALUE 0
+#endif
+
+/*
+** Attribute 3: Input capture (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef SYNC_IA_INPUT_CAPTURE_ENABLE
+ #define SYNC_IA_INPUT_CAPTURE_ENABLE TRUE
+ #define SYNC_IA_INPUT_CAPTURE_VALUE 0
+#endif
+
+/*
+** Attribute 4: Output processing (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef SYNC_IA_OUTPUT_PROCESSING_ENABLE
+ #define SYNC_IA_OUTPUT_PROCESSING_ENABLE TRUE
+ #define SYNC_IA_OUTPUT_PROCESSING_VALUE 1000L
+#endif
+
+/*
+** Attribute 5: Input processing (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef SYNC_IA_INPUT_PROCESSING_ENABLE
+ #define SYNC_IA_INPUT_PROCESSING_ENABLE TRUE
+ #define SYNC_IA_INPUT_PROCESSING_VALUE 1000L
+#endif
+
+/*
+** Attribute 6: Min cycle time (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef SYNC_IA_MIN_CYCLE_TIME_ENABLE
+ #define SYNC_IA_MIN_CYCLE_TIME_ENABLE TRUE
+ #define SYNC_IA_MIN_CYCLE_TIME_VALUE 1L
+#endif
+
+/*
+** Attribute 7: Sync mode (UINT16 - 0: Nonsynchronous operation
+** 1: Synchronous operation)
+*/
+#ifndef SYNC_IA_SYNC_MODE_ENABLE
+ #define SYNC_IA_SYNC_MODE_ENABLE TRUE
+ #define SYNC_IA_SYNC_MODE_VALUE 0x0000
+#endif
+
+/*
+** Attribute 8: Supported sync modes (UINT16 - Bit 0: 1 = Nonsynchronous mode supported
+** Bit 1: 1 = Synchronous mode supported
+** Bit 2-15: Reserved)
+*/
+#ifndef SYNC_IA_SUPPORTED_SYNC_MODES_ENABLE
+ #define SYNC_IA_SUPPORTED_SYNC_MODES_ENABLE TRUE
+ #define SYNC_IA_SUPPORTED_SYNC_MODES_VALUE 0x0003
+#endif
+
+#endif /* #if SYNC_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** Application data Object (0xF5)
+**------------------------------------------------------------------------------
+*/
+
+/*
+** These defines shall be set to the maximum number of ADIs that could be mapped
+** in either direction. Do not forget to consider remap scenarios if
+** ABCC_CFG_REMAP_SUPPORT_ENABLED is enabled in abcc_drv_cfg.h.
+*/
+#ifndef AD_MAX_NUM_WRITE_ADI_TO_MAP
+ #define AD_MAX_NUM_WRITE_ADI_TO_MAP ( 64 )
+#endif
+#ifndef AD_MAX_NUM_READ_ADI_TO_MAP
+ #define AD_MAX_NUM_READ_ADI_TO_MAP ( 64 )
+#endif
+
+/*
+** Attribute 5, 6, 7: Min, max and default attributes - (BOOL - TRUE/FALSE)
+*/
+#ifndef AD_IA_MIN_MAX_DEFAULT_ENABLE
+ #define AD_IA_MIN_MAX_DEFAULT_ENABLE ( TRUE )
+#endif
+
+/*------------------------------------------------------------------------------
+** EtherCAT Object (0xF5)
+**------------------------------------------------------------------------------
+*/
+#if ECT_OBJ_ENABLE
+/*
+** Attribute 9: ENUM ADIs (Array of UINT16 - {0x0001-0xFFFF})
+*/
+#ifndef ECT_IA_ENUM_ADIS_ENABLE
+ #define ECT_IA_ENUM_ADIS_ENABLE FALSE
+ #define ECT_IA_ENUM_ADIS_VALUE { 0x1357 }
+ #define ECT_IA_ENUM_ADIS_ARRAY_SIZE 1
+#endif
+
+/*
+** Attribute 11: Write PD assembly instance translation
+** (Array of UINT16 - {0x0001-0xFFFF})
+*/
+#ifndef ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE
+ #define ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE FALSE
+ #define ECT_IA_WR_PD_ASSY_INST_TRANS_VALUE { 0x2468 }
+ #define ECT_IA_WR_PD_ASSY_INST_TRANS_SIZE 1
+#endif
+
+/*
+** Attribute 12: Read PD assembly instance translation
+** (Array of UINT16 - {0x0001-0xFFFF})
+*/
+#ifndef ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE
+ #define ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE FALSE
+ #define ECT_IA_RD_PD_ASSY_INST_TRANS_VALUE { 0xA5A5 }
+ #define ECT_IA_RD_PD_ASSY_INST_TRANS_SIZE 1
+#endif
+
+/*
+** Attribute 13: ADI translation (Array of (Struct of {UINT16, UINT16}))
+*/
+#ifndef ECT_IA_ADI_TRANS_ENABLE
+ #define ECT_IA_ADI_TRANS_ENABLE FALSE
+ #define ECT_IA_ADI_TRANS_VALUE { { 0x1234, 0x5678 } }
+ #define ECT_IA_ADI_TRANS_SIZE 1
+#endif
+
+/*
+** Attribute 15: Object subindex translation
+** (Array of (Struct of {UINT16, UINT16, UINT8 }))
+*/
+#ifndef ECT_IA_OBJ_SUB_TRANS_ENABLE
+ #define ECT_IA_OBJ_SUB_TRANS_ENABLE FALSE
+ #define ECT_IA_OBJ_SUB_TRANS_VALUE { { 0x8765, 0x4321, 0x12 } }
+ #define ECT_IA_OBJ_SUB_TRANS_SIZE 1
+#endif
+
+#endif /* if ECT_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** PROFINET IO Object (0xF6)
+**------------------------------------------------------------------------------
+*/
+
+#if PRT_OBJ_ENABLE
+/*
+** Attribute 4: MaxAr (UINT32 - 0x00000000-0xFFFFFFFF)
+*/
+#ifndef PRT_IA_MAX_AR_ENABLE
+ #define PRT_IA_MAX_AR_ENABLE FALSE
+ #define PRT_IA_MAX_AR_VALUE 0x00000000
+#endif
+
+/*
+** Attribute 7: Record data Transparent Mode (UINT8 - 0x00-0xFF)
+*/
+#ifndef PRT_IA_RTM_ENABLE
+ #define PRT_IA_RTM_ENABLE FALSE
+ #define PRT_IA_RTM_VALUE 0x00
+#endif
+
+/*
+** Attribute 12: IM Revision counter (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef PRT_IA_IM_REV_CNT_ENABLE
+ #define PRT_IA_IM_REV_CNT_ENABLE FALSE
+ #define PRT_IA_IM_REV_CNT_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 13: IM Profile ID (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef PRT_IA_IM_PROFILE_ID_ENABLE
+ #define PRT_IA_IM_PROFILE_ID_ENABLE FALSE
+ #define PRT_IA_IM_PROFILE_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 14: IM Profile specific type (UINT16 - 1-6)
+*/
+#ifndef PRT_IA_IM_PROFILE_SPEC_TYPE_ENABLE
+ #define PRT_IA_IM_PROFILE_SPEC_TYPE_ENABLE FALSE
+ #define PRT_IA_IM_PROFILE_SPEC_TYPE_VALUE 0x0004
+#endif
+
+/*
+** Attribute 15: IM Version (2 * UINT8)
+*/
+#ifndef PRT_IA_IM_VER_ENABLE
+ #define PRT_IA_IM_VER_ENABLE FALSE
+ #define PRT_IA_IM_VER_MAJOR_VALUE 99
+ #define PRT_IA_IM_VER_MINOR_VALUE 99
+#endif
+
+/*
+** Attribute 16: IM Supported (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef PRT_IA_IM_SUPPORTED_ENABLE
+ #define PRT_IA_IM_SUPPORTED_ENABLE FALSE
+ #define PRT_IA_IM_SUPPORTED_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 17: Port 1 MAC Address (Array[6] of UINT8)
+*/
+#ifndef PRT_IA_PORT1_MAC_ADDRESS_ENABLE
+ #define PRT_IA_PORT1_MAC_ADDRESS_ENABLE FALSE
+ #define PRT_IA_PORT1_MAC_ADDRESS_VALUE "\x00\x00\x00\x00\x00\x00"
+#endif
+
+/*
+** Attribute 18: Port 2 MAC Address (Array[6] of UINT8)
+*/
+#ifndef PRT_IA_PORT2_MAC_ADDRESS_ENABLE
+ #define PRT_IA_PORT2_MAC_ADDRESS_ENABLE FALSE
+ #define PRT_IA_PORT2_MAC_ADDRESS_VALUE "\x00\x00\x00\x00\x00\x00"
+#endif
+
+/*
+** Attribute 20: Interface Description (Array of CHAR)
+*/
+#ifndef PRT_IA_INTERFACE_DESCRIPTION_ENABLE
+ #define PRT_IA_INTERFACE_DESCRIPTION_ENABLE FALSE
+ #define PRT_IA_INTERFACE_DESCRIPTION_VALUE "Interface Description"
+#endif
+
+/*
+** Attribute 21: Module Id Assignment mode (UINT8 - 0x00-0xFF)
+*/
+#ifndef PRT_IA_MOD_ID_ASSIGN_MODE_ENABLE
+ #define PRT_IA_MOD_ID_ASSIGN_MODE_ENABLE FALSE
+ #define PRT_IA_MOD_ID_ASSIGN_MODE_VALUE 0
+#endif
+
+/*
+** Attribute 23: PROFIenergy functionality (UINT8 - 0x00-0xFF)
+*/
+#ifndef PRT_IA_PROFIENERGY_FUNC_ENABLE
+ #define PRT_IA_PROFIENERGY_FUNC_ENABLE FALSE
+ #define PRT_IA_PROFIENERGY_FUNC_VALUE 0
+#endif
+
+#endif /* #if PRT_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** EtherNet/IP Object (0xF8)
+**------------------------------------------------------------------------------
+*/
+
+#if EIP_OBJ_ENABLE
+/*
+** Attribute 7: Producing instance number (Array of UINT16 - {0x0001-0xFFFF})
+*/
+#ifndef EIP_IA_PROD_INSTANCE_ENABLE
+ #define EIP_IA_PROD_INSTANCE_ENABLE FALSE
+ #define EIP_IA_PROD_INSTANCE_VALUE { 0x0064 }
+ #define EIP_IA_PROD_INSTANCE_ARRAY_SIZE 1
+#endif
+
+/*
+** Attribute 8: Consuming instance number (Array of UINT16 - {0x0001-0xFFFF})
+*/
+#ifndef EIP_IA_CONS_INSTANCE_ENABLE
+ #define EIP_IA_CONS_INSTANCE_ENABLE FALSE
+ #define EIP_IA_CONS_INSTANCE_VALUE { 0x0096 }
+ #define EIP_IA_CONS_INSTANCE_ARRAY_SIZE 1
+#endif
+
+/*
+** Attribute 9: Enable communication settings from net (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_COMM_SETTINGS_FROM_NET_ENABLE
+ #define EIP_IA_COMM_SETTINGS_FROM_NET_ENABLE FALSE
+ #define EIP_IA_COMM_SETTINGS_FROM_NET_VALUE TRUE
+#endif
+
+/*
+** Attribute 11: Enable CIP request forwarding (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_ENABLE_APP_CIP_OBJECTS_ENABLE
+ #define EIP_IA_ENABLE_APP_CIP_OBJECTS_ENABLE FALSE
+ #define EIP_IA_ENABLE_APP_CIP_OBJECTS_VALUE FALSE
+#endif
+
+/*
+** Attribute 12: Enable Parameter object (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_ENABLE_PARAM_OBJECT_ENABLE
+ #define EIP_IA_ENABLE_PARAM_OBJECT_ENABLE FALSE
+ #define EIP_IA_ENABLE_PARAM_OBJECT_VALUE TRUE
+#endif
+
+/*
+** Attribute 13: Input only heartbeat instance number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_INPUT_INSTANCE_OBJECT_ENABLE
+ #define EIP_IA_INPUT_INSTANCE_OBJECT_ENABLE FALSE
+ #define EIP_IA_INPUT_INSTANCE_OBJECT_VALUE 0x0003
+#endif
+
+/*
+** Attribute 14: Listen only heartbeat instance number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_LISTEN_INSTANCE_OBJECT_ENABLE
+ #define EIP_IA_LISTEN_INSTANCE_OBJECT_ENABLE FALSE
+ #define EIP_IA_LISTEN_INSTANCE_OBJECT_VALUE 0x0004
+#endif
+
+/*
+** Attribute 15: Assembly object Configuration instance number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_CONFIG_INSTANCE_ENABLE
+ #define EIP_IA_CONFIG_INSTANCE_ENABLE FALSE
+ #define EIP_IA_CONFIG_INSTANCE_VALUE 0x0005
+#endif
+
+/*
+** Attribute 16: Disable Strict IO match (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_DISABLE_STRICT_IO_MATCH_ENABLE
+ #define EIP_IA_DISABLE_STRICT_IO_MATCH_ENABLE FALSE
+ #define EIP_IA_DISABLE_STRICT_IO_MATCH_VALUE FALSE
+#endif
+
+/*
+** Attribute 17: Enable unconnected routing (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_ENABLE_UNCONNECTED_SEND_ENABLE
+ #define EIP_IA_ENABLE_UNCONNECTED_SEND_ENABLE FALSE
+ #define EIP_IA_ENABLE_UNCONNECTED_SEND_VALUE FALSE
+#endif
+
+/*
+** Attribute 18: Input only extended heartbeat instance number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_INPUT_EXT_INSTANCE_OBJECT_ENABLE
+ #define EIP_IA_INPUT_EXT_INSTANCE_OBJECT_ENABLE FALSE
+ #define EIP_IA_INPUT_EXT_INSTANCE_OBJECT_VALUE 0x0006
+#endif
+
+/*
+** Attribute 19: Listen only extended heartbeat instance number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_LISTEN_EXT_INSTANCE_OBJECT_ENABLE
+ #define EIP_IA_LISTEN_EXT_INSTANCE_OBJECT_ENABLE FALSE
+ #define EIP_IA_LISTEN_EXT_INSTANCE_OBJECT_VALUE 0x0007
+#endif
+
+/*
+** Attribute 20: Interface label port 1 (Array of CHAR)
+*/
+#ifndef EIP_IA_IF_LABEL_PORT_1_ENABLE
+ #define EIP_IA_IF_LABEL_PORT_1_ENABLE FALSE
+ #define EIP_IA_IF_LABEL_PORT_1_VALUE "Port 1"
+#endif
+
+/*
+** Attribute 21: Interface label port 2 (Array of CHAR)
+*/
+#ifndef EIP_IA_IF_LABEL_PORT_2_ENABLE
+ #define EIP_IA_IF_LABEL_PORT_2_ENABLE FALSE
+ #define EIP_IA_IF_LABEL_PORT_2_VALUE "Port 2"
+#endif
+
+/*
+** Attribute 22: Interface label internal port (Array of CHAR)
+*/
+#ifndef EIP_IA_IF_LABEL_PORT_INT_ENABLE
+ #define EIP_IA_IF_LABEL_PORT_INT_ENABLE FALSE
+ #define EIP_IA_IF_LABEL_PORT_INT_VALUE "Internal"
+#endif
+
+/*
+** Attribute 23: Enable CIP request forwarding extended (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_ENABLE
+ #define EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_ENABLE FALSE
+ #define EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_VALUE FALSE
+#endif
+
+/*
+** Attribute 24: Prepend producing profile instance (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_PREPEND_PRODUCING_ENABLE
+ #define EIP_IA_PREPEND_PRODUCING_ENABLE FALSE
+ #define EIP_IA_PREPEND_PRODUCING_VALUE 0x0000
+#endif
+
+/*
+** Attribute 25: Prepend consuming profile instance (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_PREPEND_CONSUMING_ENABLE
+ #define EIP_IA_PREPEND_CONSUMING_ENABLE FALSE
+ #define EIP_IA_PREPEND_CONSUMING_VALUE 0x0000
+#endif
+
+/*
+** Attribute 26: Enable EtherNet/IP QuickConnect (BOOL - TRUE/FALSE)
+*/
+#ifndef EIP_IA_ENABLE_EIP_QC_ENABLE
+ #define EIP_IA_ENABLE_EIP_QC_ENABLE FALSE
+ #define EIP_IA_ENABLE_EIP_QC_VALUE FALSE
+#endif
+
+/*
+** Attribute 27: Producing Instance Map (Array of eip_InstanceMapType)
+*/
+#ifndef EIP_IA_PROD_INSTANCE_MAP_ENABLE
+ #define EIP_IA_PROD_INSTANCE_MAP_ENABLE FALSE
+ #define EIP_IA_PROD_INSTANCE_MAP_VALUE { {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1} }
+ #define EIP_IA_PROD_INSTANCE_MAP_ARRAY_SIZE 6
+#endif
+
+/*
+** Attribute 28: Consuming Instance Map (Array of eip_InstanceMapType)
+*/
+#ifndef EIP_IA_CONS_INSTANCE_MAP_ENABLE
+ #define EIP_IA_CONS_INSTANCE_MAP_ENABLE FALSE
+ #define EIP_IA_CONS_INSTANCE_MAP_VALUE { {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1} }
+ #define EIP_IA_CONS_INSTANCE_MAP_ARRAY_SIZE 6
+#endif
+
+/*
+** Attribute 29: Ignore Sequence Count Check (BOOL -TRUE/FALSE)
+*/
+#ifndef EIP_IA_IGNORE_SEQ_COUNT_CHECK_ENABLE
+ #define EIP_IA_IGNORE_SEQ_COUNT_CHECK_ENABLE FALSE
+ #define EIP_IA_IGNORE_SEQ_COUNT_CHECK_VALUE FALSE
+#endif
+
+/*
+** Attribute 30: ABCC ADI Object number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef EIP_IA_ABCC_ADI_OBJECT_ENABLE
+ #define EIP_IA_ABCC_ADI_OBJECT_ENABLE FALSE
+ #define EIP_IA_ABCC_ADI_OBJECT_VALUE 0x0000
+#endif
+
+#endif /* #if EIP_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** Ethernet Object (0xF9)
+**------------------------------------------------------------------------------
+*/
+
+#if ETN_OBJ_ENABLE
+/*
+** Attribute 2: Enable Host IP Configuration Protocol (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_HICP_ENABLE
+ #define ETN_IA_ENABLE_HICP_ENABLE FALSE
+ #define ETN_IA_ENABLE_HICP_VALUE TRUE
+#endif
+
+/*
+** Attribute 3: Enable webserver (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_WEB_ENABLE
+ #define ETN_IA_ENABLE_WEB_ENABLE FALSE
+ #define ETN_IA_ENABLE_WEB_VALUE TRUE
+#endif
+
+/*
+** Attribute 4: Enable ModbusTCP (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_MOD_TCP_ENABLE
+ #define ETN_IA_ENABLE_MOD_TCP_ENABLE FALSE
+ #define ETN_IA_ENABLE_MOD_TCP_VALUE TRUE
+#endif
+
+/*
+** Attribute 5: Enable web ADI access (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE
+ #define ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE FALSE
+ #define ETN_IA_ENABLE_WEB_ADI_ACCESS_VALUE TRUE
+#endif
+
+/*
+** Attribute 6: Enable FTP server (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_FTP_ENABLE
+ #define ETN_IA_ENABLE_FTP_ENABLE FALSE
+ #define ETN_IA_ENABLE_FTP_VALUE TRUE
+#endif
+
+/*
+** Attribute 7: Enable admin mode (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_ADMIN_MODE_ENABLE
+ #define ETN_IA_ENABLE_ADMIN_MODE_ENABLE FALSE
+ #define ETN_IA_ENABLE_ADMIN_MODE_VALUE FALSE
+#endif
+
+/*
+** Attribute 8: Enable network status (UINT16)
+*/
+#ifndef ETN_IA_NETWORK_STATUS_ENABLE
+ #define ETN_IA_NETWORK_STATUS_ENABLE FALSE
+#endif
+
+/*
+** Attribute 9: Port 1 MAC Address (Array[6] of UINT8)
+*/
+#ifndef ETN_IA_PORT1_MAC_ADDRESS_ENABLE
+ #define ETN_IA_PORT1_MAC_ADDRESS_ENABLE TRUE
+ #define ETN_IA_PORT1_MAC_ADDRESS_VALUE "\x00\x30\x11\x00\x00\x01"
+#endif
+
+/*
+** Attribute 10: Port 2 MAC Address (Array[6] of UINT8)
+*/
+#ifndef ETN_IA_PORT2_MAC_ADDRESS_ENABLE
+ #define ETN_IA_PORT2_MAC_ADDRESS_ENABLE TRUE
+ #define ETN_IA_PORT2_MAC_ADDRESS_VALUE "\x00\x30\x11\x00\x00\x02"
+#endif
+
+/*
+** Attribute 11: Enable Address Conflict Detection (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_ACD_ENABLE
+ #define ETN_IA_ENABLE_ACD_ENABLE FALSE
+ #define ETN_IA_ENABLE_ACD_VALUE TRUE
+#endif
+
+/*
+** Attribute 12: Enable Port 1 state (ENUM)
+*/
+#ifndef ETN_IA_PORT1_STATE_ENABLE
+ #define ETN_IA_PORT1_STATE_ENABLE FALSE
+ #define ETN_IA_PORT1_STATE_VALUE ABP_ETN_IA_PORT_STATE_ENABLE
+#endif
+
+/*
+** Attribute 13: Enable Port 2 state (ENUM)
+*/
+#ifndef ETN_IA_PORT2_STATE_ENABLE
+ #define ETN_IA_PORT2_STATE_ENABLE FALSE
+ #define ETN_IA_PORT2_STATE_VALUE ABP_ETN_IA_PORT_STATE_ENABLE
+#endif
+
+/*
+** Attribute 14: Enable web update (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_WEB_UPDATE_ENABLE
+ #define ETN_IA_ENABLE_WEB_UPDATE_ENABLE FALSE
+ #define ETN_IA_ENABLE_WEB_UPDATE_VALUE TRUE
+#endif
+
+/*
+** Attribute 15: Enable HICP reset (BOOL - TRUE/FALSE)
+*/
+#ifndef ETN_IA_ENABLE_HICP_RESET_ENABLE
+ #define ETN_IA_ENABLE_HICP_RESET_ENABLE FALSE
+ #define ETN_IA_ENABLE_HICP_RESET_VALUE FALSE
+#endif
+
+/*
+** Attribute 16: Enable web update (Struct of {UINT32, UINT32, UINT32})
+*/
+#ifndef ETN_IA_IP_CONFIGURATION_ENABLE
+ #define ETN_IA_IP_CONFIGURATION_ENABLE FALSE
+#endif
+
+/*
+** Attribute 17: IP address byte 0-2 (Array[3] of UINT8)
+*/
+#ifndef ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE
+ #define ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE FALSE
+ #define ETN_IA_IP_ADDRESS_BYTE_0_2_VALUE "\xC0\xA8\x00"
+#endif
+
+
+#ifndef ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK
+ #define ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK FALSE
+#endif
+
+#endif /* #if ETN_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** Modbus Object (0xFA)
+**------------------------------------------------------------------------------
+*/
+
+#if MOD_OBJ_ENABLE
+/*
+** Attribute 9: No. of ADI indexing bits (UINT8 - 0x00-0xFF)
+*/
+#ifndef MOD_IA_ADI_INDEXING_BITS_ENABLE
+ #define MOD_IA_ADI_INDEXING_BITS_ENABLE FALSE
+ #define MOD_IA_ADI_INDEXING_BITS_VALUE 0x00
+#endif
+
+/*
+** Attribute 10: Enable Modbus Message forwarding (BOOL - TRUE/FALSE)
+*/
+#ifndef MOD_IA_MESSAGE_FORWARDING_ENABLE
+ #define MOD_IA_MESSAGE_FORWARDING_ENABLE FALSE
+ #define MOD_IA_MESSAGE_FORWARDING_VALUE FALSE
+#endif
+
+/*
+** Attribute 11: Modbus read/write registers command offset (Array of UINT16 - {0x0000-0xFFFF})
+*/
+#ifndef MOD_IA_RW_OFFSET_ENABLE
+ #define MOD_IA_RW_OFFSET_ENABLE FALSE
+ #define MOD_IA_RW_OFFSET_READ_VALUE 0x0000
+ #define MOD_IA_RW_OFFSET_WRITE_VALUE 0x0000
+#endif
+
+#endif /* #if MOD_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** DeviceNet Object (0xFC)
+**------------------------------------------------------------------------------
+*/
+
+#if DEV_OBJ_ENABLE
+/*
+** Attribute 7: Producing instance number (UINT16 - 0x0001-0xFFFF)
+*/
+#ifndef DEV_IA_PROD_INSTANCE_ENABLE
+ #define DEV_IA_PROD_INSTANCE_ENABLE FALSE
+ #define DEV_IA_PROD_INSTANCE_VALUE 0x0064
+#endif
+
+/*
+** Attribute 8: Consuming instance number (UINT16 - 0x0001-0xFFFF)
+*/
+#ifndef DEV_IA_CONS_INSTANCE_ENABLE
+ #define DEV_IA_CONS_INSTANCE_ENABLE FALSE
+ #define DEV_IA_CONS_INSTANCE_VALUE 0x0096
+#endif
+
+/*
+** Attribute 9: Enable address from net (BOOL - TRUE/FALSE)
+*/
+#ifndef DEV_IA_ADDRESS_FROM_NET_ENABLE
+ #define DEV_IA_ADDRESS_FROM_NET_ENABLE FALSE
+ #define DEV_IA_ADDRESS_FROM_NET_VALUE FALSE
+#endif
+
+/*
+** Attribute 10: Enable baud rate from net (BOOL - TRUE/FALSE)
+*/
+#ifndef DEV_IA_BAUD_RATE_FROM_NET_ENABLE
+ #define DEV_IA_BAUD_RATE_FROM_NET_ENABLE FALSE
+ #define DEV_IA_BAUD_RATE_FROM_NET_VALUE FALSE
+#endif
+
+/*
+** Attribute 11: Enable CIP request forwarding (BOOL - TRUE/FALSE)
+*/
+#ifndef DEV_IA_ENABLE_APP_CIP_OBJECTS_ENABLE
+ #define DEV_IA_ENABLE_APP_CIP_OBJECTS_ENABLE FALSE
+ #define DEV_IA_ENABLE_APP_CIP_OBJECTS_VALUE FALSE
+#endif
+
+/*
+** Attribute 12: Enable Parameter object (BOOL - TRUE/FALSE)
+*/
+#ifndef DEV_IA_ENABLE_PARAM_OBJECT_ENABLE
+ #define DEV_IA_ENABLE_PARAM_OBJECT_ENABLE FALSE
+ #define DEV_IA_ENABLE_PARAM_OBJECT_VALUE FALSE
+#endif
+
+/*
+** Attribute 13: Enable QuickConnect (BOOL - TRUE/FALSE)
+*/
+#ifndef DEV_IA_ENABLE_QUICK_CONNECT_ENABLE
+ #define DEV_IA_ENABLE_QUICK_CONNECT_ENABLE FALSE
+ #define DEV_IA_ENABLE_QUICK_CONNECT_VALUE FALSE
+#endif
+
+/*
+** Attribute 18: Prepend producing profile instance (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DEV_IA_PREPEND_PRODUCING_ENABLE
+ #define DEV_IA_PREPEND_PRODUCING_ENABLE FALSE
+ #define DEV_IA_PREPEND_PRODUCING_VALUE 0x0000
+#endif
+
+/*
+** Attribute 19: Prepend consuming profile instance (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DEV_IA_PREPEND_CONSUMING_ENABLE
+ #define DEV_IA_PREPEND_CONSUMING_ENABLE FALSE
+ #define DEV_IA_PREPEND_CONSUMING_VALUE 0x0000
+#endif
+
+/*
+** Attribute 20: ABCC ADI Object number (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DEV_IA_ABCC_ADI_OBJECT_ENABLE
+ #define DEV_IA_ABCC_ADI_OBJECT_ENABLE FALSE
+ #define DEV_IA_ABCC_ADI_OBJECT_VALUE 0x0000
+#endif
+
+#endif /* #if DEV_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** PROFIBUS DPV1 Object (0xFD)
+**------------------------------------------------------------------------------
+*/
+
+#if DPV1_OBJ_ENABLE
+/*
+** Attribute 2: Parameterization data (Array of UINT8)
+*/
+#ifndef DPV1_IA_PRM_DATA_ENABLE
+ #define DPV1_IA_PRM_DATA_ENABLE FALSE
+ #define DPV1_IA_PRM_DATA_VALUE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ #define DPV1_IA_PRM_DATA_ARRAY_SIZE 10
+#endif
+
+/*
+** Attribute 3: Expected configuration (Array of UINT8)
+*/
+#ifndef DPV1_IA_EXPECTED_CFG_DATA_ENABLE
+ #define DPV1_IA_EXPECTED_CFG_DATA_ENABLE FALSE
+ #define DPV1_IA_EXPECTED_CFG_DATA_VALUE {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ #define DPV1_IA_EXPECTED_CFG_DATA_ARRAY_SIZE 10
+#endif
+
+/*
+** Attribute 4: SSA enabled (BOOL - TRUE/FALSE)
+*/
+#ifndef DPV1_IA_SSA_ENABLED_ENABLE
+ #define DPV1_IA_SSA_ENABLED_ENABLE FALSE
+ #define DPV1_IA_SSA_ENABLED_VALUE FALSE
+#endif
+
+/*
+** Attribute 13: Revision counter (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DPV1_IA_REV_COUNTER_ENABLE
+ #define DPV1_IA_REV_COUNTER_ENABLE FALSE
+ #define DPV1_IA_REV_COUNTER_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 14: Profile ID (UINT16 - 0x0000-0xFFFF)
+*/
+#ifndef DPV1_IA_PROFILE_ID_ENABLE
+ #define DPV1_IA_PROFILE_ID_ENABLE FALSE
+ #define DPV1_IA_PROFILE_ID_VALUE 0xFFFF
+#endif
+
+/*
+** Attribute 15: Profile specific type (UINT16 - 1-6)
+*/
+#ifndef DPV1_IA_PROFILE_SPEC_TYPE_ENABLE
+ #define DPV1_IA_PROFILE_SPEC_TYPE_ENABLE FALSE
+ #define DPV1_IA_PROFILE_SPEC_TYPE_VALUE 0x0004
+#endif
+
+/*
+** Attribute 18: IM header (Array of UINT8)
+*/
+#ifndef DPV1_IA_IM_HEADER_ENABLE
+ #define DPV1_IA_IM_HEADER_ENABLE FALSE
+ #define DPV1_IA_IM_HEADER_VALUE { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ #define DPV1_IA_IM_HEADER_ARRAY_SIZE 10
+#endif
+
+#endif /* #if DPV1_OBJ_ENABLE */
+
+/*------------------------------------------------------------------------------
+** Application Object (0xFF)
+**------------------------------------------------------------------------------
+*/
+#ifndef APP_OBJ_ENABLE
+ #define APP_OBJ_ENABLE TRUE
+#endif
+
+#if APP_OBJ_ENABLE
+/*
+** Attribute 1: Configured (BOOL - TRUE/FALSE)
+*/
+#ifndef APP_IA_CONFIGURED_ENABLE
+ #define APP_IA_CONFIGURED_ENABLE TRUE
+ #define APP_IA_CONFIGURED_VALUE FALSE
+#endif
+
+/*
+** Attribute 2: Supported languages (Array of ENUM - {ABP_LANG_*})
+*/
+#ifndef APP_IA_SUP_LANG_ENABLE
+ #define APP_IA_SUP_LANG_ENABLE TRUE
+ #define APP_IA_SUP_LANG_VALUE { ABP_LANG_ENG }
+ #define APP_IA_SUP_LANG_ARRAY_SIZE 1
+#endif
+
+/*
+** Attribute 3: Serial number (UINT32 - function/variable/0x00000000-0xFFFFFFFF)
+*/
+#ifndef APP_IA_SER_NUM_ENABLE
+ #define APP_IA_SER_NUM_ENABLE FALSE
+ #define APP_IA_SER_NUM_VALUE 0
+#endif
+
+/*
+** Attribute 4: Parameter control sum (Array[16] of UINT8, {0x00-0xFF})
+*/
+#ifndef APP_IA_PAR_CRTL_SUM_ENABLE
+ #define APP_IA_PAR_CRTL_SUM_ENABLE FALSE
+ #define APP_IA_PAR_CRTL_SUM_VALUE { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+#endif
+
+/*
+** Attribute 5: Candidate firmware available (BOOL - TRUE/FALSE)
+*/
+#ifndef APP_IA_FW_AVAILABLE_ENABLE
+ #define APP_IA_FW_AVAILABLE_ENABLE TRUE
+ #define APP_IA_FW_AVAILABLE_VALUE FALSE
+#endif
+
+/*
+** Attribute 6: Hardware configurable address (BOOL - TRUE/FALSE)
+*/
+#ifndef APP_IA_HW_CONF_ADDR_ENABLE
+ #define APP_IA_HW_CONF_ADDR_ENABLE TRUE
+ #define APP_IA_HW_CONF_ADDR_VALUE FALSE
+#endif
+
+#endif /* #if APP_OBJ_ENABLE */
+
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+#include "abcc_identification.h"
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_adapt/abcc_platform_cfg.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,46 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Platform specific product configuration file. +** +** A symbol defined in this file will override the default product +** configurations in abcc_identification.h and abcc_obj_cfg.h. +** It should be used whenever the target platform needs to override an +** default configuration to realize its implementation. +******************************************************************************** +******************************************************************************** +** Services: +******************************************************************************** +******************************************************************************** +*/ +#ifndef ABCC_PLATFORM_CFG_H_ +#define ABCC_PLATFORM_CFG_H_ + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +#endif /* #ifndef ABCC_PLATFORM_CFG_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_adapt/abcc_sw_port.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,160 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Platform dependent macros and functions required by the ABCC driver and
+** Anybus objects implementation to be platform independent.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_sw_port.h"
+#include "abcc.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+#ifdef ABCC_SYS_16_BIT_CHAR
+void ABCC_PORT_CopyOctetsImpl( void* pxDest, UINT16 iDestOctetOffset,
+ void* pxSrc, UINT16 iSrcOctetOffset,
+ UINT16 iNumOctets )
+{
+ UINT16 i;
+ UINT16 iData;
+ BOOL fOddDestOctet;
+ BOOL fOddSrcOctet;
+ UINT16* piDest;
+ UINT16* piSrc;
+
+ fOddDestOctet = iDestOctetOffset & 1;
+ fOddSrcOctet = iSrcOctetOffset & 1;
+ piDest = (UINT16*)pxDest + ( iDestOctetOffset >> 1 );
+ piSrc = (UINT16*)pxSrc + ( iSrcOctetOffset >> 1 );
+
+ for( i = 0; i < iNumOctets; i++ )
+ {
+ if( fOddSrcOctet )
+ {
+ iData = ABCC_GetHighAddrOct( *piSrc );
+ piSrc++;
+ }
+ else
+ {
+ iData = ABCC_GetLowAddrOct( *piSrc );
+ }
+ fOddSrcOctet ^= 1;
+
+ if( fOddDestOctet )
+ {
+ ABCC_SetHighAddrOct( *piDest, iData );
+ piDest++;
+ }
+ else
+ {
+ ABCC_SetLowAddrOct( *piDest, iData );
+ }
+ fOddDestOctet ^= 1;
+ }
+}
+
+void ABCC_PORT_StrCpyToNativeImpl( void* pxDest, void* pxSrc,
+ UINT16 iSrcOctetOffset, UINT16 iNbrOfChars )
+{
+ UINT16 i;
+ UINT16* piDest;
+ const UINT16* piSrc;
+ BOOL fOddSrc;
+
+ piDest = pxDest;
+ piSrc = pxSrc;
+ fOddSrc = iSrcOctetOffset & 1;
+
+ for( i = 0; i < iNbrOfChars; i++ )
+ {
+ if ( fOddSrc )
+ {
+ piDest[ i ] = ABCC_GetHighAddrOct( piSrc[ i >> 1 ] );
+ }
+ else
+ {
+ piDest[ i ] = ABCC_GetLowAddrOct( piSrc[ i >> 1 ] );
+ }
+ fOddSrc ^= 1;
+ }
+}
+
+void ABCC_PORT_StrCpyToPackedImpl( void* pxDest, UINT16 iDestOctetOffset,
+ const void* pxSrc, UINT16 iNbrOfChars )
+{
+ UINT16 i;
+ UINT16* piDest;
+ const UINT16* piSrc;
+ BOOL fOddDest;
+
+ piDest = pxDest;
+ piSrc = pxSrc;
+ fOddDest = iDestOctetOffset & 1;
+
+ for( i = 0; i < iNbrOfChars; i++ )
+ {
+ if ( fOddDest )
+ {
+ ABCC_SetHighAddrOct( piDest[ i >> 1 ], piSrc[ i ] );
+ }
+ else
+ {
+ ABCC_SetLowAddrOct( piDest[ i >> 1 ], piSrc[ i ] );
+ }
+ fOddDest ^= 1;
+ }
+}
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_adapt/abcc_sw_port.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,157 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Platform dependent macros and functions required by the ABCC driver and +** Anybus objects implementation to be platform independent. +** The description of the macros are found in abcc_port.h. Abcc_port.h is found +** in the public ABCC40 driver interface. +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_PORT_DebugPrint() - Print debug info +** ABCC_PORT_UseCritical() - Used if any preparation is needed +** before calling +** "ABCC_PORT_EnterCritical()". +** ABCC_PORT_EnterCritical() - Disables all interrupts, if they are +** not already disabled. +** ABCC_PORT_ExitCritical() - Restore interrupts to the state they +** were in when +** "ABCC_PORT_EnterCritical()" was called. +** ABCC_PORT_MemCpy() - Port of standard memcpy() +** ABCC_PORT_StrCpyToNative() - Copy native char string to octet string +** ABCC_PORT_StrCpyToPacked() - Copy octetstring to native char* string +** ABCC_PORT_CopyOctets() - Copy octet aligned buffer. +** ABCC_PORT_Copy8() - Copy octet aligned 8 bit data. +** ABCC_PORT_Copy16() - Copy octet aligned 16 bit data. +** ABCC_PORT_Copy32() - Copy octet aligned 32 bit data. +** ABCC_PORT_Copy64() - Copy octet aligned 64 bit data. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_SW_PORT_H_ +#define ABCC_SW_PORT_H_ + +#include "abcc_td.h" +#include "stdio.h" +#include "string.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +#define ABCC_PORT_DebugPrint( args ) + +#define ABCC_PORT_UseCritical() + +#define ABCC_PORT_EnterCritical() + +#define ABCC_PORT_ExitCritical() + +#ifdef ABCC_SYS_16_BIT_CHAR + +void ABCC_PORT_StrCpyToPackedImpl( void* pxDest, UINT16 iDestOctetOffset, + const void* pxSrc, UINT16 iNbrOfChars ); + +void ABCC_PORT_StrCpyToNativeImpl( void* pxDest, void* pxSrc, + UINT16 iSrcOctetOffset, UINT16 iNbrOfChars ); + +void ABCC_PORT_CopyOctetsImpl( void* pxDest, UINT16 iDestOctetOffset, + void* pxSrc, UINT16 iSrcOctetOffset, + UINT16 iNumOctets ); + +#define ABCC_PORT_MemCpy( pbDest, pbSource, iNbrOfOctets ) \ + memcpy( pbDest, pbSource, ( iNbrOfOctets + 1 ) >> 1 ); + +#define ABCC_PORT_StrCpyToNative( pxDest, pxSrc, iSrcOctetOffset, iNbrOfChars ) \ + ABCC_PORT_StrCpyToNativeImpl( pxDest, pxSrc, iSrcOctetOffset, iNbrOfChars ) + +#define ABCC_PORT_StrCpyToPacked( pxDest, iDestOctetOffset, pxSrc, iNbrOfChars ) \ + ABCC_PORT_StrCpyToPackedImpl( pxDest, iDestOctetOffset, pxSrc, iNbrOfChars ) + + +#define ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset,\ + iNumOctets ) \ + ABCC_PORT_CopyOctetsImpl( pxDest, iDestOctetOffset, pxSrc, \ + iSrcOctetOffset, iNumOctets ); + +#define ABCC_PORT_Copy8( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + ABCC_PORT_CopyOctetsImpl( pxDest, iDestOctetOffset, pxSrc, \ + iSrcOctetOffset, 1 ) + +#else + +#define ABCC_PORT_MemCpy( pbDest, pbSource, iNbrOfOctets ) \ + memcpy( pbDest, pbSource, iNbrOfOctets ); + +#define ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset,\ + iNumOctets ) \ + ABCC_PORT_MemCpy( (void*)&( (UINT8*)( pxDest) )[ iDestOctetOffset ], \ + (void*)&( (UINT8*)( pxSrc) )[ iSrcOctetOffset ], \ + iNumOctets ) + +#define ABCC_PORT_StrCpyToNative( pxDest, pxSrc, iSrcOctetOffset, iNbrOfChars )\ + ABCC_PORT_MemCpy( (void*)pxDest, \ + (void*)&( (UINT8*)( pxSrc) )[ iSrcOctetOffset ], \ + iNbrOfChars ) + +#define ABCC_PORT_StrCpyToPacked( pxDest, iDestOctetOffset, pxSrc, \ + iNbrOfChars ) \ + ABCC_PORT_MemCpy( (void*)&( (UINT8*)( pxDest) )[ iDestOctetOffset ], \ + pxSrc, iNbrOfChars ) + +#define ABCC_PORT_Copy8( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + ( (UINT8*)pxDest )[ iDestOctetOffset ] = \ + ( (UINT8*)pxSrc )[ iSrcOctetOffset ] +#endif + +#define ABCC_PORT_Copy16( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset, 2 ) + +#define ABCC_PORT_Copy32( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset, 4 ) + +#if( ABCC_CFG_64BIT_ADI_SUPPORT ) +#define ABCC_PORT_Copy64( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset, 8 ) +#endif + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_adapt/abcc_sys_adapt.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,277 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_port.h"
+
+#include "abcc_sys_adapt.h"
+#include "abcc_sys_adapt_spi.h"
+#include "abcc_sys_adapt_par.h"
+#include "abcc_sys_adapt_ser.h"
+
+
+BOOL ABCC_SYS_HwInit( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+
+
+BOOL ABCC_SYS_Init( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+
+
+void ABCC_SYS_Close( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+
+
+#if( ABCC_CFG_OP_MODE_SETTABLE )
+void ABCC_SYS_SetOpmode( UINT8 bOpmode )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_OP_MODE_GETTABLE )
+UINT8 ABCC_SYS_GetOpmode( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+
+void ABCC_SYS_HWReset( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+
+
+void ABCC_SYS_HWReleaseReset( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+
+
+#ifndef ABCC_CFG_ABCC_MODULE_ID
+UINT8 ABCC_SYS_ReadModuleId( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_MOD_DETECT_PINS_CONN )
+BOOL ABCC_SYS_ModuleDetect( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+#if( ABCC_CFG_SYNC_ENABLE && ABCC_CFG_USE_ABCC_SYNC_SIGNAL )
+void ABCC_SYS_SyncInterruptEnable( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+#if( ABCC_CFG_SYNC_ENABLE && ABCC_CFG_USE_ABCC_SYNC_SIGNAL )
+void ABCC_SYS_SyncInterruptDisable( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_INT_ENABLED )
+void ABCC_SYS_AbccInterruptEnable( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+
+
+void ABCC_SYS_AbccInterruptDisable( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_POLL_ABCC_IRQ_PIN )
+BOOL ABCC_SYS_IsAbccInterruptActive( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_DRV_SPI )
+void ABCC_SYS_SpiRegDataReceived( ABCC_SYS_SpiDataReceivedCbfType pnDataReceived )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_spi.h
+ */
+}
+
+
+void ABCC_SYS_SpiSendReceive( void* pxSendDataBuffer, void* pxReceiveDataBuffer, UINT16 iLength )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_spi.h
+ */
+}
+#endif
+
+
+#if( ( ABCC_CFG_DRV_PARALLEL || ABCC_CFG_DRV_PARALLEL_30 ) && !ABCC_CFG_MEMORY_MAPPED_ACCESS )
+void ABCC_SYS_ParallelRead( UINT16 iMemOffset, void* pxData, UINT16 iLength )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+
+
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+UINT8 ABCC_SYS_ParallelRead8( UINT16 iMemOffset )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_DRV_PARALLEL )
+UINT16 ABCC_SYS_ParallelRead16( UINT16 iMemOffset )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+#endif
+
+
+void ABCC_SYS_ParallelWrite( UINT16 iMemOffset, void* pxData, UINT16 iLength )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+
+
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+void ABCC_SYS_ParallelWrite8( UINT16 iMemOffset, UINT8 pbData )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_DRV_PARALLEL )
+void ABCC_SYS_ParallelWrite16( UINT16 iMemOffset, UINT16 piData )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+#endif
+
+void* ABCC_SYS_ParallelGetRdPdBuffer( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+
+
+void* ABCC_SYS_ParallelGetWrPdBuffer( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_par.h
+ */
+}
+#endif
+
+
+#if( ABCC_CFG_DRV_SERIAL )
+void ABCC_SYS_SerRegDataReceived( ABCC_SYS_SpiDataReceivedCbfType pnDataReceived )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_ser.h
+ */
+}
+
+
+void ABCC_SYS_SerSendReceive( void* pxTxDataBuffer, void* pxRxDataBuffer, UINT16 iTxSize, UINT16 iRxSize )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_ser.h
+ */
+}
+
+
+void ABCC_SYS_SerRestart( void )
+{
+ /*
+ ** Implement according to abcc_sys_adapt_ser.h
+ */
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_adapt/abcc_td.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,141 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Definition of ABCC types +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_TD_H +#define ABCC_TD_H + +/******************************************************************************* +** +** Constants +** +******************************************************************************** +*/ + +/* #define ABCC_SYS_BIG_ENDIAN */ +/* #define ABCC_SYS_16_BIT_CHAR */ + +/*--------------------------------------------------------------------------- +** +** BOOL8 +** +** INT8 +** INT16 +** INT32 +** +** UINT8 +** UINT16 +** UINT32 +** +** FLOAT32 +** +** The standard boolean data type, 8-bit. +** The standard signed 8, 16, and 32 bit data types (respectively). +** The standard unsigned 8, 16, and 32 bit data types (respectively). +**--------------------------------------------------------------------------- +*/ +typedef int BOOL; +typedef unsigned char BOOL8; +typedef unsigned char UINT8; +typedef signed char INT8; +typedef unsigned short UINT16; +typedef signed short INT16; +typedef unsigned int UINT32; +typedef signed int INT32; +typedef float FLOAT32; + +/*------------------------------------------------------------------------------ +** LeINT16 +** LeINT32 +** LeUINT16 +** LeUINT32 +** +** Little endian data types for words and longwords. +**------------------------------------------------------------------------------ +*/ +typedef INT16 LeINT16; +typedef INT32 LeINT32; +typedef UINT16 LeUINT16; +typedef UINT32 LeUINT32; + +/*------------------------------------------------------------------------------ +** BeINT16 +** BeINT32 +** BeUINT16 +** BeUINT32 +** +** Big endian data types for words and longwords. +**------------------------------------------------------------------------------ +*/ +typedef INT16 BeINT16; +typedef INT32 BeINT32; +typedef UINT16 BeUINT16; +typedef UINT32 BeUINT32; + +/*--------------------------------------------------------------------------- +** +** FALSE +** TRUE +** +** These are the symbolic constants for true and false used in boolean +** data type comparisons. +** +**--------------------------------------------------------------------------- +*/ +#ifndef FALSE + #define FALSE 0 +#endif + +#ifndef TRUE + #define TRUE ( !FALSE ) +#endif + +/*--------------------------------------------------------------------------- +** +** NULL +** +** Default value for invalid pointers. +** +**--------------------------------------------------------------------------- +*/ +#ifndef NULL +#define NULL 0 +#endif + +#ifdef __cplusplus + #define CPLUSPLUS +#endif + +#ifdef CPLUSPLUS + #define EXTFUNC extern "C" +#else + #define EXTFUNC extern +#endif + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/inc/abcc.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,1390 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** ABCC driver API used by the the application.
+********************************************************************************
+********************************************************************************
+** Services provided by ABCC driver:
+** ABCC_StartDriver() - Make the driver ready for use.
+** ABCC_isReadyForCommunication() - Check if the driver is ready to
+** communicate.
+** ABCC_ShutdownDriver() - Close the driver.
+** ABCC_HWReset - Reset ABCC.
+** ABCC_HWReleaseReset - Release the reset on ABCC.
+** ABCC_RunTimerSystem() - Timer information to ABCC.
+** ABCC_RunDriver() - Main routine to be called cyclically
+** during polling.
+** ABCC_UserInitComplete() - End of user specific setup sequence.
+** ABCC_SendCmdMsg() - Sends a message command to ABCC.
+** ABCC_SendRespMsg() - Sends a message response to ABCC.
+** ABCC_SendRemapRespMsg() - Send remap response message
+** ABCC_SetAppStatus() - Sets the application status.
+** ABCC_GetCmdMsgBuffer() - Allocates the command message buffer.
+** ABCC_ReturnMsgBuffer() - Frees the message buffer.
+** ABCC_TakeMsgBufferOwnership() - Takes the ownership of the message buffer.
+** ABCC_ISR() - ABCC interrupt service routine.
+** ABCC_TriggerRdPdUpdate() - Triggers the RdPd read.
+** ABCC_TriggerReceiveMessage() - Triggers the message read.
+** ABCC_TriggerWrPdUpdate() - Triggers the WrPd update.
+** ABCC_TriggerAnbStatusUpdate() - Check for Anybus status change
+** ABCC_TriggerTransmitMessage() - Check sending queue
+** ABCC_ModCap() - Reads the module capability.
+** ABCC_LedStatus() - Reads the led status.
+** ABCC_AnbState() - Reads the Anybus state.
+** ABCC_NetworkType() - Get network type.
+** ABCC_ModuleType() - Get module type.
+** ABCC_DataFormatType() - Get network endian.
+** ABCC_ParameterSupport() - Get parameter support.
+** ABCC_GetOpmode() - Get operating mode.
+** ABCC_GetAttribute() - Fills "Get Attribute" message
+** ABCC_SetByteAttribute() - Fills "Set Attribute" message
+** ABCC_VerifyMessage() - Checks if E-bit is set
+** ABCC_GetDataTypeSize() - Returns size of ABCC data type
+**
+** Services to be implemented by user:
+** ABCC_CbfReceiveMsg() - Delivery of the received message.
+** ABCC_CbfAdiMappingReq() - Request of the ADI mapping information.
+** ABCC_CbfUserInitReq() - User specific setup made by the application.
+** ABCC_CbfUpdateWriteProcessData() - Request of the latest write process data.
+** ABCC_CbfNewReadPd() - Delivery of the latest read process data.
+** ABCC_CbfWdTimeout() - Communication lost.
+** ABCC_CbfWdTimeoutRecovered() - Communication restored.
+** ABCC_CbfEvent() - Events received. Called from ISR.
+** ABCC_CbfRemapDone() - Acknowledge of remap has been sent.
+** ABCC_CbfAnbStateChanged() - The anybus state has changed.
+** ABCC_CbfSyncIsr() - Callback for sync event.
+********************************************************************************
+********************************************************************************
+*/
+#ifndef ABCC_H_
+#define ABCC_H_
+
+#include "abcc_drv_cfg.h"
+#include "abcc_port.h"
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc_ad_if.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Bit definitions of ABCC events.
+** These bit definitions are used in the bit mask forwarded to the
+** ABCC_CbfEvent() callback.
+**------------------------------------------------------------------------------
+*/
+#define ABCC_ISR_EVENT_RDPD 0x01
+#define ABCC_ISR_EVENT_RDMSG 0x02
+#define ABCC_ISR_EVENT_WRMSG 0x04
+#define ABCC_ISR_EVENT_STATUS 0x08
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Function types used by user to deliver messages to the application.
+**------------------------------------------------------------------------------
+*/
+typedef void (*ABCC_MsgHandlerFuncType)( ABP_MsgType* psMsg );
+
+/*------------------------------------------------------------------------------
+** Data format type.
+**------------------------------------------------------------------------------
+*/
+typedef enum ABCC_DataFormatType
+{
+ ABCC_DF_LSB_FIRST = 0,
+ ABCC_DF_MSB_FIRST = 1
+}
+ABCC_DataFormatType;
+
+/*------------------------------------------------------------------------------
+** Driver severity codes indicated by ABCC_CbfDriverError.
+**------------------------------------------------------------------------------
+*/
+typedef enum ABCC_SeverityType
+{
+ /*
+ ** Information about an event that has occurred (e.g., serial message lost).
+ */
+ ABCC_SEV_INFORMATION = 0,
+
+ /*
+ ** An error of minor importance has occurred. The system can recover from
+ ** this error.
+ */
+ ABCC_SEV_WARNING,
+
+ /*
+ ** A fatal event has occurred, the system cannot recover (e.g., driver is
+ ** out of timers).
+ */
+ ABCC_SEV_FATAL,
+
+ /*
+ ** Force the compiler to use a 16-bit variable as enumeration.
+ */
+ ABCC_SEV_SET_ENUM_ANSI_SIZE = 0x7FFF
+
+}
+ABCC_SeverityType;
+
+/*------------------------------------------------------------------------------
+** Driver error codes indicated by ABCC_CbfDriverError.
+**------------------------------------------------------------------------------
+*/
+typedef enum ABCC_ErrorCodeType
+{
+ ABCC_EC_NO_ERROR,
+ ABCC_EC_INTERNAL_ERROR,
+ ABCC_EC_LINK_CMD_QUEUE_FULL,
+ ABCC_EC_LINK_RESP_QUEUE_FULL,
+ ABCC_EC_OUT_OF_MSG_BUFFERS,
+ ABCC_EC_TRYING_TO_FREE_NULL_POINTER,
+ ABCC_EC_INCORRECT_OPERATING_MODE,
+ ABCC_EC_INCORRECT_STATE,
+ ABCC_EC_RESP_MSG_E_BIT_SET,
+ ABCC_EC_WRPD_SIZE_ERR,
+ ABCC_EC_RDPD_SIZE_ERR,
+ ABCC_EC_RDMSG_SIZE_ERR,
+ ABCC_EC_INVALID_RESP_SOURCE_ID,
+ ABCC_EC_MODULE_NOT_DECTECTED,
+ ABCC_EC_PARAMETER_NOT_VALID,
+ ABCC_EC_MODULE_ID_NOT_SUPPORTED,
+ ABCC_EC_DEFAULT_MAP_ERR,
+ ABCC_EC_ERROR_IN_READ_MAP_CONFIG,
+ ABCC_EC_ERROR_IN_WRITE_MAP_CONFIG,
+ ABCC_EC_INTSTATUS_NOT_SUPPORTED_BY_DRV_IMPL,
+ ABCC_EC_MODCAP_NOT_SUPPORTED_BY_DRV_IMPL,
+ ABCC_EC_SPI_OP_NOT_ALLOWED_DURING_SPI_TRANSACTION,
+ ABCC_EC_WRMSG_SIZE_ERR,
+ ABCC_EC_MSG_BUFFER_CORRUPTED,
+ ABCC_EC_MSG_BUFFER_ALREADY_FREED,
+ ABCC_EC_NO_RESOURCES,
+ ABCC_EC_HW_INIT_FAILED,
+ ABCC_EC_SET_ENUM_ANSI_SIZE = 0x7FFF
+}
+ABCC_ErrorCodeType;
+
+/*------------------------------------------------------------------------------
+** ABCC_CommunicationStateType:
+**
+** ABCC_NOT_READY_FOR_COMMUNICATION: Nothing is wrong but it
+** is not yet possible to
+** communicate with the ABCC.
+** ABCC_READY_FOR_COMMUNICATION: Possible to communicate with ABCC
+** ABCC_COMMUNICATION_ERROR: ABCC module is not responding
+**
+**------------------------------------------------------------------------------
+*/
+typedef enum ABCC_CommunicationState
+{
+ ABCC_NOT_READY_FOR_COMMUNICATION = 0,
+ ABCC_READY_FOR_COMMUNICATION = 1,
+ ABCC_COMMUNICATION_ERROR = 2
+}
+ABCC_CommunicationStateType;
+
+
+/*------------------------------------------------------------------------------
+** Used for storing the data format of the field bus.
+** NET_UNKNOWN means that the Anybus-CC has not yet responded to our command to
+** read the fieldbus data format.
+**------------------------------------------------------------------------------
+*/
+typedef enum NetFormatType
+{
+ NET_LITTLEENDIAN,
+ NET_BIGENDIAN,
+ NET_UNKNOWN
+}
+NetFormatType;
+
+/*------------------------------------------------------------------------------
+** Type for indicate if parameter support is available or not.
+**------------------------------------------------------------------------------
+*/
+typedef enum ParameterSupportType
+{
+ NOT_PARAMETER_SUPPORT,
+ PARAMETER_SUPPORT,
+ PARAMETER_UNKNOWN
+}
+ParameterSupportType;
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Macros for basic endian swap. Used by conversion macros below.
+**------------------------------------------------------------------------------
+*/
+#ifndef ABCC_iEndianSwap
+#define ABCC_iEndianSwap( iFoo ) (UINT16)( ( (UINT16)(iFoo) >> 8 ) | ( (UINT16)(iFoo) << 8 ) )
+#endif
+
+#ifndef ABCC_lEndianSwap
+#define ABCC_lEndianSwap( lFoo ) (UINT32)( ( (UINT32)ABCC_iEndianSwap( (UINT16)( (UINT32)(lFoo) ) ) << 16 ) | (UINT32)ABCC_iEndianSwap( (UINT32)(lFoo) >> 16 ) )
+#endif
+
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+#ifndef ABCC_l64EndianSwap
+#define ABCC_l64EndianSwap( lFoo ) (UINT64)( ( (UINT64)ABCC_lEndianSwap( (UINT32)( (UINT64)(lFoo) ) ) << 32 ) | (UINT64)ABCC_lEndianSwap( (UINT64)(lFoo) >> 32 ) )
+#endif
+#endif
+
+/*------------------------------------------------------------------------------
+** Macros for reading/writing byte to/from a 16 bit word.
+**------------------------------------------------------------------------------
+*/
+#ifndef ABCC_iSetLSB
+#define ABCC_iSetLSB( iDest, iSrc ) \
+do \
+{ \
+ (iDest) &= (UINT16)0xFF00; \
+ (iDest) |= (UINT16)( iSrc ) & (UINT16)0x00FF; \
+} \
+while( 0 )
+#endif
+
+#ifndef ABCC_iSetMSB
+#define ABCC_iSetMSB( iDest, iSrc ) \
+do \
+{ \
+ (iDest) &= (UINT16)0x00FF; \
+ (iDest) |= (UINT16)(iSrc) << 8; \
+} \
+while( 0 )
+#endif
+
+#ifndef ABCC_iLSB
+#define ABCC_iLSB( iFoo ) (UINT16)( (iFoo) & 0x00FF)
+#endif
+
+#ifndef ABCC_iMSB
+#define ABCC_iMSB( iFoo ) (UINT16)( (UINT16)(iFoo) >> 8 )
+#endif
+
+/*------------------------------------------------------------------------------
+** Endian dependent macros:
+**------------------------------------------------------------------------------
+** Macros to convert to/from native endian to/from specified endian:
+**
+** iBeTOi( iBeFoo ) - 16 bit big endian -> native endian
+** iTOiBe( iFoo ) - 16 bit native endian -> big endian
+** iLeTOi( iLeFoo ) - 16 bit little endian -> native endian
+** iTOiLe( iFoo ) - 16 bit native endian -> little endian
+** -
+** lBeTOl( lBeFoo ) - 32 bit big endian -> native endian
+** lTOlBe( lFoo ) - 32 bit native endian -> big endian
+** lLeTOl( lLeFoo ) - 32 bit little endian -> native endian
+** lTOlLe( lFoo ) - 32 bit native endian -> little endian
+** -
+** lBeTOl64( lBeFoo ) - 64 bit big endian -> native endian
+** lTOlBe64( lFoo ) - 64 bit native endian -> big endian
+** lLeTOl64( lLeFoo ) - 64 bit little endian -> native endian
+** lTOlLe64( lFoo ) - 64 bit native endian -> little endian
+**------------------------------------------------------------------------------
+** Macros to set/get low/high address octet from a word:
+**
+** ABCC_GetLowAddrOct( iFoo )
+** ABCC_GetHighAddrOct( iFoo )
+** ABCC_SetLowAddrOct( iDest, iSrc )
+** ABCC_SetHighAddrOct( iDest, iSrc )
+**------------------------------------------------------------------------------
+*/
+#ifdef ABCC_SYS_BIG_ENDIAN
+
+ #define iBeTOi( iBeFoo ) (UINT16)(iBeFoo)
+ #define iTOiBe( iFoo ) (UINT16)(iFoo)
+ #define iLeTOi( iLeFoo ) ABCC_iEndianSwap( iLeFoo )
+ #define iTOiLe( iFoo ) ABCC_iEndianSwap( iFoo )
+
+ #define lBeTOl( lBeFoo ) (UINT32)( lBeFoo )
+ #define lTOlBe( lFoo ) (UINT32)( lFoo )
+ #define lLeTOl( lLeFoo ) ABCC_lEndianSwap( lLeFoo )
+ #define lTOlLe( lFoo ) ABCC_lEndianSwap( lFoo )
+
+
+ #define ABCC_GetLowAddrOct( iFoo ) ABCC_iMSB( iFoo )
+ #define ABCC_GetHighAddrOct( iFoo ) ABCC_iLSB( iFoo )
+
+ #define ABCC_SetLowAddrOct( iDest, iSrc ) ABCC_iSetMSB( iDest, iSrc )
+ #define ABCC_SetHighAddrOct( iDest, iSrc ) ABCC_iSetLSB( iDest, iSrc )
+
+#else
+ #define iBeTOi( iBeFoo ) ABCC_iEndianSwap( iBeFoo )
+ #define iTOiBe( iFoo ) ABCC_iEndianSwap( iFoo )
+ #define iLeTOi( iLeFoo ) (UINT16)(iLeFoo)
+ #define iTOiLe( iFoo ) (UINT16)(iFoo)
+ #define lBeTOl( lBeFoo ) ABCC_lEndianSwap( lBeFoo )
+ #define lTOlBe( lFoo ) ABCC_lEndianSwap( lFoo )
+ #define lLeTOl( lLeFoo ) (UINT32)( lLeFoo )
+ #define lTOlLe( lFoo ) (UINT32)( lFoo )
+
+ #define ABCC_GetLowAddrOct( iFoo ) ABCC_iLSB( iFoo )
+ #define ABCC_GetHighAddrOct( iFoo ) ABCC_iMSB( iFoo )
+
+ #define ABCC_SetLowAddrOct( iDest, iSrc ) ABCC_iSetLSB( iDest, iSrc )
+ #define ABCC_SetHighAddrOct( iDest, iSrc ) ABCC_iSetMSB( iDest, iSrc )
+#endif
+
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+#ifdef ABCC_SYS_BIG_ENDIAN
+#define lBeTOl64( lBeFoo ) (UINT64)( lBeFoo )
+#define lTOlBe64( lFoo ) (UINT64)( lFoo )
+#define lLeTOl64( lLeFoo ) ABCC_l64EndianSwap( lLeFoo )
+#define lTOlLe64( lFoo ) ABCC_l64EndianSwap( lFoo )
+#else
+#define lBeTOl64( lBeFoo ) ABCC_l64EndianSwap( lBeFoo )
+#define lTOlBe64( lFoo ) ABCC_l64EndianSwap( lFoo )
+#define lLeTOl64( lLeFoo ) (UINT64)( lLeFoo )
+#define lTOlLe64( lFoo ) (UINT64)( lFoo )
+#endif
+#endif
+
+/*------------------------------------------------------------------------------
+** 8/16 bit char platform dependent macros for reading ABP message type members
+**------------------------------------------------------------------------------
+** ABCC_GetMsgDataSize( psMsg ) - Message data size (in octets)
+** ABCC_GetMsgInstance( psMsg ) - Message instance
+** ABCC_GetMsgSourceId( psMsg ) - Message source id
+** ABCC_GetMsgDestObj( psMsg ) - Destination object
+** ABCC_IsCmdMsg( psMsg ) - Message command bit
+** ABCC_GetMsgCmdBits( psMsg ) - Message command
+** ABCC_GetMsgCmdExt0( psMsg ) - Command extension 0
+** ABCC_GetMsgCmdExt1( psMsg ) - Command extension 1
+** ABCC_GetMsgCmdExt( psMsg ) - Get extension 0 and 1 16 bit type
+** ABCC_SetMsgCmdExt( psMsg ) - Set extension 0 and 1 16 bit type
+**------------------------------------------------------------------------------
+*/
+
+#define ABCC_GetMsgDataSize( psMsg ) ( iLeTOi( (psMsg)->sHeader.iDataSize ) )
+#define ABCC_GetMsgInstance( psMsg ) ( iLeTOi( (psMsg)->sHeader.iInstance ) )
+
+#ifdef ABCC_SYS_16_BIT_CHAR
+#define ABCC_GetMsgSourceId( psMsg ) ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iSourceIdDestObj ) )
+#define ABCC_GetMsgDestObj( psMsg ) ( ABCC_GetHighAddrOct( (psMsg)->sHeader.iSourceIdDestObj ) )
+#define ABCC_IsCmdMsg( psMsg ) ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT )
+#define ABCC_GetMsgCmdBits( psMsg ) ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdReserved ) & ABP_MSG_HEADER_CMD_BITS )
+#define ABCC_GetMsgCmdExt0( psMsg ) ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdExt0CmdExt1) )
+#define ABCC_GetMsgCmdExt1( psMsg ) ( ABCC_GetHighAddrOct( (psMsg)->sHeader.iCmdExt0CmdExt1) )
+#define ABCC_GetMsgCmdExt( psMsg ) ( iLeTOi( (psMsg)->sHeader.iCmdExt0CmdExt1 ) )
+#define ABCC_SetMsgCmdExt( psMsg, iExt ) ( (psMsg)->sHeader.iCmdExt0CmdExt1 = iTOiLe( iExt ) )
+#define ABCC_GetMsgDataPtr( psMsg ) ( (psMsg)->aiData )
+#else
+#define ABCC_GetMsgSourceId( psMsg ) ( (psMsg)->sHeader.bSourceId )
+#define ABCC_GetMsgDestObj( psMsg ) (psMsg)->sHeader.bDestObj
+#define ABCC_IsCmdMsg( psMsg ) ( (psMsg)->sHeader.bCmd & ABP_MSG_HEADER_C_BIT )
+#define ABCC_GetMsgCmdBits( psMsg ) ( (psMsg)->sHeader.bCmd & ABP_MSG_HEADER_CMD_BITS )
+#define ABCC_GetMsgCmdExt0( psMsg ) ( (psMsg)->sHeader.bCmdExt0 )
+#define ABCC_GetMsgCmdExt1( psMsg ) ( (psMsg)->sHeader.bCmdExt1 )
+#define ABCC_GetMsgCmdExt( psMsg ) ( iLeTOi( *(UINT16*)&(psMsg)->sHeader.bCmdExt0 ) )
+#define ABCC_SetMsgCmdExt( psMsg, iExt ) ( *(UINT16*)&(psMsg)->sHeader.bCmdExt0 = iTOiLe( iExt ) )
+#define ABCC_GetMsgDataPtr( psMsg ) ( (psMsg)->abData )
+#endif
+
+/*------------------------------------------------------------------------------
+** 8/16 bit char platform dependent macros to read and write message data
+**------------------------------------------------------------------------------
+** ABCC_SetMsgString() - Copy native string to ABCC message
+** ABCC_GetMsgString() - Copy ABCC message string to native string
+** ABCC_SetMsgData8() - Write 8 bit data to ABCC message
+** ABCC_SetMsgData16() - Write 16 bit data to ABCC message
+** ABCC_SetMsgData32() - Write 32 bit data to ABCC message
+** ABCC_GetMsgData8() - Read 8 bit data from an ABCC message
+** ABCC_GetMsgData16() - Read 16 bit data from an ABCC message
+** ABCC_GetMsgData32() - Read 32 bit data from an ABCC message
+**------------------------------------------------------------------------------
+** ABCC_SetMsgString( psMsg, pcString, iNumChar, iOctetOffset )
+** psMsg - Pointer to message
+** pcString - String to be written
+** iNumChar - Number of chars in the string
+** iOctetOffset - Offset to where the string shall be written.
+**
+** ABCC_GetMsgString( psMsg, pcString, iNumChar, iOctetOffset )
+** psMsg - Pointer to message
+** pcString - String to be written
+** iNumChar - Number of chars in the string
+** iOctetOffset - Offset to where the string shall be read.
+**
+** ABCC_SetMsgDataX( psMsg, Data, iOctetOffset )
+** psMsg - Pointer to message
+** Data - Data to be set
+** iOctetOffset - Offset to where data shall be written.
+**
+** ABCC_GetMsgDataX( psMsg, Data, iOctetOffset )
+** psMsg - Pointer to message
+** Data - Read data variable
+** iOctetOffset - Offset to where data shall be read.
+**------------------------------------------------------------------------------
+*/
+void ABCC_SetMsgString( ABP_MsgType* psMsg, const char* pcString, UINT16 iNumChar, UINT16 iOctetOffset );
+void ABCC_GetMsgString( ABP_MsgType* psMsg, char* pcString, UINT16 iNumChar, UINT16 iOctetOffset );
+
+void ABCC_GetMsgData8( ABP_MsgType* psMsg, UINT8* pbData, UINT16 iOctetOffset );
+void ABCC_SetMsgData8( ABP_MsgType* psMsg, UINT8 bData, UINT16 iOctetOffset );
+
+void ABCC_GetMsgData16( ABP_MsgType* psMsg, UINT16* piData, UINT16 iOctetOffset );
+void ABCC_SetMsgData16( ABP_MsgType* psMsg, UINT16 iData, UINT16 iOctetOffset );
+
+void ABCC_GetMsgData32( ABP_MsgType* psMsg, UINT32* plData, UINT16 iOctetOffset );
+void ABCC_SetMsgData32( ABP_MsgType* psMsg, UINT32 lData, UINT16 iOctetOffset );
+
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+UINT64 ABCC_GetMsgData64( ABP_MsgType* psMsg, UINT16 iOctetOffset );
+void ABCC_SetMsgData64( ABP_MsgType* psMsg, UINT64 lData, UINT16 iOctetOffset );
+#endif
+
+/*------------------------------------------------------------------------------
+** Copy a number of bytes, from the source pointer to the destination pointer.
+** This function can be modified to use performance enhancing platform specific
+** instructions. The default implementation is memcpy().
+**------------------------------------------------------------------------------
+** Arguments:
+** pbDestinationPtr - Pointer to the destination.
+** pbSourcePtr - Pointer to source data.
+** iNbrOfBytes - The number of bytes that shall be copied.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#define ABCC_MemCpy( pbDestinationPtr, pbSourcePtr, iNbrOfBytes ) \
+ ABCC_PORT_MemCpy( pbDestinationPtr, pbSourcePtr, iNbrOfBytes )
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This function is used to measure sync timings. ABCC_CFG_SYNC_MEASUREMENT_OP
+** is used when measuring the output processing time and
+** ABCC_CFG_SYNC_MEASUREMENT_IP is used to measure the input processing time.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP )
+EXTFUNC void ABCC_GpioReset( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** This function is used to measure sync timings. ABCC_CFG_SYNC_MEASUREMENT_OP
+** is used when measuring the output processing time and
+** ABCC_CFG_SYNC_MEASUREMENT_IP is used to measure the input processing time.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP )
+EXTFUNC void ABCC_GpioSet( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** This function will initiate the hardware required to communicate with the
+** ABCC. This interface shall be called once during the power up initialization.
+** The driver can be restarted without calling this interface again.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_HwInit( void );
+
+/*------------------------------------------------------------------------------
+** This function will initiate the driver, enable interrupt, and set the
+** operation mode. If a firmware update is pending a delay, iMaxStartupTime, can
+** be defined describing how long the driver is to wait for the startup
+** interrupt. iMaxStartupTime set to Zero (0) makes the driver use the
+** ABCC_CFG_STARTUP_TIME_MS time.
+** When this function has been called the timer system could be started,
+** see ABCC_RunTimerSystem().
+** Note! This function will NOT release the reset of the ABCC.
+** To release reset, ABCC_HwReleaseReset() has to be called by the application.
+**------------------------------------------------------------------------------
+** Arguments:
+** lMaxStartupTimeMs - Max startup time for ABCC
+**
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_StartDriver( UINT32 lMaxStartupTimeMs );
+
+/*------------------------------------------------------------------------------
+** Stops the driver and puts it into SHUTDOWN state. The ABCC will be reset.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_ShutdownDriver( void );
+
+/*------------------------------------------------------------------------------
+** This function shall be polled after ABCC_StartDriver() has been executed
+** until ABCC_READY_FOR_COMMUNICATION is returned. This indicates that the ABCC
+** is ready for communication and the ABCC setup sequence is started.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** ABCC_CommunicationStateType:
+** ( see description of ABCC_CommunicationStateType )
+**
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_CommunicationStateType ABCC_isReadyForCommunication( void );
+
+/*------------------------------------------------------------------------------
+** This function should be called from inside the ABCC interrupt routine to
+** acknowledge and handle received ABCC events (Triggered by IRQ_n on the
+** abcc application interface).
+** The user configuration defines, ABCC_CFG_INT_ENABLE_MASK and
+** ABCC_CFG_HANDLE_IN_ABCC_ISR_MASK, allows configuration of which events to
+** handle by the ISR and which events to pass on to the application
+** (ABCC_CbfEvent()).
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ( *ABCC_ISR )( void );
+
+/*------------------------------------------------------------------------------
+** This function is responsible for handling all timers for the ABCC-driver. It
+** is recommended to call this function on a regular basis from a timer
+** interrupt. Without this function no timeout and watchdog functionality will
+** work. This function can be called after ABCC_StartDriver() has been called.
+**------------------------------------------------------------------------------
+** Arguments:
+** iDeltaTimeMs - Milliseconds since last call.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_RunTimerSystem( const INT16 iDeltaTimeMs );
+
+/*------------------------------------------------------------------------------
+** ABCC hardware reset.
+** Note! This function will only set reset pin to low. It the responsibility of
+** the caller to make sure that the reset time is long enough.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_HWReset( void );
+
+/*------------------------------------------------------------------------------
+** Releases the ABCC reset.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_HWReleaseReset( void );
+
+/*------------------------------------------------------------------------------
+** This function drives the ABCC driver sending and receiving mechanism.
+** The driver must be ready for communication before this function is called
+** (ABCC_isReadyForCommunication() must be TRUE). This function could be called
+** cyclically or be based on events from the ABCC. If all events are handled in
+** the interrupt context then there is no need to call this function.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType (*ABCC_RunDriver)( void );
+
+/*------------------------------------------------------------------------------
+** This function should be called by the application when the last response from
+** the user specific setup has been received. This will end the ABCC setup
+** sequence and ABCC_SETUP_COMPLETE will be sent. The user specific setup is a
+** part of the ABCC setup sequence and it is initiated by the driver by calling
+** the ABCC_CbfUserInitReq() function.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_UserInitComplete( void );
+
+/*------------------------------------------------------------------------------
+** Sends a command message to the ABCC.
+** The function ABCC_GetCmdMsgBuffer() must be used to allocate the message
+** buffer. It is OK to re-use a previously received response buffer
+** The driver will use the sourceId to map the response to the correct response
+** handler. ABCC_GetNewSourceId() could be used to provide an new source id.
+** Example where ABCC_CbfMessageReceived() function is used as response handler:
+**
+** eResp = ABCC_SendCmdMsg( psMsg, ABCC_CbfMessageReceived );
+**------------------------------------------------------------------------------
+** Arguments:
+** psCmdMsg - Pointer to the command message.
+** pnMsgHandler - Pointer to the function to handle the response
+** message.
+**
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_SendCmdMsg( ABP_MsgType* psCmdMsg,
+ ABCC_MsgHandlerFuncType pnMsgHandler );
+
+/*------------------------------------------------------------------------------
+** Retrieves the number of entries left in the command queue.
+** Note! When sending a message the returned status must always be checked to
+** verify that the message has in fact been sent.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Number of queue entries left in the command queue
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 ABCC_GetCmdQueueSize( void );
+
+/*------------------------------------------------------------------------------
+** Sends a response message to the ABCC.
+** Note! The received command buffer can be reused as a response buffer. If a
+** new buffer is used then the function ABCC_GetCmdMsgBuffer() must be used to
+** allocate the buffer.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsgResp - Pointer to the message.
+**
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_SendRespMsg( ABP_MsgType* psMsgResp );
+
+/*------------------------------------------------------------------------------
+** Sends a remap response to the ABCC. When the response is sent the new process
+** data sizes will be set and the function ABCC_CbfRemapDone() will be called to
+** indicate the change.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsgResp - Pointer to the response message.
+** iNewReadPdSize - RdPd size when the remap is done.
+** iNewWritePdSize - WrPd size when the remap is done.
+**
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+EXTFUNC ABCC_ErrorCodeType ABCC_SendRemapRespMsg( ABP_MsgType* psMsgResp,
+ UINT16 iNewReadPdSize,
+ const UINT16 iNewWritePdSize );
+#endif
+
+/*------------------------------------------------------------------------------
+** Get the current application status.
+** Note! This information is only supported in SPI and parallel operating mode.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** The application status of the ABCC
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABP_AppStatusType ABCC_GetAppStatus( void );
+
+/*------------------------------------------------------------------------------
+** Sets the current application status.
+** Note! This information is only supported in SPI and parallel operating mode.
+** When used for other operating modes the call has no effect.
+**------------------------------------------------------------------------------
+** Arguments:
+** eAppStatus - Current application status
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_SetAppStatus( ABP_AppStatusType eAppStatus );
+
+/*------------------------------------------------------------------------------
+** Retrieves a message buffer. This function MUST be used when allocating
+** message buffers. The size of the buffer is controlled by
+** ABCC_CFG_MAX_MSG_SIZE.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** ABP_MsgType* - Pointer to the message buffer.
+** NULL is returned if no resource is available.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABP_MsgType* ABCC_GetCmdMsgBuffer( void );
+
+/*------------------------------------------------------------------------------
+** Returns the message buffer to the driver's message pool.
+** Note! This function may only be used in combination with
+** ABCC_TakeMsgBufferOwnership().
+**------------------------------------------------------------------------------
+** Arguments:
+** ppsBuffer - Pointer to the message buffer that was freed.
+** The buffer pointer will be set to NULL.
+**
+** Returns:
+** ABCC_ErrorCodeType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_ReturnMsgBuffer( ABP_MsgType** ppsBuffer );
+
+/*------------------------------------------------------------------------------
+** Takes the ownership of the message buffer. The driver will not free this
+** buffer when returning from e.g. a response callback. It is the user's
+** responsibility to free this buffer when it is not needed anymore by using
+** ABCC_ReturnMsgBuffer().
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to the message buffer to take ownership of
+**
+** Returns:
+** ABCC_StatusType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_TakeMsgBufferOwnership( ABP_MsgType* psMsg );
+
+/*------------------------------------------------------------------------------
+** Reads the module ID.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** ModuleId
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT8 ABCC_ReadModuleId( void );
+
+/*------------------------------------------------------------------------------
+** Detects if a module is present. If the ABCC Module detect pins on the host
+** connector is not connected (ABCC_CFG_MOD_DETECT_PINS_CONN shall be defined)
+** this interface will always return TRUE.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** TRUE - Module detected.
+** FALSE - No module detected
+**------------------------------------------------------------------------------
+*/
+EXTFUNC BOOL ABCC_ModuleDetect( void );
+
+/*------------------------------------------------------------------------------
+** Reads the module capability. This function is only supported by the ABCC40
+** parallel operating mode.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Module capability
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_DRV_PARALLEL )
+EXTFUNC UINT16 ABCC_ModCap( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** Reads the LED status. Only supported in SPI and parallel operating mode.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** LED status according to the software design guide.
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_DRV_PARALLEL || ABCC_CFG_DRV_SPI )
+EXTFUNC UINT16 ABCC_LedStatus( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** Reads the current Anybus state.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Anybus state
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT8 ABCC_AnbState( void);
+
+/*------------------------------------------------------------------------------
+** Returns the current status of the supervision bit.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** TRUE - Is supervised by another network device.
+** FALSE - Not supervised.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC BOOL ABCC_IsSupervised( void );
+
+/*------------------------------------------------------------------------------
+** Retrieves the network type.
+** This function will return a valid value after ABCC_CbfAdiMappingReq has been
+** called by the driver. If called earlier the function will return 0xFFFF which
+** indicates that the network is unknown. The different newtwork types could
+** be found in abp.h.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Network type (0xFFFF if the network is unknown)
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 ABCC_NetworkType( void );
+
+/*------------------------------------------------------------------------------
+** Retrieves the module type.
+** This function will return a valid value after ABCC_CbfAdiMappingReq has been
+** called by the driver. If called earlier the function will return 0xFFFF which
+** indicates that the moduleType is unknown. The different module types types
+** could be found in abp.h.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Module type (0x04XX for Anybus-CC modules).
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 ABCC_ModuleType( void );
+
+/*------------------------------------------------------------------------------
+** Retrieves the network format.
+** This function will return a valid value after ABCC_CbfAdiMappingReq has been
+** called by the driver. If called earlier the function will return NET_UNKNOWN.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Network format type (NET_LITTLEENDIAN, NET_BIGENDIAN).
+**------------------------------------------------------------------------------
+*/
+EXTFUNC NetFormatType ABCC_NetFormatType( void );
+
+/*------------------------------------------------------------------------------
+** Retrieves the parameter support.
+** This function will return a valid value after ABCC_CbfAdiMappingReq has been
+** called by the driver. If called earlier PARAMETR_UNKNOWN will be returned.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** ParamemterSupportType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ParameterSupportType ABCC_ParameterSupport( void );
+
+/*------------------------------------------------------------------------------
+** This function will call ABCC_SYS_GetOpmode() to read the operating mode from
+** HW. If the operation is known and fixed or in any other way decided by the
+** application this function could be ignored.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** The ABCC40 4 bit operating mode according to abp.h
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT8 ABCC_GetOpmode( void );
+
+/*******************************************************************************
+** Callback Functions.
+** These function must be implemented by the application. The context of the
+** callback will differ depending on implementation.
+** If, for example, the read process data is chosen to be interrupt driven and
+** the message handling chosen to be polled ( see ABCC_CFG_INT_ENABLE_MASK and
+** HANDLE_ABCC_CFG_IN_ABCC_ISR in ABCC_CFG_def.h ), the ABCC_CbfNewReadPd()
+** will be called from interrupt context and ABCC_CbfReceiveMsg() will be called
+** from the same context as ABCC_RunDriver().
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This function is called from ABCC_ISR() when events specified in
+** ABCC_CFG_INT_ENABLE_MASK_X have occurred. The function returns a mask of
+** ABCC_ISR_EVENT_X bits with the currently active events that has not already
+** been handled by the ISR itself. What interrupt to be handled by the ISR is
+** defined in the ABCC_CFG_HANDLE_INT_IN_ISR_MASK.
+** This function is always called from interrupt context.
+**------------------------------------------------------------------------------
+** Arguments:
+** iEvents - Mask according to the ISR event bits ABCC_ISR_EVENT_X
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CbfEvent( UINT16 iEvents);
+
+/*------------------------------------------------------------------------------
+** If sync is supported this function will be invoked at the sync event.
+** The function is executed in interrupt context. If the separate sync pin in
+** the ABCC interface is used this function shall be called from the interrupt
+** handler. If the ABCC interrupt is used the driver will call this function.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if ABCC_CFG_SYNC_ENABLE
+EXTFUNC void ABCC_CbfSyncIsr( void );
+#endif
+
+
+/*------------------------------------------------------------------------------
+** This function needs to be implemented by the application. The function is
+** called to trigger a user specific setup during the ABCC setup state. The ABCC
+** driver will remain in ABCC_CFG_INIT state until ABCC_UserInitComplete() is called
+** by the application. If no user specific setup is required,
+** ABCC_UserInitComplete() must be called inside this function otherwise setup
+** complete will never be sent.
+**
+** This function call will be invoked in same context as the read message handling.
+** (See comment for callback section above)
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CbfUserInitReq( void );
+
+/*------------------------------------------------------------------------------
+** A message has been received from the ABCC. This is the receive function for
+** all received commands from the ABCC. It could also be used as a response
+** handler if passed on as an argument to the ABCC_SendCmdMsg() function.
+** Regarding callback context, see comment for callback section above.
+**------------------------------------------------------------------------------
+** Arguments:
+** psReceivedMsg - Pointer to received message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CbfReceiveMsg( ABP_MsgType* psReceivedMsg );
+
+/*------------------------------------------------------------------------------
+** This function needs to be implemented by the application. The function
+** updates the current write process data. The data must be copied into the
+** buffer before returning from the function.
+** The data will only be sent to the ABCC if the return value is TRUE.
+** Regarding callback context, see comment for callback section above.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxWritePd - Pointer to the process data to be sent.
+**
+** Returns:
+** TRUE - If the process data has been changed since last call.
+** FALSE - Process data not changed.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC BOOL ABCC_CbfUpdateWriteProcessData( void* pxWritePd );
+
+/*------------------------------------------------------------------------------
+** This function needs to be implemented by the application. The function is
+** called when new process data has been received. The process data needs to
+** be copied to the application ADI:s before returning from the function. Note
+** that the data may not be changed since last time.
+** Regarding callback context, see comment for callback section above.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxReadPd - Pointer to the received process data.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CbfNewReadPd( void* pxReadPd );
+
+/*------------------------------------------------------------------------------
+** This function needs to be implemented by the application. The function is
+** called when communication with the ABCC module has been lost. The watchdog
+** timeout is defined by ABCC_CFG_WD_TIMEOUT_MS.
+** Note! No watch functionality is provided for parallel 8/16 bit operation
+** mode.
+** This function is invoked in the same context as ABCC_RunTimerSystem().
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_SERIAL || \
+ ABCC_CFG_DRV_PARALLEL_30 )
+EXTFUNC void ABCC_CbfWdTimeout( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** This function needs to be implemented by the application. The function
+** indicates that we recently had an ABCC watchdog timeout but now the
+** communication is working again.
+** This function will be invoked from same context as the receive handling.
+** (see comment for callback section above).
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_SERIAL || \
+ ABCC_CFG_DRV_PARALLEL_30 )
+EXTFUNC void ABCC_CbfWdTimeoutRecovered( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** This function need to be implemented by the application. The function is
+** called when the driver is about to start the automatic process data mapping.
+** If no automatic configuration is desired then the pointers are set to NULL.
+** Otherwise the pointers are set to point at the structures containing mapping
+** information. The mapping structures are defined in abcc_ad_if.h.
+** This function will be invoked in same context as the read message handling.
+** (See comment for callback section above)
+**------------------------------------------------------------------------------
+** Arguments:
+** ppsAdiEntry - Pointer to the requested configuration structure pointer.
+** ppsDefaultMap - Pointer to default mapping table.
+**
+** Returns:
+** Number of Adi:s in the psAdiEntry table.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 ABCC_CbfAdiMappingReq( const AD_AdiEntryType** const ppsAdiEntry,
+ const AD_DefaultMapType** const ppsDefaultMap );
+
+/*------------------------------------------------------------------------------
+** This function needs to be implemented by the application.
+** The context of the call is depending on where the error has occured.
+**------------------------------------------------------------------------------
+** Arguments:
+** eSeverity - Severity of the event (see ABCC_SeverityType).
+** iErrorCode - Error code.
+** lAddInfo - Depending on error different additional information can be
+** added.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CbfDriverError( ABCC_SeverityType eSeverity,
+ ABCC_ErrorCodeType iErrorCode,
+ UINT32 lAddInfo );
+
+/*------------------------------------------------------------------------------
+** This callback is invoked if the anybus changes state
+** See ABP_AnbStateType in abp.h for more information.
+**
+** Regarding callback context, see comment for callback section above.
+**------------------------------------------------------------------------------
+** Arguments:
+** bNewAnbState - New anybus state
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CbfAnbStateChanged( ABP_AnbStateType bNewAnbState );
+
+/*******************************************************************************
+** REMAP Related functions
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This callback is invoked when REMAP response is successfully sent to the
+** ABCC.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+EXTFUNC void ABCC_CbfRemapDone( void );
+#endif
+
+/*******************************************************************************
+** Event related functions
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This function is called to trigger a RdPd read. If the read process data is
+** available then a call to the function ABCC_CbfNewReadPd() will be triggered.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_TriggerRdPdUpdate( void );
+
+/*------------------------------------------------------------------------------
+** This function is called to trigger a message receive read. If a read message
+** is available then the corresponding message handler will be called.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_TriggerReceiveMessage( void );
+
+/*------------------------------------------------------------------------------
+** This function indicates that new process data from the application is
+** available and will be sent to the ABCC.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void (*ABCC_TriggerWrPdUpdate)( void );
+
+/*------------------------------------------------------------------------------
+** Check if current anybus status has changed.
+** If the status is changed ABCC_CbfAnbStatusChanged() will be invoked.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_TriggerAnbStatusUpdate( void );
+
+/*------------------------------------------------------------------------------
+** Checks if there are any messages to send.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_TriggerTransmitMessage( void );
+
+/*******************************************************************************
+** Message support functions
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This function fills an ABCC message with parameters to get an attribute.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to message buffer.
+** bObject - Object number.
+** iInstance - Instance number.
+** bAttribute - Attribute number.
+** bSourceId - Source identifier
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_GetAttribute( ABP_MsgType* psMsg,
+ UINT8 bObject,
+ UINT16 iInstance,
+ UINT8 bAttribute,
+ UINT8 bSourceId );
+
+/*------------------------------------------------------------------------------
+** This function fills an ABCC message with parameters in order to set an
+** attribute.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to message buffer.
+** bObject - Object number.
+** iInstance - Instance number.
+** bAttribute - Attribute number.
+** bVal - Value to set.
+** bSourceId - Source identifier.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_SetByteAttribute( ABP_MsgType* psMsg,
+ UINT8 bObject,
+ UINT16 iInstance,
+ UINT8 bAttribute,
+ UINT8 bVal,
+ UINT8 bSourceId );
+
+/*------------------------------------------------------------------------------
+** This function sets the input arguments to the ABCC message header correctly.
+** The data must be copied to message data buffer separately.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to message buffer.
+** bObject - Object number.
+** iInstance - Instance number.
+** bAttribute - Attribute number.
+** eService - Message command
+** iDataSize - Size of the message data in bytes
+** bSourceId - Source identifier.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_SetMsgHeader( ABP_MsgType* psMsg,
+ UINT8 bObject,
+ UINT16 iInstance,
+ UINT8 bAttribute,
+ ABP_MsgCmdType eService,
+ UINT16 iDataSize,
+ UINT8 bSourceId );
+
+/*------------------------------------------------------------------------------
+** This function verifies an ABCC response message.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to message buffer.
+**
+** Returns:
+** ABCC_ErrorCodeType.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_VerifyMessage( const ABP_MsgType* psMsg );
+
+/*------------------------------------------------------------------------------
+** This function returns a new source id that could used when sending a command
+** message. It is guaranteed be unique if this function is used every time a new
+** command is sent. The alternative would be that the user uses fixed source
+** id:s.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** New SourceId
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT8 ABCC_GetNewSourceId( void );
+
+/*------------------------------------------------------------------------------
+** This function returns the size of an ABP data type.
+**------------------------------------------------------------------------------
+** Arguments:
+** bDataType - Data type number.
+**
+** Returns:
+** Data type size in bytes.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT8 ABCC_GetDataTypeSize( UINT8 bDataType );
+
+/*------------------------------------------------------------------------------
+** This function returns the size of an ABP data type in bits.
+**------------------------------------------------------------------------------
+** Arguments:
+** bDataType - Data type number.
+**
+** Returns:
+** Data type size in bits.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 ABCC_GetDataTypeSizeInBits( UINT8 bDataType );
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/inc/abcc_ad_if.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,676 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Typedefs provided by ABCC_driver, used to specify ADI mapping tables.
+********************************************************************************
+********************************************************************************
+** Services:
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABCC_AD_IF_H_
+#define ABCC_AD_IF_H_
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*
+** Type for defining the direction of the process data map.
+** PD_END_MAP is used to indicate end of default map list.
+*/
+typedef enum
+{
+ PD_READ,
+ PD_WRITE,
+ PD_END_MAP
+} PD_DirType;
+
+
+
+/*-------------------------------------------------------------------------------
+** AD_DefaultMapType.
+** Note! The example at the end of this file shows how to use this type.
+**
+** iInstance: AD instance in default map structure.
+** If instance == AD_MAP_PAD_ADI (0), bNumElem indicates
+** number of bits to pad with.
+**
+** eDir: Direction of map. Set to PD_END_MAP to indicate end of
+** default map list.
+** bNumElem: Number of elements to map.
+** Can only be > 1 for arrays or structures.
+** AD_DEFAULT_MAP_ALL_ELEM indicates that all elements shall
+** be mapped. If instance == AD_MAP_PAD_ADI, bNumElem
+** indicates number of bits to pad with.
+**
+** bElemStartIndex: Element start index within an array or structure
+**-------------------------------------------------------------------------------
+*/
+#define AD_DEFAULT_MAP_END_ENTRY 0xFFFF, PD_END_MAP, 0, 0
+#define AD_DEFAULT_MAP_ALL_ELEM 0
+#define AD_MAP_PAD_ADI 0
+
+typedef struct AD_DefaultMap
+{
+ UINT16 iInstance;
+ PD_DirType eDir;
+ UINT8 bNumElem;
+ UINT8 bElemStartIndex;
+}
+AD_DefaultMapType;
+
+/*------------------------------------------------------------------------------
+** ADI type property defines (min/max/default/(enum strings)).
+**
+** AD_MinMaxDefaultIndexType - Index to access min, max or default in the
+** xMinMaxDefault array.
+**
+** AD_UINT8Type - ABP_UINT8 property type
+** AD_CHARType - ABP_CHAR property type
+** AD_BOOL8Type - ABP_BOOL property type
+** AD_SINT8Type - ABP_SINT8 property type
+** AD_UINT16Type - ABP_UINT16 property type
+** AD_SINT16Type - ABP_UINT16 property type
+** AD_UINT32Type - ABP_UINT32 property type
+** AD_SINT32Type - ABP_SINT32 property type
+** AD_FLOAT32Type - ABP_FLOAT32 property type
+** AD_ENUMType - ABP_ENUM property type
+** AD_UINT64Type - ABP_UINT64 property type
+** AD_SINT64Type - ABP_SINT64 property type
+**
+** AD_ENUMStrType - Enumeration string type, used with AD_ENUMType
+** to specify value/string mappings.
+**------------------------------------------------------------------------------
+*/
+typedef enum AD_MinMaxDefaultIndex
+{
+ AD_MIN_VALUE_INDEX = 0,
+ AD_MAX_VALUE_INDEX = 1,
+ AD_DEFAULT_VALUE_INDEX = 2
+}
+AD_MinMaxDefaultIndexType;
+
+typedef struct AD_UINT8
+{
+ UINT8 bMinMaxDefault[ 3 ];
+}
+AD_UINT8Type, AD_CHARType, AD_BOOL8Type, AD_OctetType;
+
+typedef struct AD_SINT8
+{
+ INT8 bMinMaxDefault[ 3 ];
+}
+AD_SINT8Type;
+
+typedef struct AD_UINT16
+{
+ UINT16 iMinMaxDefault[ 3 ];
+}
+AD_UINT16Type;
+
+typedef struct AD_SINT16
+{
+ INT16 iMinMaxDefault[ 3 ];
+}
+AD_SINT16Type;
+
+typedef struct AD_UINT32
+{
+ UINT32 lMinMaxDefault[ 3 ];
+}
+AD_UINT32Type;
+
+typedef struct AD_SINT32
+{
+ INT32 lMinMaxDefault[ 3 ];
+}
+AD_SINT32Type;
+
+typedef struct AD_FLOAT32
+{
+ FLOAT32 rMinMaxDefault[ 3 ];
+}
+AD_FLOAT32Type;
+
+typedef struct AD_ENUMStr
+{
+ UINT8 eValue;
+ char* acEnumStr;
+}
+AD_ENUMStrType;
+
+typedef struct AD_ENUM
+{
+ UINT8 eMinMaxDefault[ 3 ];
+ UINT8 bNumOfEnumStrings;
+ AD_ENUMStrType* pasEnumStrings;
+}
+AD_ENUMType;
+
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+typedef struct AD_UINT64
+{
+ UINT64 lMinMaxDefault[ 3 ];
+}
+AD_UINT64Type;
+
+typedef struct AD_SINT64
+{
+ INT64 lMinMaxDefault[ 3 ];
+}
+AD_SINT64Type;
+#endif
+
+
+ typedef union
+ {
+ struct
+ {
+ void* pxValuePtr;
+ void* pxValueProps;
+ } sVOID;
+ struct
+ {
+ UINT8* pbValuePtr;
+ AD_UINT8Type* psValueProps;
+ } sUINT8, sCHAR, sBOOL;
+ struct
+ {
+ UINT8* pbValuePtr;
+ AD_ENUMType* psValueProps;
+ }sENUM;
+ struct
+ {
+ INT8* pbValuePtr;
+ AD_SINT8Type* psValueProps;
+ } sSINT8;
+ struct
+ {
+ UINT16* piValuePtr;
+ AD_UINT16Type* psValueProps;
+ } sUINT16;
+ struct
+ {
+ INT16* piValuePtr;
+ AD_SINT16Type* psValueProps;
+ } sSINT16;
+ struct
+ {
+ UINT32* plValuePtr;
+ AD_UINT32Type* psValueProps;
+ } sUINT32;
+ struct
+ {
+ INT32* plValuePtr;
+ AD_SINT32Type* psValueProps;
+ } sSINT32;
+ struct
+ {
+ FLOAT32* prValuePtr;
+ AD_FLOAT32Type* psValueProps;
+ } sFLOAT;
+
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+ struct
+ {
+ UINT64* plValuePtr;
+ AD_UINT64Type* psValueProps;
+ } sUINT64;
+ struct
+ {
+ INT64* plValuePtr;
+ AD_SINT64Type* psValueProps;
+ } sSINT64;
+#endif
+
+ } uDataType;
+
+/*------------------------------------------------------------------------------
+** AD_StructDataType (describes a member of a structured data type). The structured
+** data type must contain packed data. All non bit-data types
+** (including ABP_BITS8, ABP_BITS16 and ABP_BITS32) must be at least 8 bit aligned.
+** ABP_PADx data types can be used for padding.
+** Note! The example at the end of this file shows how to use this type.
+**
+**------------------------------------------------------------------------------
+** 1. bDataType - Element data type format, which can be one of the
+** following:
+** ABP_BOOL: Boolean.
+** ABP_SINT8: 8-bit signed integer.
+** ABP_SINT16: 16-bit signed integer.
+** ABP_SINT32: 32-bit signed integer.
+** ABP_UINT8: 8-bit unsigned integer.
+** ABP_UINT16: 16-bit unsigned integer.
+** ABP_UINT32: 32-bit unsigned integer.
+** ABP_CHAR: Character.
+** ABP_ENUM: Enumeration.
+** ABP_SINT64: 64-bit signed integer.
+** ABP_UINT64: 64-bit unsigned integer.
+** ABP_FLOAT: floating point value (32-bits).
+** ABP_OCTET: 8 bit data (ABCC40)
+** ABP_BITS8: 8 bit-data type (ABCC40)
+** ABP_BITS16: 16 bit-data type (ABCC40)
+** ABP_BITS32: 32 bit-data type (ABCC40)
+** ABP_BIT1 1 bit-data type (ABCC40)
+** ABP_BIT2 2 bit-data type (ABCC40)
+** :
+** ABP_BIT7 7 bit.data type (ABCC40)
+** ABP_PAD0 0 pad-bit data type (ABCC40)
+** ABP_PAD1 1 pad-bit data type (ABCC40)
+** :
+** ABP_BIT7 16 pad-bit data type (ABCC40)
+**
+** 2. iNumSubElem - Number of sub elements the specified data type (1).
+** Only allowed to be larger than 1 for ABP_CHAR or ABP_OCTET.
+**
+** 3. bDesc - Entry descriptor; bits filled with the following
+** configurations:
+** ABP_APPD_DESCR_GET_ACCESS: Get service is
+** allowed on value attribute.
+** ABP_APPD_DESCR_SET_ACCESS: Set service is
+** allowed on value attribute.
+** ABP_APPD_DESCR_MAPPABLE_WRITE_PD: Set if
+** possible to map.
+** ABP_APPD_DESCR_MAPPABLE_READ_PD:Set if
+** possible to map.
+** 4. bBitOffset - Offset to where the bit data type is located relative
+** the position given by (5). This could be used used to
+** pack bit data types in the ADI place holder.
+** For 8 bit char platforms the offset must be within
+** an octet ( 0 -7 ). For a 16 bit char system the offset
+** must be within a 16 bit word.
+** Note that the bit type is allowed cross octet boundaries.
+** 5. pxValuePtr - Pointer to the local value variable.
+** 6. psValueProps - Pointer to the local value properties struct.
+** If NULL, no properties are applied (max/min/default).
+**---------------------------------------------------------------------------------------------
+** 1. bDataType | 2. iNumSubElem | 3. bDesc | 4. bBitOffset | 5. pxValuePtr | 6. pxValuePropPtr
+**----------------------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+typedef struct AD_StructDataType
+{
+ UINT8 bDataType;
+ UINT16 iNumSubElem;
+ UINT8 bDesc;
+ UINT8 bBitOffset;
+ uDataType uData;
+} AD_StructDataType;
+#endif
+
+
+#if( ABCC_CFG_ADI_GET_SET_CALLBACK )
+
+/*------------------------------------------------------------------------------
+** Forward declaration of ADI entry type.
+**------------------------------------------------------------------------------
+*/
+struct AD_AdiEntry;
+
+/*------------------------------------------------------------------------------
+** ABCC_GetAdiValueFuncType
+** This function will be called to indicate that the ABCC has requested to read
+** of the ADI, either through explicit or implicit messaging. The function call
+** could be used to trigger an update of the ADI to hold the latest value.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry
+** bNumElements - Number of elements to update.
+** bStartIndex - Start index of first element to update.
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+typedef void (*ABCC_GetAdiValueFuncType)( const struct AD_AdiEntry* psAdiEntry,
+ UINT8 bNumElements,
+ UINT8 bStartIndex );
+
+/*------------------------------------------------------------------------------
+** ABCC_SetAdiValueFuncType
+** This function is called to indicate that the ABCC has updated the ADI either
+** through explicit or implicit messaging. The function call
+** could be used to trigger action based on the ADI update.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry
+** bNumElements - Number of elements that has been updated.
+** bStartIndex - Start index of first updated element.
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+typedef void (*ABCC_SetAdiValueFuncType)( const struct AD_AdiEntry* psAdiEntry,
+ UINT8 bNumElements,
+ UINT8 bStartIndex );
+#endif
+
+/*------------------------------------------------------------------------------
+** AD_AdiEntryType (describing an ADI). Structured data types
+** are enabled by defining ABCC_CFG_STRUCT_DATA_TYPE in abcc_drv_cfg.h
+** Note! The example at the end of this file shows how to use this type.
+** Get/Set callbacks are enabled by defining ABCC_CFG_ADI_GET_SET_CALLBACK
+**------------------------------------------------------------------------------
+** 1. iInstance - ADI instance number (1-65535); 0 is reserved for
+** the Class.
+** 2. pabName - Name of each ADI as a character string
+** (ADI instance attribute #1).
+** If NULL, a 0 length name will be returned.
+** 3. bDataType - ADI data type format, which can be one of the
+** following:
+** ABP_BOOL: Boolean.
+** ABP_SINT8: 8-bit signed integer.
+** ABP_SINT16: 16-bit signed integer.
+** ABP_SINT32: 32-bit signed integer.
+** ABP_UINT8: 8-bit unsigned integer.
+** ABP_UINT16: 16-bit unsigned integer.
+** ABP_UINT32: 32-bit unsigned integer.
+** ABP_CHAR: Character.
+** ABP_ENUM: Enumeration.
+** ABP_SINT64: 64-bit signed integer.
+** ABP_UINT64: 64-bit unsigned integer.
+** ABP_FLOAT: floating point value (32-bits).
+** ABP_OCTET: 8 bit data (ABCC40)
+** ABP_BITS8: 8 bit-data type (ABCC40)
+** ABP_BITS16: 16 bit-data type (ABCC40)
+** ABP_BITS32: 32 bit-data type (ABCC40)
+** ABP_BIT1 1 bit-data type (ABCC40)
+** ABP_BIT2 2 bit-data type (ABCC40)
+** :
+** ABP_BIT7 7 bit.data type (ABCC40)
+** ABP_PAD0 0 pad-bit data type (ABCC40)
+** ABP_PAD1 1 pad-bit data type (ABCC40)
+** :
+** ABP_BIT7 16 pad-bit data type (ABCC40)
+**
+** 4. bNumOfElements - For arrays ( psStruct (8) is NULL ):
+** Number of elements of the specified data type ( 3 )
+** - For structured data type ( psStruct (8) != NULL ):
+** Number of elements in the structure
+** 5. bDesc - Ignored for structured data types ( psStruct (8) != NULL )
+** All other data types:
+** Entry descriptor; bits filled with the following
+** configurations:
+** ABP_APPD_DESCR_GET_ACCESS: Get service is
+** allowed on value attribute.
+** ABP_APPD_DESCR_SET_ACCESS: Set service is
+** allowed on value attribute.
+** ABP_APPD_DESCR_MAPPABLE_WRITE_PD: Set if
+** possible to map.
+** ABP_APPD_DESCR_MAPPABLE_READ_PD:Set if
+** possible to map.
+** 6. pxValuePtr - Ignored for structured data type ( psStruct (8) != NULL )
+** All other data types:
+** Pointer to the local value variable.
+** 7. psValueProps - Ignored for structured data type ( psStruct (8) != NULL )
+** All other data types:
+** Pointer to the local value properties struct.
+** If NULL, no properties are applied (max/min/default).
+** 8. psStruct(optional) - Pointer to an AD_StructDataType.
+** Set to NULL for non structured data type. This field is
+** enabled by defining ABCC_CFG_STRUCT_DATA_TYPE.
+** 9. pnGetAdiValue (optional)- Pointer to an ABCC_GetAdiValueFuncType
+** Called when getting ADI value if defined
+**10. pnSetAdiValue (optional)- Pointer to an ABCC_SetAdiValueFuncType
+** Called when setting ADI value if defined
+**
+**------------------------------------------------------------------------------
+** 1. iInstance | 2. pabName | 3. bDataType | 4. bNumOfElements | 5. bDesc |
+** 6. pxValuePtr | 7. pxValuePropPtr | 8. psStruct | 9. pnGetAdiValue | 10. pnSetAdiValue }
+**------------------------------------------------------------------------------
+*/
+typedef struct AD_AdiEntry
+{
+ UINT16 iInstance;
+ char* pacName;
+ UINT8 bDataType;
+ UINT8 bNumOfElements;
+ UINT8 bDesc;
+ uDataType uData;
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ const AD_StructDataType *psStruct;
+#endif
+#if( ABCC_CFG_ADI_GET_SET_CALLBACK )
+ ABCC_GetAdiValueFuncType pnGetAdiValue;
+ ABCC_SetAdiValueFuncType pnSetAdiValue;
+#endif
+} AD_AdiEntryType;
+
+
+
+
+#if 0
+/*******************************************************************************
+** Example of ADI mapping without structured data type support i.e.
+** ABCC_CFG_STRUCT_DATA_TYPE is NOT defined.
+********************************************************************************
+*/
+
+/*
+ ** Example with all access flags set.
+ */
+#define ADI_DESCR_ALL_ACCESS ( ABP_APPD_DESCR_GET_ACCESS | ABP_APPD_DESCR_SET_ACCESS | ABP_APPD_DESCR_MAPPABLE_WRITE_PD | ABP_APPD_DESCR_MAPPABLE_READ_PD )
+
+/*------------------------------------------------------------------------------
+** ADI instance allocation.
+**------------------------------------------------------------------------------------------------------------
+** 1. iInstance | 2. pabName | 3. bDataType | 4. bNumOfElements | 5. bDesc | 6.pxValuePtr | 7. pxValuePropPtr|
+**------------------------------------------------------------------------------------------------------------
+*/
+const AD_AdiEntryType AD_asADIEntryList[] =
+{
+ { 1, "RadOnOff_BOOL8", ABP_BOOL, 1, ADI_DESCR_ALL_ACCESS, &VAPP_fRadOnOff, &VAPP_BOOL8Props_fRadOnOff },
+ { 2, "RadSetpointTemp_FLOAT", ABP_FLOAT, 1, ADI_DESCR_ALL_ACCESS, &VAPP_rRadSetpointTemp, &VAPP_FLOAT32Props_rRadSetpointTemp },
+ { 3, "RadErrCode_ENUM", ABP_ENUM, 1, ADI_DESCR_ALL_ACCESS, &VAPP_eRadErrCode, &VAPP_ENUMProps_RadErrCode },
+ { 4, "Fan_OnOff_BOOL8", ABP_BOOL, 1, ADI_DESCR_ALL_ACCESS, &VAPP_fFanOnOff, &VAPP_BOOL8Props_fRadOnOff },
+ { 5, "FanOpErrCode_ENUM", ABP_ENUM, 1, ADI_DESCR_ALL_ACCESS, &VAPP_eFanErrCode, &VAPP_ENUMProps_FanErrCode },
+ { 6, "ActTemp_FLOAT", ABP_FLOAT, 1, ADI_DESCR_ALL_ACCESS, &VAPP_rActTemp, &VAPP_FLOAT32Props_rRadSetpointTemp },
+ { 500,"ActTempErrCode_ENUM", ABP_ENUM, 1, ADI_DESCR_ALL_ACCESS, &VAPP_eActTempErrCode, &VAPP_ENUMProps_ActTempErrCode },
+ { 501,"InputTemp_FLOAT", ABP_FLOAT, 1, ADI_DESCR_ALL_ACCESS, &VAPP_rInputTemp, NULL },
+ { 502,"HeatEffect_deg/sec_FLOAT",ABP_FLOAT, 1, ADI_DESCR_ALL_ACCESS, &VAPP_rRadHeatPowerPerSec, NULL },
+ { 503,"SystemTripBits_UINT8", ABP_UINT8, 1, ADI_DESCR_ALL_ACCESS, &VAPP_bTripBits, NULL },
+};
+
+
+/*------------------------------------------------------------------------------
+** ADI read/write process data mappings.
+**------------------------------------------------------------------------------
+** Array of mapping elements containing ADI in AD_asADIEntryList
+** in native mapping order and direction of the map.
+** Note! Mapping sequence is terminated by AD_DEFAULT_MAP_ENTRY and
+** MUST be present at end of LIST.
+**------------------------------------------------------------------------------
+*/
+AD_DefaultMapType sDefaultMap[{ 3, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 5, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 6, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 1, PD_READ, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 2, PD_READ, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 500, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 501, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 502, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 4, PD_READ, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { 503, PD_READ, AD_DEFAULT_MAP_ALL_ELEM ,0 },
+ { AD_DEFAULT_MAP_ENTRY } ];
+
+
+/*******************************************************************************
+** Example of ADI mapping structured data type (ABCC_CFG_STRUCT_DATA_TYPE
+** defined in abcc_drv_cfg.h )
+********************************************************************************
+*/
+
+/* -----------------------------------------------------------------------------
+** Variable place holders for the ADI:s
+*------------------------------------------------------------------------------
+*/
+/*
+** The content of struct1 is described by APPL_AdiStruct1 below
+*/
+struct
+{
+ UINT16 iData;
+ UINT32 lData;
+} struct1;
+
+/*
+** The content of struct2 is described by APPL_AdiStruct2 below
+*/
+struct
+{
+ UINT8 bBitData[2];
+ UINT16 iData;
+} struct2;
+
+
+/*
+** Basic 8 bit ADI
+*/
+UINT8 bData;
+
+
+
+/*-----------------------------------------------------------------------------
+** APPL_AdiStruct1 describes a structured ADI with two members. ( struct1 )
+**-----------------------------------------------------------------------------
+*/
+static const AD_StructDataType APPL_AdiStruct1[] =
+{
+
+ /*---------------------------------------------------------------------------------------------
+ | 1. bDataType | 2. iNumSubElem | 3. bDesc | 4. bBitOffset | 5. pxValuePtr | 6. pxValuePropPtr
+ ---------------------------------------------------------------------------------------------- */
+ /* Index: 0 */ { ABP_UINT16, 1, ALL_ACCESS_DESC, 0, { { &struct1.iData, NULL } } },
+ /* Index: 1 */ { ABP_SINT32, 1, ALL_ACCESS_DESC, 0, { { &struct1.lData, NULL } } },
+}
+
+
+
+/*------------------------------------------------------------------------------------------------------
+** APPL_AdiStruct2 describes a structured ADI with 4 members (struct2). The structure includes
+** bit data types and padding. The picture below shows the packed ADI result. The numbers are
+** referring to the index in APPL_AdiStruct2.
+**
+**
+** Bit: 7 6 5 4 3 2 1 0
+** ---------------------------------
+** | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | struct2.bBitData[ 0 ]
+** ---------------------------------
+** ---------------------------------
+** | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 1 | struct2.bBitData[ 1 ]
+** ---------------------------------
+** ---------------------------------
+** | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | struct2.iData
+** ---------------------------------
+** ---------------------------------
+** | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | struct2.iData
+** ---------------------------------
+**---------------------------------------------------------------------------------------------
+** 1. bDataType | 2. iNumSubElem | 3. bDesc | 4. bBitOffset | 5. pxValuePtr | 6. pxValuePropPtr
+**----------------------------------------------------------------------------------------------
+*/
+static const AD_StructDataType APPL_AdiStruct2[] =
+{
+ /*---------------------------------------------------------------------------------------------
+ | 1. bDataType | 2. iNumSubElem | 3. bDesc | 4. bBitOffset | 5. pxValuePtr | 6. pxValuePropPtr
+ ---------------------------------------------------------------------------------------------- */
+ /* Index: 0 */ { ABP_BIT5, 1, ALL_ACCESS_DESC, 0, { { &struct2.bBitData[ 0 ], NULL } } }, /* First 5 bits in struct2.bBitData[ 0 ] */
+ /* Index: 1 */ { ABP_BIT4, 1, ALL_ACCESS_DESC, 5, { { &struct2.bBitData[ 0 ], NULL } } }, /* 4 bits starting at position 5 in struct2.bBitData[ 0 ] */
+ /* Index: 2 */ { ABP_PAD7, 1, ALL_ACCESS_DESC, 1, { { NULL, NULL } } }, /* 7 bits padding is needed starting at position 1 in struct2.bBitData[ 1 ] */
+ /* Index: 3 */ { ABP_UINT16, 1, ALL_ACCESS_DESC, 0, { { &struct2.iData, NULL } } }, /* 16 bit type must at least be on a 8 bit aligned position */
+}
+
+/*------------------------------------------------------------------------------
+** ADI instance allocation with structured ADI:s. The last member ( 8. psStruct )
+** is referring the structured data types described above.
+** Note that member 3,5,6 and 7 are ignored if psStruct ( 8.) is a valid pointer.
+*/
+const AD_AdiEntryType AD_asADIEntryList[] =
+{
+/*-------------------------------------------------------------------------------------------------------------------------
+ 1. iInstance | 2. pabName | 3. bDataType | 4. bNumOfElements | 5. bDesc | 6.pxValuePtr | 7. pxValuePropPtr | 8. psStruct |
+---------------------------------------------------------------------------------------------------------------------------*/
+ { 10, "Struct1", ABP_BOOL, 2, ADI_DESCR_ALL_ACCESS, NULL, NULL }, APPL_AdiStruct1,
+ { 20, "Struct2", ABP_BOOL, 4, ADI_DESCR_ALL_ACCESS, NULL, NULL }, APPL_AdiStruct2,
+ { 30, "NoStruct", ABP_UINT8, 1, ADI_DESCR_ALL_ACCESS, &bData, NULL }, NULL }
+
+/* -----------------------------------------------------------------------------
+** sDefaultMap is an example of a default map using bit data types, structured
+** ADI:s. and process data padding.
+** The mapping result is shown below.
+**
+** Read mapping where ( OctetOffset + Bitoffset ) is the offset from rdpd buffer start.
+**
+** Octetoffset | Bitoffset | Data type | ADI | Place holder |
+** ---------------------------------------------------------------
+** 0 0 ABP_UINT16 10 struct1 element 0
+** 2 0 ABP_UINT32 10 struct1 element 1
+** 6 0 ABP_BIT4 20 struct2 element 1
+** 6 4 ABP_PAD1x4 0 No implementation
+** 7 0 ABP_UINT8 30 bData
+**
+** Write mapping where ( OctetOffset + Bitoffset ) is the offset from wrpd buffer start.
+**
+** Octetoffset | Bitoffset | Data type | ADI | Place holder |
+** ---------------------------------------------------------------
+** 0 0 ABP_BIT5 20 struct2 element 0
+** 0 5 ABP_BIT4 20 struct2 element 1
+** 1 1 ABP_PAD1x7 0 No implementation
+**
+*/
+
+/*
+ --------------------------------------------------------------
+ | 1. iInstance | 2. eDir | 3. bNumElem | 4. bElemStartIndex |
+ --------------------------------------------------------------*/
+AD_DefaultMapType sDefaultMap[{ 10, PD_READ, AD_DEFAULT_MAP_ALL_ELEM ,0 }, /* ADI 10 is mapped. ( All elements ) */
+ { 20, PD_READ, 1, 1 }, /* ADI 20 element 1 (index) is mapped ( 4 Bits ) */
+ { AD_MAP_PAD_ADI , PD_READ, 4, 0 }, /* PAD process data with 4 bits for correct alignment */
+ { 30, PD_READ, 1, 0 }, /* Map ADI 30 */
+ { 20, PD_WRITE, 2, 0 }, /* ADI 20 element 0 and 1 is mapped ( 9 bits ) */
+ { AD_MAP_PAD_ADI , PD_WRITE, 7, 0 }, /* PAD process data with 7 bits for correct alignment */
+ { AD_DEFAULT_MAP_END } ];
+
+
+
+
+#endif
+
+#endif /* inclusion lock */
+
+/*******************************************************************************
+** End of abcc_ad_if.h
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/inc/abcc_cfg.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,506 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This program is the property of HMS Industrial Networks AB. ** +** It may not be reproduced, distributed, or used without permission ** +** of an authorized company official. ** +******************************************************************************** +******************************************************************************** +** Configuration parameters of the driver. +** +** The following user definitions are used to control and configure the driver. +** These defines shall be specified by the user in abcc_drv_cfg.h. +******************************************************************************** +******************************************************************************** +** Services: +** None +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_CFG_H_ +#define ABCC_CFG_H_ + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_SYS_BIG_ENDIAN +** +** Defined in abcc_td.h. +** +** Define if an big endian system is used as host. If not defined little endian +** is assumed. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_SYS_16_BIT_CHAR +** +** Defined in abcc_td.h. +** +** Define if a 16 bit char system is used as host. If not defined 8 bit char +** system is assumed. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DRV_SPI (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for SPI operating mode. +** Note! Support for multiple operating modes is possible. +** Depending on module id different operating modes can be activated (see +** ABCC_CFG_ABCC_OP_MODE_30 and ABCC_CFG_ABCC_OP_MODE_40 configuration further +** down). Each supported mode increases memory usage. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DRV_PARALLEL (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for parallel event operating mode for both 8 +** and 16 bit mode. +** Note! Support for multiple operating modes is possible. +** Depending on module id different operating modes can be activated (see +** ABCC_CFG_ABCC_OP_MODE_30 and ABCC_CFG_ABCC_OP_MODE_40 configuration further +** down). Each supported mode increases memory usage. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DRV_PARALLEL_30 (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for parallel 8-bit ping-pong operating mode. +** Note! Support for multiple operating modes is possible. +** Depending on module id different operating modes can be activated (see +** ABCC_CFG_ABCC_OP_MODE_30 and ABCC_CFG_ABCC_OP_MODE_40 configuration further +** down). Each supported mode increases memory usage. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DRV_SERIAL (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for serial ping/pong operating mode. +** Note! Support for multiple operating modes is possible. +** Depending on module id different operating modes can be activated (see +** ABCC_CFG_ABCC_OP_MODE_30 and ABCC_CFG_ABCC_OP_MODE_40 configuration further +** down). Each supported mode increases memory usage. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_OP_MODE_GETTABLE (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver to retrieve the operating mode from external hardware. +** If TRUE the ABCC_SYS_GetOpmode() function must be implemented in the system +** adaption layer. +** +** If this is not TRUE ABCC_CFG_ABCC_OP_MODE_X described above must be defined. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_OP_MODE_SETTABLE (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver to control the operating mode set to the ABCC host +** connector. Else it is assumed the operating mode signals of the host +** connector is fixed or controlled by external hardware. +** If TRUE the ABCC_SYS_SetOpmode() function must be implemented in the system +** adaption layer. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_ABCC_OP_MODE_30 +** #define ABCC_CFG_ABCC_OP_MODE_40 +** +** Defined in abcc_drv_cfg.h. +** +** These definitions shall be defined if only one operating mode per module type +** is used. It is only necessary to define the operating mode for the module +** types to be used. If defined it shall be set to any ABP_OP_MODE_X definition +** from abp.h. +** If an operating mode for each module type is set the ABCC_SYS_SetOpmode() +** has to be implemented. +** If none of these definitions are set the ABCC_SYS_GetOpmode() must be +** implemented to retrieve the operating mode from external hardware +** (e.g. DIP switch) and ABCC_SYS_SetOpmode() must be implemented to set the +** operating mode to the host connector. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_SPI_MSG_FRAG_LEN ( 32 ) +** +** Defined in abcc_drv_cfg.h. +** +** Length of SPI message fragment in bytes per SPI transaction. +** If the message fragment length is shorter than the largest message to be +** transmitted the sending or receiving of a message may be fragmented and +** take several SPI transactions to be completed. Each SPI transaction will have +** a message field of this length regardless if a message is present or not. +** If messages are important the fragment length should be set to the largest +** message to avoid fragmentation. If IO data are important the message fragment +** length should be set to a smaller value to speed up the SPI transaction. +** For high message performance a fragment length up to 1524 octets is +** supported. The message header is 12 octets, so 16 or 32 octets will be enough +** to support small messages without fragmentation. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_MEMORY_MAPPED_ACCESS (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for memory mapped ABCC interface. If memory +** direct access is chosen the user will have access directly to the ABCC +** process data memory i.e. no internal copy is required. +** If FALSE the following functions must be implemented in the system adaption +** layer: +** ABCC_SYS_ParallelRead() +** ABCC_SYS_ParallelRead8() +** ABCC_SYS_ParallelRead16() +** ABCC_SYS_ParallelWrite() +** ABCC_SYS_ParallelWrite8() +** ABCC_SYS_ParallelWrite16() +** ABCC_SYS_ParallelGetRdPdBuffer() +** ABCC_SYS_ParallelGetWrPdBuffer() +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_PARALLEL_BASE_ADR ( 0x00000000 ) +** +** Defined in abcc_drv_cfg.h. +** +** Define the base address of the ABCC if a memory mapped interface is used. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_ABCC_MODULE_ID +** +** Defined in abcc_drv_cfg.h. +** +** If the ABCC module detection pins on the host connector are not +** connected ABCC_CFG_ABCC_MODULE_ID must be defined to the correct +** ABCC module id that corresponds to the module ID of the used device. +** If defined it shall be set to any ABP_MODULE_ID_X definition from abp.h. +**----------------------------------------------------------------------------- +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_MOD_DETECT_PINS_CONN (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Set to TRUE if the module detect pins on the ABCC host connector are +** in use. If TRUE the ABCC_SYS_ModuleDetect() function in the system adaption +** layer must be implemented. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_MAX_NUM_APPL_CMDS ( 2 ) +** +** Defined in abcc_drv_cfg.h. +** +** Number of commands that could be sent without receiving a response. +** At least 2 buffers are required by the driver. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_MAX_NUM_ABCC_CMDS ( 2 ) +** +** Defined in abcc_drv_cfg.h. +** +** Number of commands that could be received without sending a response. +** At least 2 buffers are required by the driver. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_MAX_MSG_SIZE ( 255 ) +** +** Defined in abcc_drv_cfg.h. +** +** Size of largest message in bytes that will be used. +** +** Note! ABCC30 supports 255 byte messages and ABCC40 supports 1524 byte +** messages. ABCC_CFG_MAX_MSG_SIZE should be set to largest size that will be +** sent or received. If this size is not known it recommended to set the maximum +** supported size. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_MAX_PROCESS_DATA_SIZE ( 512 ) +** +** Defined in abcc_drv_cfg.h. +** +** Size of max process data in bytes that will be used in either direction. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_SYNC_ENABLE (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for sync. +** If TRUE the ABCC_CbfSyncIsr() must be implemented by the application. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_USE_ABCC_SYNC_SIGNAL (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support to enable and disable sync interrupt using +** the sync signal from the ABCC. +** If TRUE ABCC_SYS_SyncInterruptEnable() and ABCC_SYS_SyncInterruptDisable() +** must be implemented by the application and ABCC_CbfSyncIsr() must be called +** from the sync interrupt handler. +** If FALSE the ABCC interrupt sync event will be used as sync source and +** ABCC_CbfSyncIsr() will be called by the driver. +** The define is only valid if ABCC_CFG_SYNC_ENABLE is TRUE. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_POLL_ABCC_IRQ_PIN (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support to read the status of the interrupt pin. +** This function will enable the driver to use the interrupt pin to check if an +** event has occurred even if the interrupt is disabled. For example the ABCC +** power up event could be detected this way. +** If TRUE the user will be forced to implement the +** ABCC_SYS_IsAbccInterruptActive() function in the system adaption layer. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_INT_ENABLED (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for ABCC interrupt (IRQ_N pin on the host +** connector). If TRUE the user will be forced to implement the following +** functions in the system adaption layer: +** +** ABCC_SYS_AbccInterruptEnable() +** ABCC_SYS_AbccInterruptDisable() +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_INT_ENABLE_MASK_PAR ( ABP_INTMASK_RDPDIEN ) +** +** Defined in abcc_drv_cfg.h. +** +** Defines what ABCC interrupts shall be enabled in parallel operating mode. +** This is a bit mask built up by the ABP_INTMASK_X definitions in abp.h. +** If an event is not notified via the ABCC interrupt it must be polled by +** ABCC_RunDriver(). If not defined in abcc_drv_cfg.h the default mask is 0. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_INT_ENABLE_MASK_SPI ( 0 ) +** +** Defined in abcc_drv_cfg.h. +** +** Defines what ABCC interrupts shall be enabled in SPI operating mode. +** The mask is composed of ABP_INTMASK_X definitions in abp.h. +** If an event is not notified via the ABCC interrupt it must be polled using +** ABCC_RunDriver(). +** If not defined in abcc_drv_cfg.h the default mask is 0. +** +** Note! There are currently no support in the driver to handle interrupt +** driven SPI based on ABCC events. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_HANDLE_INT_IN_ISR_MASK ( ABP_INTMASK_RDPDIEN ) +** +** Defined in abcc_drv_cfg.h. +** +** Defines what interrupt events from the ABCC that should be handled in +** interrupt context. The mask is composed of ABP_INTMASK_X bits. +** Events that are enabled in the interrupt enable mask (ABCC_CFG_INT_ENABLE_MASK_X) +** but not configured to be handled by the ISR will be translated to a bit field +** of ABCC_ISR_EVENT_X definitions and forwarded to the user via the +** ABCC_CbfEvent() callback. +** If not defined in abcc_drv_cfg.h the default value will be: +** Parallel 16/8: 0 (No events handled by the ISR) +** Other operating modes N/A +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_WD_TIMEOUT_MS ( 1000 ) +** +** Defined in abcc_drv_cfg.h. +** +** Timeout for ABCC communication watchdog. +** Note! Currently the watchdog functionality is only supported by SPI-, +** serial- and paralell30 (ping/pong) operating modes. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_REMAP_SUPPORT_ENABLED (BOOL - TRUE/FALSE) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver and AD object support for the re-map command. +** If TRUE the ABCC_CbfRemapDone() needs to be implemented by the application. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_STRUCT_DATA_TYPE (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver and AD object support for structured data data types. +** This define will affect the AD_AdiEntryType (abcc_ad_if.h) used for defining +** the user ADI:s. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_ADI_GET_SET_CALLBACK (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for triggering of callback notifications each +** time an ADI is read or written. This define will affect the AD_AdiEntryType +** (abcc_ad_if.h) used for defining the user ADI:s. +** If an ADI is read by the network the callback is invoked before the action. +** If an ADI is written by the network the callback is invoked after the action. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_64BIT_ADI_SUPPORT +** +** Defined in abcc_drv_cfg.h. +** +** Define if 64 bit data type in the Application Data object shall be supported. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_ERR_REPORTING_ENABLED (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable the error reporting callback function (ABCC_CbfDriverError()) +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DEBUG_EVENT_ENABLED (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for print out of debug events within the +** driver. ABCC_PORT_DebugPrint() (abcc_sw_port.h) will be used to print debug +** information. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DEBUG_ERR_ENABLED (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable printout of debug information when ABCC_CbfDriverError() is +** called such as file name and line number. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_DEBUG_MESSAGING (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable printout of received and sent messages. Related events such as +** buffer allocation and qeueing information is also printed. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_STARTUP_TIME_MS ( 1500 ) +** +** If the ABCC interrupt pin is connected this define will be used as a timeout +** while waiting for the ABCC to become ready for communication. If the +** interrupt pin is not available the define will serve as time to wait before +** starting to communicate with ABCC. If not defined default will be 1500 ms. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_SYNC_MEASUREMENT_IP (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for measurement of input processing time (used +** for SYNC). This define is used during development by activating it and +** compiling special test versions of the product. +** When ABCC_CFG_SYNC_MEASUREMENT_IP is TRUE ABCC_SYS_GpioReset() is +** called at the WRPD interrupt. If running in SPI operating mode it is +** instead called when ABCC_SpiRunDriver() has finished sending data to the +** Anybus. +** When ABCC_CFG_SYNC_MEASUREMENT_IP is TRUE ABCC_GpioSet() needs to be +** called at the Input Capture Point. +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** #define ABCC_CFG_SYNC_MEASUREMENT_OP (BOOL - TRUE/FALSE ) +** +** Defined in abcc_drv_cfg.h. +** +** Enable/disable driver support for measurement of output processing time (used +** for SYNC). This define is used during development by activating it and +** compiling special test versions of the product. +** When ABCC_CFG_SYNC_MEASUREMENT_OP is TRUE ABCC_SYS_GpioSet() is called +** from the RDPDI interrupt. +** When ABCC_CFG_SYNC_MEASUREMENT_OP is TRUE ABCC_GpioReset() needs to be +** called at the Output Valid Point. +**------------------------------------------------------------------------------ +*/ + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/inc/abcc_port.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,362 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** ABCC driver API used by the the application. +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_PORT_DebugPrint() - Prints a string +** ABCC_PORT_UseCritical() - Used if any preparation is needed before +** calling "ABCC_PORT_EnterCritical()". +** ABCC_PORT_EnterCritical() - Disables all interrupts, if they are not +** already disabled. +** ABCC_PORT_ExitCritical() - Restore interrupts to the state they were +** in when "ABCC_PORT_EnterCritical()" was +** called. +** ABCC_PORT_MemCopy() - Copy a number of octets, from the source +** pointer to the destination pointer. +** ABCC_PORT_StrCpyToNative() - Copy native char string to octet string +** ABCC_PORT_StrCpyToPacked() - Copy octetstring to native char* string +** ABCC_PORT_CopyOctets() - Copy octet aligned buffer. +** ABCC_PORT_Copy8() - Copy octet aligned 8 bit data. +** ABCC_PORT_Copy16() - Copy octet aligned 16 bit data. +** ABCC_PORT_Copy32() - Copy octet aligned 32 bit data. +** ABCC_PORT_Copy64() - Copy octet aligned 64 bit data. +** +******************************************************************************** +******************************************************************************** +*/ + +#include "abcc_sw_port.h" + +#ifndef ABCC_PORT_H_ +#define ABCC_PORT_H_ + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Macro is used by driver for debug prints such as events or error debug +** information. If not defined the driver will be silent. +** Note! The compiler need to be C99 compliant to support VA_ARGS in in macro. +**------------------------------------------------------------------------------ +** Arguments: +** args - Formatted string +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_DebugPrint +#define ABCC_PORT_DebugPrint( args ) +#endif + +/*------------------------------------------------------------------------------ +** Copy a number of octets, from the source pointer to the destination pointer. +** This function can be modified to use performance enhancing platform specific +** instructions. The default implementation is memcpy(). +** Note that for a 16 bit char platform this function only supports an even +** number of octets. +**------------------------------------------------------------------------------ +** Arguments: +** pbDest - Pointer to the destination. +** pbSource - Pointer to source data. +** iNbrOfOctets - The number of octets that shall be copied. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_MemCpy +#define ABCC_PORT_MemCpy( pbDest, pbSource, iNbrOfOctets ) \ + #error "ABCC_PORT_MemCpy() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Critical section implementation guidance. +** +** Critical sections are used when there is a risk of resource conflicts or race +** conditions between ABCC interrupt handler context and the application thread. +** +** Three macros are used to implement the critical sections: +** ABCC_PORT_UseCritical() +** ABCC_PORT_EnterCritical() +** ABCC_PORT_ExitCritical() +** +** Depending on the configuration of the driver there are different requirements +** on the critical section implementation. Please choose the most suitable +** implementation from the numbered list below. The first statement that is true +** will choose the requirement. +** +** 1. All three macros need to be implemented if any of the statements below are +** true. +** - Any message handling is done within interrupt context. +** +** Requirements: +** - The implementation must support that a critical section is entered +** from interrupt context. ABCC_PORT_UseCritical() should be used for any +** declarations needed in advance by ABCC_PORT_EnterCritical(). +** - When entering the critical section the required interrupts i.e. +** any interrupt that may lead to driver access, must be disabled. When +** leaving the critical section the interrupt configuration must be +** restored to the previous state. +** +** 2. ABCC_PORT_EnterCritical() and ABCC_PORT_ExitCritical() need to be +** implemented if any of the statements below are true. +** - ABCC_RunTimerSystem() is called from a timer interrupt. +** - The application is accessing the ABCC driver message interface from +** different processes or threads without protecting the message +** interface on a higher level (semaphores or similar). +** +** Requirement: +** - When entering the critical section the required interrupts i.e. any +** interrupt that may lead to driver access, must be disabled. When +** leaving the critical section the interrupts must be enabled again. +** +** 3. If none of the above is true no implementation is required. +** +**------------------------------------------------------------------------------ +*/ + +/*------------------------------------------------------------------------------ +** Please read the general description above about the critical sections +** implementation for implementation guidance. +** +** If any preparation is needed before calling "ABCC_PORT_EnterCritical()" or +** "ABCC_PORT_ExitCritical()" this macro is used to add HW specific necessities. +** This could for example be a local variable to store the current interrupt +** status. +** +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_UseCritical +#define ABCC_PORT_UseCritical() +#endif + +/*------------------------------------------------------------------------------ +** Please read the general description above about the critical sections +** implementation for implementation guidance. +** +** If required the macro temporary disables interrupts +** to avoid conflict. Note that all interrupts that could lead to a driver +** access must be disabled. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_EnterCritical +#define ABCC_PORT_EnterCritical() +#endif + +/*------------------------------------------------------------------------------ +** Please read the general description above about the critical sections +** implementation for implementation guidance. +** +** Restore interrupts to the state when "ABCC_PORT_EnterCritical()" +** was called. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_ExitCritical +#define ABCC_PORT_ExitCritical() +#endif + +/*------------------------------------------------------------------------------ +** Copy a native formatted string to a packed string +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Pointer to the destination. +** iDestOctetOffset - Octet offset to the destination where the copy will +** begin. +** pxSrc - Pointer to source data. +** iNbrOfChars - The number of bytes that shall be copied. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_StrCpyToPacked +#define ABCC_PORT_StrCpyToPacked( pxDest, iDestOctetOffset, pxSrc, iNbrOfChars ) \ + #error "ABCC_PORT_StrCpyToPacked() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Copy a packed string to a native formatted string +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Pointer to the destination. +** pxSrc - Pointer to source data. +** iSrcOctetOffset - Octet offset to the source where the copy will begin. +** iNbrOfChars - The number of bytes that shall be copied. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_StrCpyToNative +#define ABCC_PORT_StrCpyToNative( pxDest, pxSrc, iSrcOctetOffset, iNbrOfChars ) \ + #error "ABCC_PORT_StrCpyToNative() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Copy a number of octets from a source to a destination. +** For a 16 bit char platform octet alignment support (the octet offset is odd) +** need to be considered when porting this macro. +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Base pointer to the destination. +** iDestOctetOffset - Octet offset to the destination where the copy will +** begin. +** pxSrc - Base pointer to source data. +** iSrcOctetOffset - Octet offset to the source where the copy will begin. +** iNumOctets - Number of octets to copy. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_CopyOctets +#define ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset, iNumOctets ) \ + #error "ABCC_PORT_CopyOctets() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Copy 8 bits from a source to a destination. +** For a 16 bit char platform octet alignment support (the octet offset is odd) +** need to be considered when porting this macro. +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Base pointer to the destination. +** iDestOctetOffset - Octet offset to the destination where the copy will +** begin. +** pxSrc - Base pointer to source data. +** iSrcOctetOffset - Octet offset to the source where the copy will begin. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_Copy8 +#define ABCC_PORT_Copy8( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + #error "ABCC_PORT_Copy8() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Copy 16 bits from a source to a destination. +** Octet alignment support (the octet offset is odd) need to be considered +** when porting this macro. +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Base pointer to the destination. +** iDestOctetOffset - Octet offset to the destination where the copy will +** begin. +** pxSrc - Base pointer to source data. +** iSrcOctetOffset - Octet offset to the source where the copy will begin. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ + +#ifndef ABCC_PORT_Copy16 +#define ABCC_PORT_Copy16( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + #error "ABCC_PORT_Copy16() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Copy 32 bits from a source to a destination. +** Octet alignment support (the octet offset is odd) need to be considered +** when porting this macro. +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Base pointer to the destination. +** iDestOctetOffset - Octet offset to the destination where the copy will +** begin. +** pxSrc - Base pointer to source data. +** iSrcOctetOffset - Octet offset to the source where the copy will begin. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_PORT_Copy32 +#define ABCC_PORT_Copy32( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) + #error "ABCC_PORT_Copy32() must be ported in abcc_sw_port.h" +#endif + +/*------------------------------------------------------------------------------ +** Copy 64 bits from a source to a destination. +** Octet alignment support (the octet offset is odd) need to be considered +** when porting this macro. +**------------------------------------------------------------------------------ +** Arguments: +** pxDest - Base pointer to the destination. +** iDestOctetOffset - Octet offset to the destination where the copy will +** begin. +** pxSrc - Base pointer to source data. +** iSrcOctetOffset - Octet offset to the source where the copy will begin. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_64BIT_ADI_SUPPORT ) +#ifndef ABCC_PORT_Copy64 +#define ABCC_PORT_Copy64( pxDest, iDestOctetOffset, pxSrc, iSrcOctetOffset ) \ + #error "ABCC_PORT_Copy64() must be ported in abcc_sw_port.h" +#endif +#endif +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/inc/abcc_sys_adapt.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,336 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Defines system specific interface. +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_SYS_AbccInterruptEnable - Enable interrupts. +** ABCC_SYS_AbccInterruptDisable - Disable interrupts. +** ABCC_SYS_HWReset() - Puts Anybus HW into reset. +** ABCC_SYS_HWReleaseReset - Pulls Anybus HW out of reset. +** ABCC_SYS_IsAbccInterruptActive- Check if interrupt is active. +** ABCC_SYS_ReadModuleId - Read Module Identification pins from the +** ABCC interface. +** ABCC_SYS_SetOpmode - Sets ABCC Operating Mode pins from the +** ABCC interface +** ABCC_SYS_GetOpmode - Reads ABCC Operating Mode from hardware +** ABCC_SYS_ModuleDetect - Detects if a module is present by reading +** the Module Detection pins. +** ABCC_SYS_Init() - Hardware or system dependent +** initialization. +** ABCC_SYS_Close() - Close or free all resources allocated in +** ABCC_SYS_Init +******************************************************************************** +******************************************************************************** +*/ +#ifndef ABCC_SYS_ADAPT +#define ABCC_SYS_ADAPT +#include "abcc_drv_cfg.h" +#include "abcc_td.h" + +/******************************************************************************* +** Defines +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services Definitions +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Enable the ABCC HW interrupt (IRQ_N pin on the application interface) +** This function will be called by the driver when the ABCC interrupt shall be +** enabled. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_INT_ENABLED ) +EXTFUNC void ABCC_SYS_AbccInterruptEnable( void ); +#endif + +/*------------------------------------------------------------------------------ +** Disable ABCC HW interrupt (IRQ_N pin on the application interface) +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_INT_ENABLED ) +EXTFUNC void ABCC_SYS_AbccInterruptDisable( void ); +#endif + +/*------------------------------------------------------------------------------ +** Enable the sync interrupt triggered by the sync pin on the application +** interface (MI0/SYNC). +** This function will be called by the driver when the sync interrupt shall be +** enabled. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_SYNC_ENABLE && ABCC_CFG_USE_ABCC_SYNC_SIGNAL ) +EXTFUNC void ABCC_SYS_SyncInterruptEnable( void ); +#endif + +/*------------------------------------------------------------------------------ +** Disable sync interrupt +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_SYNC_ENABLE && ABCC_CFG_USE_ABCC_SYNC_SIGNAL ) +EXTFUNC void ABCC_SYS_SyncInterruptDisable( void ); +#endif + +/*------------------------------------------------------------------------------ +** Reset ABCC. Set the reset pin on the ABCC interface to low. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_HWReset( void ); + +/*------------------------------------------------------------------------------ +** Release reset of ABCC. Sets the reset pin on the ABCC_ interface to high. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------- +*/ +EXTFUNC void ABCC_SYS_HWReleaseReset( void ); + +/*------------------------------------------------------------------------------ +** This function shall be able to read the interrupt signal from the ABCC. It is +** used to enable polling of interrupts if they should not be enabled. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Returns TRUE if an interrupt is active, otherwise it returns FALSE. +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_POLL_ABCC_IRQ_PIN ) +EXTFUNC BOOL ABCC_SYS_IsAbccInterruptActive( void ); +#endif + +/*------------------------------------------------------------------------------ +** Read Module Identification pins on the host connector. +** If the identification pins are not connected the ABCC_CFG_ABCC_MODULE_ID +** definition must be set in abcc_drv_cfg.h with the correct value +** corresponding to the used device. +** +** Valid return values: +** 00b (0) Active CompactCom 30-series +** 01b (1) Passive CompactCom +** 10b (2) Active CompactCom 40-series +** 11b (3) Customer specific +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** Module identification value +** +**------------------------------------------------------------------------------ +*/ +#ifndef ABCC_CFG_ABCC_MODULE_ID +EXTFUNC UINT8 ABCC_SYS_ReadModuleId( void ); +#endif + +/*------------------------------------------------------------------------------ +** Sets ABCC Operating Mode pins on the ABCC interface. If the operating mode is +** fixed the definition ABCC_CFG_ABCC_OP_MODE_X shall be set to the configured +** operating mode instead of implementing this function. If it is hardware +** configurable ABCC_CFG_OP_MODE_HW_CONF must be defined. +**------------------------------------------------------------------------------ +** Arguments: +** bOpMode - 1 SPI +** - 2 Shift Register ( not supported ) +** - 3-6 Reserved +** - 7 16 bit parallel +** - 8 8 bit parallel +** - 9 Serial 19.2 kbit/s +** - 10 Serial 57.6 kbit/s +** - 11 Serial 115.2 kbit/s +** - 12 Serial 625 kbit/s +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_OP_MODE_SETTABLE ) +EXTFUNC void ABCC_SYS_SetOpmode( UINT8 bOpMode ); +#endif + +/*------------------------------------------------------------------------------ +** Read the configured operating mode to be used from hardware. It could be +** either e.g. a switch or the operating mode pins of the host connector. +** This function needs to be implemented if the operating mode is hardware +** configurable. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** bOpMode - 1 SPI +** - 2 Shift Register ( not supported ) +** - 3-6 Reserved +** - 7 16 bit parallel +** - 8 8 bit parallel +** - 9 Serial 19.2 kbit/s +** - 10 Serial 57.6 kbit/s +** - 11 Serial 115.2 kbit/s +** - 12 Serial 625 kbit/s +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_OP_MODE_GETTABLE ) +EXTFUNC UINT8 ABCC_SYS_GetOpmode( void ); +#endif + +/*------------------------------------------------------------------------------ +** Detects if a module is present by reading the Module Detection pins on the +** ABCC interface. +** If the ABCC Module detection pins are not connected +** ABCC_CFG_MOD_DETECT_PINS_CONN must be defined. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** TRUE - Module is detected. +** FALSE - Module is not detected. +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MOD_DETECT_PINS_CONN ) +EXTFUNC BOOL ABCC_SYS_ModuleDetect( void ); +#endif + +/*------------------------------------------------------------------------------ +** This function is called by the driver from the ABCC_HwInit() interface. +** If there is any hardware or system dependent initialization required +** to be done at the power up initialization it shall be done here. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** TRUE - Initialization succeeded. +** FALSE - Initialization failed. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_SYS_HwInit( void ); + +/*------------------------------------------------------------------------------ +** This function is used to measure sync timings. ABCC_CFG_SYNC_MEASUREMENT_OP +** is used when measuring the output processing time and +** ABCC_CFG_SYNC_MEASUREMENT_IP is used to measure the input processing time. +** It should reset an output signal that can be measured to ascertain +** aforementioned sync times. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if ( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP ) +EXTFUNC void ABCC_SYS_GpioReset( void ); +#endif + +/*------------------------------------------------------------------------------ +** This function is used to measure sync timings. ABCC_CFG_SYNC_MEASUREMENT_OP +** is used when measuring the output processing time and +** ABCC_CFG_SYNC_MEASUREMENT_IP is used to measure the input processing time. +** It should set an output signal that can be measured to ascertain +** aforementioned sync times. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if ( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP ) +EXTFUNC void ABCC_SYS_GpioSet( void ); +#endif + +/*------------------------------------------------------------------------------ +** This function is called by the driver at the beginning ABCC_StartDriver(). +** If there is any hardware specific tasks required to be done every time the +** driver starts it shall be done here. Note that ABCC_StartDriver() will also +** be called during restart of the driver. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** TRUE - Initialization succeeded. +** FALSE - Initialization failed. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_SYS_Init( void ); + +/*------------------------------------------------------------------------------ +** Called from driver at the end of ABCC_ShutDown(). Any hardware specific +** tasks that is required to be done every time the driver is stopped it shall +** be done here. Note that the driver could be started again by calling +** ABCC_StartDriver(). +**------------------------------------------------------------------------------ +** Arguments: +** None +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_Close( void ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/inc/abcc_sys_adapt_par.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,215 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Target dependent interface for parallel 8 / 16 operation mode. +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_SYS_ParallelRead() - Reads an amount of bytes from the +** ABCC +** ABCC_SYS_ParallelRead8() - Reads a byte from the ABCC +** ABCC_SYS_ParallelRead16() - Reads a word from the ABCC +** ABCC_SYS_ParallelWrite() - Writes an amount of bytes +** ABCC_SYS_ParallelWrite8() - Writes a byte to the ABCC +** ABCC_SYS_ParallelWrite16() - Writes a word to the ABCC +** ABCC_SYS_ParallelGetRdPdBuffer() - Get the address to the received read +** process data. +** ABCC_SYS_ParallelGetWrPdBuffer() - Get the address to the write process +** data. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_SYS_ADAPT_PARI_ +#define ABCC_SYS_ADAPT_PARI_ +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abp.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Reads an amount of bytes from the ABCC memory. Implementation is not needed +** for a memory mapped system. +** This function/macro will be used by the driver when reading process data or +** message data from the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Memory offset to start writing to. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** pxData - Pointer to the data to be written. +** iLength - The amount of data to write in octets. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) +EXTFUNC void ABCC_SYS_ParallelRead( UINT16 iMemOffset, void* pxData, UINT16 iLength ); +#endif + +/*------------------------------------------------------------------------------ +** Reads a byte from the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** +** Returns: +** Read UINT8s +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) +EXTFUNC UINT8 ABCC_SYS_ParallelRead8( UINT16 iMemOffset ); +#endif + +/*------------------------------------------------------------------------------ +** Reads a word from the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** +** Returns: +** Read UINT16 +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) +EXTFUNC UINT16 ABCC_SYS_ParallelRead16( UINT16 iMemOffset ); +#endif + +/*------------------------------------------------------------------------------ +** Writes an amount of bytes to the ABCC memory +** This function will be used by the driver when writing process data or message +** data to the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Memory offset to start writing to. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** pxData - Pointer to the data to be written. +** iLength - The amount of data to write in octets. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) +EXTFUNC void ABCC_SYS_ParallelWrite( UINT16 iMemOffset, + void* pxData, + UINT16 iLength ); +#endif + +/*------------------------------------------------------------------------------ +** Writes a byte to the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** pbData - Data to be written to ABCC +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) +EXTFUNC void ABCC_SYS_ParallelWrite8( UINT16 iMemOffset, UINT8 pbData ); +#endif + +/*------------------------------------------------------------------------------ +** Writes a word to the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** iData - Data to be written to ABCC +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) +EXTFUNC void ABCC_SYS_ParallelWrite16( UINT16 iMemOffset, UINT16 iData ); +#endif + +/*------------------------------------------------------------------------------ +** Get the address to the received read process data. +** For a non memory mapped system the system adaption layer need to provide a +** buffer where the read process data can be stored. +**------------------------------------------------------------------------------ +** Argument: +** None +** +** Returns: +** Address to RdPdBuffer. +** +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) + EXTFUNC void* ABCC_SYS_ParallelGetRdPdBuffer( void ); +#endif + +/*------------------------------------------------------------------------------ +** Get the address to store the write process data. +** For a non memory mapped system the system adaption layer need to provide a +** buffer where the write process data can be stored. +** No implementation is needed for a memory mapped system since the macro +** provides the information. +**------------------------------------------------------------------------------ +** Argument: +** None +** +** Returns: +** Address to WrPdBuffer +** +**------------------------------------------------------------------------------ +*/ +#if( !ABCC_CFG_MEMORY_MAPPED_ACCESS ) + EXTFUNC void* ABCC_SYS_ParallelGetWrPdBuffer( void ); +#endif + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/inc/abcc_sys_adapt_ser.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,117 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +** file_description +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_SYS_SerRegDataReceived() - Indicate to driver that RX data is received +** ABCC_SYS_SerSendReceive() - Send TX telegram and prepare RX receive. +** ABCC_SYS_SerRestart() - Restart serial driver +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_SYS_ADAPT_SER_ +#define ABCC_SYS_ADAPT_SER_ +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ +/*------------------------------------------------------------------------------ +** Function pointer type for RX telegram ready callback. +** **------------------------------------------------------------------------------ +*/ +typedef void ( *ABCC_SYS_SerDataReceivedCbfType )( void ); + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services() +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** ABCC_SYS_SerRegDataReceived() +** Registers a callback function that indicates that new data has been received +** on the serial channel. The received data shall be located in the buffer +** provided when ABCC_SYS_SerSendRecieved() was called. +** The data in the buffer is valid until next time ABCC_SYS_SerSendReceive() is +** called. +**------------------------------------------------------------------------------ +** Arguments: +** pnDataReceived: Function to call when RX telegram (pong) is received. +** +** Returns: +** - +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_SerRegDataReceived( ABCC_SYS_SerDataReceivedCbfType pnDataReceived ); + +/*------------------------------------------------------------------------------ +** Send TX telegram and prepare for RX telegram reception. The the RX telegram +** will be stored in the pbRxDataBuffer. +** Note the data pbRxDataBuffer is not valid upon return of this function. When +** valid data RX data is available the callback function registered in +** ABCC_SYS_SerRegDataReceived() will be called. +**------------------------------------------------------------------------------ +** Arguments: +** pxTxDataBuffer Pointer to TX telegram +** pxRxDataBuffer Pointer to RX telegram. +** iTxSize Length of TX telegram +** iRxSize Expected length of RX telegram (in bytes) +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_SerSendReceive( void* pxTxDataBuffer, void* pxRxDataBuffer, + UINT16 iTxSize, UINT16 iRxSize ); + + +/*------------------------------------------------------------------------------ +** ABCC_SYS_SerRestart() +** Restart the serial driver. Typically used when telegram has timed out. +** Flush all buffers and restart communication and start waiting for RX telegram +** with length of latest provided RX telegram length +** (provided in ABCC_SYS_SerSendReceive() +**------------------------------------------------------------------------------ +** Arguments: +** None +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_SerRestart( void ); + + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/inc/abcc_sys_adapt_spi.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,103 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** File Description: +** Defines system specific interface for SPI +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_SYS_SpiRegDataReceived() - MISO received +** ABCC_SYS_SpiSendReceive() - Start transaction +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_SYS_ADAPT_SPI_ +#define ABCC_SYS_ADAPT_SPI_ +#include "abcc_drv_cfg.h" +#include "abcc_td.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Function pointer type for MISO frame ready callback. +** ------------------------------------------------------------------------------ +*/ +typedef void ( *ABCC_SYS_SpiDataReceivedCbfType )( void ); + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services() +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** ABCC_SYS_SpiRegDataReceived() +** As soon as the MISO frame is received by the low level SPI hardware driver, +** this registered function shall be called to indicate to the SPI driver that +** the MISO frame could be processed. +**------------------------------------------------------------------------------ +** Arguments: +** pnDataReceived Function to call when MISO frame is received. +** +** Returns: +** +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_SpiRegDataReceived( ABCC_SYS_SpiDataReceivedCbfType pnDataReceived ); + +/*------------------------------------------------------------------------------ +** ABCC_SYS_SpiSendReceive() +** This function is called by the SPI driver when the MOSI frame shall be sent. +** Two buffers are provided, one with MOSI data frame to be sent and one buffer +** to store the received MISO frame. +** If the callback registered by ABCC_SYS_SpiRegDataReceived() is invoked within +** this function, indicating that the MISO frame is already received ,the MISO +** frame will be processed by the SPI driver on return of this function. +** Otherwise the MISO frame will be processed the next time the driver is polled +** (ABCC_RunDriver() ) after the MISO frame received callback is invoked. +**------------------------------------------------------------------------------ +** Arguments: +** pxSendDataBuffer Pointer to MOSI Buffer to send +** pxReceiveDataBuffer Pointer to MISO Buffer. +** iLength Length of SPI frame ( in bytes ) +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SYS_SpiSendReceive( void* pxSendDataBuffer, void* pxReceiveDataBuffer, UINT16 iLength ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_debug_err.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,120 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** ABCC driver error and debug functions.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_sw_port.h"
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc_debug_err.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+#ifdef ABCC_SYS_16_BIT_CHAR
+#define ABCC_GetMsgCmdField( psMsg ) ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdReserved ) )
+#else
+#define ABCC_GetMsgCmdField( psMsg ) ( (psMsg)->sHeader.bCmd )
+#endif
+
+ABCC_ErrorReporter ErrorReporter;
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+#if ABCC_CFG_DEBUG_MESSAGING
+void ABCC_DebugPrintMsg( char* pcInfo, ABP_MsgType* psMsg )
+{
+ UINT16 i;
+ UINT16 iDataSize;
+ UINT8 bData;
+
+ iDataSize = ABCC_GetMsgDataSize( psMsg );
+
+ ABCC_PORT_DebugPrint( ( "\n%s:\n", pcInfo ) );
+ ABCC_PORT_DebugPrint( ( "[ MsgBuf:0x%08x Size:0x%04x SrcId :0x%02x DestObj:0x%02x\n Inst :0x%04x Cmd :0x%02x CmdExt0:0x%02x CmdExt1:0x%02x ]\n",
+ (UINT32)psMsg,
+ ABCC_GetMsgDataSize( psMsg ),
+ ABCC_GetMsgSourceId( psMsg ),
+ ABCC_GetMsgDestObj( psMsg ),
+ ABCC_GetMsgInstance( psMsg ),
+ ABCC_GetMsgCmdField( psMsg ),
+ ABCC_GetMsgCmdExt0( psMsg ),
+ ABCC_GetMsgCmdExt1( psMsg ) ) );
+
+ ABCC_PORT_DebugPrint( ("[ ") );
+ for( i = 0; i < iDataSize; i++ )
+ {
+ if( ( i % 16 ) == 15 )
+ {
+ ABCC_PORT_DebugPrint( ("\n ") );
+ }
+
+ ABCC_GetMsgData8( psMsg, &bData, i );
+ ABCC_PORT_DebugPrint( ("0x%02x ", bData ) );
+ }
+
+ ABCC_PORT_DebugPrint( ( "]\n\n") );
+}
+
+void ABCC_DebugPrintMsgEvent( char* pcInfo, ABP_MsgType* psMsg )
+{
+ ABCC_PORT_DebugPrint( ( "%s: MsgBuf:0x%08x SrcId:0x%02x\n",
+ pcInfo,(UINT32)psMsg,
+ ABCC_GetMsgSourceId( psMsg ) ) );
+}
+#endif
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_debug_err.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,143 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Common defines error codes and functions for abcc driver and application.
+********************************************************************************
+********************************************************************************
+** Services :
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABCC_COMMON_H_
+#define ABCC_COMMON_H_
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc_sys_adapt.h"
+#include "abcc.h"
+#include "abcc_port.h"
+#include "abcc_handler.h"
+
+typedef void (*ABCC_ErrorReporter)( ABCC_SeverityType eSeverity,
+ ABCC_ErrorCodeType iErrorCode,
+ UINT32 lAddInfo );
+
+void SetErrorReporter( ABCC_ErrorReporter nFunc );
+EXTFUNC ABCC_ErrorReporter ErrorReporter;
+
+/*------------------------------------------------------------------------------
+** Help macros for debugging and error reporting.
+**------------------------------------------------------------------------------
+*/
+
+/*
+** Create constant strings for file and line information.
+*/
+#define STR( x ) #x
+#define XSTR( x ) STR( x )
+#define FileLine "Line nr: " XSTR( __LINE__ ) "\nFile: " __FILE__
+
+/*
+** Error reporting.
+*/
+#if( ABCC_CFG_ERR_REPORTING_ENABLED )
+ #define _ABCC_ERROR( eSeverity, iErrorCode, lAddInfo ) ErrorReporter( eSeverity, iErrorCode, lAddInfo )
+#else
+#define _ABCC_ERROR( eSeverity, iErrorCode, lAddInfo )
+#endif
+
+/*
+** DEBUG Level macros.
+*/
+#if( ABCC_CFG_DEBUG_EVENT_ENABLED )
+#define DEBUG_EVENT( args ) ABCC_PORT_DebugPrint( args )
+#else
+#define DEBUG_EVENT( args )
+#endif
+
+#if( ABCC_CFG_DEBUG_ERR_ENABLED )
+#define DEBUG_ERR( args ) ABCC_PORT_DebugPrint( args )
+#else
+#define DEBUG_ERR( args )
+#endif
+
+
+#define ABCC_ASSERT( x ) if ( !( x ) ){ \
+ DEBUG_ERR( ( FileLine ) ); \
+ _ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_INTERNAL_ERROR, 0 );}
+
+#define ABCC_ASSERT_ERR(x, eSeverity, iErrorCode, lAddInfo ) if (!( x )){ \
+ DEBUG_ERR( ( FileLine ) ); \
+ _ABCC_ERROR( eSeverity, iErrorCode, lAddInfo );}
+
+#define ABCC_ERROR( eSeverity, iErrorCode, lAddInfo ) \
+ DEBUG_ERR( ( FileLine ) ); \
+ _ABCC_ERROR( eSeverity, iErrorCode, lAddInfo ); \
+ ABCC_SetMainStateError()
+
+
+#if ABCC_CFG_DEBUG_MESSAGING
+/*------------------------------------------------------------------------------
+** Prints ABCC message content using ABCC_PORT_DebugPrint().
+** Prints: Message buffer address, message header and message data
+**------------------------------------------------------------------------------
+** Arguments:
+** pcInfo - General information about the debug print.
+** psMsg - ABCC message
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void ABCC_DebugPrintMsg( char* pcInfo, ABP_MsgType* psMsg );
+
+/*------------------------------------------------------------------------------
+** Prints buffer address and source id for an ABCC message.
+**------------------------------------------------------------------------------
+** Arguments:
+** pcInfo - General information about the debug print.
+** psMsg - ABCC message
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void ABCC_DebugPrintMsgEvent( char* pcInfo, ABP_MsgType* psMsg );
+
+#define ABCC_DEBUG_MSG_DATA( pcInfo, psMsg ) ABCC_DebugPrintMsg( ( pcInfo ), ( psMsg ) )
+#define ABCC_DEBUG_MSG_EVENT( pcInfo, psMsg ) ABCC_DebugPrintMsgEvent( ( pcInfo ), ( psMsg ) )
+#define ABCC_DEBUG_MSG_GENERAL( pcInfo ) ABCC_PORT_DebugPrint( pcInfo )
+#else
+#define ABCC_DEBUG_MSG_DATA( pcInfo, psMsg )
+#define ABCC_DEBUG_MSG_EVENT( pcInfo, psMsg )
+#define ABCC_DEBUG_MSG_GENERAL( pcInfo )
+#endif
+
+#endif
+
+/*******************************************************************************
+** End of abcc_common.h
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/abcc_drv_if.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,609 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Defines the generic driver interface implemented by each specific driver. +******************************************************************************** +******************************************************************************** +** Driver services: +** pnABCC_DrvInit() - Initialize driver privates and +** states to default values. +** pnABCC_DrvISR() - Calls in the interrupt context to +** acknowledge received +** interrupts. +** pnABCC_DrvRunDriverTx() - Drives the internal send process +** if applicable +** pnABCC_DrvRunDriverRx() - Drives the internal receive +** process if applicable +** pnABCC_DrvWriteMessage() - Writes a message. +** pnABCC_DrvWriteProcessData() - Writes current process data. +** pnABCC_DrvISReadyForWriteMessage() - Checks if the driver is ready +** to send a new write message. +** pnABCC_DrvISReadyForCmd() - Checks if the Anybus is ready to +** receive a new command message. +** pnABCC_DrvSetNbrOfCmds() - Sets the number of simultaneous +** commands that is supported by +** the application. +** pnABCC_DrvSetAppStatus() - Sets the current application +** status. +** pnABCC_DrvSetPdSize() - Sets the current process data +** size. +** pnABCC_DrvSetMsgReceiverBuffer() - Sets the message receiver buffer. +** pnABCC_DrvSetIntMask() - Set interrupt mask +** pnABCC_DrvGetWrPdBuffer() - Get wrpd buffer +** pnABCC_DrvGetModCap() - Read module capability +** pnABCC_DrvGetLedStatus() - Read led status +** pnABCC_DrvGetIntStatus() - Get current interrupt status +** pnABCC_DrvGetAnybusState() - Get current Anybus state +** pnABCC_DrvReadProcessData() - Get read process data if any. +** pnABCC_DrvReadMessage() - Get read message if any. +** pnABCC_DrvIsSuperviced() - Is the network supervised +******************************************************************************** +******************************************************************************** +*/ + +#ifndef PHY_DRV_IF_H_ +#define PHY_DRV_IF_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abcc_debug_err.h" +#include "abp.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Reads an amount of bytes from the ABCC memory. +** This function/macro will be used by the driver when reading process data or +** message data from the ABCC memory. +** See also the ABCC_SYS_READ_RDPD macro description below. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Memory offset to start writing to. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** pxData - Pointer to the data to be written. +** iLength - The amount of data to write in octets. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_DrvParallelRead( iMemOffset, pxData, iLength ) \ + ABCC_PORT_MemCpy( (pxData), (void*)( ABCC_CFG_PARALLEL_BASE_ADR + (iMemOffset) ), (iLength) ) +#else +#define ABCC_DrvParallelRead( iMemOffset, pxData, iLength ) \ + ABCC_SYS_ParallelRead( iMemOffset, pxData, iLength ) +#endif + +/*------------------------------------------------------------------------------ +** Reads a byte from the ABCC memory. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** +** Returns: +** Read UINT8 +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_DrvRead8( iMemOffset ) \ + *(volatile UINT8*)( ABCC_CFG_PARALLEL_BASE_ADR + ( iMemOffset ) ) +#define ABCC_DrvRead16( iMemOffset ) \ + *(volatile UINT16*)( ABCC_CFG_PARALLEL_BASE_ADR + ( iMemOffset ) ) +#else +#define ABCC_DrvRead8( iMemOffset ) ABCC_SYS_ParallelRead8( iMemOffset ) +#define ABCC_DrvRead16( iMemOffset ) ABCC_SYS_ParallelRead16( iMemOffset ) +#endif + +/*------------------------------------------------------------------------------ +** Writes a word to the ABCC memory. +** In case of a memory mapped system this function does not need not be +** implemented. See ABCC_SYS_WRITE16 macro description below. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** iData - Data to be written to ABCC +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_DrvParallelWrite( iMemOffset, pxData, iLength ) \ + ABCC_PORT_MemCpy( (void*)( ABCC_CFG_PARALLEL_BASE_ADR + (iMemOffset) ), (pxData), (iLength) ) +#else +#define ABCC_DrvParallelWrite( iMemOffset, pxData, iLength ) \ + ABCC_SYS_ParallelWrite( iMemOffset, pxData, iLength ) +#endif + +/*------------------------------------------------------------------------------ +** The driver will use the ABCC_SYS_WRITE8 and ABCC_SYS_WRITE16 macros to +** access the ABCC registers. In case of a memory mapped system, +** MEMORY_MAPPED_ACCESS is defined an direct memory access will be done +** using ABCC_CFG_PARALLEL_BASE_ADR to calculate the absolute address. In case +** of a non memory mapped system the ABCC_SYS_ParallelWrite8/16 will be called. +**------------------------------------------------------------------------------ +** Arguments: +** iMemOffset - Offset from ABCC base address. +** 8 bit char platforms : iMemOffset in octets +** 16 bit char platforms : iMemOffset in 16 bit words +** pbData - Data to be written to ABCC +** +** Returns: +** None +** +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_DrvWrite8( iMemOffset, pbData ) \ + *(volatile UINT8*)( ABCC_CFG_PARALLEL_BASE_ADR + ( iMemOffset ) ) = pbData +#define ABCC_DrvWrite16( iMemOffset, pbData ) \ + *(volatile UINT16*)( ABCC_CFG_PARALLEL_BASE_ADR + ( iMemOffset ) ) = pbData +#else +#define ABCC_DrvWrite8( iMemOffset, pbData ) \ + ABCC_SYS_ParallelWrite8( iMemOffset, pbData ) +#define ABCC_DrvWrite16( iMemOffset, pbData ) \ + ABCC_SYS_ParallelWrite16( iMemOffset, pbData ) +#endif + +/*------------------------------------------------------------------------------ +** Get the address to the received read process data. +** For a non memory mapped system the system adaption layer need to provide a +** buffer where the read process data can be stored. +** No implementation is needed for a memory mapped system since the macro +** provides the information. +**------------------------------------------------------------------------------ +** Argument: +** None +** +** Returns: +** Address to RdPdBuffer. +** +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#if( ABCC_CFG_DRV_PARALLEL_30 ) +#define ABCC_DrvParallelGetRdPdBuffer() \ + (void*)( ABCC_CFG_PARALLEL_BASE_ADR + ABP_RDPDM_ADR_OFFSET ) +#else +#ifdef ABCC_SYS_16_BIT_CHAR +#define ABCC_DrvParallelGetRdPdBuffer() \ + (void*)( ABCC_CFG_PARALLEL_BASE_ADR + ( ABP_RDPD_ADR_OFFSET >> 1 ) ) +#else +#define ABCC_DrvParallelGetRdPdBuffer() \ + (void*)( ABCC_CFG_PARALLEL_BASE_ADR + ABP_RDPD_ADR_OFFSET ) +#endif +#endif +#else +#define ABCC_DrvParallelGetRdPdBuffer() \ + ABCC_SYS_ParallelGetRdPdBuffer() +#endif + +/*------------------------------------------------------------------------------ +** This macro will be used by the driver to read process data. In case of a +** memory mapped system the macro will be empty since the buffer already +** contains the received data. ( See ABCC_SYS_ParallelGetRdPdBuffer ). +** For a non memory mapped system ABCC_SYS_ParallelRead will be called with the +** buffer received from ABCC_SYS_ParallelGetRdPdBuffer() +** The buffer will be valid until the next read process data read is done. +** For ABCC30 ( ABCC_CFG_DRV_PARALLEL_30 defined ) the legacy address offset is +** used. +**------------------------------------------------------------------------------ +** Arguments: +** buffer: Pointer where to store received process data +** size: Size of read process data in octets. +** Returns: +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_DrvReadRdPd( buffer, size ) (void)(buffer); \ + (void)(size) +#else +#if( ABCC_CFG_DRV_PARALLEL_30 ) +#define ABCC_DrvReadRdPd( buffer, size ) \ + ABCC_SYS_ParallelRead( ABP_RDPDM_ADR_OFFSET, buffer, size ) +#else +#define ABCC_DrvReadRdPd( buffer, size ) \ + ABCC_SYS_ParallelRead( ABP_RDPD_ADR_OFFSET, buffer, size ) +#endif +#endif + +/*------------------------------------------------------------------------------ +** Get the address to store the write process data. +** For a non memory mapped system the system adaption layer need to provide a +** buffer where the write process data can be stored. +** No implementation is needed for a memory mapped system since the macro +** provides the information. +**------------------------------------------------------------------------------ +** Argument: +** None +** +** Returns: +** Address to WrPdBuffer +** +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#if( ABCC_CFG_DRV_PARALLEL_30 ) +#define ABCC_DrvParallelGetWrPdBuffer() \ + (void*)( ABCC_CFG_PARALLEL_BASE_ADR + ABP_WRPDM_ADR_OFFSET ) +#else +#ifdef ABCC_SYS_16_BIT_CHAR +#define ABCC_DrvParallelGetWrPdBuffer() \ + (void*)( ABCC_CFG_PARALLEL_BASE_ADR + ( ABP_WRPD_ADR_OFFSET >> 1 ) ) +#else +#define ABCC_DrvParallelGetWrPdBuffer() \ + (void*)( ABCC_CFG_PARALLEL_BASE_ADR + ABP_WRPD_ADR_OFFSET ) +#endif +#endif +#else +#define ABCC_DrvParallelGetWrPdBuffer() ABCC_SYS_ParallelGetWrPdBuffer() +#endif + +/*------------------------------------------------------------------------------ +** This macro will be used by the driver to write process data. In case of a +** memory mapped system the macro will be empty since the buffer already +** contains the written data. ( See ABCC_SYS_ParallelGetWrPdBuffer ). +** For a non memory mapped system ABCC_SYS_ParallelWrite will be called with the +** buffer received from ABCC_SYS_ParallelGetWrPdBuffer(). +** When function has returned new process data can be written to the buffer. +** For ABCC30 ( ABCC_CFG_DRV_PARALLEL_30 defined ) the legacy address offset is +** used. +**------------------------------------------------------------------------------ +** Arguments: +** buffer - Pointer to write process data +** size - Size of write process data in octets. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +#if( ABCC_CFG_MEMORY_MAPPED_ACCESS ) +#define ABCC_DrvWriteWrPd( pxBuffer, iSize ) +#else +#if( ABCC_CFG_DRV_PARALLEL_30 ) +#define ABCC_DrvWriteWrPd( pxBuffer, iSize ) \ + ABCC_SYS_ParallelWrite( ABP_WRPDM_ADR_OFFSET, pxBuffer, iSize ) +#else +#define ABCC_DrvWriteWrPd( pxBuffer, iSize ) \ + ABCC_SYS_ParallelWrite( ABP_WRPD_ADR_OFFSET, pxBuffer, iSize ) +#endif +#endif + +/*------------------------------------------------------------------------------ +** Initializes the driver to default values. +** Must be called before the driver is used. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvInit )( UINT8 bOpmode ); + +/*------------------------------------------------------------------------------ +** Calls in the interrupt context to acknowledge received interrupts.The ISR +** routine will clear all pending interrupts. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Acknowledged interrupts. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ( *pnABCC_DrvISR )( void ); + +/*------------------------------------------------------------------------------ +** Drives the internal send process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvRunDriverTx )( void ); + +/*------------------------------------------------------------------------------ +** Drives the internal receive process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to successfully sent write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ( *pnABCC_DrvRunDriverRx )( void ); + +/*------------------------------------------------------------------------------ +** Writes a message to the driver. +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg - Pointer to message. +** +** Returns: +** True - Message was successfully written and can be deallocated +** immediately. +** False - Message was not yet written and cannot be deallocated. +** The psWriteMsg pointer is owned by the driver until the +** message is written and the pointer is returned in the +** driver execution response. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ( *pnABCC_DrvWriteMessage) ( ABP_MsgType* psWriteMsg ); + +/*------------------------------------------------------------------------------ +** Writes current process data. +** The data is copied before returning from the method. +**------------------------------------------------------------------------------ +** Arguments: +** pbProcessData - Pointer to process data to be sent. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvWriteProcessData )( void* pbProcessData ); + +/*------------------------------------------------------------------------------ +** Checks if the driver is in the correct state for writing process data to the +** anybus +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** True - Driver is in correct state to send WrPd +** False: - Driver is not in correct state to send Wrpd +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ( *pnABCC_DrvISReadyForWrPd )( void ); + +/*------------------------------------------------------------------------------ +** Checks if the driver is ready to send a new write message. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** True - Driver is ready to send a new write message. +** False - Driver is not ready to send a new write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ( *pnABCC_DrvISReadyForWriteMessage )( void ); + +/*------------------------------------------------------------------------------ +** The host application checks if the Anybus is ready to receive a new command +** message. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** True - OK to send new command. +** False - NOK to send new command. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ( *pnABCC_DrvISReadyForCmd )( void ); + + +/*------------------------------------------------------------------------------ +** Sets the number of simultaneous commands that is supported by the +** application. +**------------------------------------------------------------------------------ +** Arguments: +** bNbrOfCmds - Number of commands that the application is ready to receive. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvSetNbrOfCmds )( UINT8 bNbrOfCmds ); + +/*------------------------------------------------------------------------------ +** Sets the current application status. +** Note! This information is not supported by all protocols. +**------------------------------------------------------------------------------ +** Arguments: +** eAppStatus - Current application status. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvSetAppStatus )( ABP_AppStatusType eAppStatus ); + +/*------------------------------------------------------------------------------ +** Sets the current process data size. +**------------------------------------------------------------------------------ +** Arguments: +** iReadPdSize - Size of read process data (bytes) +** iWritePdSize - Size of write process data (bytes) +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvSetPdSize )( const UINT16 iReadPdSize, + const UINT16 iWritePdSize ); + +/*------------------------------------------------------------------------------ +** Sets Interrupt mask according to h_aci.h. +**------------------------------------------------------------------------------ +** Arguments: +** iIntMask - Interrupt mask set according to h_aci.h. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ( *pnABCC_DrvSetIntMask )( const UINT16 iIntMask ); + +/*------------------------------------------------------------------------------ +** Get WrpdBuffer for the user to update. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** Pointer to WrPd buffer. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ( *pnABCC_DrvGetWrPdBuffer )( void ); + +/*------------------------------------------------------------------------------ +** Read module capabillity +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ( *pnABCC_DrvGetModCap )( void ); + +/*------------------------------------------------------------------------------ +** Read module capability +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ( *pnABCC_DrvGetLedStatus )( void ); + +/*------------------------------------------------------------------------------ +** Gets the Anybus interrupt status. The pnABCC_DrvISR() function will clear all +** pending interrupts. This function must be called before pnABCC_DrvISR() or it +** will always return 0. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus interrupt status. +**------------------------------------------------------------------------------ +*/ +/*EXTFUNC UINT16 ( *pnABCC_DrvGetIntStatus )( void );*/ + +/*------------------------------------------------------------------------------ +** Gets the Anybus state. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** The Anybus state +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ( *pnABCC_DrvGetAnybusState )( void ); + +/*------------------------------------------------------------------------------ +** Reads the read process data. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read process data; or NULL if no process data to read +** was available. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ( *pnABCC_DrvReadProcessData )( void ); + +/*------------------------------------------------------------------------------ +** Reads the read message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read message; or NULL if no message is available. +** The pointer, if not NULL, will point to the buffer previously set by +** calling pnABCC_DrvSetMsgReceiverBuffer(). +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ( *pnABCC_DrvReadMessage )( void ); + +/*------------------------------------------------------------------------------ +** Returns supervision bit in status register. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** TRUE: The device is supervised by another network device. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ( *pnABCC_DrvIsSupervised )( void ); + +/*------------------------------------------------------------------------------ +** Returns anybus status register. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** Anybus status register +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ( *pnABCC_DrvGetAnbStatus )( void ); + +#endif /* inclusion lock */ + +/******************************************************************************* +** End of drv_if.h +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_handler.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,1251 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Implementation of operation mode independent parts of the abcc handler.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+#include "abcc_drv_if.h"
+#include "abp.h"
+#include "abcc.h"
+#include "abcc_link.h"
+#include "abcc_mem.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_debug_err.h"
+#include "abcc_handler.h"
+#include "abcc_timer.h"
+#include "abcc_setup.h"
+#include "abcc_port.h"
+
+#if( ABCC_CFG_DRV_SPI )
+#include "spi/abcc_drv_spi_if.h"
+#endif
+#if( ABCC_CFG_DRV_PARALLEL )
+#include "par/abcc_drv_par_if.h"
+#endif
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+#include "par30/abcc_drv_par30_if.h"
+#endif
+#if( ABCC_CFG_DRV_SERIAL )
+#include "serial/abcc_drv_ser_if.h"
+#endif
+
+/*
+** Registerd handler functions
+*/
+EXTFUNC ABCC_ErrorCodeType ABCC_SpiRunDriver( void );
+EXTFUNC void ABCC_SpiISR( void );
+
+EXTFUNC ABCC_ErrorCodeType ABCC_ParRunDriver( void );
+EXTFUNC void ABCC_ParISR( void );
+
+EXTFUNC ABCC_ErrorCodeType ABCC_Par30RunDriver( void );
+EXTFUNC void ABCC_Par30ISR( void );
+
+EXTFUNC ABCC_ErrorCodeType ABCC_SerRunDriver( void );
+EXTFUNC void ABCC_SerISR( void );
+
+
+
+
+/*
+ ** Default USER defines
+ */
+#ifndef ABCC_CFG_STARTUP_TIME_MS
+#define ABCC_CFG_STARTUP_TIME_MS ( 1500 )
+#endif
+
+/********************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*
+** Registered handler functions
+*/
+
+ABCC_ErrorCodeType ( *ABCC_RunDriver )( void );
+void ( *ABCC_ISR )( void );
+void ( *ABCC_TriggerWrPdUpdate )( void );
+
+/*
+** The interrupt mask that has been set to the ABCC at start up.
+*/
+UINT16 ABCC_iInterruptEnableMask;
+
+/*
+** Registerd driver functions
+*/
+
+void ( *pnABCC_DrvInit )( UINT8 bOpmode );
+UINT16 ( *pnABCC_DrvISR )( void );
+void ( *pnABCC_DrvRunDriverTx )( void );
+ABP_MsgType* ( *pnABCC_DrvRunDriverRx )( void );
+BOOL ( *pnABCC_DrvWriteMessage) ( ABP_MsgType* psWriteMsg );
+void ( *pnABCC_DrvWriteProcessData )( void* pbProcessData );
+BOOL ( *pnABCC_DrvISReadyForWrPd )( void );
+BOOL ( *pnABCC_DrvISReadyForWriteMessage )( void );
+BOOL ( *pnABCC_DrvISReadyForCmd )( void );
+void ( *pnABCC_DrvSetNbrOfCmds )( UINT8 bNbrOfCmds );
+void ( *pnABCC_DrvSetAppStatus )( ABP_AppStatusType eAppStatus );
+void ( *pnABCC_DrvSetPdSize )( const UINT16 iReadPdSize, const UINT16 iWritePdSize );
+void ( *pnABCC_DrvSetIntMask )( const UINT16 iIntMask );
+void* ( *pnABCC_DrvGetWrPdBuffer )( void );
+UINT16 ( *pnABCC_DrvGetModCap )( void );
+UINT16 ( *pnABCC_DrvGetLedStatus )( void );
+UINT16 ( *pnABCC_DrvGetIntStatus )( void );
+UINT8 ( *pnABCC_DrvGetAnybusState )( void );
+void* ( *pnABCC_DrvReadProcessData )( void );
+ABP_MsgType* ( *pnABCC_DrvReadMessage )( void );
+BOOL ( *pnABCC_DrvIsSupervised )( void );
+UINT8 ( *pnABCC_DrvGetAnbStatus )( void );
+
+#if( ABCC_CFG_SYNC_MEASUREMENT_IP )
+BOOL fAbccUserSyncMeasurementIp;
+#endif
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static volatile UINT8 abcc_bAnbState = 0xff;
+
+static ABCC_MainStateType abcc_eMainState = ABCC_DRV_INIT;
+
+/*
+** Pointer to WRPD buffer.
+*/
+static void* abcc_pbWrPdBuffer;
+
+/*
+ ** Tmo handler for
+ */
+static ABCC_TimerHandle abcc_TmoHandle;
+
+/*
+ ** Indicate ready for communication
+ */
+static BOOL abcc_fReadyForCommunicationTmo = FALSE;
+static BOOL abcc_fReadyForCommunication = FALSE;
+
+/*
+ ** Current operation mode
+ */
+static UINT8 abcc_bOpmode = 0;
+
+#if( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_PARALLEL_30 || ABCC_CFG_DRV_SERIAL )
+/*
+ ** Flag to indicate that WrPD update shall be done
+ */
+static BOOL abcc_fDoWrPdUpdate = FALSE;
+#endif
+
+/*
+** The Application status register value of the Anybus module
+*/
+static volatile ABP_AppStatusType abcc_eAppStatus = ABP_APPSTAT_NO_ERROR;
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+static void TriggerWrPdUpdateNow( void )
+{
+ if( ABCC_GetMainState() == ABCC_DRV_RUNNING )
+ {
+ /*
+ ** Send new "write process data" to the Anybus-CC.
+ ** The data format of the process data is network specific.
+ ** The application converts the data accordingly.
+ */
+ if( pnABCC_DrvISReadyForWrPd() )
+ {
+ if( ABCC_CbfUpdateWriteProcessData( abcc_pbWrPdBuffer ) )
+ {
+ pnABCC_DrvWriteProcessData( abcc_pbWrPdBuffer );
+#if( ABCC_CFG_SYNC_MEASUREMENT_IP )
+ if( ABCC_GetOpmode() == ABP_OP_MODE_SPI )
+ {
+ fAbccUserSyncMeasurementIp = TRUE;
+ }
+ else
+ {
+ ABCC_SYS_GpioReset();
+ }
+#endif
+ }
+ }
+ }
+}
+
+#if( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_PARALLEL_30 || ABCC_CFG_DRV_SERIAL )
+static void TriggerWrPdUpdateLater( void )
+{
+ abcc_fDoWrPdUpdate = TRUE;
+}
+#endif
+
+static BOOL IsInterruptInUse( void )
+{
+ BOOL fReturn;
+
+ fReturn = FALSE;
+#if( ABCC_CFG_INT_ENABLED )
+ switch( abcc_bOpmode )
+ {
+ case ABP_OP_MODE_16_BIT_PARALLEL:
+ case ABP_OP_MODE_8_BIT_PARALLEL:
+ case ABP_OP_MODE_SPI:
+ fReturn = TRUE;
+ break;
+
+ default:
+ break;
+ }
+
+ return( fReturn );
+#else
+ return( fReturn );
+#endif /* End of #if ABCC_CFG_INT_ENABLED */
+}
+
+static BOOL IsPolledInterruptInUse( void )
+{
+ BOOL fReturn;
+
+ fReturn = FALSE;
+#if( ABCC_CFG_POLL_ABCC_IRQ_PIN )
+ switch( abcc_bOpmode )
+ {
+ case ABP_OP_MODE_16_BIT_PARALLEL:
+ case ABP_OP_MODE_8_BIT_PARALLEL:
+ case ABP_OP_MODE_SPI:
+ fReturn = TRUE;
+ break;
+
+ default:
+
+ break;
+ }
+
+ return( fReturn );
+#else
+ return( fReturn );
+#endif /* End of #if ABCC_CFG_POLL_ABCC_IRQ_PIN */
+}
+
+static void SetReadyForCommunicationTmo( void )
+{
+ abcc_fReadyForCommunicationTmo = TRUE;
+}
+
+/*******************************************************************************
+** Public Service
+********************************************************************************
+*/
+
+#if( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_PARALLEL_30 || ABCC_CFG_DRV_SERIAL )
+void ABCC_CheckWrPdUpdate( void )
+{
+ if( abcc_fDoWrPdUpdate )
+ {
+ abcc_fDoWrPdUpdate = FALSE;
+ TriggerWrPdUpdateNow();
+ }
+}
+#endif
+
+void ABCC_SetReadyForCommunication( void )
+{
+ abcc_fReadyForCommunication = TRUE;
+}
+
+void ABCC_SetMainStateError( void )
+{
+ abcc_eMainState = ABCC_DRV_ERROR;
+}
+
+ABCC_MainStateType ABCC_GetMainState( void )
+{
+ return( abcc_eMainState );
+}
+
+void ABCC_TriggerAnbStatusUpdate( void )
+{
+ UINT8 bAnbState;
+
+ bAnbState = pnABCC_DrvGetAnybusState();
+ if( bAnbState != abcc_bAnbState )
+ {
+ abcc_bAnbState = bAnbState;
+ ABCC_CbfAnbStateChanged( (ABP_AnbStateType)bAnbState );
+ }
+}
+
+void ABCC_TriggerTransmitMessage( void )
+{
+ ABCC_LinkCheckSendMessage();
+}
+
+#if ( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP )
+void ABCC_GpioReset( void )
+{
+ ABCC_SYS_GpioReset();
+}
+#endif
+
+#if ( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP )
+void ABCC_GpioSet( void )
+{
+ ABCC_SYS_GpioSet();
+}
+#endif
+
+ABCC_ErrorCodeType ABCC_HwInit( void )
+{
+ if( !ABCC_SYS_HwInit() )
+ {
+ return( ABCC_EC_HW_INIT_FAILED );
+ }
+ return( ABCC_EC_NO_ERROR );
+}
+
+
+ABCC_ErrorCodeType ABCC_StartDriver( UINT32 lMaxStartupTimeMs )
+{
+ UINT8 bModuleId;
+ UINT8 bOpmode;
+
+ if( lMaxStartupTimeMs == 0 )
+ {
+ lMaxStartupTimeMs = ABCC_CFG_STARTUP_TIME_MS;
+ }
+
+ SetErrorReporter( ABCC_CbfDriverError );
+
+ bModuleId = ABCC_ReadModuleId();
+
+#if( ABCC_CFG_DRV_SERIAL || ABCC_CFG_DRV_PARALLEL_30 )
+ if( ( bModuleId != ABP_MODULE_ID_ACTIVE_ABCC40 ) && ( bModuleId != ABP_MODULE_ID_ACTIVE_ABCC30 ) )
+#elif( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_PARALLEL )
+ if( bModuleId != ABP_MODULE_ID_ACTIVE_ABCC40 )
+#endif
+ {
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_MODULE_ID_NOT_SUPPORTED, (UINT32)bModuleId );
+
+ return( ABCC_EC_MODULE_ID_NOT_SUPPORTED );
+ }
+
+ bOpmode = ABCC_GetOpmode();
+ abcc_bOpmode = bOpmode;
+
+ switch( bOpmode )
+ {
+#if( ABCC_CFG_DRV_SERIAL )
+ case ABP_OP_MODE_SERIAL_19_2:
+ case ABP_OP_MODE_SERIAL_57_6:
+ case ABP_OP_MODE_SERIAL_115_2:
+ case ABP_OP_MODE_SERIAL_625:
+
+ ABCC_ISR = NULL;
+ ABCC_RunDriver = &ABCC_SerRunDriver;
+ ABCC_TriggerWrPdUpdate = &TriggerWrPdUpdateLater;
+
+ pnABCC_DrvInit = &ABCC_DrvSerInit;
+ pnABCC_DrvISR = &ABCC_DrvSerISR;
+ pnABCC_DrvRunDriverTx = &ABCC_DrvSerRunDriverTx;
+ pnABCC_DrvRunDriverRx = &ABCC_DrvSerRunDriverRx;
+ pnABCC_DrvWriteMessage = &ABCC_DrvSerWriteMessage;
+ pnABCC_DrvWriteProcessData = &ABCC_DrvSerWriteProcessData;
+ pnABCC_DrvISReadyForWrPd = &ABCC_DrvSerIsReadyForWrPd;
+ pnABCC_DrvISReadyForWriteMessage = &ABCC_DrvSerIsReadyForWriteMessage;
+ pnABCC_DrvISReadyForCmd = &ABCC_DrvSerIsReadyForCmd;
+ pnABCC_DrvSetNbrOfCmds = &ABCC_DrvSerSetNbrOfCmds;
+ pnABCC_DrvSetAppStatus = &ABCC_DrvSerSetAppStatus;
+ pnABCC_DrvSetPdSize = &ABCC_DrvSerSetPdSize;
+ pnABCC_DrvSetIntMask = &ABCC_DrvSerSetIntMask;
+ pnABCC_DrvGetWrPdBuffer = &ABCC_DrvSerGetWrPdBuffer;
+ pnABCC_DrvGetModCap = &ABCC_DrvSerGetModCap;
+ pnABCC_DrvGetLedStatus = &ABCC_DrvSerGetLedStatus;
+ pnABCC_DrvGetIntStatus = &ABCC_DrvSerGetIntStatus;
+ pnABCC_DrvGetAnybusState = &ABCC_DrvSerGetAnybusState;
+ pnABCC_DrvReadProcessData = &ABCC_DrvSerReadProcessData;
+ pnABCC_DrvReadMessage = &ABCC_DrvSerReadMessage;
+ pnABCC_DrvIsSupervised = &ABCC_DrvSerIsSupervised;
+ pnABCC_DrvGetAnbStatus = &ABCC_DrvSerGetAnbStatus;
+
+ ABCC_iInterruptEnableMask = 0;
+
+ break;
+#endif /* End of #if ABCC_CFG_DRV_SERIAL */
+#if( ABCC_CFG_DRV_SPI )
+ case ABP_OP_MODE_SPI:
+
+ if( bModuleId == ABP_MODULE_ID_ACTIVE_ABCC40 )
+ {
+ ABCC_ISR = &ABCC_SpiISR;
+ ABCC_RunDriver = &ABCC_SpiRunDriver;
+ ABCC_TriggerWrPdUpdate = &TriggerWrPdUpdateLater;
+
+ pnABCC_DrvInit = &ABCC_DrvSpiInit;
+ pnABCC_DrvISR = NULL;
+ pnABCC_DrvRunDriverTx = &ABCC_DrvSpiRunDriverTx;
+ pnABCC_DrvRunDriverRx = &ABCC_DrvSpiRunDriverRx;
+ pnABCC_DrvWriteMessage = &ABCC_DrvSpiWriteMessage;
+ pnABCC_DrvWriteProcessData = &ABCC_DrvSpiWriteProcessData;
+ pnABCC_DrvISReadyForWrPd = &ABCC_DrvSpiIsReadyForWrPd;
+ pnABCC_DrvISReadyForWriteMessage = &ABCC_DrvSpiIsReadyForWriteMessage;
+ pnABCC_DrvISReadyForCmd = &ABCC_DrvSpiIsReadyForCmd;
+ pnABCC_DrvSetNbrOfCmds = &ABCC_DrvSpiSetNbrOfCmds;
+ pnABCC_DrvSetAppStatus = &ABCC_DrvSpiSetAppStatus;
+ pnABCC_DrvSetPdSize = &ABCC_DrvSpiSetPdSize;
+ pnABCC_DrvSetIntMask = &ABCC_DrvSpiSetIntMask;
+ pnABCC_DrvGetWrPdBuffer = &ABCC_DrvSpiGetWrPdBuffer;
+ pnABCC_DrvGetModCap = &ABCC_DrvSpiGetModCap;
+ pnABCC_DrvGetLedStatus = &ABCC_DrvSpiGetLedStatus;
+ pnABCC_DrvGetIntStatus = &ABCC_DrvSpiGetIntStatus;
+ pnABCC_DrvGetAnybusState = &ABCC_DrvSpiGetAnybusState;
+ pnABCC_DrvReadProcessData = &ABCC_DrvSpiReadProcessData;
+ pnABCC_DrvReadMessage = &ABCC_DrvSpiReadMessage;
+ pnABCC_DrvIsSupervised = &ABCC_DrvSpiIsSupervised;
+ pnABCC_DrvGetAnbStatus = &ABCC_DrvSpiGetAnbStatus;
+
+ ABCC_iInterruptEnableMask = ABCC_CFG_INT_ENABLE_MASK_SPI;
+ }
+ else
+ {
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+ }
+
+ break;
+#endif /* End of #if ABCC_CFG_DRV_SPI */
+#if( ABCC_CFG_DRV_PARALLEL || ABCC_CFG_DRV_PARALLEL_30 )
+ case ABP_OP_MODE_8_BIT_PARALLEL:
+#if( ABCC_CFG_DRV_PARALLEL )
+ if( bModuleId == ABP_MODULE_ID_ACTIVE_ABCC30 )
+#endif /* End of #if ABCC_CFG_DRV_PARALLEL */
+ {
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+ ABCC_ISR = &ABCC_Par30ISR;
+ ABCC_RunDriver = &ABCC_Par30RunDriver;
+ ABCC_TriggerWrPdUpdate = &TriggerWrPdUpdateLater;
+
+ pnABCC_DrvInit = &ABCC_DrvPar30Init;
+ pnABCC_DrvISR = &ABCC_DrvPar30ISR;
+ pnABCC_DrvRunDriverTx = &ABCC_DrvPar30RunDriverTx;;
+ pnABCC_DrvRunDriverRx = &ABCC_DrvPar30RunDriverRx;
+ pnABCC_DrvWriteMessage = &ABCC_DrvPar30WriteMessage;
+ pnABCC_DrvWriteProcessData = &ABCC_DrvPar30WriteProcessData;
+ pnABCC_DrvISReadyForWrPd = &ABCC_DrvPar30IsReadyForWrPd;
+ pnABCC_DrvISReadyForWriteMessage = &ABCC_DrvPar30IsReadyForWriteMessage;
+ pnABCC_DrvISReadyForCmd = &ABCC_DrvPar30IsReadyForCmd;
+ pnABCC_DrvSetNbrOfCmds = &ABCC_DrvPar30SetNbrOfCmds;
+ pnABCC_DrvSetAppStatus = &ABCC_DrvPar30SetAppStatus;
+ pnABCC_DrvSetPdSize = &ABCC_DrvPar30SetPdSize;
+ pnABCC_DrvSetIntMask = &ABCC_DrvPar30SetIntMask;
+ pnABCC_DrvGetWrPdBuffer = &ABCC_DrvPar30GetWrPdBuffer;
+ pnABCC_DrvGetModCap = &ABCC_DrvPar30GetModCap;
+ pnABCC_DrvGetLedStatus = &ABCC_DrvPar30GetLedStatus;
+ pnABCC_DrvGetIntStatus = &ABCC_DrvPar30GetIntStatus;
+ pnABCC_DrvGetAnybusState = &ABCC_DrvPar30GetAnybusState;
+ pnABCC_DrvReadProcessData = &ABCC_DrvPar30ReadProcessData;
+ pnABCC_DrvReadMessage = &ABCC_DrvPar30ReadMessage;
+ pnABCC_DrvIsSupervised = &ABCC_DrvPar30IsSupervised;
+ pnABCC_DrvGetAnbStatus = &ABCC_DrvPar30GetAnbStatus;
+
+ ABCC_iInterruptEnableMask = ABCC_CFG_INT_ENABLE_MASK_PAR30;
+#else
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+#endif /* End of #if ABCC_CFG_DRV_PARALLEL_30 */
+ break;
+ }
+
+ /*
+ ** If event driven parallel operating mode is enabled and an ABCC 40
+ ** module is mounted fall through to the 16-bit parallel operating mode
+ ** case which sets up the event driven parallel operating mode.
+ */
+#endif /* End of #if ABCC_CFG_DRV_PARALLEL or ABCC_CFG_DRV_PARALLEL_30 */
+#if( ABCC_CFG_DRV_PARALLEL )
+ case ABP_OP_MODE_16_BIT_PARALLEL:
+
+ if( bModuleId == ABP_MODULE_ID_ACTIVE_ABCC30 )
+ {
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+
+ break;
+ }
+
+ ABCC_ISR = &ABCC_ParISR;
+ ABCC_RunDriver = &ABCC_ParRunDriver;
+ ABCC_TriggerWrPdUpdate = &TriggerWrPdUpdateNow;
+
+ pnABCC_DrvInit = &ABCC_DrvParInit;
+ pnABCC_DrvISR = &ABCC_DrvParISR;
+ pnABCC_DrvRunDriverTx = NULL;
+ pnABCC_DrvRunDriverRx = &ABCC_DrvParRunDriverRx;
+ pnABCC_DrvWriteMessage = &ABCC_DrvParWriteMessage;
+ pnABCC_DrvWriteProcessData = &ABCC_DrvParWriteProcessData;
+ pnABCC_DrvISReadyForWrPd = &ABCC_DrvParIsReadyForWrPd;
+ pnABCC_DrvISReadyForWriteMessage = &ABCC_DrvParIsReadyForWriteMessage;
+ pnABCC_DrvISReadyForCmd = &ABCC_DrvParIsReadyForCmd;
+ pnABCC_DrvSetNbrOfCmds = &ABCC_DrvParSetNbrOfCmds;
+ pnABCC_DrvSetAppStatus = &ABCC_DrvParSetAppStatus;
+ pnABCC_DrvSetPdSize = &ABCC_DrvParSetPdSize;
+ pnABCC_DrvSetIntMask = &ABCC_DrvParSetIntMask;
+ pnABCC_DrvGetWrPdBuffer = &ABCC_DrvParGetWrPdBuffer;
+ pnABCC_DrvGetModCap = &ABCC_DrvParGetModCap;
+ pnABCC_DrvGetLedStatus = &ABCC_DrvParGetLedStatus;
+ pnABCC_DrvGetIntStatus = &ABCC_DrvParGetIntStatus;
+ pnABCC_DrvGetAnybusState = &ABCC_DrvParGetAnybusState;
+ pnABCC_DrvReadProcessData = &ABCC_DrvParReadProcessData;
+ pnABCC_DrvReadMessage = &ABCC_DrvParReadMessage;
+ pnABCC_DrvIsSupervised = &ABCC_DrvParIsSupervised;
+ pnABCC_DrvGetAnbStatus = &ABCC_DrvParGetAnbStatus;
+
+#if ABCC_CFG_INT_ENABLED
+ ABCC_iInterruptEnableMask = ABCC_CFG_INT_ENABLE_MASK_PAR;
+
+#if ABCC_CFG_SYNC_ENABLE && !ABCC_CFG_USE_ABCC_SYNC_SIGNAL
+ ABCC_iInterruptEnableMask |= ABP_INTMASK_SYNCIEN;
+#endif
+#else
+ ABCC_iInterruptEnableMask = 0;
+#endif
+
+ break;
+#endif /* End of #if ABCC_CFG_DRV_PARALLEL */
+ default:
+
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+
+ return( ABCC_EC_INCORRECT_OPERATING_MODE );
+ }
+
+ if ( !( ( abcc_eMainState == ABCC_DRV_INIT ) ||
+ ( abcc_eMainState == ABCC_DRV_SHUTDOWN ) ) )
+ {
+ ABCC_ERROR(ABCC_SEV_FATAL, ABCC_EC_INCORRECT_STATE, (UINT32)abcc_eMainState );
+ abcc_eMainState = ABCC_DRV_ERROR;
+
+ return( ABCC_EC_INCORRECT_STATE );
+ }
+
+ if ( !ABCC_SYS_Init() )
+ {
+ return( ABCC_EC_INTERNAL_ERROR );
+ }
+
+ ABCC_TimerInit();
+ pnABCC_DrvInit( bOpmode );
+
+ ABCC_LinkInit();
+ ABCC_SetupInit();
+
+ abcc_bAnbState = 0xff;
+
+ abcc_TmoHandle = ABCC_TimerCreate( SetReadyForCommunicationTmo );
+
+ abcc_pbWrPdBuffer = pnABCC_DrvGetWrPdBuffer();
+
+ if( !ABCC_ModuleDetect() )
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_MODULE_NOT_DECTECTED, 0);
+
+ return( ABCC_EC_MODULE_NOT_DECTECTED );
+ }
+
+#if( ABCC_CFG_OP_MODE_SETTABLE )
+ ABCC_SYS_SetOpmode( bOpmode );
+#endif
+
+ abcc_fReadyForCommunicationTmo = FALSE;
+ abcc_fReadyForCommunication = FALSE;
+
+#if( ABCC_CFG_SYNC_ENABLE && ABCC_CFG_USE_ABCC_SYNC_SIGNAL )
+ ABCC_SYS_SyncInterruptEnable();
+#endif
+
+#if( ABCC_CFG_INT_ENABLED )
+ if( IsInterruptInUse() )
+ {
+ ABCC_SYS_AbccInterruptEnable();
+ }
+#endif /* End of #if ABCC_CFG_INT_ENABLED */
+
+ abcc_eMainState = ABCC_DRV_WAIT_COMMUNICATION_RDY;
+
+ ABCC_TimerStart( abcc_TmoHandle, lMaxStartupTimeMs );
+
+ return( ABCC_EC_NO_ERROR );
+}
+
+ABCC_CommunicationStateType ABCC_isReadyForCommunication( void )
+{
+ if( abcc_eMainState > ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ return( ABCC_READY_FOR_COMMUNICATION );
+ }
+
+ if( abcc_eMainState < ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ return( ABCC_NOT_READY_FOR_COMMUNICATION );
+ }
+
+ if( abcc_fReadyForCommunicationTmo == TRUE )
+ {
+ if( IsInterruptInUse() || IsPolledInterruptInUse() )
+ {
+ return( ABCC_COMMUNICATION_ERROR );
+ }
+ else
+ {
+ abcc_fReadyForCommunication = TRUE;
+ }
+ }
+
+#if( !ABCC_CFG_INT_ENABLED ) && ( ABCC_CFG_POLL_ABCC_IRQ_PIN )
+ if( IsPolledInterruptInUse() )
+ {
+ abcc_fReadyForCommunication = ABCC_SYS_IsAbccInterruptActive();
+ }
+#endif
+
+ if( abcc_fReadyForCommunication == TRUE )
+ {
+ pnABCC_DrvSetIntMask( ABCC_iInterruptEnableMask );
+ abcc_eMainState = ABCC_DRV_SETUP;
+ pnABCC_DrvSetNbrOfCmds( ABCC_CFG_MAX_NUM_APPL_CMDS );
+
+ ABCC_SetupCommands();
+ return( ABCC_READY_FOR_COMMUNICATION );
+ }
+
+ return( ABCC_NOT_READY_FOR_COMMUNICATION );
+}
+
+
+void ABCC_NewWrPdEvent( void )
+{
+ if( ABCC_GetMainState() == ABCC_DRV_RUNNING )
+ {
+ /*
+ ** Send new "write process data" to the Anybus-CC.
+ ** The data format of the process data is network specific.
+ ** The application converts the data accordingly.
+ */
+ if ( pnABCC_DrvISReadyForWrPd() )
+ {
+ if( ABCC_CbfUpdateWriteProcessData( abcc_pbWrPdBuffer ) )
+ {
+ pnABCC_DrvWriteProcessData( abcc_pbWrPdBuffer );
+#if( ABCC_CFG_SYNC_MEASUREMENT_IP )
+ if( ABCC_GetOpmode() == ABP_OP_MODE_SPI )
+ {
+ fAbccUserSyncMeasurementIp = TRUE;
+ }
+ else
+ {
+ ABCC_SYS_GpioReset();
+ }
+#endif
+ }
+ }
+ }
+}
+
+
+
+void ABCC_TriggerRdPdUpdate( void )
+{
+ void* bpRdPd;
+
+#if( ABCC_CFG_SYNC_MEASUREMENT_OP )
+ ABCC_SYS_GpioSet();
+#endif
+
+ bpRdPd = pnABCC_DrvReadProcessData();
+
+ if( bpRdPd )
+ {
+ if( pnABCC_DrvGetAnybusState() == ABP_ANB_STATE_PROCESS_ACTIVE )
+ {
+ /*
+ ** The "read process data" is only valid in the PROCESS_ACTIVE state.
+ ** Retrieve the new "read process data" from the Anybus-CC.
+ ** The data format of the process data is network specific.
+ ** Convert it to our native format.
+ */
+ ABCC_CbfNewReadPd( bpRdPd );
+ }
+ }
+
+#if( ABCC_CFG_SYNC_MEASUREMENT_OP )
+ /*
+ ** This is the Output Valid point (for OuputValidTime = 0). The
+ ** applications has received data and handled it. Thus we reset the
+ ** ABCC_CFG_SYNC_MEASUREMENT_OP measurement.
+ */
+ ABCC_SYS_GpioReset();
+#endif
+}
+
+void ABCC_TriggerReceiveMessage ( void )
+{
+ ABCC_MsgType sRdMsg;
+ ABCC_MemBufferStatusType eBufferStatus;
+
+ sRdMsg.psMsg = ABCC_LinkReadMessage();
+
+ if( sRdMsg.psMsg == NULL )
+ {
+ return;
+ }
+
+ ABCC_DEBUG_MSG_DATA( "Msg received", sRdMsg.psMsg );
+
+ eBufferStatus = ABCC_MemGetBufferStatus( sRdMsg.psMsg );
+
+ /*
+ ** A new message is available.
+ */
+ if( ABCC_GetLowAddrOct( sRdMsg.psMsg16->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT )
+ {
+ /*
+ ** The message is a command, let the application respond.
+ */
+ ABCC_CbfReceiveMsg( sRdMsg.psMsg );
+ }
+ else
+ {
+ if( abcc_eMainState == ABCC_DRV_SETUP )
+ {
+ /*
+ ** The message is a reponse to a setup command we have sent.
+ */
+ ABCC_DEBUG_MSG_EVENT( "Routing response to setup state machine",
+ sRdMsg.psMsg );
+ ABCC_SetupResponses( sRdMsg.psMsg );
+
+ if ( ABCC_SetupCommands() )
+ {
+ abcc_eMainState = ABCC_DRV_RUNNING;
+ }
+ }
+ else
+ {
+ ABCC_MsgHandlerFuncType pnMsgHandler = 0;
+ pnMsgHandler = ABCC_LinkGetMsgHandler( ABCC_GetLowAddrOct( sRdMsg.psMsg16->sHeader.iSourceIdDestObj ) );
+
+ if( pnMsgHandler )
+ {
+ ABCC_DEBUG_MSG_EVENT( "Routing response to registered response handler", sRdMsg.psMsg );
+ pnMsgHandler( sRdMsg.psMsg );
+ }
+ else
+ {
+ ABCC_DEBUG_MSG_EVENT( "No response handler found", sRdMsg.psMsg );
+ ABCC_CbfReceiveMsg( sRdMsg.psMsg );
+ }
+ }
+ }
+
+ if( ABCC_MemGetBufferStatus( sRdMsg.psMsg ) == eBufferStatus )
+ {
+ /*
+ ** The status has not been changed while the user processed the response
+ ** message. Then this buffer shall be freed by the driver.
+ */
+ ABCC_ReturnMsgBuffer( &sRdMsg.psMsg );
+ }
+}
+
+ABCC_ErrorCodeType ABCC_SendCmdMsg( ABP_MsgType* psCmdMsg, ABCC_MsgHandlerFuncType pnMsgHandler )
+{
+ ABCC_ErrorCodeType eResult;
+ ABCC_MsgType sMsg;
+
+ sMsg.psMsg = psCmdMsg;
+
+ /*
+ ** Register function to handle response.
+ ** Must be done before sending the message to avoid race condition.
+ */
+ if( ABCC_LinkMapMsgHandler( ABCC_GetLowAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj ),
+ pnMsgHandler ) == ABCC_EC_NO_ERROR )
+ {
+ eResult = ABCC_LinkWriteMessage( sMsg.psMsg );
+ if( eResult != ABCC_EC_NO_ERROR )
+ {
+ /*
+ ** Free message handler resource
+ */
+ (void)ABCC_LinkGetMsgHandler( ABCC_GetLowAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj ) );
+ }
+ }
+ else
+ {
+ eResult = ABCC_EC_NO_RESOURCES;
+
+ /*
+ ** Report error
+ */
+ ABCC_ASSERT( FALSE );
+ }
+
+ return( eResult );
+}
+
+UINT16 ABCC_GetCmdQueueSize( void )
+{
+ return( ABCC_LinkGetNumCmdQueueEntries() );
+}
+
+
+ABCC_ErrorCodeType ABCC_SendRespMsg( ABP_MsgType* psMsgResp )
+{
+ return( ABCC_LinkWriteMessage( psMsgResp ) );
+}
+
+ABP_MsgType* ABCC_GetCmdMsgBuffer( void )
+{
+ if( ABCC_GetCmdQueueSize() == 0 )
+ {
+ return( NULL );
+ }
+ return( ABCC_MemAlloc() );
+}
+
+ABCC_ErrorCodeType ABCC_ReturnMsgBuffer( ABP_MsgType** ppsBuffer )
+{
+ ABCC_LinkFree( ppsBuffer );
+
+ return( ABCC_EC_NO_ERROR );
+}
+
+void ABCC_TakeMsgBufferOwnership( ABP_MsgType* psMsg )
+{
+ ABCC_MemSetBufferStatus( psMsg, ABCC_MEM_BUFSTAT_OWNED );
+}
+
+void ABCC_SetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize )
+{
+ DEBUG_EVENT( ( "New process data sizes RdPd %d WrPd %d\n", iReadPdSize, iWritePdSize ) );
+ pnABCC_DrvSetPdSize( iReadPdSize, iWritePdSize );
+}
+
+
+void ABCC_HWReset( void )
+{
+ DEBUG_EVENT( ( "HW Reset\n" ) );
+ ABCC_ShutdownDriver();
+ ABCC_SYS_HWReset();
+}
+
+
+void ABCC_ShutdownDriver( void )
+{
+ DEBUG_EVENT( ( " Enter Shutdown state\n" ) );
+
+#if( ABCC_CFG_SYNC_ENABLE && ABCC_CFG_USE_ABCC_SYNC_SIGNAL )
+ ABCC_SYS_SyncInterruptDisable();
+#endif
+
+#if( ABCC_CFG_INT_ENABLED )
+ ABCC_SYS_AbccInterruptDisable();
+#endif
+ ABCC_SYS_Close();
+ ABCC_TimerDisable();
+ abcc_eMainState = ABCC_DRV_SHUTDOWN;
+}
+
+
+BOOL ABCC_ModuleDetect( void )
+{
+#if( ABCC_CFG_MOD_DETECT_PINS_CONN )
+ return( ABCC_SYS_ModuleDetect() );
+#else
+ return( TRUE );
+#endif
+}
+
+UINT16 ABCC_ModCap( void )
+{
+ return( pnABCC_DrvGetModCap() );
+}
+
+UINT16 ABCC_LedStatus()
+{
+ return( pnABCC_DrvGetLedStatus() );
+}
+
+UINT8 ABCC_AnbState( void )
+{
+ return( pnABCC_DrvGetAnybusState() );
+}
+
+BOOL ABCC_IsSupervised( void )
+{
+ return( pnABCC_DrvIsSupervised() );
+}
+
+void ABCC_HWReleaseReset( void )
+{
+ ABCC_SYS_HWReleaseReset();
+}
+
+ABP_AppStatusType ABCC_GetAppStatus( void )
+{
+ return( abcc_eAppStatus );
+}
+
+void ABCC_SetAppStatus( ABP_AppStatusType eAppStatus )
+{
+ if( abcc_eAppStatus != eAppStatus )
+ {
+ abcc_eAppStatus = eAppStatus;
+ pnABCC_DrvSetAppStatus( eAppStatus );
+ }
+}
+
+UINT8 ABCC_ReadModuleId( void )
+{
+#ifdef ABCC_CFG_ABCC_MODULE_ID
+ return( ABCC_CFG_ABCC_MODULE_ID );
+#else
+ return( ABCC_SYS_ReadModuleId() );
+#endif
+}
+
+void ABCC_RunTimerSystem( const INT16 iDeltaTimeMs )
+{
+ ABCC_TimerTick( iDeltaTimeMs );
+}
+
+
+UINT8 ABCC_GetNewSourceId( void )
+{
+ static UINT8 bSourceId = 0;
+ UINT8 bTempSrcId;
+ ABCC_PORT_UseCritical();
+
+ do
+ {
+ ABCC_PORT_EnterCritical();
+ bTempSrcId = ++bSourceId;
+ ABCC_PORT_ExitCritical();
+ } while ( ABCC_LinkIsSrcIdUsed( bTempSrcId ) );
+
+ return( bTempSrcId );
+}
+
+UINT8 ABCC_GetOpmode( void )
+{
+#if( ABCC_CFG_OP_MODE_GETTABLE )
+ return( ABCC_SYS_GetOpmode() );
+#elif ( defined( ABCC_CFG_ABCC_OP_MODE_30 ) && \
+ defined( ABCC_CFG_ABCC_OP_MODE_40 ) )
+ UINT8 bModuleId;
+
+ bModuleId = ABCC_ReadModuleId();
+
+ if( bModuleId == ABP_MODULE_ID_ACTIVE_ABCC30 )
+ {
+ return( ABCC_CFG_ABCC_OP_MODE_30 );
+ }
+ else
+ {
+ return( ABCC_CFG_ABCC_OP_MODE_40 );
+ }
+#elif defined( ABCC_CFG_ABCC_OP_MODE_30 )
+ return( ABCC_CFG_ABCC_OP_MODE_30 );
+#elif defined( ABCC_CFG_ABCC_OP_MODE_40 )
+ return( ABCC_CFG_ABCC_OP_MODE_40 );
+#else
+ /*
+ ** The user has not configured any way to determine the operating mode
+ */
+ #error "No method to determine the operating mode is available. Either set ABCC_CFG_OP_MODE_GETTABLE to TRUE or any of ABCC_CFG_ABCC_OP_MODE_X. See descriptions in abcc_cfg.h for details."
+#endif /* End of #if defined( ABCC_CFG_OP_MODE_HW_CONF ) */
+}
+
+
+void ABCC_GetAttribute( ABP_MsgType* psMsg,
+ UINT8 bObject,
+ UINT16 iInstance,
+ UINT8 bAttribute,
+ UINT8 bSourceId )
+{
+ ABCC_MsgType sMsg;
+ sMsg.psMsg = psMsg;
+
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj, bSourceId ); /* SourceId */
+ ABCC_SetHighAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj, bObject ); /* bObject */
+ psMsg->sHeader.iInstance = iTOiLe( iInstance ); /* Instance */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iCmdReserved,
+ ABP_MSG_HEADER_C_BIT | ABP_CMD_GET_ATTR ); /* Command */
+
+ sMsg.psMsg16->sHeader.iDataSize = 0; /* Data size */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iCmdExt0CmdExt1, bAttribute ); /* CmdExt0 (Attribute) */
+ ABCC_SetHighAddrOct( sMsg.psMsg16->sHeader.iCmdExt0CmdExt1, 0 ); /* CmdExt1 (reserved) */
+}
+
+void ABCC_SetByteAttribute(ABP_MsgType* psMsg,
+ UINT8 bObject,
+ UINT16 iInstance,
+ UINT8 bAttribute,
+ UINT8 bVal,
+ UINT8 bSourceId )
+{
+ ABCC_MsgType sMsg;
+ sMsg.psMsg = psMsg;
+
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj, bSourceId ); /* SourceId */
+ ABCC_SetHighAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj, bObject ); /* bObject */
+ psMsg->sHeader.iInstance = iTOiLe( iInstance ); /* Instance */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iCmdReserved,
+ ABP_MSG_HEADER_C_BIT | ABP_CMD_SET_ATTR ); /* Command */
+
+ sMsg.psMsg16->sHeader.iDataSize = iTOiLe( 1 ); /* Data size */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iCmdExt0CmdExt1, bAttribute ); /* CmdExt0 (Attribute) */
+ ABCC_SetHighAddrOct( sMsg.psMsg16->sHeader.iCmdExt0CmdExt1, 0 ); /* CmdExt1 (reserved) */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->aiData[ 0 ], bVal ); /* Data */
+}
+
+void ABCC_SetMsgHeader( ABP_MsgType* psMsg,
+ UINT8 bObject,
+ UINT16 iInstance,
+ UINT8 bAttribute,
+ ABP_MsgCmdType eService,
+ UINT16 iDataSize,
+ UINT8 bSourceId )
+{
+ ABCC_MsgType sMsg;
+ sMsg.psMsg = psMsg;
+
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj, bSourceId ); /* SourceId */
+ ABCC_SetHighAddrOct( sMsg.psMsg16->sHeader.iSourceIdDestObj, bObject ); /* bObject */
+ psMsg->sHeader.iInstance = iTOiLe( iInstance ); /* Instance */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iCmdReserved,
+ ABP_MSG_HEADER_C_BIT | eService ); /* Command */
+
+ sMsg.psMsg16->sHeader.iDataSize = iTOiLe( iDataSize ); /* Data size */
+ ABCC_SetLowAddrOct( sMsg.psMsg16->sHeader.iCmdExt0CmdExt1, bAttribute ); /* CmdExt0 (Attribute) */
+ ABCC_SetHighAddrOct( sMsg.psMsg16->sHeader.iCmdExt0CmdExt1, 0 ); /* CmdExt1 (reserved) */
+}
+
+ABCC_ErrorCodeType ABCC_VerifyMessage( const ABP_MsgType* psMsg )
+{
+ const ABP_MsgType16* psMsg16 = (const ABP_MsgType16* )psMsg;
+ if( ABCC_GetLowAddrOct( psMsg16->sHeader.iCmdReserved ) & ABP_MSG_HEADER_E_BIT )
+ {
+ return( ABCC_EC_RESP_MSG_E_BIT_SET );
+ }
+ return( ABCC_EC_NO_ERROR );
+}
+
+
+void SetErrorReporter( ABCC_ErrorReporter nFunc )
+{
+ ErrorReporter = nFunc;
+}
+
+
+/*------------------------------------------------------------------------------
+** ABCC_GetDataTypeSizeInBits()
+**------------------------------------------------------------------------------
+*/
+UINT16 ABCC_GetDataTypeSizeInBits( UINT8 bDataType )
+{
+ UINT16 iSetBitSize;
+
+ if( ABP_Is_PADx( bDataType ) )
+ {
+ iSetBitSize = bDataType - ABP_PAD0;
+ }
+ else if ( ABP_Is_BITx( bDataType ) )
+ {
+ iSetBitSize = ( ( bDataType - ABP_BIT1 ) + 1 );
+ }
+ else
+ {
+ iSetBitSize = (UINT16)ABCC_GetDataTypeSize( bDataType );
+ iSetBitSize *= 8;
+ }
+
+ return( iSetBitSize );
+}
+
+
+
+/*------------------------------------------------------------------------------
+** ABCC_GetDataTypeSize()
+**------------------------------------------------------------------------------
+*/
+
+UINT8 ABCC_GetDataTypeSize( UINT8 bDataType )
+{
+ UINT8 bSize;
+ switch( bDataType )
+ {
+
+ case ABP_UINT8:
+ case ABP_BOOL:
+ case ABP_SINT8:
+ case ABP_ENUM:
+ case ABP_BITS8:
+ case ABP_CHAR:
+ case ABP_OCTET:
+ bSize = ABP_UINT8_SIZEOF;
+ break;
+
+ case ABP_UINT16:
+ case ABP_BITS16:
+ case ABP_SINT16:
+ bSize = ABP_UINT16_SIZEOF;
+ break;
+ case ABP_UINT32:
+ case ABP_SINT32:
+ case ABP_BITS32:
+ case ABP_FLOAT:
+ bSize = ABP_UINT32_SIZEOF;
+ break;
+
+ case ABP_SINT64:
+ case ABP_UINT64:
+ bSize = ABP_UINT64_SIZEOF;
+ break;
+
+ case ABP_BIT1:
+ case ABP_BIT2:
+ case ABP_BIT3:
+ case ABP_BIT4:
+ case ABP_BIT5:
+ case ABP_BIT6:
+ case ABP_BIT7:
+ bSize = ABP_UINT8_SIZEOF;
+ break;
+
+
+ case ABP_PAD1:
+ case ABP_PAD2:
+ case ABP_PAD3:
+ case ABP_PAD4:
+ case ABP_PAD5:
+ case ABP_PAD6:
+ case ABP_PAD7:
+ case ABP_PAD8:
+ bSize = ABP_UINT8_SIZEOF;
+ break;
+
+ case ABP_PAD9:
+ case ABP_PAD10:
+ case ABP_PAD11:
+ case ABP_PAD12:
+ case ABP_PAD13:
+ case ABP_PAD14:
+ case ABP_PAD15:
+ case ABP_PAD16:
+ bSize = ABP_UINT16_SIZEOF;
+ break;
+ default:
+ bSize = 0;
+ break;
+ }
+
+ return( bSize );
+}
+
+void ABCC_GetMsgString( ABP_MsgType* psMsg, char* pcString, UINT16 iNumChar, UINT16 iOctetOffset )
+{
+ ABCC_PORT_StrCpyToNative( pcString,
+ ABCC_GetMsgDataPtr( psMsg ),
+ iOctetOffset,
+ iNumChar );
+}
+
+void ABCC_SetMsgString( ABP_MsgType* psMsg, const char* pcString, UINT16 iNumChar, UINT16 iOctetOffset )
+{
+ ABCC_PORT_StrCpyToPacked( ABCC_GetMsgDataPtr( psMsg ),
+ iOctetOffset,
+ pcString,
+ iNumChar );
+}
+
+void ABCC_GetMsgData8( ABP_MsgType* psMsg, UINT8* pbData, UINT16 iOctetOffset )
+{
+#ifdef ABCC_SYS_16_BIT_CHAR
+ *pbData = 0;
+#endif
+ ABCC_PORT_Copy8( pbData, 0, ABCC_GetMsgDataPtr( psMsg ), iOctetOffset );
+}
+
+void ABCC_SetMsgData8( ABP_MsgType* psMsg, UINT8 bData, UINT16 iOctetOffset )
+{
+ ABCC_PORT_Copy8( ABCC_GetMsgDataPtr( psMsg ), iOctetOffset, &bData, 0 );
+}
+
+void ABCC_GetMsgData16( ABP_MsgType* psMsg, UINT16* piData, UINT16 iOctetOffset )
+{
+ ABCC_PORT_Copy16( piData, 0, ABCC_GetMsgDataPtr( psMsg ), iOctetOffset );
+ *piData = iLeTOi( *piData );
+}
+
+void ABCC_SetMsgData16( ABP_MsgType* psMsg, UINT16 iData, UINT16 iOctetOffset )
+{
+ iData = iTOiLe( iData );
+ ABCC_PORT_Copy16( ABCC_GetMsgDataPtr( psMsg ), iOctetOffset, &iData, 0 );
+}
+
+void ABCC_GetMsgData32( ABP_MsgType* psMsg, UINT32* plData, UINT16 iOctetOffset )
+{
+ ABCC_PORT_Copy32( plData, 0, ABCC_GetMsgDataPtr( psMsg ), iOctetOffset );
+ *plData = lLeTOl( *plData );
+}
+
+void ABCC_SetMsgData32( ABP_MsgType* psMsg, UINT32 lData, UINT16 iOctetOffset )
+{
+ lData = lTOlLe( lData );
+ ABCC_PORT_Copy32( ABCC_GetMsgDataPtr( psMsg ), iOctetOffset, &lData, 0 );
+}
+
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+void ABCC_GetMsgData64( ABP_MsgType* psMsg, UINT64* plData, UINT16 iOctetOffset );
+{
+ ABCC_PORT_Copy64( plData, 0, ABCC_GetMsgDataPtr( psMsg ), iOctetOffset );
+ *plData = lLeTOl64( *plData );
+}
+
+void ABCC_SetMsgData64( ABP_MsgType* psMsg, UINT64 lData, UINT16 iOctetOffset );
+{
+ lData = lTOlLe64( lData );
+ ABCC_PORT_Copy64( ABCC_GetMsgDataPtr( psMsg ), iOctetOffset, &lData, 0 );
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_handler.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,186 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Interface for driver internal interface to the abcc_handler
+********************************************************************************
+********************************************************************************
+** Services:
+** ABCC_SetReadyForCommunication() : Indicate anybus ready for communication
+** ABCC_SetMainStateError() : Set driver in ABCC_ERROR state
+** ABCC_GetMainState() : Get current state
+
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABCC_HANDLER_H_
+#define ABCC_HANDLER_H_
+
+#include "abcc_drv_cfg.h"
+#include "abp.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*
+ ** Set default interrupt mask if not defined in abcc_drv_cfg.h
+ */
+#if( ABCC_CFG_DRV_PARALLEL )
+#ifndef ABCC_CFG_INT_ENABLE_MASK_PAR
+#define ABCC_CFG_INT_ENABLE_MASK_PAR ( 0 )
+#endif
+#endif
+
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+#ifndef ABCC_CFG_INT_ENABLE_MASK_PAR30
+#define ABCC_CFG_INT_ENABLE_MASK_PAR30 ( 0 )
+#endif
+#endif
+
+#if( ABCC_CFG_DRV_SPI )
+#ifndef ABCC_CFG_INT_ENABLE_MASK_SPI
+#define ABCC_CFG_INT_ENABLE_MASK_SPI ( 0 )
+#endif
+#endif
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+typedef union
+{
+ ABP_MsgType* psMsg;
+ ABP_MsgType16* psMsg16;
+} ABCC_MsgType;
+
+/*
+** Type for ABCC main states
+*/
+typedef enum ABCC_MainStateType
+{
+ ABCC_DRV_INIT,
+ ABCC_DRV_SHUTDOWN,
+ ABCC_DRV_ERROR,
+ ABCC_DRV_WAIT_COMMUNICATION_RDY,
+ ABCC_DRV_SETUP,
+ ABCC_DRV_RUNNING
+} ABCC_MainStateType;
+
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+#if( ABCC_CFG_SYNC_MEASUREMENT_IP )
+/*------------------------------------------------------------------------------
+** Flag used for sync measurement
+**------------------------------------------------------------------------------
+*/
+extern BOOL fAbccUserSyncMeasurementIp;
+#endif
+
+/*
+** The interrupt mask that has been set to the ABCC at start up.
+*/
+extern UINT16 ABCC_iInterruptEnableMask;
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+
+/*------------------------------------------------------------------------------
+** ABCC_SetPdSize()
+** Sets the new process data sizes.
+**------------------------------------------------------------------------------
+** Arguments:
+** iReadPdSize - Size of the read process data (in bytes), used from
+** this point on.
+** iWritePdSize - Size of the write process data (in bytes), used from
+** this point on.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_SetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize );
+
+
+/*------------------------------------------------------------------------------
+** The anybus is ready for communication. This function shall be called either
+** due to power up interrupt or initial handshake timeout
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_SetReadyForCommunication( void );
+
+/*------------------------------------------------------------------------------
+** Set main state machine into error state. This will stop ABCC_ISR()
+** and ABCC_RunDriver to perform any action towards application or anybus
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_SetMainStateError( void );
+
+/*------------------------------------------------------------------------------
+** Gets currents state
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** Current state ( ABCC_MainStateType )
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_MainStateType ABCC_GetMainState( void );
+
+/*------------------------------------------------------------------------------
+** Checks if update write process data is requested.
+** If requested, the update is performed.
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None:
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_CheckWrPdUpdate( void );
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_link.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,580 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Implements message queuing and write message flow control.
+**. and response handler functionality
+**
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+#include "abcc_debug_err.h"
+#include "abcc_link.h"
+#include "abcc_drv_if.h"
+#include "abcc_mem.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_timer.h"
+#include "abcc_handler.h"
+#include "abcc_port.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*
+** Max number of messages in each send queue.
+*/
+#define LINK_MAX_NUM_CMDS_IN_Q ABCC_CFG_MAX_NUM_APPL_CMDS
+#define LINK_MAX_NUM_RESP_IN_Q ABCC_CFG_MAX_NUM_ABCC_CMDS
+
+/*
+** Total number of message resources.
+*/
+#define LINK_NUM_MSG_IN_POOL ABCC_CFG_MAX_NUM_MSG_RESOURCES
+
+/*
+** Max num message handlers for responses.
+** The max number of outstanding commands counter is decremented
+** before the handler is invoked therefore we need to handle 1 extra
+** handler
+*/
+#define LINK_MAX_NUM_MSG_HDL ( LINK_MAX_NUM_CMDS_IN_Q + 1 )
+
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*
+** Message queue type for queueing cmds and responses.
+*/
+typedef struct MsgQueueType
+{
+ ABP_MsgType** queue;
+ INT8 bReadIndex;
+ INT8 bQueueSize;
+ INT8 bNumInQueue;
+} MsgQueueType;
+
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*
+ * Largest supported message size.
+ */
+static UINT16 link_iMaxMsgSize;
+
+/*
+ ** Command and response queues
+ */
+static ABP_MsgType* link_psCmds[LINK_MAX_NUM_CMDS_IN_Q ];
+static ABP_MsgType* link_psResponses[LINK_MAX_NUM_RESP_IN_Q];
+
+static MsgQueueType link_sCmdQueue;
+static MsgQueueType link_sRespQueue;
+
+/*
+ ** Response handlers
+ */
+static ABCC_MsgHandlerFuncType link_pnMsgHandler[ LINK_MAX_NUM_MSG_HDL ];
+static UINT8 link_bMsgSrcId[ LINK_MAX_NUM_MSG_HDL ];
+
+static ABCC_LinkNotifyIndType pnMsgSentHandler;
+static ABP_MsgType* link_psNotifyMsg;
+
+
+/*
+ ** Max number of outstanding commands ( no received response yet )
+ */
+static UINT8 link_bNumberOfOutstandingCommands = 0;
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+static ABP_MsgType* link_DeQueue( MsgQueueType* psMsgQueue )
+{
+ ABP_MsgType* psMsg = NULL;
+ if ( psMsgQueue->bNumInQueue != 0 )
+ {
+ psMsg = psMsgQueue->queue[ psMsgQueue->bReadIndex++];
+ psMsgQueue->bNumInQueue--;
+ psMsgQueue->bReadIndex %= psMsgQueue->bQueueSize;
+ }
+ ABCC_ASSERT(psMsgQueue->bNumInQueue >= 0);
+ return psMsg;
+}
+
+
+static BOOL link_EnQueue( MsgQueueType* psMsgQueue, ABP_MsgType* psMsg )
+{
+ if ( psMsgQueue->bNumInQueue < psMsgQueue->bQueueSize )
+ {
+ psMsgQueue->queue[ ( psMsgQueue->bNumInQueue + psMsgQueue->bReadIndex ) % psMsgQueue->bQueueSize ] = psMsg;
+ psMsgQueue->bNumInQueue++;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static ABP_MsgType* link_Peek( MsgQueueType* psMsgQueue )
+{
+ ABP_MsgType* psMsg;
+
+ psMsg = NULL;
+
+ if( psMsgQueue->bNumInQueue != 0 )
+ {
+ psMsg = psMsgQueue->queue[ psMsgQueue->bReadIndex ];
+ }
+
+ return( psMsg );
+}
+
+
+static void link_CheckNotification( const ABP_MsgType* const psMsg )
+{
+ ABCC_DEBUG_MSG_DATA( "Msg sent", (ABP_MsgType*)psMsg );
+ if( ( pnMsgSentHandler != NULL ) && ( psMsg == link_psNotifyMsg ) )
+ {
+ pnMsgSentHandler();
+ pnMsgSentHandler = NULL;
+ }
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+void ABCC_LinkInit( void )
+{
+ UINT16 iCount;
+ /*
+ ** Init Queue structures.
+ */
+ link_sCmdQueue.bNumInQueue = 0;
+ link_sCmdQueue.bQueueSize = LINK_MAX_NUM_CMDS_IN_Q;
+ link_sCmdQueue.bReadIndex = 0;
+ link_sCmdQueue.queue = link_psCmds;
+
+ link_sRespQueue.bNumInQueue = 0;
+ link_sRespQueue.bQueueSize = LINK_MAX_NUM_RESP_IN_Q;
+ link_sRespQueue.bReadIndex = 0;
+ link_sRespQueue.queue = link_psResponses;
+
+ ABCC_MemCreatePool();
+
+ for( iCount = 0; iCount < LINK_MAX_NUM_CMDS_IN_Q; iCount++ )
+ {
+ link_pnMsgHandler[ iCount ] = 0;
+ link_bMsgSrcId[iCount ] = 0;
+ }
+
+ /*
+ ** Initialize driver privates and states to default values.
+ */
+ link_bNumberOfOutstandingCommands = 0;
+
+ pnMsgSentHandler = NULL;
+ link_psNotifyMsg = NULL;
+
+ link_iMaxMsgSize = ABCC_CFG_MAX_MSG_SIZE;
+ /*
+ ** Limit ABCC 30 messages to 255 bytes
+ */
+ if( ABCC_ReadModuleId() == ABP_MODULE_ID_ACTIVE_ABCC30 )
+ {
+ if ( link_iMaxMsgSize > ABP_MAX_MSG_255_DATA_BYTES )
+ {
+ link_iMaxMsgSize = ABP_MAX_MSG_255_DATA_BYTES;
+ }
+ }
+}
+
+
+ABP_MsgType* ABCC_LinkReadMessage( void )
+{
+ ABCC_MsgType psReadMessage;
+ ABCC_PORT_UseCritical();
+
+ psReadMessage.psMsg = pnABCC_DrvReadMessage();
+
+ if( psReadMessage.psMsg != NULL )
+ {
+ if( ( ABCC_GetLowAddrOct( psReadMessage.psMsg16->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT ) == 0 )
+ {
+ /*
+ ** Decrement number of outstanding commands if a response is received
+ */
+ ABCC_PORT_EnterCritical();
+ link_bNumberOfOutstandingCommands--;
+ ABCC_PORT_ExitCritical();
+ ABCC_DEBUG_MSG_GENERAL( ( "Outstanding commands: %d\n",
+ link_bNumberOfOutstandingCommands ) );
+ }
+ }
+ return psReadMessage.psMsg;
+}
+
+
+void ABCC_LinkCheckSendMessage( void )
+{
+ BOOL fCmdMsg;
+ BOOL fMsgWritten;
+ BOOL fSendMsg;
+ ABP_MsgType* psWriteMessage = NULL;
+
+ ABCC_PORT_UseCritical();
+
+ fSendMsg = FALSE;
+
+ ABCC_PORT_EnterCritical();
+
+ /*
+ ** Check if any messages are queued.
+ ** If the queue index > 0 then there are messages in the qeueue.
+ ** Response messages are prioritised before command messages.
+ **
+ ** Note: Only a reference to the message is retrieved from the queue before
+ ** the transmission. It must stay in the queue until the transmission is
+ ** completed to guarantee the thread protection that is implemented in
+ ** ABCC_LinkWriteMessage().
+ */
+ if ( link_sRespQueue.bNumInQueue > 0 )
+ {
+ fCmdMsg = FALSE;
+ fSendMsg = TRUE;
+
+ psWriteMessage = link_Peek( &link_sRespQueue );
+ }
+ else if ( link_sCmdQueue.bNumInQueue > 0 )
+ {
+ fCmdMsg = TRUE;
+ fSendMsg = TRUE;
+
+ psWriteMessage = link_Peek( &link_sCmdQueue );
+ }
+
+ ABCC_PORT_ExitCritical();
+
+ if ( fSendMsg && ( ( fCmdMsg && pnABCC_DrvISReadyForCmd() ) ||
+ ( !fCmdMsg && pnABCC_DrvISReadyForWriteMessage() ) ) )
+ {
+ fMsgWritten = pnABCC_DrvWriteMessage( psWriteMessage );
+
+ /*
+ ** The message has been transmitted, now it is time to dequeue it.
+ */
+ ABCC_PORT_EnterCritical();
+
+ if( fCmdMsg )
+ {
+ link_DeQueue( &link_sCmdQueue );
+ ABCC_DEBUG_MSG_EVENT( "Command dequeued", psWriteMessage );
+ ABCC_DEBUG_MSG_GENERAL( ( "CmdQ status: %d(%d)\n", link_sCmdQueue.bNumInQueue, link_sCmdQueue.bQueueSize ) );
+ }
+ else
+ {
+ link_DeQueue( &link_sRespQueue );
+ ABCC_DEBUG_MSG_EVENT( "Response dequeued", psWriteMessage );
+ ABCC_DEBUG_MSG_GENERAL( ( "RespQ status: %d(%d)\n", link_sRespQueue.bNumInQueue, link_sRespQueue.bQueueSize ) );
+ }
+
+ ABCC_PORT_ExitCritical();
+
+ if( fMsgWritten )
+ {
+ /*
+ ** The message was successfully written and can be deallocated now.
+ */
+ link_CheckNotification( psWriteMessage );
+ ABCC_LinkFree( &psWriteMessage );
+ }
+ }
+}
+
+
+void ABCC_LinkRunDriverRx( void )
+{
+ ABP_MsgType* psSentMsg;
+
+ psSentMsg = pnABCC_DrvRunDriverRx();
+ /*
+ ** If a write message was sent, free the buffer.
+ */
+ if( psSentMsg )
+ {
+ link_CheckNotification( psSentMsg );
+ ABCC_LinkFree( &psSentMsg );
+ }
+}
+
+
+UINT16 ABCC_LinkGetNumCmdQueueEntries( void )
+{
+ UINT16 iQEntries;
+ iQEntries = LINK_MAX_NUM_CMDS_IN_Q - link_bNumberOfOutstandingCommands;
+ return iQEntries;
+}
+
+
+ABCC_ErrorCodeType ABCC_LinkWriteMessage( ABP_MsgType* psWriteMsg )
+{
+ BOOL fSendMsg;
+ ABCC_MsgType uWriteMsg;
+ BOOL fMsgWritten;
+ BOOL fCmdMsg;
+ ABCC_ErrorCodeType eErrorCode;
+ UINT32 lAddErrorInfo;
+
+ ABCC_PORT_UseCritical();
+
+ eErrorCode = ABCC_EC_NO_ERROR;
+ lAddErrorInfo = 0;
+
+ fSendMsg = FALSE;
+ uWriteMsg.psMsg = psWriteMsg;
+
+ if( iLeTOi( psWriteMsg->sHeader.iDataSize ) > link_iMaxMsgSize )
+ {
+ eErrorCode = ABCC_EC_WRMSG_SIZE_ERR;
+ ABCC_CbfDriverError( ABCC_SEV_WARNING, eErrorCode,
+ iLeTOi( psWriteMsg->sHeader.iDataSize ) );
+ return( eErrorCode );
+ }
+
+ ABCC_PORT_EnterCritical();
+
+ /*
+ ** Check if there are any messages already queued. If both queues are empty
+ ** that means there is no ongoing transmission and this message can be
+ ** transmitted right now. If any of the queues are populated there is an
+ ** ongoing transmission, in this case only queue the message.
+ */
+ if( ( link_sCmdQueue.bNumInQueue == 0 ) && ( link_sRespQueue.bNumInQueue == 0 ) )
+ {
+ fSendMsg = TRUE;
+ }
+
+ /*
+ ** Always queue the message even if it can be transmitted directly. This is
+ ** the lock to inhibit other threads to interrupt the ongoing transmission.
+ */
+ if( ABCC_GetLowAddrOct( uWriteMsg.psMsg16->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT )
+ {
+ fCmdMsg = TRUE;
+
+ if( LINK_MAX_NUM_CMDS_IN_Q == link_bNumberOfOutstandingCommands )
+ {
+ fSendMsg = FALSE;
+ lAddErrorInfo = (UINT32)link_bNumberOfOutstandingCommands;
+ eErrorCode = ABCC_EC_LINK_CMD_QUEUE_FULL;
+ }
+ else if( link_EnQueue(&link_sCmdQueue, psWriteMsg ) )
+ {
+ ABCC_DEBUG_MSG_EVENT( "Command queued", psWriteMsg );
+ ABCC_DEBUG_MSG_GENERAL( ( "CmdQ status: %d(%d)\n", link_sCmdQueue.bNumInQueue, link_sCmdQueue.bQueueSize ) );
+
+ ABCC_MemSetBufferStatus( psWriteMsg, ABCC_MEM_BUFSTAT_SENT );
+ link_bNumberOfOutstandingCommands++;
+ ABCC_DEBUG_MSG_GENERAL( ( "Outstanding commands: %d\n", link_bNumberOfOutstandingCommands ) );
+ }
+ else
+ {
+ ABCC_DEBUG_MSG_EVENT("Command queue full", psWriteMsg );
+ ABCC_DEBUG_MSG_GENERAL( ( "CmdQ status: %d(%d)\n", link_sCmdQueue.bNumInQueue, link_sCmdQueue.bQueueSize ) );
+ fSendMsg = FALSE;
+ eErrorCode = ABCC_EC_LINK_CMD_QUEUE_FULL;
+ ABCC_ASSERT( FALSE );
+ }
+ }
+ else
+ {
+ fCmdMsg = FALSE;
+
+ if( link_EnQueue( &link_sRespQueue, psWriteMsg ) )
+ {
+ ABCC_DEBUG_MSG_EVENT("Response msg queued ", psWriteMsg );
+ ABCC_DEBUG_MSG_GENERAL( ( "RespQ status: %d(%d)\n", link_sRespQueue.bNumInQueue, link_sRespQueue.bQueueSize ) );
+ ABCC_MemSetBufferStatus( psWriteMsg, ABCC_MEM_BUFSTAT_SENT );
+ }
+ else
+ {
+ ABCC_DEBUG_MSG_EVENT("Response queue full", psWriteMsg );
+ ABCC_DEBUG_MSG_GENERAL( ( "RespQ status: %d(%d)\n", link_sRespQueue.bNumInQueue, link_sRespQueue.bQueueSize ) );
+ fSendMsg = FALSE;
+ eErrorCode = ABCC_EC_LINK_RESP_QUEUE_FULL;
+ lAddErrorInfo = (UINT32)psWriteMsg;
+ }
+ }
+
+ ABCC_PORT_ExitCritical();
+
+ /*
+ ** Continue the transmission of the message if both queues were empty.
+ ** Else the message will be transmitted at the next ABCC write message event.
+ */
+ if( fSendMsg && ( ( fCmdMsg && pnABCC_DrvISReadyForCmd() ) ||
+ ( !fCmdMsg && pnABCC_DrvISReadyForWriteMessage() ) ) )
+ {
+ fMsgWritten = pnABCC_DrvWriteMessage( psWriteMsg );
+
+ ABCC_PORT_EnterCritical();
+
+ /*
+ ** The message has been transmitted, now it is time to dequeue it.
+ */
+ if( fCmdMsg )
+ {
+ link_DeQueue( &link_sCmdQueue );
+ ABCC_DEBUG_MSG_EVENT( "Command dequeued", psWriteMsg );
+ ABCC_DEBUG_MSG_GENERAL( ( "CmdQ status: %d(%d)\n", link_sCmdQueue.bNumInQueue, link_sCmdQueue.bQueueSize ) );
+ }
+ else
+ {
+ link_DeQueue( &link_sRespQueue );
+ ABCC_DEBUG_MSG_EVENT( "Response dequeued", psWriteMsg );
+ ABCC_DEBUG_MSG_GENERAL( ( "RespQ status: %d(%d)\n", link_sRespQueue.bNumInQueue, link_sRespQueue.bQueueSize ) );
+ }
+
+ ABCC_PORT_ExitCritical();
+
+ if( fMsgWritten )
+ {
+ /*
+ ** The message was successfully written and can be deallocated now.
+ */
+ link_CheckNotification( psWriteMsg );
+ ABCC_LinkFree( &psWriteMsg );
+ }
+ }
+
+ if( eErrorCode != ABCC_EC_NO_ERROR )
+ {
+ ABCC_CbfDriverError( ABCC_SEV_WARNING, eErrorCode, lAddErrorInfo );
+ }
+
+ return( eErrorCode );
+}
+
+ABCC_ErrorCodeType ABCC_LinkWrMsgWithNotification( ABP_MsgType* psWriteMsg,
+ ABCC_LinkNotifyIndType pnHandler )
+{
+ ABCC_ErrorCodeType eResult;
+
+ /*
+ ** Save callback function to call when message is successfully sent.
+ */
+ ABCC_ASSERT( pnMsgSentHandler == NULL );
+ pnMsgSentHandler = pnHandler;
+ link_psNotifyMsg = psWriteMsg;
+
+ eResult = ABCC_LinkWriteMessage( psWriteMsg );
+
+ return( eResult );
+}
+
+void ABCC_LinkFree( ABP_MsgType** ppsBuffer )
+{
+ ABCC_ASSERT_ERR( *ppsBuffer != 0, ABCC_SEV_WARNING, ABCC_EC_TRYING_TO_FREE_NULL_POINTER, 0 );
+
+ ABCC_MemFree( ppsBuffer );
+}
+
+ABCC_ErrorCodeType ABCC_LinkMapMsgHandler( UINT8 bSrcId, ABCC_MsgHandlerFuncType pnMSgHandler )
+{
+ UINT16 iIndex;
+ ABCC_ErrorCodeType eResult = ABCC_EC_NO_RESOURCES;
+ ABCC_PORT_UseCritical();
+
+ /*
+ ** Find free spot.
+ */
+ ABCC_PORT_EnterCritical();
+ for ( iIndex = 0; iIndex < LINK_MAX_NUM_MSG_HDL ; iIndex++ )
+ {
+ if (link_pnMsgHandler[ iIndex ] == 0 )
+ {
+ link_pnMsgHandler[ iIndex ] = pnMSgHandler;
+ link_bMsgSrcId[ iIndex ] = bSrcId;
+ eResult = ABCC_EC_NO_ERROR;
+ break;
+ }
+ }
+ ABCC_PORT_ExitCritical();
+ return( eResult );
+}
+
+ABCC_MsgHandlerFuncType ABCC_LinkGetMsgHandler( UINT8 bSrcId )
+{
+ UINT16 iIndex;
+ ABCC_MsgHandlerFuncType pnHandler = NULL;
+ ABCC_PORT_UseCritical();
+
+ /*
+ ** Find message handler. If not found return NULL.
+ */
+ ABCC_PORT_EnterCritical();
+ for ( iIndex = 0; iIndex < LINK_MAX_NUM_MSG_HDL ; iIndex++ )
+ {
+ if ( ( link_pnMsgHandler[ iIndex ] != NULL ) && ( link_bMsgSrcId[ iIndex ] == bSrcId ) )
+ {
+ pnHandler = link_pnMsgHandler[ iIndex ];
+ link_pnMsgHandler[ iIndex ] = NULL;
+ break;
+ }
+ }
+ ABCC_PORT_ExitCritical();
+ return pnHandler;
+}
+
+BOOL ABCC_LinkIsSrcIdUsed( UINT8 bSrcId )
+{
+ BOOL fFound = FALSE;
+ UINT16 iIndex;
+
+ for ( iIndex = 0; iIndex < LINK_MAX_NUM_MSG_HDL ; iIndex++ )
+ {
+ if ( ( link_pnMsgHandler[ iIndex ] != NULL ) && ( link_bMsgSrcId[ iIndex ] == bSrcId ) )
+ {
+ fFound = TRUE;
+ break;
+ }
+ }
+ return fFound;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/abcc_link.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,255 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Provides messages handling services including flow control message resource +** handling and message destination mapping. +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_LinkInit() - Init queues and mempools +** ABCC_LinkRunDriverRx() - Receive for serial interface +** ABCC_LinkWriteMessage() - Write message to driver +** ABCC_LinkGetCmdQueueEntries() - Number of cmd queue entries left. +** ABCC_LinkAlloc() - Allocates a message resource +** ABCC_LinkFree() - Free message resource +** ABCC_LinkMapMsgHandler() - Map src id to handler function for resp. +** ABCC_LinkGetMsgHandler() - Get handler from source id. +** ABCC_LinkReadMessage() - Get read message if any. +** ABCC_LinkCheckSendMessage() - Checks the queue for send write messages +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_LINK_H_ +#define ABCC_LINK_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + + +typedef void (*ABCC_LinkNotifyIndType)( void ); + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Must be called before the driver is used. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_LinkInit( void ); + +/*------------------------------------------------------------------------------ +** This method drives the internal receive state machine. +**------------------------------------------------------------------------------ +** Arguments: - +** +** Returns: +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_LinkRunDriverRx( void ); + + +/*------------------------------------------------------------------------------ +** Write message to the driver. ABCC_MSG_Q_FULL +** +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg: Pointer to message. +** +** Returns: +** ABCC_ErrorCodeType +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABCC_ErrorCodeType ABCC_LinkWriteMessage( ABP_MsgType* psWriteMsg ); + +/*------------------------------------------------------------------------------ +** Provides number of queue entries left in the command queue. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** Number of queue entries left in the command queue +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_LinkGetNumCmdQueueEntries( void ); + +/*------------------------------------------------------------------------------ +** Write message to the driver. ABCC_MsgCmdStatus is returned. +** Note that if the message was sent successfully before returning from the function +** no callback is invoked. +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg: Pointer to message. +** pnHandler: Function to call when message is sent +** +** Returns: +** ABCC_ErrorCodeType +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABCC_ErrorCodeType ABCC_LinkWrMsgWithNotification( ABP_MsgType* psWriteMsg, + ABCC_LinkNotifyIndType pnHandler ); + + +/*------------------------------------------------------------------------------ +** Allocates a message buffer. +**------------------------------------------------------------------------------ +** Arguments: +** iSize: Required size (in bytes) of the buffer. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_LinkFree( ABP_MsgType** ppsBuffer ); + + +/*------------------------------------------------------------------------------ +** Maps the source id to a message handle function. +** Typically used when sending a command with a given source id knowing what +** function must handle the response ( ABCC_LinkGetMsgHandler() ). +**------------------------------------------------------------------------------ +** Arguments: +** bSrcId: Key to cross reference table. +** pnMSgHandler: Pointer to handle function for message using key +** source id. +** +** Returns: +** ABCC_ErrorCodeType +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABCC_ErrorCodeType ABCC_LinkMapMsgHandler( UINT8 bSrcId, ABCC_MsgHandlerFuncType pnMSgHandler ); + +/*------------------------------------------------------------------------------ +** Get function that is mapped to a given source id ( ABCC_LinkMapMsgHandler() ). +**------------------------------------------------------------------------------ +** Arguments: +** bSrcId: Given source id. +** +** Returns: +** Function to call. NULL if no cross reference is found. +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABCC_MsgHandlerFuncType ABCC_LinkGetMsgHandler( UINT8 bSrcId ); + + +/*------------------------------------------------------------------------------ +** Returns TRUE if the source id has a valid map in the message handler table +**------------------------------------------------------------------------------ +** Arguments: +** bSrcId: Given source id. +** +** Returns: +** TRUE Used +** FALSE Not Used +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_LinkIsSrcIdUsed( UINT8 bSrcId ); + + + + +/*------------------------------------------------------------------------------ +** Receive read message if available +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to received message. NULL if no message is found +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_LinkReadMessage( void ); + +/*------------------------------------------------------------------------------ +** Check queues for write messages +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_LinkCheckSendMessage( void ); + + +/*------------------------------------------------------------------------------ +** Check queues for write mess +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ + + + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_mem.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,236 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Memory allocation implementation.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_mem.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_port.h"
+#include "abcc_debug_err.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*
+** Set default value for maximum number of resources
+*/
+#ifndef ABCC_CFG_MAX_NUM_MSG_RESOURCES
+#define ABCC_CFG_MAX_NUM_MSG_RESOURCES ( ABCC_CFG_MAX_NUM_APPL_CMDS + ABCC_CFG_MAX_NUM_ABCC_CMDS )
+#endif
+
+/*
+** Magic cookie
+*/
+#define ABCC_MEM_MAGIC_COOKIE 0x5CC5
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure for defining size of memory message allocation
+**
+** The magic cookie field is used to evaluate if the buffer status field
+** is broken. The buffer status could be broken if the user writes outside the
+** bounds of the message data area.
+**------------------------------------------------------------------------------
+*/
+typedef struct
+{
+ ABP_MsgHeaderType16 sHeader;
+ UINT32 alData[ ( ABCC_CFG_MAX_MSG_SIZE + 3 ) >> 2 ];
+ UINT16 iMagicCookie;
+ UINT16 iBufferStatus;
+}
+PACKED_STRUCT ABCC_MemAllocType;
+
+/*------------------------------------------------------------------------------
+** Union used for casting between memory ABCC_MemAllocType and ABP_MsgType.
+**------------------------------------------------------------------------------
+*/
+typedef union
+{
+ ABCC_MemAllocType* psAllocMsg;
+ ABP_MsgType* psMsg;
+}
+ABCC_MemAllocUnion;
+
+/*------------------------------------------------------------------------------
+** Memory pool structure
+**
+** ------------------
+** iNumFreeMsg = 3 |
+** ------------------
+** Msg 0 pointer |---|
+** ------------------ |
+** Msg 1 pointer |---+--|
+** ------------------ | |
+** Msg 2 pointer |---+--+--|
+** ------------------ | | |
+** Msg 0 |<--| | |
+** ------------------ | |
+** Msg 1 |<-----| |
+** ------------------ |
+** Msg 2 |<--------|
+** ------------------
+**------------------------------------------------------------------------------
+*/
+static UINT16 abcc_iNumFreeMsg;
+static ABCC_MemAllocUnion abcc_uFreeMsgStack[ ABCC_CFG_MAX_NUM_MSG_RESOURCES ];
+static ABCC_MemAllocType abcc_asMsgPool[ ABCC_CFG_MAX_NUM_MSG_RESOURCES ];
+
+
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void ABCC_MemCreatePool( void )
+{
+ UINT16 i;
+
+ abcc_iNumFreeMsg = ABCC_CFG_MAX_NUM_MSG_RESOURCES;
+
+ for( i = 0; i < ABCC_CFG_MAX_NUM_MSG_RESOURCES ; i++ )
+ {
+ abcc_uFreeMsgStack[ i ].psAllocMsg = &abcc_asMsgPool[ i ];
+ abcc_asMsgPool[ i ].iMagicCookie = ABCC_MEM_MAGIC_COOKIE;
+ abcc_asMsgPool[ i ].iBufferStatus = ABCC_MEM_BUFSTAT_FREE;
+ }
+}
+
+ABP_MsgType* ABCC_MemAlloc( void )
+{
+ ABP_MsgType* pxItem = NULL;
+ ABCC_PORT_UseCritical();
+ ABCC_PORT_EnterCritical();
+ if( abcc_iNumFreeMsg > 0 )
+ {
+ abcc_iNumFreeMsg--;
+ pxItem = abcc_uFreeMsgStack[ abcc_iNumFreeMsg ].psMsg;
+ ( (ABCC_MemAllocType*)pxItem )->iBufferStatus = ABCC_MEM_BUFSTAT_ALLOCATED;
+ }
+
+ ABCC_PORT_ExitCritical();
+
+ ABCC_DEBUG_MSG_GENERAL( ( "Mem: Buffer allocated: 0x%08x\n", (UINT32)pxItem ) );
+
+ return( pxItem );
+}
+
+void ABCC_MemFree( ABP_MsgType** pxItem)
+{
+ ABCC_MemAllocType* const psBuf = (ABCC_MemAllocType*)(*pxItem);
+ ABCC_PORT_UseCritical();
+
+ ABCC_DEBUG_MSG_GENERAL( ( "Mem: Buffer returned: 0x%08x\n", (UINT32)*pxItem ) );
+
+ if( psBuf->iMagicCookie != ABCC_MEM_MAGIC_COOKIE )
+ {
+ ABCC_CbfDriverError( ABCC_SEV_FATAL,
+ ABCC_EC_MSG_BUFFER_CORRUPTED,
+ (UINT32)psBuf );
+ return;
+ }
+
+ if( psBuf->iBufferStatus == ABCC_MEM_BUFSTAT_FREE )
+ {
+ ABCC_CbfDriverError( ABCC_SEV_FATAL,
+ ABCC_EC_MSG_BUFFER_ALREADY_FREED,
+ (UINT32)psBuf );
+ return;
+ }
+
+ ABCC_PORT_EnterCritical();
+
+ abcc_uFreeMsgStack[ abcc_iNumFreeMsg ].psAllocMsg = psBuf;
+ abcc_iNumFreeMsg++;
+ psBuf->iBufferStatus = ABCC_MEM_BUFSTAT_FREE;
+ *pxItem = NULL;
+
+ ABCC_PORT_ExitCritical();
+}
+
+ABCC_MemBufferStatusType ABCC_MemGetBufferStatus( ABP_MsgType* psMsg )
+{
+ const ABCC_MemAllocType* const psBuf = (ABCC_MemAllocType*)psMsg;
+
+ if( psBuf->iMagicCookie != ABCC_MEM_MAGIC_COOKIE )
+ {
+ ABCC_CbfDriverError( ABCC_SEV_FATAL,
+ ABCC_EC_MSG_BUFFER_CORRUPTED,
+ (UINT32)psBuf );
+
+ return( ABCC_MEM_BUFSTAT_UNKNOWN );
+ }
+
+ return( (ABCC_MemBufferStatusType)psBuf->iBufferStatus );
+}
+
+void ABCC_MemSetBufferStatus( ABP_MsgType* psMsg,
+ ABCC_MemBufferStatusType eStatus )
+{
+ ABCC_MemAllocType* const psBuf = (ABCC_MemAllocType*)psMsg;
+
+ if( psBuf->iMagicCookie != ABCC_MEM_MAGIC_COOKIE )
+ {
+ ABCC_CbfDriverError( ABCC_SEV_FATAL,
+ ABCC_EC_MSG_BUFFER_CORRUPTED,
+ (UINT32)psMsg );
+ return;
+ }
+
+ psBuf->iBufferStatus = eStatus;
+}
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_mem.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,134 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This program is the property of HMS Industrial Networks AB. **
+** It may not be reproduced, distributed, or used without permission **
+** of an authorized company official. **
+********************************************************************************
+********************************************************************************
+** Memory management of the driver
+********************************************************************************
+********************************************************************************
+** Services:
+** ABCC_MemCreatePool() - Create memory resource pool
+** ABCC_MemAlloc() - Alloc memory resource
+** ABCC_MemFree() - Free memory resource
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ABCC_MEM_H_
+#define ABCC_MEM_H_
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Buffer status used to keep track of a memory buffer's current state
+**------------------------------------------------------------------------------
+*/
+typedef enum ABCC_MemBufferStatusType
+{
+ ABCC_MEM_BUFSTAT_FREE = 0,
+ ABCC_MEM_BUFSTAT_ALLOCATED = 1,
+ ABCC_MEM_BUFSTAT_SENT = 2,
+ ABCC_MEM_BUFSTAT_OWNED = 3,
+
+ ABCC_MEM_BUFSTAT_UNKNOWN = 0x7FFF
+}
+ABCC_MemBufferStatusType;
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Creates a memory pool of buffers with a specific size.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void ABCC_MemCreatePool( void );
+
+/*------------------------------------------------------------------------------
+** Allocates and return pointer to memory of predefined size (ABCC_MemCreatePool)
+**------------------------------------------------------------------------------
+** Arguments:
+** pxMemHandler - Handler for the pool where the memory is taken from
+**
+** Returns:
+** Pointer to allocated memory. NULL if pool is empty.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABP_MsgType* ABCC_MemAlloc( void );
+
+/*------------------------------------------------------------------------------
+** Return memory to the pool. Note that it is important that the returned memory
+** is belonging to the pool from the beginning.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxMemHandler - Handler for the pool where the memory is returned.
+** pxItem - Pointer to the memory to be returned. The pointer is set to
+** NULL.
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_MemFree( ABP_MsgType** pxItem );
+
+/*------------------------------------------------------------------------------
+** Get the currently status of the memory buffer
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Message buffer to check the status of
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC ABCC_MemBufferStatusType ABCC_MemGetBufferStatus( ABP_MsgType* psMsg );
+
+/*------------------------------------------------------------------------------
+** Set a new status to the memory buffer
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Memory buffer to set the status to
+** eStatus - Status to be set to the message buffer
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void ABCC_MemSetBufferStatus( ABP_MsgType* psMsg,
+ ABCC_MemBufferStatusType eStatus );
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_remap.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,77 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Implementation of remap function
+********************************************************************************
+********************************************************************************
+*/
+
+
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc.h"
+#include "abcc_handler.h"
+#include "abcc_link.h"
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static UINT16 abcc_iNewPdReadSize = 0;
+static UINT16 abcc_iNewPdWriteSize = 0;
+
+
+static void abcc_RemapRespMsgSent( void )
+{
+ ABCC_SetPdSize( abcc_iNewPdReadSize, abcc_iNewPdWriteSize );
+ ABCC_CbfRemapDone();
+}
+
+ABCC_ErrorCodeType ABCC_SendRemapRespMsg( ABP_MsgType* psMsgResp, UINT16 iNewReadPdSize, const UINT16 iNewWritePdSize )
+{
+ ABCC_ErrorCodeType eResult;
+ abcc_iNewPdReadSize = iNewReadPdSize;
+ abcc_iNewPdWriteSize = iNewWritePdSize;
+
+ /*
+ ** When ack is sent abcc_RemapRespMsgSent will be called.
+ */
+ eResult = ABCC_LinkWrMsgWithNotification( psMsgResp, abcc_RemapRespMsgSent );
+
+ return( eResult );
+}
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_setup.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,595 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Implementation of abcc setup state machine
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_td.h"
+#include "abcc_drv_if.h"
+#include "abp.h"
+#include "abcc.h"
+#include "abcc_handler.h"
+#include "abcc_link.h"
+#include "abcc_mem.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_debug_err.h"
+#include "abcc_timer.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*
+** Invalid ADI index.
+*/
+#define AD_INVALID_ADI_INDEX ( 0xffff )
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+typedef enum CmdStateType
+{
+ /*
+ ** Order dependent states.
+ */
+ MSG_GET_DATA_FORMAT,
+ MSG_GET_NW_PARAM_SUPPORT,
+ MSG_GET_MODULE_TYPE,
+ MSG_GET_NETWORK_TYPE,
+ MSG_MAP_PD_READ_WRITE,
+ MSG_USER_INIT_START,
+ MSG_USER_INIT,
+ MSG_READ_RDPD_SIZE,
+ MSG_READ_WRPD_SIZE,
+ MSG_SETUP_COMPLETE,
+ MSG_DONE
+}
+CmdStateType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** iModuleType - ABCC module type (read out during SETUP state)
+** iNetworkType - ABCC network type (read out during SETUP state)
+** abcc_iPdReadSize - Read process data size
+** abcc_iPdWriteSize - Write process data size
+** eParameterSupport - Parameter support (read out during SETUP state)
+**------------------------------------------------------------------------------
+*/
+static UINT16 iModuleType;
+static UINT16 iNetworkType;
+static NetFormatType eNetFormat;
+static ParameterSupportType eParameterSupport;
+
+static CmdStateType eCmdState = MSG_GET_DATA_FORMAT;
+
+/*
+** Help varibales for ADI mapping servcie
+*/
+static AD_AdiEntryType* psAdiEntry = NULL;
+static AD_DefaultMapType* psDefaultMap = NULL;
+static UINT16 abcc_iNumAdi = 0;
+static UINT16 iMappingIndex = 0;
+
+/*
+** Currently used processdata sizes
+*/
+static UINT16 abcc_iPdReadSize = 0;
+static UINT16 abcc_iPdWriteSize = 0;
+
+/*
+** Current wrpd sizes devided in octet and bits
+*/
+static UINT16 abcc_iPdWriteBitSize = 0;
+
+/*
+** Current rdpd sizes devided in octet and bits
+*/
+static UINT16 abcc_iPdReadBitSize = 0;
+
+
+
+/*------------------------------------------------------------------------------
+** SetupCommands()
+**------------------------------------------------------------------------------
+*/
+void ABCC_SetupInit( void )
+{
+ eCmdState = MSG_GET_DATA_FORMAT;
+
+ iModuleType = 0xFFFF;
+ iNetworkType = 0xFFFF;
+ eNetFormat = NET_UNKNOWN;
+ eParameterSupport = PARAMETER_UNKNOWN;
+
+ psAdiEntry = NULL;
+ psDefaultMap = NULL;
+ abcc_iNumAdi = 0;
+ iMappingIndex = 0;
+ abcc_iPdReadSize = 0;
+ abcc_iPdWriteSize = 0;
+ abcc_iPdWriteBitSize = 0;
+ abcc_iPdReadBitSize = 0;
+}
+
+
+/*------------------------------------------------------------------------------
+** Find ADI entry table index for the specified instance number.
+**------------------------------------------------------------------------------
+** Arguments:
+** iInstance - Instance number.
+**
+** Returns:
+** AD_INVALID_ADI_INDEX - Instance was not found.
+**------------------------------------------------------------------------------
+*/
+static UINT16 GetAdiIndex( UINT16 iInstance )
+{
+ UINT16 i;
+ UINT16 iIndex;
+
+ iIndex = AD_INVALID_ADI_INDEX;
+
+ for( i = 0; i < abcc_iNumAdi; i++ )
+ {
+ if( psAdiEntry[ i ].iInstance == iInstance )
+ {
+ iIndex = i;
+ break;
+ }
+ }
+
+ return( iIndex );
+}
+
+static UINT16 abcc_GetAdiMapSizeInBits(const AD_AdiEntryType* psAdiEntry, UINT8 bNumElem, UINT8 bElemStartIndex )
+{
+ UINT16 iSize;
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ UINT16 i;
+ if( psAdiEntry->psStruct == NULL )
+ {
+ iSize = ABCC_GetDataTypeSizeInBits( psAdiEntry->bDataType ) * bNumElem ;
+ }
+ else
+ {
+ iSize = 0;
+ for( i = bElemStartIndex; i < ( bNumElem + bElemStartIndex ) ; i++ )
+ {
+ iSize += ABCC_GetDataTypeSizeInBits( psAdiEntry->psStruct[ i ].bDataType );
+ }
+ }
+#else
+ (void)bElemStartIndex;
+ iSize = ABCC_GetDataTypeSizeInBits( psAdiEntry->bDataType ) * bNumElem ;
+#endif
+
+ return iSize;
+}
+
+static void abcc_FillMapExtCommand( ABP_MsgType16* psMsg16, UINT16 iAdi, UINT8 bAdiTotNumElem, UINT8 bElemStartIndex, UINT8 bNumElem, UINT8 bDataType )
+{
+ psMsg16->aiData[ 0 ] = iTOiLe( iAdi ); /* ADI Instance number. */
+ ABCC_SetLowAddrOct( psMsg16->aiData[ 1 ], bAdiTotNumElem); /* Total number of elements in ADI. */
+ ABCC_SetHighAddrOct( psMsg16->aiData[ 1 ], bElemStartIndex );
+ ABCC_SetLowAddrOct( psMsg16->aiData[ 2 ], bNumElem);
+ ABCC_SetHighAddrOct( psMsg16->aiData[ 2 ], 1 ); /* Number of type descriptors. */
+ ABCC_SetLowAddrOct( psMsg16->aiData[ 3 ], bDataType ); /* ADI element data type. */
+ psMsg16->sHeader.iDataSize = iTOiLe( 7 ); /* The number of used octets in aiData. (The bytes written below). */
+}
+
+BOOL ABCC_SetupCommands( void )
+{
+ UINT16 iLocalMapIndex;
+ UINT16 iLocalSize;
+ BOOL fRunSM = TRUE;
+ ABCC_MsgType pMsgSendBuffer;
+
+ while( fRunSM )
+ {
+ fRunSM = FALSE;
+ switch( eCmdState )
+ {
+ case MSG_GET_DATA_FORMAT:
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_GetAttribute( pMsgSendBuffer.psMsg, ABP_OBJ_NUM_NW, 1 ,
+ ABP_NW_IA_DATA_FORMAT, ABCC_GetNewSourceId() );
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+ break;
+
+ case MSG_GET_NW_PARAM_SUPPORT:
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_GetAttribute( pMsgSendBuffer.psMsg, ABP_OBJ_NUM_NW, 1 ,
+ ABP_NW_IA_PARAM_SUPPORT, ABCC_GetNewSourceId() );
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg );
+ break;
+
+ case MSG_GET_MODULE_TYPE:
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_GetAttribute( pMsgSendBuffer.psMsg, ABP_OBJ_NUM_ANB, 1 ,
+ ABP_ANB_IA_MODULE_TYPE, ABCC_GetNewSourceId() );
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+ break;
+
+ case MSG_GET_NETWORK_TYPE:
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_GetAttribute( pMsgSendBuffer.psMsg, ABP_OBJ_NUM_NW, 1 ,
+ ABP_NW_IA_NW_TYPE, ABCC_GetNewSourceId() );
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+ break;
+
+ case MSG_MAP_PD_READ_WRITE:
+
+ if( psAdiEntry && psDefaultMap && ( psDefaultMap[ iMappingIndex ].eDir != PD_END_MAP ) )
+ {
+ if( psDefaultMap[ iMappingIndex ].iInstance != AD_MAP_PAD_ADI )
+ {
+ iLocalMapIndex = GetAdiIndex( psDefaultMap[ iMappingIndex ].iInstance );
+
+ if( iLocalMapIndex == AD_INVALID_ADI_INDEX )
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_DEFAULT_MAP_ERR,
+ (UINT32)psDefaultMap[ iMappingIndex ].iInstance );
+ ABCC_SetMainStateError();
+ break;
+ }
+ }
+ }
+ else
+ {
+ eCmdState = MSG_USER_INIT_START;
+ fRunSM = TRUE;
+ break;
+ }
+
+ if( ABCC_ReadModuleId() == ABP_MODULE_ID_ACTIVE_ABCC40 ) /* If an ABCC40 is attached. */
+ {
+ UINT8 bNumElemToMap;
+ UINT8 bElemMapStartIndex;
+
+ /*
+ ** Implement mapping according to the extended command for ABCC40.
+ */
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_SetHighAddrOct( pMsgSendBuffer.psMsg16->sHeader.iSourceIdDestObj, ABP_OBJ_NUM_NW );
+ pMsgSendBuffer.psMsg16->sHeader.iInstance = iTOiLe( 1 );
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->sHeader.iCmdExt0CmdExt1, 1 ); /* Number of mapping items to add. */
+ ABCC_SetHighAddrOct( pMsgSendBuffer.psMsg16->sHeader.iCmdExt0CmdExt1, 0 ); /* Reserved. */
+
+ if ( psDefaultMap[ iMappingIndex ].iInstance != AD_MAP_PAD_ADI )
+ {
+ if( psDefaultMap[ iMappingIndex ].bNumElem == AD_DEFAULT_MAP_ALL_ELEM )
+ {
+ bNumElemToMap = psAdiEntry[ iLocalMapIndex ].bNumOfElements;
+ bElemMapStartIndex = 0;
+ }
+ else
+ {
+ bNumElemToMap = psDefaultMap[ iMappingIndex ].bNumElem;
+ bElemMapStartIndex = psDefaultMap[ iMappingIndex ].bElemStartIndex;
+ }
+
+ abcc_FillMapExtCommand( pMsgSendBuffer.psMsg16,
+ psAdiEntry[ iLocalMapIndex ].iInstance , /* Adi */
+ psAdiEntry[ iLocalMapIndex ].bNumOfElements , /* Adi total num elements */
+ bElemMapStartIndex, /* Mapping start index */
+ bNumElemToMap, /* Num elements to map */
+ psAdiEntry[ iLocalMapIndex ].bDataType ); /* Data type */
+ iLocalSize = abcc_GetAdiMapSizeInBits( &psAdiEntry[ iLocalMapIndex ],
+ bNumElemToMap, bElemMapStartIndex );
+
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if ( psAdiEntry[ iLocalMapIndex ].psStruct != NULL )
+ {
+ UINT16 iDescOffset;
+ iDescOffset = 0;
+ ABCC_SetHighAddrOct( pMsgSendBuffer.psMsg16->aiData[ 2 ], bNumElemToMap );
+
+ while ( iDescOffset < bNumElemToMap )
+ {
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->aiData[ ( iDescOffset >> 1) + 3 ], psAdiEntry[ iLocalMapIndex ].psStruct[ iDescOffset + bElemMapStartIndex].bDataType );
+ iDescOffset++;
+ if( iDescOffset < bNumElemToMap )
+ {
+ ABCC_SetHighAddrOct( pMsgSendBuffer.psMsg16->aiData[ ( iDescOffset >> 1) + 3 ], psAdiEntry[ iLocalMapIndex ].psStruct[ iDescOffset + bElemMapStartIndex].bDataType );
+ iDescOffset++;
+ }
+ }
+ pMsgSendBuffer.psMsg16->sHeader.iDataSize = iTOiLe( 6 + iDescOffset );
+ }
+#endif
+ }
+ else
+ {
+
+ abcc_FillMapExtCommand( pMsgSendBuffer.psMsg16,
+ 0 , /* Adi */
+ psDefaultMap[ iMappingIndex ].bNumElem , /* Adi total num elements */
+ 0, /* Mapping start index */
+ psDefaultMap[ iMappingIndex ].bNumElem , /* Num elements to map */
+ ABP_PAD1 ); /* Data type */
+ iLocalSize = psDefaultMap[ iMappingIndex ].bNumElem;
+
+ }
+
+ if( psDefaultMap[ iMappingIndex ].eDir == PD_READ )
+ {
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->sHeader.iCmdReserved, ABP_MSG_HEADER_C_BIT | ABP_NW_CMD_MAP_ADI_READ_EXT_AREA );
+ abcc_iPdReadBitSize += iLocalSize;
+ abcc_iPdReadSize = ( abcc_iPdReadBitSize + 7 )/8;
+ }
+ else
+ {
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->sHeader.iCmdReserved, ABP_MSG_HEADER_C_BIT | ABP_NW_CMD_MAP_ADI_WRITE_EXT_AREA );
+ abcc_iPdWriteBitSize += iLocalSize;
+ abcc_iPdWriteSize = ( abcc_iPdWriteBitSize + 7 )/8;
+ }
+ iMappingIndex++;
+
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+ break;
+ }
+ else /* If an ABCC30 is attached. */
+ {
+ iLocalSize = ABCC_GetDataTypeSize( psAdiEntry[ iLocalMapIndex ].bDataType ) * psAdiEntry[ iLocalMapIndex ].bNumOfElements;
+
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_SetHighAddrOct( pMsgSendBuffer.psMsg16->sHeader.iSourceIdDestObj, ABP_OBJ_NUM_NW );
+ pMsgSendBuffer.psMsg16->sHeader.iInstance = iTOiLe( 1 );
+ pMsgSendBuffer.psMsg16->sHeader.iDataSize = iTOiLe( 4 );
+ pMsgSendBuffer.psMsg16->sHeader.iCmdExt0CmdExt1 = iTOiLe( psAdiEntry[ iLocalMapIndex ].iInstance ); /* ADI Instance number. */
+
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->aiData[ 0 ], psAdiEntry[ iLocalMapIndex ].bDataType ); /* ADI data type. */
+ ABCC_SetHighAddrOct( pMsgSendBuffer.psMsg16->aiData[ 0 ], psAdiEntry[ iLocalMapIndex ].bNumOfElements ); /* Number of elements in ADI. */
+ pMsgSendBuffer.psMsg16->aiData[ 1 ] = iTOiLe( iLocalMapIndex + 1 ); /* ADI order number. */
+
+ if( psDefaultMap[ iMappingIndex ].eDir == PD_READ )
+ {
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->sHeader.iCmdReserved, ABP_MSG_HEADER_C_BIT | ABP_NW_CMD_MAP_ADI_READ_AREA );
+ abcc_iPdReadSize += iLocalSize;
+ }
+ else
+ {
+ ABCC_SetLowAddrOct( pMsgSendBuffer.psMsg16->sHeader.iCmdReserved, ABP_MSG_HEADER_C_BIT | ABP_NW_CMD_MAP_ADI_WRITE_AREA );
+ abcc_iPdWriteSize += iLocalSize;
+ }
+ iMappingIndex++;
+
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+ break;
+ }
+
+ case MSG_USER_INIT_START:
+ eCmdState = MSG_USER_INIT;
+ ABCC_CbfUserInitReq();
+
+ break;
+ case MSG_USER_INIT:
+ /* Do nothing */
+ break;
+
+ case MSG_READ_RDPD_SIZE:
+ /* Do nothing */
+ break;
+
+ case MSG_READ_WRPD_SIZE:
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+ ABCC_GetAttribute( pMsgSendBuffer.psMsg, ABP_OBJ_NUM_NW, 1 ,
+ ABP_NW_IA_WRITE_PD_SIZE, ABCC_GetNewSourceId() );
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+ break;
+
+ case MSG_SETUP_COMPLETE:
+
+ pMsgSendBuffer.psMsg = ABCC_GetCmdMsgBuffer();
+
+ ABCC_SetByteAttribute( pMsgSendBuffer.psMsg, ABP_OBJ_NUM_ANB, 1,
+ ABP_ANB_IA_SETUP_COMPLETE, TRUE,
+ ABCC_GetNewSourceId() );
+
+ ABCC_LinkWriteMessage( pMsgSendBuffer.psMsg);
+
+ break;
+
+ case MSG_DONE:
+ return TRUE;
+ } /* end switch( command state ) */
+ }
+
+ return FALSE;
+}
+
+
+/*------------------------------------------------------------------------------
+** SetupResponses()
+**------------------------------------------------------------------------------
+*/
+void ABCC_SetupResponses( ABP_MsgType* psMsgReciveBuffer )
+{
+ ABCC_MsgType pMsgReciveBuffer;
+ ABCC_MsgHandlerFuncType pnMsgHandler = 0;
+ pMsgReciveBuffer.psMsg = psMsgReciveBuffer;
+
+ switch( eCmdState )
+ {
+ case MSG_GET_DATA_FORMAT:
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32)ABCC_GetLowAddrOct(pMsgReciveBuffer.psMsg16->aiData[ 0 ]) );
+ eNetFormat = ( NetFormatType )ABCC_GetLowAddrOct( pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ ABCC_ASSERT( eNetFormat < 2 );
+ DEBUG_EVENT( ( "RSP MSG_DATA_FORMAT: %d\n", eNetFormat ) );
+
+ eCmdState = MSG_GET_NW_PARAM_SUPPORT;
+ break;
+
+ case MSG_GET_NW_PARAM_SUPPORT:
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32)ABCC_GetLowAddrOct( pMsgReciveBuffer.psMsg16->aiData[ 0 ] ) );
+ eParameterSupport = ( ParameterSupportType )ABCC_GetLowAddrOct ( pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ DEBUG_EVENT( ( "RSP MSG_GET_PARAM_SUPPORT: %d\n", eParameterSupport) );
+ eCmdState = MSG_GET_MODULE_TYPE;
+ break;
+
+ case MSG_GET_MODULE_TYPE:
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32) pMsgReciveBuffer.psMsg16->aiData[ 0 ]);
+ iModuleType = iLeTOi( pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ DEBUG_EVENT( ( "RSP MSG_GET_MODULE_ID: 0x%x\n",iModuleType ) );
+ eCmdState = MSG_GET_NETWORK_TYPE;
+ break;
+
+ case MSG_GET_NETWORK_TYPE:
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32) pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ iNetworkType = iLeTOi( pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ DEBUG_EVENT( ( "RSP MSG_GET_NETWORK_ID :0x%x\n", iNetworkType ) );
+
+ /*
+ ** We now have all information needed to initialize the ADIs and the mapping.
+ */
+ eCmdState = MSG_MAP_PD_READ_WRITE;
+ abcc_iNumAdi = ABCC_CbfAdiMappingReq ( (const AD_AdiEntryType** )&psAdiEntry,
+ (const AD_DefaultMapType** )&psDefaultMap );
+ break;
+
+ case MSG_USER_INIT:
+ DEBUG_EVENT( ( "RSP MSG_ABCC_USER_INIT\n" ) );
+ pnMsgHandler = ABCC_LinkGetMsgHandler( ABCC_GetLowAddrOct( pMsgReciveBuffer.psMsg16->sHeader.iSourceIdDestObj ) );
+ if( pnMsgHandler )
+ {
+ pnMsgHandler( pMsgReciveBuffer.psMsg );
+ }
+ else
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INVALID_RESP_SOURCE_ID,(UINT32) pMsgReciveBuffer.psMsg );
+ }
+ break;
+
+ case MSG_MAP_PD_READ_WRITE:
+ DEBUG_EVENT( ( "RSP MSG_MAP_IO_****\n" ) );
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32) pMsgReciveBuffer.psMsg);
+ break;
+
+ case MSG_READ_RDPD_SIZE:
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32) pMsgReciveBuffer.psMsg);
+
+ if( psDefaultMap == NULL )
+ {
+ /* Use received read size */
+ abcc_iPdReadSize = iLeTOi( pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ }
+ else
+ {
+ /* Verify that ABCC and driver has the same view */
+ ABCC_ASSERT( abcc_iPdReadSize == iLeTOi( pMsgReciveBuffer.psMsg16->aiData[ 0 ] ) );
+ }
+ eCmdState = MSG_READ_WRPD_SIZE;
+ break;
+
+ case MSG_READ_WRPD_SIZE:
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32) pMsgReciveBuffer.psMsg);
+
+ if( psDefaultMap == NULL )
+ {
+ /* Use received write size */
+ abcc_iPdWriteSize = iLeTOi( pMsgReciveBuffer.psMsg16->aiData[ 0 ] );
+ }
+ else
+ {
+ /* Verify that ABCC and driver has the same view */
+ ABCC_ASSERT(abcc_iPdWriteSize == iLeTOi( pMsgReciveBuffer.psMsg16->aiData[ 0 ] ) );
+ }
+
+ eCmdState = MSG_SETUP_COMPLETE;
+ break;
+
+ case MSG_SETUP_COMPLETE:
+ DEBUG_EVENT( ( "RSP MSG_SETUP_COMPLETE\n" ) );
+ ABCC_ASSERT_ERR( ABCC_VerifyMessage( pMsgReciveBuffer.psMsg ) == ABCC_EC_NO_ERROR, ABCC_SEV_WARNING, ABCC_EC_RESP_MSG_E_BIT_SET, (UINT32) pMsgReciveBuffer.psMsg );
+
+ DEBUG_EVENT( ( "Mapped PD size, RdPd %d WrPd: %d", abcc_iPdReadSize, abcc_iPdWriteSize ) );
+ pnABCC_DrvSetPdSize(abcc_iPdReadSize, abcc_iPdWriteSize );
+ eCmdState = MSG_DONE;
+ break;
+
+ default:
+ ABCC_ASSERT( FALSE );
+ break;
+ } /* end switch */
+}
+
+
+void ABCC_UserInitComplete( void )
+{
+ ABP_MsgType* pMsgSendBuffer;
+
+ eCmdState = MSG_READ_RDPD_SIZE;
+
+ pMsgSendBuffer = ABCC_GetCmdMsgBuffer();
+ ABCC_GetAttribute( pMsgSendBuffer, ABP_OBJ_NUM_NW, 1 ,
+ ABP_NW_IA_READ_PD_SIZE, ABCC_GetNewSourceId() );
+ ABCC_LinkWriteMessage( pMsgSendBuffer );
+}
+
+UINT16 ABCC_NetworkType( void )
+{
+ return iNetworkType;
+}
+
+UINT16 ABCC_ModuleType( void )
+{
+ return iModuleType;
+}
+
+NetFormatType ABCC_NetFormatType( void )
+{
+ return eNetFormat;
+}
+
+ParameterSupportType ABCC_ParameterSupport( void )
+{
+ return eParameterSupport;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/abcc_setup.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,94 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This program is the property of HMS Industrial Networks AB. ** +** It may not be reproduced, distributed, or used without permission ** +** of an authorized company official. ** +******************************************************************************** +******************************************************************************** +** file_description +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_SetupInit() : Init setup state amchine +** ABCC_SetupCommands() : Send next command +** ABCC_SetupResponses() : Handle setup comand response +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_SETUP_H_ +#define ABCC_SETUP_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abp.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Inititsiate internal varaibles used by the setup state machine +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SetupInit( void ); + +/*------------------------------------------------------------------------------ +** Run send next command in the setup statemachone +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** TRUE : Setup state machine has finished +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_SetupCommands( void ); + +/*------------------------------------------------------------------------------ +** Handle setup command response. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_SetupResponses( ABP_MsgType* pMsgReciveBuffer ); + + + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/abcc_timer.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,201 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Timer implementation.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_timer.h"
+#include "abcc_debug_err.h"
+#include "abcc_port.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+/*
+ * Timer resource structure
+ */
+typedef struct ABCC_TimerTimeoutType
+{
+ BOOL fActive;
+ BOOL fTmoOccured;
+ INT32 lTimeLeft;
+ ABCC_TimerTimeoutCallbackType pnHandleTimeout;
+}
+ABCC_TimerTimeoutType;
+
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+#define MAX_NUM_TIMERS 3
+static ABCC_TimerTimeoutType sTimer[ MAX_NUM_TIMERS ];
+static BOOL fTimerEnabled = FALSE;
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+void ABCC_TimerInit( void )
+{
+ ABCC_TimerHandle xHandle;
+
+ for ( xHandle = 0; xHandle < MAX_NUM_TIMERS; xHandle++ )
+ {
+ sTimer[ xHandle ].pnHandleTimeout = NULL;
+ }
+ fTimerEnabled = TRUE;
+}
+
+
+/*
+** ABCC_TimerCreateTimer()
+*/
+ABCC_TimerHandle ABCC_TimerCreate( ABCC_TimerTimeoutCallbackType pnHandleTimeout )
+{
+ ABCC_TimerHandle xHandle = ABCC_TIMER_NO_HANDLE;
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+
+ for ( xHandle = 0; xHandle < MAX_NUM_TIMERS; xHandle++ )
+ {
+ if ( sTimer[ xHandle ].pnHandleTimeout == NULL )
+ {
+ sTimer[ xHandle ].fActive = FALSE;
+ sTimer[ xHandle ].fTmoOccured = FALSE;
+ sTimer[ xHandle ].pnHandleTimeout = pnHandleTimeout;
+ break;
+ }
+ }
+ ABCC_PORT_ExitCritical();
+
+ if ( xHandle >= MAX_NUM_TIMERS )
+ {
+ xHandle = ABCC_TIMER_NO_HANDLE;
+ }
+ return( xHandle );
+}
+
+BOOL ABCC_TimerStart( ABCC_TimerHandle xHandle,
+ UINT32 lTimeoutMs )
+{
+ BOOL fTmo;
+ ABCC_PORT_UseCritical();
+
+ ABCC_ASSERT( sTimer[ xHandle ].pnHandleTimeout );
+
+ ABCC_PORT_EnterCritical();
+ fTmo = sTimer[ xHandle ].fTmoOccured;
+ sTimer[ xHandle ].lTimeLeft = (INT32)lTimeoutMs;
+ sTimer[ xHandle ].fTmoOccured = FALSE;
+ sTimer[ xHandle ].fActive = TRUE;
+
+ ABCC_PORT_ExitCritical();
+ return( fTmo );
+}
+
+
+/*
+** ABCC_TimerStopTimer()
+*/
+BOOL ABCC_TimerStop( ABCC_TimerHandle xHandle )
+{
+ BOOL fTmo;
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ fTmo = sTimer[ xHandle ].fTmoOccured;
+
+ sTimer[ xHandle ].fActive = FALSE;
+ sTimer[ xHandle ].fTmoOccured = FALSE;
+
+ ABCC_PORT_ExitCritical();
+ return( fTmo );
+}
+
+/*
+** ABCC_TimerTick()
+*/
+void ABCC_TimerTick(const INT16 iDeltaTimeMs)
+{
+ ABCC_TimerHandle xHandle;
+ ABCC_PORT_UseCritical();
+
+ if( !fTimerEnabled )
+ {
+ return;
+ }
+
+ ABCC_PORT_EnterCritical();
+
+ for ( xHandle = 0; xHandle < MAX_NUM_TIMERS; xHandle++ )
+ {
+ if ( ( sTimer[ xHandle ].pnHandleTimeout != NULL ) &&
+ ( sTimer[ xHandle ].fActive == TRUE ) )
+ {
+ sTimer[ xHandle ].lTimeLeft -= (INT32)iDeltaTimeMs;
+ if( sTimer[ xHandle ].lTimeLeft <= 0 )
+ {
+ sTimer[ xHandle ].fTmoOccured = TRUE;
+ sTimer[ xHandle ].fActive = FALSE;
+ sTimer[ xHandle ].pnHandleTimeout();
+ }
+ }
+ }
+
+ ABCC_PORT_ExitCritical();
+}
+
+void ABCC_TimerDisable( void )
+{
+ fTimerEnabled = FALSE;
+}
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/abcc_timer.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,159 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This program is the property of HMS Industrial Networks AB. ** +** It may not be reproduced, distributed, or used without permission ** +** of an authorized company official. ** +******************************************************************************** +******************************************************************************** +** Implements abcc timer service. +******************************************************************************** +******************************************************************************** +** Services: +** ABCC_TimerInit() - Init internal +** ABCC_TimerCreate() - Start Timer +** ABCC_TimerStart() - Start Timer +** ABCC_TimerStop() - Stop timer +** ABCC_TimerTick() - Tick +** ABCC_TimerDisable() - Disable tick action +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef ABCC_TIMER_H_ +#define ABCC_TIMER_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abcc_sys_adapt.h" + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +#define ABCC_TIMER_NO_HANDLE ( 0xff ) + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/* + ** Timeout callback function type. + */ +typedef void (*ABCC_TimerTimeoutCallbackType)( void ); + + +/* + ** Type for identifying timer + */ +typedef UINT8 ABCC_TimerHandle; + + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + + +/*------------------------------------------------------------------------------ +** void ABCC_TimerInit( void ); +** Need to called before the timer is used +**------------------------------------------------------------------------------ +** Arguments: +** None +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_TimerInit( void ); + + +/*------------------------------------------------------------------------------ +** Allocates a timer resource and returns a handle. +**------------------------------------------------------------------------------ +** Arguments: +** pnHandleTimeout: Function to call if timeout. +** Returns: +** ABCC_TimerHandle ( Used as identifier when using timer functions. ) +** TIMER_NO_HANDLE is returned if no timer was available +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABCC_TimerHandle ABCC_TimerCreate( ABCC_TimerTimeoutCallbackType pnHandleTimeout ); + + +/*------------------------------------------------------------------------------ +** Start timer. +** When the timeout is reached, the registered callback function is called. +** Note!! This function is dependent on that ABCC_TimerTick() is called +** on regular basis. +**------------------------------------------------------------------------------ +** Arguments: +** xHandle: Identifier of timer to be started. +** lTimeoutMs: Timeout in ms. +** +** Returns: +** TRUE if the timer had expired before re-start. +** FALSE Timer had not expired before re-start. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_TimerStart( ABCC_TimerHandle xHandle, + UINT32 lTimeoutMs ); + + +/*------------------------------------------------------------------------------ +** Stop timer. +**------------------------------------------------------------------------------ +** Arguments: +** xHandle: Identifier of timer to be stopped. +** Returns: +** FALSE If timeout is already reached +** TRUE: Timer stopped OK +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_TimerStop( ABCC_TimerHandle xHandle ); + + + +/*------------------------------------------------------------------------------ +** ABCC_TimerTick(). Provides delta time since last timer tick call. +** Typically called from timer interrupt. +**------------------------------------------------------------------------------ +** Arguments: +** iDeltaTimeMs: Time in ms since last timerTick call +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_TimerTick(const INT16 iDeltaTimeMs); + + +/*------------------------------------------------------------------------------ +** ABCC_TimerDisable(). Disable tick action +**------------------------------------------------------------------------------ +** Arguments: +** None +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_TimerDisable( void ); + + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/par/abcc_drv_par_if.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,411 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Defines the parallel driver interface. +******************************************************************************** +******************************************************************************** +** Driver services: +** ABCC_DrvParInit() - Initialize driver privates and states to default values. +** ABCC_DrvParISR() - Calls in the interrupt context to acknowledge received interrupts. +** ABCC_DrvParExecute() - Drives the internal send/receive process if applicable +** ABCC_DrvParWriteMessage() - Writes a message. +** ABCC_DrvParWriteProcessData() - Writes current process data. +** ABCC_DrvParIsReadyForWriteMessage() - Checks if the driver is ready to send a new write message. +** ABCC_DrvParIsReadyForCmd() - Checks if the Anybus is ready to receive a new command message. +** ABCC_DrvParSetNbrOfCmds() - Sets the number of simultaneous commands that is supported by the application. +** ABCC_DrvParSetAppStatus() - Sets the current application status. +** ABCC_DrvParSetPdSize() - Sets the current process data size. +** ABCC_DrvParSetMsgReceiverBuffer() - Sets the message receiver buffer. +** ABCC_DrvParSetIntMask() - Set interrupt mask +** ABCC_DrvParGetWrPdBuffer() - Get wrpd buffer +** ABCC_DrvParGetModCap() - Read module capability +** ABCC_DrvParGetLedStat() - Read led status +** ABCC_DrvParParGetIntStatus() - Get current interrupt status +** ABCC_DrvParGetAnybusState() - Get current Anybus state +** ABCC_DrvParReadProcessData() - Get read process data if any. +** ABCC_DrvParReadMessage() - Get read message if any. +** ABCC_DrvParRegisterWd() - Function to call when Wd timeOuts +** ABCC_DrvParIsSuperviced() - Is the network supervised +******************************************************************************** +******************************************************************************** +*/ + +#ifndef PHY_DRV_PAR_IF_H_ +#define PHY_DRV_PAR_IF_H_ +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abp.h" + +#if( ABCC_CFG_DRV_PARALLEL ) + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + + + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Initializes the driver to default values. +** Must be called before the driver is used. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParInit( UINT8 bOpmode ); + + +/*------------------------------------------------------------------------------ +** Calls in the interrupt context to acknowledge received interrupts. +** +** Remarks: +** The ISR routine will clear all pending interrupts. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Acknowledged interrupts. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvParISR( void ); + + +/*------------------------------------------------------------------------------ +** Drives the internal send process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParRunDriverTx( void ); + +/*------------------------------------------------------------------------------ +** Drives the internal receive process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to successfully sent write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvParRunDriverRx( void ); + + +/*------------------------------------------------------------------------------ +** Writes a message to the driver. +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg: Pointer to message. +** +** Returns: +** True: Message was successfully written and can be deallocated +** immediately. +** False: Message was not yet written and cannot be deallocated. +** The psWriteMsg pointer is owned by the driver until the +** message is written and the pointer is returned in the +** driver execution response. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvParWriteMessage( ABP_MsgType* psWriteMsg ); + + +/*------------------------------------------------------------------------------ +** Writes current process data. +** The data is copied before returning from the method. +**------------------------------------------------------------------------------ +** Arguments: +** pxProcessData: Pointer to process data to be sent. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParWriteProcessData( void* pxProcessData ); + +/*------------------------------------------------------------------------------ +** Checks if the driver is in the correct state for writing process data to the anybus +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is in correct state to send WrPd +** False: Driver is not in correct state to send Wrpd +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvParIsReadyForWrPd( void ); + + +/*------------------------------------------------------------------------------ +** Checks if the driver is ready to send a new write message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is ready to send a new write message. +** False: Driver is not ready to send a new write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvParIsReadyForWriteMessage( void ); + + +/*------------------------------------------------------------------------------ +** The host application checks if the Anybus is ready to receive a new command +** message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: OK to send new command. +** False: NOK to send new command. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvParIsReadyForCmd( void ); + + +/*------------------------------------------------------------------------------ +** Sets the number of simultaneous commands that is supported by the application. +**------------------------------------------------------------------------------ +** Arguments: +** bNbrOfCmds: Number of commands that the application is ready to receive. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParSetNbrOfCmds( UINT8 bNbrOfCmds ); + + +/*------------------------------------------------------------------------------ +** Sets the current application status. +** Note! This information is not supported by all protocols. +**------------------------------------------------------------------------------ +** Arguments: +** eAppStatus: Current application status. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParSetAppStatus( ABP_AppStatusType eAppStatus ); + + +/*------------------------------------------------------------------------------ +** Sets the current process data size. +**------------------------------------------------------------------------------ +** Arguments: +** iReadPdSize: Size of read process data (bytes) +** iWritePdSize: Size of write process data (bytes) +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize ); + + +/*------------------------------------------------------------------------------ +** Sets the receiver buffer, to be used for the next read message. +**------------------------------------------------------------------------------ +** Arguments: +** psReadMsg: Pointer where next read message will be put. +** psReadMsg is not allowed to contain a NULL value. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg ); + + +/*------------------------------------------------------------------------------ +** Sets Interrupt mask according to h_aci.h. +**------------------------------------------------------------------------------ +** Arguments: +** iIntMask: Interrupt mask set according to h_aci.h. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvParSetIntMask( const UINT16 iIntMask ); + + +/*------------------------------------------------------------------------------ +** Get WrpdBuffer for the user to update. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to WrPd buffer. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvParGetWrPdBuffer( void ); + + +/*------------------------------------------------------------------------------ +** Read module capabillity +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvParGetModCap( void ); + + +/*------------------------------------------------------------------------------ +** Read module capability +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvParGetLedStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus interrupt status. +** +** Remarks: +** The ABCC_DrvISR() function will clear all pending interrupts. This +** function must be called before ABCC_DrvISR() or it will always return 0. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus interrupt status. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvParGetIntStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus state. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus state. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvParGetAnybusState( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read process data. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read process data; or NULL if no process data to read +** was available. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvParReadProcessData( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read message; or NULL if no message is available. +** The pointer, if not NULL, will point to the buffer previously set by +** calling ABCC_DrvSetMsgReceiverBuffer(). +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvParReadMessage( void ); + +/*------------------------------------------------------------------------------ +** Returns supervision bit in status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** TRUE: The device is supervised by another network device. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvParIsSupervised( void ); + + +/*------------------------------------------------------------------------------ +** Returns anybus status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** Anybus status register +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvParGetAnbStatus ( void ); + +#endif /* ABCC_CFG_DRV_PARALLEL */ + +#endif /* inclusion lock */ + +/******************************************************************************* +** End of drv_if.h +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/par/abcc_handler_par.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,258 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** This file implements the ABCC_DunDriver() and ABCC_ISR() routine
+** for parallel operating mode.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_PARALLEL )
+
+#include "abcc_td.h"
+#include "../abcc_drv_if.h"
+#include "abp.h"
+#include "abcc.h"
+#include "../abcc_link.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_debug_err.h"
+#include "../abcc_handler.h"
+#include "../abcc_timer.h"
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+#ifndef ABCC_CFG_SYNC_ENABLE
+#define ABCC_CFG_SYNC_ENABLE ( FALSE )
+#endif
+
+#ifndef ABCC_CFG_USE_ABCC_SYNC_SIGNAL
+#define ABCC_CFG_USE_ABCC_SYNC_SIGNAL ( FALSE )
+#endif
+
+#if ( ABCC_CFG_INT_ENABLE_MASK_PAR & ABP_INTMASK_SYNCIEN )
+#error "Use ABCC_CFG_USE_ABCC_SYNC_SIGNAL define in abcc_drv_cfg.h to choose sync interrupt source. Do not use ABP_INTMASK_SYNCIEN"
+#endif
+
+#ifndef ABCC_CFG_HANDLE_INT_IN_ISR_MASK
+#define ABCC_CFG_HANDLE_INT_IN_ISR_MASK ( 0 )
+#endif
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Translates the ABP Interrupt status register value to the driver's ISR Event
+** bit definitions (ABCC_ISR_EVENT_X).
+**------------------------------------------------------------------------------
+** Arguments:
+** iIntStatus - ABP Interrupt status register value
+**
+** Returns:
+** Bit field composed of ABCC_ISR_EVENT_X bit definitions
+**------------------------------------------------------------------------------
+*/
+static UINT16 AbpIntStatusToAbccIsrEvent( UINT16 iIntStatus )
+{
+ UINT16 iAbccIsrEvents;
+
+ iAbccIsrEvents = 0;
+
+ if( iIntStatus & ABP_INTSTATUS_RDPDI )
+ {
+ iAbccIsrEvents |= ABCC_ISR_EVENT_RDPD;
+ }
+
+ if( iIntStatus & ABP_INTSTATUS_RDMSGI )
+ {
+ iAbccIsrEvents |= ABCC_ISR_EVENT_RDMSG;
+ }
+
+ if( ( iIntStatus & ABP_INTSTATUS_WRMSGI ) ||
+ ( iIntStatus & ABP_INTSTATUS_ANBRI ) )
+ {
+ iAbccIsrEvents |= ABCC_ISR_EVENT_WRMSG;
+ }
+
+ if( iIntStatus & ABP_INTSTATUS_STATUSI )
+ {
+ iAbccIsrEvents |= ABCC_ISR_EVENT_STATUS;
+ }
+
+ return( iAbccIsrEvents );
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ABCC_RunDriver()
+**------------------------------------------------------------------------------
+*/
+ABCC_ErrorCodeType ABCC_ParRunDriver( void )
+{
+ ABCC_MainStateType eMainState = ABCC_GetMainState();
+
+ if( eMainState < ABCC_DRV_SETUP )
+ {
+ if( eMainState != ABCC_DRV_ERROR )
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INCORRECT_STATE, 0 );
+ ABCC_SetMainStateError();
+ }
+
+ return( ABCC_EC_INCORRECT_STATE );
+ }
+
+ if( ( ABCC_iInterruptEnableMask & ( ABP_INTMASK_WRMSGIEN | ABP_INTMASK_ANBRIEN ) ) == 0 )
+ {
+ ABCC_LinkCheckSendMessage();
+ }
+
+ if( ( ABCC_iInterruptEnableMask & ABP_INTMASK_RDPDIEN ) == 0 )
+ {
+ ABCC_TriggerRdPdUpdate();
+ }
+
+ if( ( ABCC_iInterruptEnableMask & ABP_INTMASK_STATUSIEN ) == 0 )
+ {
+ ABCC_TriggerAnbStatusUpdate();
+ }
+
+ if( ( ABCC_iInterruptEnableMask & ABP_INTMASK_RDMSGIEN ) == 0 )
+ {
+ ABCC_TriggerReceiveMessage();
+ }
+
+ return( ABCC_EC_NO_ERROR );
+}
+#if( ABCC_CFG_INT_ENABLED )
+void ABCC_ParISR( void )
+{
+ UINT16 iIntStatus;
+ UINT16 iIntToHandleInISR;
+ UINT16 iEventToHandleInCbf;
+ ABCC_MainStateType eMainState;
+
+ eMainState = ABCC_GetMainState();
+
+ /*
+ ** Let the driver handle the interrupt and clear the interrupt register.
+ */
+ iIntStatus = pnABCC_DrvISR();
+
+ if( eMainState < ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ return;
+ }
+
+ if( eMainState == ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ ABCC_SetReadyForCommunication();
+ return;
+ }
+
+ /*
+ ** Only handle event defined in ABCC_CFG_HANDLE_INT_IN_ISR_MASK
+ ** Special case for sync. If sync is supported and the sync signal
+ ** is not used.
+ */
+#if( ABCC_CFG_SYNC_ENABLE && !ABCC_CFG_USE_ABCC_SYNC_SIGNAL )
+ iIntToHandleInISR = iIntStatus & ( ABCC_CFG_HANDLE_INT_IN_ISR_MASK | ABP_INTSTATUS_SYNCI );
+
+ if( iIntToHandleInISR & ABP_INTSTATUS_SYNCI )
+ {
+ ABCC_CbfSyncIsr();
+ }
+#else
+ iIntToHandleInISR = iIntStatus & ABCC_CFG_HANDLE_INT_IN_ISR_MASK;
+#endif
+
+
+ if( iIntToHandleInISR & ABP_INTSTATUS_RDPDI )
+ {
+ ABCC_TriggerRdPdUpdate();
+ }
+
+ if( iIntToHandleInISR & ABP_INTSTATUS_STATUSI )
+ {
+ ABCC_TriggerAnbStatusUpdate();
+ }
+
+ if( iIntToHandleInISR & ABP_INTSTATUS_RDMSGI )
+ {
+ ABCC_TriggerReceiveMessage();
+ }
+
+ if( ( iIntToHandleInISR & ABP_INTSTATUS_WRMSGI ) ||
+ ( iIntToHandleInISR & ABP_INTSTATUS_ANBRI ) )
+ {
+ /*
+ ** Check if there is something in the queue to be sent.
+ */
+ ABCC_LinkCheckSendMessage();
+ }
+
+ if( ( iIntStatus & ~ABCC_CFG_HANDLE_INT_IN_ISR_MASK ) != 0 )
+ {
+ iEventToHandleInCbf = AbpIntStatusToAbccIsrEvent( iIntStatus & ~ABCC_CFG_HANDLE_INT_IN_ISR_MASK );
+
+ if( iEventToHandleInCbf != 0 )
+ {
+ ABCC_CbfEvent( iEventToHandleInCbf );
+ }
+ }
+}
+#else
+void ABCC_ParISR( void )
+{
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INTERNAL_ERROR, 0);
+}
+#endif
+
+#endif /* ABCC_CFG_DRV_PARALLEL */
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/par/abcc_par_drv.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,519 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Parallel (PARI) driver implementation.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_PARALLEL )
+
+#include "abcc_td.h"
+#include "../abcc_debug_err.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_timer.h"
+#include "../abcc_drv_if.h"
+#include "../abcc_mem.h"
+#include "abp.h"
+#include "abcc_sys_adapt_par.h"
+#include "../abcc_handler.h"
+#include "abcc_port.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static ABCC_MsgType par_drv_uReadMessageData;
+static void* par_drv_pbRdPdBuffer;
+
+static UINT16 par_drv_iSizeOfReadPd;
+static UINT16 par_drv_iSizeOfWritePd;
+
+static UINT8 par_drv_bNbrOfCmds; /* Number of commands supported by the application. */
+
+static const UINT16 iWRPDFlag = 0x01;
+static const UINT16 iRDPDFlag = 0x02;
+static const UINT16 iWRMSGFlag = 0x04;
+static const UINT16 iRDMSGFlag = 0x08;
+static const UINT16 iANBRFlag = 0x10;
+static const UINT16 iAPPRFlag = 0x20;
+static const UINT16 iAPPRCLRFlag = 0x40;
+
+#define ABCC_MSG_HEADER_TYPE_SIZEOF 12
+
+#ifdef ABCC_SYS_16_BIT_CHAR
+static const UINT16 iWrMsgAdrOffset = ABP_WRMSG_ADR_OFFSET / 2;
+static const UINT16 iRdMsgAdrOffset = ABP_RDMSG_ADR_OFFSET / 2;
+static const UINT16 iModCapAdrOffset = ABP_MODCAP_ADR_OFFSET / 2;
+static const UINT16 iLedStatusAdrOffset = ABP_LEDSTATUS_ADR_OFFSET / 2;
+static const UINT16 iAppStatusAdrOffset = ABP_APPSTATUS_ADR_OFFSET / 2;
+static const UINT16 iAnbStatusAdrOffset = ABP_ANBSTATUS_ADR_OFFSET / 2;
+static const UINT16 iBufCtrlAdrOffset = ABP_BUFCTRL_ADR_OFFSET / 2;
+static const UINT16 iMsgHdrEndAdrOffset = ABCC_MSG_HEADER_TYPE_SIZEOF / 2;
+static const UINT16 iIntMaskAdrOffset = ABP_INTMASK_ADR_OFFSET / 2;
+static const UINT16 iIntStatusAdrOffset = ABP_INTSTATUS_ADR_OFFSET / 2;
+#else
+static const UINT16 iWrMsgAdrOffset = ABP_WRMSG_ADR_OFFSET;
+static const UINT16 iRdMsgAdrOffset = ABP_RDMSG_ADR_OFFSET;
+static const UINT16 iModCapAdrOffset = ABP_MODCAP_ADR_OFFSET;
+static const UINT16 iLedStatusAdrOffset = ABP_LEDSTATUS_ADR_OFFSET;
+static const UINT16 iAppStatusAdrOffset = ABP_APPSTATUS_ADR_OFFSET;
+static const UINT16 iAnbStatusAdrOffset = ABP_ANBSTATUS_ADR_OFFSET;
+static const UINT16 iBufCtrlAdrOffset = ABP_BUFCTRL_ADR_OFFSET;
+static const UINT16 iMsgHdrEndAdrOffset = ABCC_MSG_HEADER_TYPE_SIZEOF;
+static const UINT16 iIntMaskAdrOffset = ABP_INTMASK_ADR_OFFSET;
+static const UINT16 iIntStatusAdrOffset = ABP_INTSTATUS_ADR_OFFSET;
+
+#endif
+
+/*******************************************************************************
+** Private forward declarations
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+void ABCC_DrvParInit( UINT8 bOpmode )
+{
+ /*
+ ** Initialize privates and states.
+ */
+
+ ABCC_ASSERT_ERR( ( bOpmode == 7) || ( bOpmode == 8) , ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+
+ par_drv_iSizeOfReadPd = 0;
+ par_drv_iSizeOfWritePd = 0;
+ par_drv_bNbrOfCmds = 0;
+ par_drv_pbRdPdBuffer = ABCC_DrvParallelGetRdPdBuffer();
+}
+
+
+void ABCC_DrvParSetIntMask( const UINT16 iIntMask )
+{
+ ABCC_DrvWrite16( iIntMaskAdrOffset, iTOiLe( iIntMask ) ) ;
+}
+
+#if( ABCC_CFG_INT_ENABLED )
+UINT16 ABCC_DrvParISR( void )
+{
+ UINT16 iIntStatus;
+ UINT16 iIntToHandle;
+
+ /*---------------------------------------------------------------------------
+ ** Read the interrupt status register and acknowledge all interrupts.
+ ** Read interrupt status until all enabled interrupts are acknowledged.
+ ** This will make sure that edge triggered interrupt always will trigger
+ ** even if a new event has occurred between the int status read the
+ ** acknowledge.
+ **---------------------------------------------------------------------------
+ */
+ iIntStatus = ABCC_DrvRead16( iIntStatusAdrOffset );
+ ABCC_DrvWrite16( iIntStatusAdrOffset, iIntStatus );
+ iIntStatus = ( iLeTOi( iIntStatus ) ) & ABCC_iInterruptEnableMask;
+ iIntToHandle = iIntStatus;
+
+ while( iIntStatus != 0 )
+ {
+ iIntStatus = ABCC_DrvRead16( iIntStatusAdrOffset );
+ ABCC_DrvWrite16( iIntStatusAdrOffset, iIntStatus );
+ iIntStatus = ( iLeTOi( iIntStatus ) ) & ABCC_iInterruptEnableMask;
+ iIntToHandle |= iIntStatus;
+ }
+
+ return iIntToHandle;
+}
+#else
+UINT16 ABCC_DrvParISR( void )
+{
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INTERNAL_ERROR, 0);
+ return 0;
+}
+#endif
+
+
+
+ABP_MsgType* ABCC_DrvParRunDriverRx( void )
+{
+ /*
+ ** Always NULL for the parallel interface.
+ */
+ return NULL;
+}
+
+
+BOOL ABCC_DrvParWriteMessage( ABP_MsgType* psWriteMsg )
+{
+ UINT16 iBufControlWriteFlags;
+ ABCC_MsgType uMsg;
+ iBufControlWriteFlags = 0;
+ ABCC_ASSERT( psWriteMsg );
+ uMsg.psMsg = psWriteMsg;
+
+ /*
+ ** Write message data.
+ **
+ ** Note: The application is only allowed to write to the write message
+ ** area when the WRMSG bit it set to 0.
+ ** However, the !( iBufControl & iWRMSGFlag ) check should have
+ ** already been performed inside link.c, and is thus not required here.
+ */
+#ifdef MSG_TIMING
+ /*Toggle led for timing measurement*/
+ GPIO_OUT0 = 0;
+#endif
+ ABCC_DrvParallelWrite( iWrMsgAdrOffset, psWriteMsg, ABCC_MSG_HEADER_TYPE_SIZEOF + iLeTOi( psWriteMsg->sHeader.iDataSize ) );
+
+ iBufControlWriteFlags |= iWRMSGFlag;
+
+ /*
+ ** Determine if command messages (instead of response messages) can be sent.
+ */
+ if( !( ABCC_GetLowAddrOct( (uMsg.psMsg16->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT ) ) )
+ {
+ /*
+ ** A command message has been received by the host application and a
+ ** response message (not a command message) will be sent back to the
+ ** Anybus. The number of commands the host application can receive
+ ** shall be increased by one, as a previous received command is now
+ ** handled.
+ */
+ par_drv_bNbrOfCmds++;
+
+ /*
+ ** When a change of the number of commands which the host application
+ ** can receive is made from 0 to 1, it means that we can set the APPRF
+ ** flag again to indicate for the Anybus that the host is now ready to
+ ** receive a new command.
+ */
+ if( par_drv_bNbrOfCmds == 1 )
+ {
+ iBufControlWriteFlags |= iAPPRFlag;
+ }
+ }
+ /*
+ ** Update the buffer control register.
+ */
+
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iBufControlWriteFlags ) );
+#ifdef MSG_TIMING
+ /*Toggle led for timing measurement*/
+ GPIO_OUT0 = 1;
+#endif
+ return( TRUE );
+}
+
+
+void ABCC_DrvParWriteProcessData( void* pxProcessData )
+{
+
+ if( par_drv_iSizeOfWritePd )
+ {
+ /*
+ ** Write process data.
+ */
+ ABCC_DrvWriteWrPd( pxProcessData, par_drv_iSizeOfWritePd );
+
+ /*
+ ** Update the buffer control register.
+ */
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iWRPDFlag ) );
+#ifdef PD_TIMING
+ /*Toggle led for timing measurement*/
+ GPIO_OUT0 = 1;
+#endif
+ }
+}
+
+
+BOOL ABCC_DrvParIsReadyForWriteMessage( void )
+{
+ UINT16 iBufControl;
+ iBufControl = ABCC_DrvRead16( iBufCtrlAdrOffset );
+
+ return( !( iLeTOi( iBufControl ) & iWRMSGFlag ) );
+}
+
+
+BOOL ABCC_DrvParIsReadyForCmd( void )
+{
+ UINT16 iBufControl;
+ iBufControl = ABCC_DrvRead16( iBufCtrlAdrOffset );
+ iBufControl = iLeTOi( iBufControl );
+ return( !( iBufControl & iWRMSGFlag ) && ( iBufControl & iANBRFlag ) );
+}
+
+
+void ABCC_DrvParSetNbrOfCmds( UINT8 bNbrOfCmds )
+{
+ par_drv_bNbrOfCmds = bNbrOfCmds;
+
+ /*
+ ** Acknowledge that we are ready to accept the first command message.
+ */
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iAPPRFlag ) );
+}
+
+
+void ABCC_DrvParSetAppStatus( ABP_AppStatusType eAppStatus )
+{
+ ABCC_DrvWrite16( iAppStatusAdrOffset, iTOiLe( (UINT16)eAppStatus ) );
+}
+
+
+void ABCC_DrvParSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize )
+{
+ par_drv_iSizeOfReadPd = iReadPdSize;
+ par_drv_iSizeOfWritePd = iWritePdSize;
+}
+
+
+static void DrvParSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg )
+{
+ par_drv_uReadMessageData.psMsg = psReadMsg;
+}
+
+
+UINT16 ABCC_DrvParGetIntStatus( void )
+{
+ UINT16 iIntStatus;
+
+ iIntStatus = ABCC_DrvRead16( iIntStatusAdrOffset );
+
+ return iLeTOi( iIntStatus );
+}
+
+UINT8 ABCC_DrvParGetAnybusState( void )
+{
+ UINT16 iAnbStatus;
+
+ /*
+ ** Reading out the Anybus status.
+ */
+ iAnbStatus = ABCC_DrvRead16( iAnbStatusAdrOffset );
+
+ /*
+ ** The Anybus state is stored in bits 0-2 of the read register.
+ */
+ return( (UINT8)( iLeTOi( iAnbStatus ) & 0x07 ) );
+}
+
+
+void* ABCC_DrvParReadProcessData( void )
+{
+ UINT16 iBufctrl;
+
+ /*
+ ** Check if the Anybus has updated the read process data.
+ */
+ iBufctrl = ABCC_DrvRead16( iBufCtrlAdrOffset );
+
+ if( iLeTOi( iBufctrl ) & iRDPDFlag )
+ {
+ /*
+ ** The RDPD flag must be set before we try to read the process data.
+ ** Otherwise the buffers won't be switched and we won't have any process
+ ** data available.
+ */
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iRDPDFlag ) );
+
+ /*
+ ** We have process data to read.
+ */
+ ABCC_DrvReadRdPd( par_drv_pbRdPdBuffer, par_drv_iSizeOfReadPd );
+
+ return( par_drv_pbRdPdBuffer );
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+ABP_MsgType* ABCC_DrvParReadMessage( void )
+{
+ UINT16 iBufctrl;
+ UINT16 iMsgSize;
+
+ iBufctrl = ABCC_DrvRead16( iBufCtrlAdrOffset );
+
+ if( iLeTOi( iBufctrl ) & iRDMSGFlag )
+ {
+ DrvParSetMsgReceiverBuffer( ABCC_MemAlloc() );
+
+ if( par_drv_uReadMessageData.psMsg == NULL )
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_OUT_OF_MSG_BUFFERS, 0 );
+ return( NULL );
+ }
+
+ /*
+ ** We have message data to read. First read the header and check the size
+ ** of data area.
+ */
+ ABCC_DrvParallelRead( iRdMsgAdrOffset, par_drv_uReadMessageData.psMsg16, ABCC_MSG_HEADER_TYPE_SIZEOF );
+
+ iMsgSize = iLeTOi( par_drv_uReadMessageData.psMsg16->sHeader.iDataSize );
+
+ if( iMsgSize > ABCC_CFG_MAX_MSG_SIZE )
+ {
+ /*
+ ** Message size exceeds buffer.
+ */
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_RDMSG_SIZE_ERR, 0 );
+
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iRDMSGFlag ) );
+ return( NULL );
+ }
+
+ /*
+ ** Continue reading data area if > 0.
+ */
+ if( iMsgSize > 0 )
+ {
+ ABCC_DrvParallelRead( iRdMsgAdrOffset + iMsgHdrEndAdrOffset,
+ par_drv_uReadMessageData.psMsg16->aiData,
+ iMsgSize );
+ }
+
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iRDMSGFlag ) );
+
+ /*
+ ** Determine if command messages (instead of response messages) can be read.
+ */
+ if( ABCC_GetLowAddrOct( par_drv_uReadMessageData.psMsg16->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT )
+ {
+ /*
+ ** A command messages has been sent by the Anybus and it has been read
+ ** by the host application. The number of commands allowed by the host
+ ** application must be decreased by one.
+ */
+ par_drv_bNbrOfCmds--;
+
+ /*
+ ** Indicates that the host application is not ready to receive a new
+ ** command from the Anybus. Writing to this register must only be done
+ ** when the RDMSG bit is set to 1. A check is not required however,
+ ** since the RDMSG bit is set to 1 a few lines higher up in the code.
+ */
+ if( par_drv_bNbrOfCmds == 0 )
+ {
+ /*
+ ** Update the buffer control register.
+ */
+ ABCC_DrvWrite16( iBufCtrlAdrOffset, iTOiLe( iAPPRCLRFlag ) );
+ }
+ }
+
+ return( par_drv_uReadMessageData.psMsg );
+ }
+ else
+ {
+ return( NULL );
+ }
+}
+
+void* ABCC_DrvParGetWrPdBuffer( void )
+{
+ return ABCC_DrvParallelGetWrPdBuffer();
+}
+
+UINT16 ABCC_DrvParGetModCap( void )
+{
+ UINT16 iModCap;
+ iModCap = ABCC_DrvRead16( iModCapAdrOffset );
+ return iLeTOi( iModCap );
+}
+
+
+UINT16 ABCC_DrvParGetLedStatus( void )
+{
+ UINT16 iLedStatus;
+ iLedStatus = ABCC_DrvRead16( iLedStatusAdrOffset );
+ return iLeTOi( iLedStatus );
+}
+
+BOOL ABCC_DrvParIsReadyForWrPd( void )
+{
+ return TRUE;
+}
+
+
+BOOL ABCC_DrvParIsSupervised( void )
+{
+ UINT16 iAnbStatus;
+ /*
+ ** Reading out the Anybus status.
+ */
+ iAnbStatus = ABCC_DrvRead16( iAnbStatusAdrOffset );
+ iAnbStatus = iLeTOi( iAnbStatus );
+
+ /*
+ ** The Anybus supervision bis is stored in bit 3
+ */
+ return( ( iAnbStatus >> 3 ) & 1 );
+
+}
+
+UINT8 ABCC_DrvParGetAnbStatus( void )
+{
+ UINT16 iAnbStatus;
+ /*
+ ** Reading out the Anybus status.
+ */
+ iAnbStatus = ABCC_DrvRead16( iAnbStatusAdrOffset );
+ iAnbStatus = iLeTOi( iAnbStatus );
+ return (UINT8)iAnbStatus & 0xf ;
+
+}
+#endif
+
+
+
+/*******************************************************************************
+** End of par_drv.c
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/par30/abcc_drv_par30_if.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,409 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Defines the generic driver interface implemented by each specific driver. +******************************************************************************** +******************************************************************************** +** Driver services: +** ABCC_DrvPar30Init() - Initialize driver privates and states to default values. +** ABCC_DrvPar30ISR() - Calls in the interrupt context to acknowledge received interrupts. +** ABCC_DrvPar30Execute() - Drives the internal send/receive process if applicable +** ABCC_DrvPar30WriteMessage() - Writes a message. +** ABCC_DrvPar30WriteProcessData() - Writes current process data. +** ABCC_DrvPar30IsReadyForWriteMessage() - Checks if the driver is ready to send a new write message. +** ABCC_DrvPar30IsReadyForCmd() - Checks if the Anybus is ready to receive a new command message. +** ABCC_DrvPar30SetNbrOfCmds() - Sets the number of simultaneous commands that is supported by the application. +** ABCC_DrvPar30SetAppStatus() - Sets the current application status. +** ABCC_DrvPar30SetPdSize() - Sets the current process data size. +** ABCC_DrvPar30SetMsgReceiverBuffer() - Sets the message receiver buffer. +** ABCC_DrvPar30SetIntMask() - Set interrupt mask +** ABCC_DrvPar30GetWrPdBuffer() - Get wrpd buffer +** ABCC_DrvPar30GetModCap() - Read module capability +** ABCC_DrvPar30GetLedStat() - Read led status +** ABCC_DrvPar30GetIntStatus() - Get current interrupt status +** ABCC_DrvPar30GetAnybusState() - Get current Anybus state +** ABCC_DrvPar30ReadProcessData() - Get read process data if any. +** ABCC_DrvPar30ReadMessage() - Get read message if any. +** ABCC_DrvPar30RegisterWd() - Function to call when Wd timeOuts +** ABCC_DrvPar30IsSuperviced() - Is the network supervised +******************************************************************************** +******************************************************************************** +*/ + +#ifndef PHY_DRV_PAR30_IF_H_ +#define PHY_DRV_PAR30_IF_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abp.h" + +#if( ABCC_CFG_DRV_PARALLEL_30 ) +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Initializes the driver to default values. +** Must be called before the driver is used. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30Init( UINT8 bOpmode ); + + +/*------------------------------------------------------------------------------ +** Calls in the interrupt context to acknowledge received interrupts. +** +** Remarks: +** The ISR routine will clear all pending interrupts. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Acknowledged interrupts. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvPar30ISR( void ); + + +/*------------------------------------------------------------------------------ +** Drives the internal send process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30RunDriverTx( void ); + +/*------------------------------------------------------------------------------ +** Drives the internal receive process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to successfully sent write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvPar30RunDriverRx( void ); + + +/*------------------------------------------------------------------------------ +** Writes a message to the driver. +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg: Pointer to message. +** +** Returns: +** True: Message was successfully written and can be deallocated +** immediately. +** False: Message was not yet written and cannot be deallocated. +** The psWriteMsg pointer is owned by the driver until the +** message is written and the pointer is returned in the +** driver execution response. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvPar30WriteMessage( ABP_MsgType* psWriteMsg ); + + +/*------------------------------------------------------------------------------ +** Writes current process data. +** The data is copied before returning from the method. +**------------------------------------------------------------------------------ +** Arguments: +** pxProcessData: Pointer to process data to be sent. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30WriteProcessData( void* pxProcessData ); + +/*------------------------------------------------------------------------------ +** Checks if the driver is in the correct state for writing process data to the anybus +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is in correct state to send WrPd +** False: Driver is not in correct state to send Wrpd +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvPar30IsReadyForWrPd( void ); + + +/*------------------------------------------------------------------------------ +** Checks if the driver is ready to send a new write message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is ready to send a new write message. +** False: Driver is not ready to send a new write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvPar30IsReadyForWriteMessage( void ); + + +/*------------------------------------------------------------------------------ +** The host application checks if the Anybus is ready to receive a new command +** message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: OK to send new command. +** False: NOK to send new command. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvPar30IsReadyForCmd( void ); + + +/*------------------------------------------------------------------------------ +** Sets the number of simultaneous commands that is supported by the application. +**------------------------------------------------------------------------------ +** Arguments: +** bNbrOfCmds: Number of commands that the application is ready to receive. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30SetNbrOfCmds( UINT8 bNbrOfCmds ); + + +/*------------------------------------------------------------------------------ +** Sets the current application status. +** Note! This information is not supported by all protocols. +**------------------------------------------------------------------------------ +** Arguments: +** eAppStatus: Current application status. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30SetAppStatus( ABP_AppStatusType eAppStatus ); + + +/*------------------------------------------------------------------------------ +** Sets the current process data size. +**------------------------------------------------------------------------------ +** Arguments: +** iReadPdSize: Size of read process data (bytes) +** iWritePdSize: Size of write process data (bytes) +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30SetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize ); + + +/*------------------------------------------------------------------------------ +** Sets the receiver buffer, to be used for the next read message. +**------------------------------------------------------------------------------ +** Arguments: +** psReadMsg: Pointer where next read message will be put. +** psReadMsg is not allowed to contain a NULL value. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30SetMsgReceiverBuffer( ABP_MsgType* const psReadMsg ); + + +/*------------------------------------------------------------------------------ +** Sets Interrupt mask according to h_aci.h. +**------------------------------------------------------------------------------ +** Arguments: +** iIntMask: Interrupt mask set according to h_aci.h. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvPar30SetIntMask( const UINT16 iIntMask ); + + +/*------------------------------------------------------------------------------ +** Get WrpdBuffer for the user to update. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to WrPd buffer. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvPar30GetWrPdBuffer( void ); + + +/*------------------------------------------------------------------------------ +** Read module capabillity +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvPar30GetModCap( void ); + + +/*------------------------------------------------------------------------------ +** Read module capability +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvPar30GetLedStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus interrupt status. +** +** Remarks: +** The ABCC_DrvISR() function will clear all pending interrupts. This +** function must be called before ABCC_DrvISR() or it will always return 0. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus interrupt status. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvPar30GetIntStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus state. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus state. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvPar30GetAnybusState( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read process data. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read process data; or NULL if no process data to read +** was available. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvPar30ReadProcessData( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read message; or NULL if no message is available. +** The pointer, if not NULL, will point to the buffer previously set by +** calling ABCC_DrvSetMsgReceiverBuffer(). +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvPar30ReadMessage( void ); + +/*------------------------------------------------------------------------------ +** Returns supervision bit in status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** TRUE: The device is supervised by another network device. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvPar30IsSupervised( void ); + + +/*------------------------------------------------------------------------------ +** Returns anybus status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** Anybus status register +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvPar30GetAnbStatus( void ); + + +#endif /* ABCC_CFG_DRV_PARALLEL_30 */ + +#endif /* inclusion lock */ + +/******************************************************************************* +** End of drv_if.h +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/par30/abcc_handler_par30.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,138 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** ** This file implements the ABCC_DunDriver() and ABCC_ISR() routine
+** for parallel ping/pong operating mode.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc_port.h"
+
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+
+#include "abcc_td.h"
+#include "../abcc_drv_if.h"
+#include "abp.h"
+#include "abcc.h"
+#include "../abcc_link.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_debug_err.h"
+#include "../abcc_handler.h"
+#include "../abcc_timer.h"
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Functions
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ABCC_RunDriver()
+**------------------------------------------------------------------------------
+*/
+ABCC_ErrorCodeType ABCC_Par30RunDriver( void )
+{
+ ABCC_MainStateType eMainState = ABCC_GetMainState();
+ if ( eMainState < ABCC_DRV_SETUP )
+ {
+ if ( eMainState != ABCC_DRV_ERROR )
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_INCORRECT_STATE, 0);
+ ABCC_SetMainStateError();
+ }
+ return( ABCC_EC_INCORRECT_STATE );
+ }
+
+#if( !ABCC_CFG_INT_ENABLED )
+ (void)pnABCC_DrvRunDriverRx();
+ ABCC_TriggerRdPdUpdate();
+ ABCC_TriggerAnbStatusUpdate();
+ ABCC_TriggerReceiveMessage();
+#endif
+ ABCC_CheckWrPdUpdate();
+ ABCC_LinkCheckSendMessage();
+ pnABCC_DrvRunDriverTx();
+
+ return( ABCC_EC_NO_ERROR );
+ /* end of AnybusMain() */
+}
+
+
+#if( ABCC_CFG_INT_ENABLED )
+void ABCC_Par30ISR()
+{
+ ABCC_MainStateType eMainState;
+
+ eMainState = ABCC_GetMainState();
+
+ if ( eMainState < ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ return;
+ }
+
+ if ( eMainState == ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ ABCC_SetReadyForCommunication();
+ }
+ /*
+ ** Let the driver handle the interrupt and clear the interrupt register.
+ */
+ (void)pnABCC_DrvISR();
+
+ ABCC_LinkRunDriverRx();
+ ABCC_TriggerRdPdUpdate();
+ ABCC_TriggerAnbStatusUpdate();
+ ABCC_TriggerReceiveMessage();
+}
+#else
+void ABCC_Par30ISR()
+{
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INTERNAL_ERROR, 0);
+}
+#endif
+
+#endif /* ABCC_CFG_DRV_PARALLEL_30 */
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/par30/abcc_par30_drv.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,601 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Parallel (PARI) driver implementation.
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_PARALLEL_30 )
+
+#include "abcc_td.h"
+#include "../abcc_debug_err.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_timer.h"
+#include "../abcc_drv_if.h"
+#include "../abcc_mem.h"
+#include "abp.h"
+#include "abcc_sys_adapt_par.h"
+#include "abcc_port.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+typedef enum ABCC_DrvPar30State
+{
+ SM_RDY_TO_PING,
+ SM_WAITING_FOR_PONG,
+ SM_SER_INIT
+}
+ABCC_DrvPar30StateType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static ABP_MsgType* par_drv_pbReadMessageData;
+static UINT8* par_drv_pbRdPdBuffer;
+
+static UINT16 par_drv_iSizeOfReadPd;
+static UINT16 par_drv_iSizeOfWritePd;
+
+static UINT8 par_drv_bNbrOfCmds; /* Number of commands supported by the application. */
+static ABCC_TimerHandle xWdTmoHandle;
+static BOOL fWdTmo; /* Current wd timeout status */
+static BOOL drv_fLegacy; /* USe legacy format */
+
+/*
+** Working copies of the status and control registers
+*/
+static volatile UINT8 bControlReg = ABP_CTRL_R_BIT;
+static volatile UINT8 bStatusReg = 0x80;
+static volatile ABCC_DrvPar30StateType eState = SM_SER_INIT;
+
+
+
+/*******************************************************************************
+** Private forward declarations
+********************************************************************************
+*/
+
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+/*
+** Converting to/from legacy message format.
+**
+** ABCC40 msg header Leagcy msg header
+** --------------------
+** | UINT16 iDataSize |
+** --------------------
+** | UINT16 iReserved |
+** -------------------- --------------------
+** | UINT8 bSourceId | | UINT8 bSourceId |
+** -------------------- --------------------
+** | UINT8 bDestObj | | UINT8 bDestObj |
+** -------------------- --------------------
+** | UINT8 bSourceId | | UINT8 bSourceId |
+** -------------------- --------------------
+** | UINT16 iInstance | | UINT16 iInstance |
+** -------------------- --------------------
+** | UINT8 bReserved | | UINT8 bDataSize |
+** -------------------- --------------------
+** | UINT8 bCmdExt0 | | UINT8 bCmdExt0 |
+** -------------------- --------------------
+** | UINT8 bCmdExt1 | | UINT8 bCmdExt1 |
+** -------------------- --------------------
+**
+** The last 8 bytes in the new message format
+** structured the same way as the legacy message format
+** except for bReserved which is placed on the legacy
+** bDataSize position.
+**
+** This means that the conversion from "new" meessage format
+** to legacy format
+** is simply done by copying the iDataSize to the bReserved
+** filed and the message is sent from the bsourceId address position.
+**
+**
+** Read message are converted the same way. The data from
+** ACI are copied to the bSourceId address position. The bReserved
+** field are copied to the iDataSize filed.
+**
+** Note that the iDataSize need to be converted to/from little endian.
+**
+*/
+static void drv_DoMsgWrite( ABP_MsgType* psMsg )
+{
+ /*
+ ** First Calculate total message size
+ */
+ UINT16 iMsgSize = iLeTOi( psMsg->sHeader.iDataSize );
+
+ ABCC_ASSERT( iMsgSize < ABP_MAX_MSG_DATA_BYTES );
+ iMsgSize += sizeof( ABP_MsgHeaderType );
+
+ ABCC_DrvParallelWrite( ABP_WRMSG_ADR_OFFSET, (UINT8*)psMsg, iMsgSize );
+}
+
+
+static void drv_DoLegacyMsgWrite( ABP_MsgType* psMsg )
+{
+ UINT16 iMsgSize = iLeTOi( psMsg->sHeader.iDataSize );
+
+ ABCC_ASSERT( iMsgSize <= ABP_MAX_MSG_255_DATA_BYTES );
+ iMsgSize += sizeof( ABP_Msg255HeaderType );
+ psMsg->sHeader.bReserved = (UINT8)psMsg->sHeader.iDataSize;
+ ABCC_DrvParallelWrite( ABP_WRMSG_LEGACY_ADR_OFFSET, (UINT8*)&psMsg->sHeader.bSourceId, iMsgSize );
+}
+
+static void drv_DoMsgRead( ABP_MsgType* psMsg )
+{
+ UINT16 iMsgSize;
+
+ ABCC_DrvParallelRead( ABP_RDMSG_ADR_OFFSET, (UINT8*)psMsg, sizeof( ABP_MsgHeaderType ) );
+
+ iMsgSize = iLeTOi( psMsg->sHeader.iDataSize );
+
+ if( iMsgSize > ABCC_CFG_MAX_MSG_SIZE )
+ {
+ /*
+ ** Message size exceeds buffer.
+ */
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_RDMSG_SIZE_ERR, 0 );
+
+ return;
+ }
+
+ /*
+ ** Continue reading data area if > 0.
+ */
+ if ( iMsgSize > 0 )
+ {
+ ABCC_DrvParallelRead( ABP_RDMSG_ADR_OFFSET + sizeof( ABP_MsgHeaderType ),
+ psMsg->abData,
+ iMsgSize );
+ }
+}
+
+
+void drv_DoLegacyMsgRead( ABP_MsgType* psMsg )
+{
+ UINT16 iMsgSize;
+
+ ABCC_DrvParallelRead( ABP_RDMSG_LEGACY_ADR_OFFSET, (UINT8*)&psMsg->sHeader.bSourceId, sizeof( ABP_Msg255HeaderType ) );
+
+ iMsgSize = (UINT16)( psMsg->sHeader.bReserved );
+
+ if( ( iMsgSize > ABP_MAX_MSG_255_DATA_BYTES ) ||
+ ( iMsgSize > ABCC_CFG_MAX_MSG_SIZE ) )
+ {
+ /*
+ ** Message size exceeds buffer.
+ */
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_RDMSG_SIZE_ERR, 0 );
+
+ return;
+ }
+
+ psMsg->sHeader.iDataSize = iTOiLe( iMsgSize );
+
+ /*
+ ** Continue reading data area if > 0.
+ */
+ if( iMsgSize > 0 )
+ {
+ ABCC_DrvParallelRead( ABP_RDMSG_LEGACY_ADR_OFFSET + sizeof( ABP_Msg255HeaderType ),
+ psMsg->abData,
+ iMsgSize );
+ }
+}
+
+
+static void drv_WdTimeoutHandler( void )
+{
+ fWdTmo = TRUE;
+ ABCC_CbfWdTimeout();
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+void ABCC_DrvPar30Init( UINT8 bOpmode )
+{
+ /*
+ ** Initialize privates and states.
+ */
+ ABCC_ASSERT_ERR( bOpmode == 8 , ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+
+ par_drv_iSizeOfReadPd = 0;
+ par_drv_iSizeOfWritePd = 0;
+ par_drv_bNbrOfCmds = 0;
+ par_drv_pbRdPdBuffer = ABCC_DrvParallelGetRdPdBuffer();
+ bControlReg = ABP_CTRL_R_BIT | ABP_CTRL_T_BIT;
+ bStatusReg = 0;
+ eState = SM_SER_INIT;
+ xWdTmoHandle = ABCC_TimerCreate( drv_WdTimeoutHandler );
+ fWdTmo = FALSE;
+
+ /* If an ABCC40 is attached then use big messages */
+ if ( ABCC_ReadModuleId() == ABP_MODULE_ID_ACTIVE_ABCC40 )
+ {
+ drv_fLegacy = FALSE;
+ }
+ else
+ {
+ drv_fLegacy = TRUE;
+ }
+}
+
+void ABCC_DrvPar30SetIntMask( const UINT16 iIntMask )
+{
+ /*
+ ** Not possible to set interrupt mask.
+ */
+ (void)iIntMask;
+}
+
+#if( ABCC_CFG_INT_ENABLED )
+UINT16 ABCC_DrvPar30ISR( void )
+{
+ /*
+ ** Interrupt is acknowledged when status register is read
+ */
+ ABCC_DrvRead8( ABP_STATUS_ADR_OFFSET );
+
+ return 0;
+}
+#else
+UINT16 ABCC_DrvPar30ISR( void )
+{
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INTERNAL_ERROR, 0);
+ return 0;
+}
+#endif
+
+
+ABP_MsgType* ABCC_DrvPar30RunDriverRx( void )
+{
+ UINT8 bNewStatusReg1;
+ UINT8 bNewStatusReg2;
+
+ if ( eState == SM_WAITING_FOR_PONG )
+ {
+
+ do
+ {
+ bNewStatusReg1 = ABCC_DrvRead8( ABP_STATUS_ADR_OFFSET );
+ bNewStatusReg2 = ABCC_DrvRead8( ABP_STATUS_ADR_OFFSET );
+ } while ( bNewStatusReg1 != bNewStatusReg2 );
+
+
+ if( ( bNewStatusReg1 & ABP_STAT_T_BIT ) != ( bStatusReg & ABP_STAT_T_BIT ) )
+ {
+ bStatusReg = bNewStatusReg1;
+ bControlReg &= ~ABP_CTRL_M_BIT;
+ bControlReg ^= ABP_CTRL_T_BIT;
+
+ ABCC_TimerStop( xWdTmoHandle );
+ /*
+ ** Check if timeout has occurred.
+ */
+ if( fWdTmo == TRUE )
+ {
+ ABCC_CbfWdTimeoutRecovered();
+ }
+ fWdTmo = FALSE;
+ eState = SM_RDY_TO_PING;
+ }
+ }
+ else if ( eState == SM_SER_INIT )
+ {
+ eState = SM_RDY_TO_PING;
+ }
+
+ return NULL;
+}
+
+
+void ABCC_DrvPar30RunDriverTx( void )
+{
+ if(eState == SM_RDY_TO_PING )
+ {
+ ABCC_DrvWrite8( ABP_CONTROL_ADR_OFFSET, bControlReg );
+ /*
+ ** Start WD timer
+ */
+ ABCC_TimerStart(xWdTmoHandle, ABCC_CFG_WD_TIMEOUT_MS );
+ eState = SM_WAITING_FOR_PONG;
+ }
+}
+
+
+
+
+BOOL ABCC_DrvPar30WriteMessage( ABP_MsgType* psWriteMsg )
+{
+ ABCC_ASSERT( psWriteMsg );
+
+ if( drv_fLegacy )
+ {
+ drv_DoLegacyMsgWrite( psWriteMsg );
+ }
+ else
+ {
+ drv_DoMsgWrite( psWriteMsg );
+ }
+
+ bControlReg |= ABP_CTRL_M_BIT;
+
+ /*
+ ** Determine if command messages (instead of response messages) can be sent.
+ */
+ if( !( psWriteMsg->sHeader.bCmd & ABP_MSG_HEADER_C_BIT ) )
+ {
+ /*
+ ** A command message has been received by the host application and a
+ ** response message (not a command message) will be sent back to the
+ ** Anybus. The number of commands the host application can receive
+ ** shall be increased by one, as a previous received command is now
+ ** handled.
+ */
+ par_drv_bNbrOfCmds++;
+
+ /*
+ ** When a change of the number of commands which the host application
+ ** can receive is made from 0 to 1, it means that we can set the APPRF
+ ** flag again to indicate for the Anybus that the host is now ready to
+ ** receive a new command.
+ */
+ bControlReg |= ABP_CTRL_R_BIT;;
+ }
+
+ /*
+ ** Update the buffer control register.
+ */
+ return( TRUE);
+}
+
+
+void ABCC_DrvPar30WriteProcessData( void* pxProcessData )
+{
+
+ if( par_drv_iSizeOfWritePd )
+ {
+ /*
+ ** Write process data.
+ */
+ ABCC_DrvWriteWrPd(pxProcessData, par_drv_iSizeOfWritePd );
+ }
+}
+
+
+BOOL ABCC_DrvPar30IsReadyForWriteMessage( void )
+{
+ BOOL fRdyForCmd = FALSE;
+
+ if( eState == SM_RDY_TO_PING )
+ {
+ if( !( bControlReg & ABP_CTRL_M_BIT ) )
+ {
+ fRdyForCmd = TRUE;
+ }
+ }
+ return fRdyForCmd;
+}
+
+
+BOOL ABCC_DrvPar30IsReadyForCmd( void )
+{
+ BOOL fRdyForCmd = FALSE;
+
+ if( eState == SM_RDY_TO_PING )
+ {
+ if( ( bStatusReg & ABP_STAT_R_BIT ) && !( bControlReg & ABP_CTRL_M_BIT ) )
+ {
+ fRdyForCmd = TRUE;
+ }
+ }
+
+ return fRdyForCmd;
+}
+
+
+void ABCC_DrvPar30SetNbrOfCmds( UINT8 bNbrOfCmds )
+{
+ par_drv_bNbrOfCmds = bNbrOfCmds;
+
+ /*
+ ** Acknowledge that we are ready to accept the first command message.
+ */
+ bControlReg |= ABP_CTRL_R_BIT;
+}
+
+
+void ABCC_DrvPar30SetAppStatus( ABP_AppStatusType eAppStatus )
+{
+ (void)eAppStatus;
+}
+
+void ABCC_DrvPar30SetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize )
+{
+ par_drv_iSizeOfReadPd = iReadPdSize;
+ par_drv_iSizeOfWritePd = iWritePdSize;
+}
+
+
+static void DrvPar30SetMsgReceiverBuffer( ABP_MsgType* const psReadMsg )
+{
+ /*
+ ** The buffer can be NULL if we are out of msg resources.
+ ** We can not start a new ping-pong before this is resolved.
+ */
+ par_drv_pbReadMessageData = psReadMsg;
+}
+
+
+UINT16 ABCC_DrvPar30GetIntStatus( void )
+{
+ return 0;
+}
+
+UINT8 ABCC_DrvPar30GetAnybusState( void )
+{
+ /*
+ ** The Anybus state is stored in bits 0-2 of the status register.
+ */
+ return( bStatusReg & 0x07 );
+}
+
+
+void* ABCC_DrvPar30ReadProcessData( void )
+{
+ /*
+ ** TODO Check valid data
+ */
+
+ if ( ( par_drv_iSizeOfReadPd == 0) || ( eState == SM_WAITING_FOR_PONG ) )
+ {
+ return NULL;
+ }
+
+ ABCC_DrvReadRdPd( par_drv_pbRdPdBuffer, par_drv_iSizeOfReadPd );
+ return( par_drv_pbRdPdBuffer );
+}
+
+ABP_MsgType* ABCC_DrvPar30ReadMessage( void )
+{
+ if( eState == SM_RDY_TO_PING )
+ {
+ if( bStatusReg & ABP_STAT_M_BIT )
+ {
+ DrvPar30SetMsgReceiverBuffer( ABCC_MemAlloc() );
+
+ if( par_drv_pbReadMessageData == NULL )
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_OUT_OF_MSG_BUFFERS, 0 );
+ return( NULL );
+ }
+
+ if( drv_fLegacy )
+ {
+ drv_DoLegacyMsgRead( par_drv_pbReadMessageData );
+ }
+ else
+ {
+ drv_DoMsgRead( par_drv_pbReadMessageData );
+ }
+
+ /*
+ ** Determine if command messages (instead of response messages) can be read.
+ */
+ if( par_drv_pbReadMessageData->sHeader.bCmd & ABP_MSG_HEADER_C_BIT )
+ {
+ /*
+ ** A command messages has been sent by the Anybus and it has been read
+ ** by the host application. The number of commands allowed by the host
+ ** application must be decreased by one.
+ */
+ par_drv_bNbrOfCmds--;
+
+ /*
+ ** Indicates that the host application is not ready to receive a new
+ ** command from the Anybus. Writing to this register must only be done
+ ** when the RDMSG bit is set to 1. A check is not required however,
+ ** since the RDMSG bit is set to 1 a few lines higher up in the code.
+ */
+ if( par_drv_bNbrOfCmds == 0 )
+ {
+ /*
+ ** Update the buffer control register.
+ */
+ bControlReg &= ~ABP_CTRL_R_BIT;
+ }
+ }
+
+ return( par_drv_pbReadMessageData );
+ }
+ }
+ return( NULL );
+}
+
+BOOL ABCC_DrvPar30IsReadyForWrPd( void )
+{
+ if ( eState == SM_RDY_TO_PING )
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+UINT8* ABCC_DrvPar30GetWrPdBuffer( void )
+{
+ return ABCC_DrvParallelGetWrPdBuffer();
+}
+
+
+UINT16 ABCC_DrvPar30GetModCap( void )
+{
+ return 0xFFFF;
+}
+
+UINT16 ABCC_DrvPar30GetLedStatus( void )
+{
+ return 0;
+}
+
+BOOL ABCC_DrvPar30IsSupervised( void )
+{
+ /*
+ ** The Anybus supervision bis is stored in bit 3
+ */
+ return( ( bStatusReg >> 3 ) & 1 );
+}
+
+UINT8 ABCC_DrvPar30GetAnbStatus( void )
+{
+ return bStatusReg & 0xf ;
+}
+
+
+
+#endif
+/*******************************************************************************
+** End of par_drv.c
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/serial/abcc_crc16.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,153 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Object containing implementations for Crc 16 calculations.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_SERIAL )
+
+#include "abcc_td.h"
+#include "abcc_crc16.h"
+
+/****************************************************************************
+** Private Globals
+*****************************************************************************
+*/
+
+/*
+** Tables for generating CRC16 checksum
+*/
+
+const UINT8 abCrc16Hi[] =
+{
+ 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00,
+ 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1,
+ 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
+ 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+ 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01,
+ 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
+ 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80,
+ 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+ 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00,
+ 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
+ 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
+ 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+ 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,
+ 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
+ 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,
+ 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+ 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,
+ 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1,
+ 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80,
+ 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
+};
+
+
+const UINT8 abCrc16Lo[] =
+{
+ 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05,
+ 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA,
+ 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA,
+ 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15,
+ 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10, 0xF0,
+ 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35,
+ 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B,
+ 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA,
+ 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27,
+ 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
+ 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64,
+ 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB,
+ 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE,
+ 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7,
+ 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91,
+ 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54,
+ 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99,
+ 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E,
+ 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46,
+ 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40
+};
+
+
+/*******************************************************************************
+**
+** Public Services
+**
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** CRC_Crc16()
+**------------------------------------------------------------------------------
+*/
+
+UINT16 CRC_Crc16( UINT8* pbBufferStart, UINT16 iLength )
+{
+ UINT8 bIndex;
+ UINT8 bCrcLo;
+ UINT8 bCrcHi;
+
+
+ /*
+ ** Init crc to 0xFFFF
+ */
+
+ bCrcLo = 0xFF;
+ bCrcHi = 0xFF;
+
+ /*
+ ** Do the crc calculation
+ */
+
+ while( iLength > 0 )
+ {
+ bIndex = bCrcLo ^ *pbBufferStart++;
+ bCrcLo = bCrcHi ^ abCrc16Hi[ bIndex ];
+ bCrcHi = abCrc16Lo[ bIndex ];
+ iLength--;
+ }
+
+ return( bCrcHi << 8 | bCrcLo );
+
+} /* End of CRC_Crc16() */
+#endif
+
+
+/*******************************************************************************
+**
+** Private services
+**
+********************************************************************************
+*/
+
+/*******************************************************************************
+**
+** End of crc.c
+**
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/serial/abcc_crc16.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,88 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** File Description: +** This is the public header file for the CRC calculation routines. +******************************************************************************** +******************************************************************************** +** Services: +** +** CRC_Crc16() - CRC16 checksum calculation function. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef CRC16_H +#define CRC16_H + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" + +/******************************************************************************* +** +** Typedefs +** +******************************************************************************** +*/ + +/******************************************************************************* +** +** Public Services +** +******************************************************************************** +*/ + +/*--------------------------------------------------------------------------- +** +** CRC_Crc16() +** +** Calculates a CRC16 checksum on the indicated bytes. +** +**--------------------------------------------------------------------------- +** +** Inputs: +** pbBufferStart - Where to start calculation +** iLength - The amount of bytes to include +** +** Outputs: +** Returns - The calculated CRC16 checksum +** +** Usage: +** iCrc = CRC_Crc16( pbStart, 20 ); +** +**--------------------------------------------------------------------------- +*/ + +EXTFUNC UINT16 CRC_Crc16( UINT8* pbBufferStart, UINT16 iLength ); + + +#endif /* inclusion lock */ + + +/******************************************************************************* +** +** End of crc.h +** +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/serial/abcc_drv_ser_if.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,411 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Defines the generic driver interface implemented by each specific driver. +******************************************************************************** +******************************************************************************** +** Driver services: +** ABCC_DrvSerInit() - Initialize driver privates and states to default values. +** ABCC_DrvSerISR() - Calls in the interrupt context to acknowledge received interrupts. +** ABCC_DrvSerExecute() - Drives the internal send/receive process if applicable +** ABCC_DrvSerWriteMessage() - Writes a message. +** ABCC_DrvSerWriteProcessData() - Writes current process data. +** ABCC_DrvSerIsReadyForWriteMessage() - Checks if the driver is ready to send a new write message. +** ABCC_DrvSerIsReadyForCmd() - Checks if the Anybus is ready to receive a new command message. +** ABCC_DrvSerSetNbrOfCmds() - Sets the number of simultaneous commands that is supported by the application. +** ABCC_DrvSerSetAppStatus() - Sets the current application status. +** ABCC_DrvSerSetPdSize() - Sets the current process data size. +** ABCC_DrvSerSetMsgReceiverBuffer() - Sets the message receiver buffer. +** ABCC_DrvSerSetIntMask() - Set interrupt mask +** ABCC_DrvSerGetWrPdBuffer() - Get wrpd buffer +** ABCC_DrvSerGetModCap() - Read module capability +** ABCC_DrvSerGetLedStat() - Read led status +** ABCC_DrvSerGetIntStatus() - Get current interrupt status +** ABCC_DrvSerGetAnybusState() - Get current Anybus state +** ABCC_DrvSerReadProcessData() - Get read process data if any. +** ABCC_DrvSerReadMessage() - Get read message if any. +** ABCC_DrvSerRegisterWd() - Function to call when Wd timeOuts +** ABCC_DrvSerIsSuperviced() - Is the network supervised +******************************************************************************** +******************************************************************************** +*/ +#ifndef PHY_DRV_SER_IF_H_ +#define PHY_DRV_SER_IF_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abp.h" + +#if( ABCC_CFG_DRV_SERIAL ) +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + + + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Initializes the driver to default values. +** Must be called before the driver is used. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerInit( UINT8 bOpmode ); + + +/*------------------------------------------------------------------------------ +** Calls in the interrupt context to acknowledge received interrupts. +** +** Remarks: +** The ISR routine will clear all pending interrupts. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Acknowledged interrupts. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSerISR( void ); + + +/*------------------------------------------------------------------------------ +** Drives the internal send process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerRunDriverTx( void ); + +/*------------------------------------------------------------------------------ +** Drives the internal receive process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to successfully sent write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvSerRunDriverRx( void ); + + +/*------------------------------------------------------------------------------ +** Writes a message to the driver. +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg: Pointer to message. +** +** Returns: +** True: Message was successfully written and can be deallocated +** immediately. +** False: Message was not yet written and cannot be deallocated. +** The psWriteMsg pointer is owned by the driver until the +** message is written and the pointer is returned in the +** driver execution response. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSerWriteMessage( ABP_MsgType* psWriteMsg ); + + +/*------------------------------------------------------------------------------ +** Writes current process data. +** The data is copied before returning from the method. +**------------------------------------------------------------------------------ +** Arguments: +** pxProcessData: Pointer to process data to be sent. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerWriteProcessData( void* pxProcessData ); + +/*------------------------------------------------------------------------------ +** Checks if the driver is in the correct state for writing process data to the anybus +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is in correct state to send WrPd +** False: Driver is not in correct state to send Wrpd +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSerIsReadyForWrPd( void ); + + +/*------------------------------------------------------------------------------ +** Checks if the driver is ready to send a new write message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is ready to send a new write message. +** False: Driver is not ready to send a new write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSerIsReadyForWriteMessage( void ); + + +/*------------------------------------------------------------------------------ +** The host application checks if the Anybus is ready to receive a new command +** message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: OK to send new command. +** False: NOK to send new command. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSerIsReadyForCmd( void ); + + +/*------------------------------------------------------------------------------ +** Sets the number of simultaneous commands that is supported by the application. +**------------------------------------------------------------------------------ +** Arguments: +** bNbrOfCmds: Number of commands that the application is ready to receive. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerSetNbrOfCmds( UINT8 bNbrOfCmds ); + + +/*------------------------------------------------------------------------------ +** Sets the current application status. +** Note! This information is not supported by all protocols. +**------------------------------------------------------------------------------ +** Arguments: +** eAppStatus: Current application status. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerSetAppStatus( ABP_AppStatusType eAppStatus ); + + +/*------------------------------------------------------------------------------ +** Sets the current process data size. +**------------------------------------------------------------------------------ +** Arguments: +** iReadPdSize: Size of read process data (bytes) +** iWritePdSize: Size of write process data (bytes) +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize ); + + +/*------------------------------------------------------------------------------ +** Sets the receiver buffer, to be used for the next read message. +**------------------------------------------------------------------------------ +** Arguments: +** psReadMsg: Pointer where next read message will be put. +** psReadMsg is not allowed to contain a NULL value. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg ); + + +/*------------------------------------------------------------------------------ +** Sets Interrupt mask according to h_aci.h. +**------------------------------------------------------------------------------ +** Arguments: +** iIntMask: Interrupt mask set according to h_aci.h. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSerSetIntMask( const UINT16 iIntMask ); + + +/*------------------------------------------------------------------------------ +** Get WrpdBuffer for the user to update. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to WrPd buffer. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvSerGetWrPdBuffer( void ); + + +/*------------------------------------------------------------------------------ +** Read module capabillity +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSerGetModCap( void ); + + +/*------------------------------------------------------------------------------ +** Read module capability +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSerGetLedStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus interrupt status. +** +** Remarks: +** The ABCC_DrvISR() function will clear all pending interrupts. This +** function must be called before ABCC_DrvISR() or it will always return 0. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus interrupt status. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSerGetIntStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus state. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus state. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvSerGetAnybusState( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read process data. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read process data; or NULL if no process data to read +** was available. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvSerReadProcessData( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read message; or NULL if no message is available. +** The pointer, if not NULL, will point to the buffer previously set by +** calling ABCC_DrvSetMsgReceiverBuffer(). +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvSerReadMessage( void ); + +/*------------------------------------------------------------------------------ +** Returns supervision bit in status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** TRUE: The device is supervised by another network device. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSerIsSupervised( void ); + + +/*------------------------------------------------------------------------------ +** Returns anybus status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** Anybus status register +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvSerGetAnbStatus( void ); + + +#endif /* ABCC_CFG_DRV_SERIAL */ + +#endif /* inclusion lock */ + +/******************************************************************************* +** End of drv_if.h +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/serial/abcc_handler_ser.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,100 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** This file implements the ABCC_DunDriver() and ABCC_ISR() routine for serial
+** operating mode.
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_SERIAL )
+
+#include "abcc_td.h"
+#include "../abcc_drv_if.h"
+#include "abp.h"
+#include "abcc.h"
+#include "../abcc_link.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_debug_err.h"
+#include "../abcc_handler.h"
+#include "../abcc_timer.h"
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Functions
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ABCC_RunDriver()
+**------------------------------------------------------------------------------
+*/
+ABCC_ErrorCodeType ABCC_SerRunDriver( void )
+{
+ ABCC_MainStateType eMainState;
+
+ eMainState = ABCC_GetMainState();
+
+ if ( eMainState < ABCC_DRV_SETUP )
+ {
+ if ( eMainState != ABCC_DRV_ERROR )
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_INCORRECT_STATE, 0);
+ ABCC_SetMainStateError();
+ }
+ return( ABCC_EC_INCORRECT_STATE );
+ }
+
+ ABCC_LinkRunDriverRx();
+ ABCC_TriggerRdPdUpdate();
+ ABCC_TriggerAnbStatusUpdate();
+ ABCC_TriggerReceiveMessage();
+
+ ABCC_CheckWrPdUpdate();
+ ABCC_LinkCheckSendMessage();
+ pnABCC_DrvRunDriverTx();
+
+ return( ABCC_EC_NO_ERROR );
+}
+#endif /* End of #if( ABCC_CFG_DRV_SERIAL ) */
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/serial/abcc_serial_drv.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,847 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Implementation of serial driver ping protocol
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_SERIAL )
+
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc.h"
+#include "../abcc_debug_err.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_timer.h"
+#include "../abcc_drv_if.h"
+#include "../abcc_mem.h"
+#include "abcc_crc16.h"
+#include "abcc_sys_adapt_ser.h"
+#include "abcc_port.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+#define SER_CRC_LEN ( 2 )
+#define SER_MSG_FRAG_LEN ( 16 )
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+typedef struct
+{
+ UINT8* pbCurrPtr; /* Pointer to the current position in the send buffer. */
+ INT16 iNumBytesLeft; /* Number of bytes left to send. */
+ UINT16 iFragLength; /* Current fragmentation block length. */
+} WrMsgFragType;
+
+
+typedef struct
+{
+ UINT8* pbCurrPtr; /* Pointer to the current position in receive buffer. */
+ UINT16 iNumBytesReceived; /* Number of bytes received. */
+ UINT16 iFragLength; /* Current fragmentation block length. */
+ UINT16 iMaxLength; /* Max num bytes to receive*/
+} RdMsgFragType;
+
+
+typedef struct SerTxTelegramType
+{
+ UINT8 bControl;
+ UINT8 abWrMsg[ SER_MSG_FRAG_LEN ];
+ UINT8 abData[ ABCC_CFG_MAX_PROCESS_DATA_SIZE + SER_CRC_LEN ];
+} SerTxTelegramType;
+
+
+typedef struct SerRxTelegramType
+{
+ UINT8 bStatus;
+ UINT8 abRdMsg[ SER_MSG_FRAG_LEN ];
+ UINT8 abData[ ABCC_CFG_MAX_PROCESS_DATA_SIZE + SER_CRC_LEN ];
+} SerRxTelegramType;
+
+
+/*------------------------------------------------------------------------------
+** Internal states.
+**------------------------------------------------------------------------------
+*/
+typedef enum
+{
+ SM_SER_INIT = 0,
+ SM_SER_RDY_TO_SEND_PING,
+ SM_SER_WAITING_FOR_PONG
+} drv_SerStateType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+
+/*------------------------------------------------------------------------------
+** General privates.
+**------------------------------------------------------------------------------
+*/
+
+
+static drv_SerStateType drv_eState; /* Serial driver state. */
+static UINT8 drv_bStatus; /* Latest received status */
+
+
+static ABP_MsgType* drv_psWriteMessage; /* Pointer to active write message. */
+
+static ABP_MsgType* drv_psReadMessage; /* Pointer to the read message. */
+static BOOL drv_fNewReadMessage; /* Indicate that new message has arrived. */
+
+static UINT16 drv_iWritePdSize; /* Current write PD size. */
+static UINT16 drv_iReadPdSize; /* Current read PD size. */
+
+static UINT16 drv_iTxFrameSize; /* Current ping frame size. */
+static UINT16 drv_iRxFrameSize; /* Current ping frame size. */
+
+
+static UINT8 drv_bNbrOfCmds; /* Number of commands that can be received by the application */
+
+static SerRxTelegramType drv_sRxTelegram; /* Place holder for Rx telegram */
+static SerTxTelegramType drv_sTxTelegram; /* Place holder for Tx telegram */
+
+static WrMsgFragType sTxFragHandle;
+static RdMsgFragType sRxFragHandle;
+static BOOL fSendWriteMessageEndMark; /* Indicate end of message */
+
+
+static BOOL drv_fNewRxTelegramReceived; /* Serail driver has a complete message */
+static UINT8* drv_bpRdPd; /* Pointer to valid read process data */
+
+
+/*
+ ** Timers and watchdogs
+ */
+static ABCC_TimerHandle xWdTmoHandle;
+static BOOL fWdTmo; /* Current wd timeout status */
+static ABCC_TimerHandle xTelegramTmoHandle;
+static BOOL fTelegramTmo; /* Current telegram tmo status */
+static UINT16 iTelegramTmoMs; /* Telegram timeout */
+
+
+/*******************************************************************************
+** Private forward declarations.
+********************************************************************************
+*/
+static void DrvSerSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg );
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Callback from the physical layer to indicate that a RX telegran was received.
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void drv_RxTelegramReceived( void )
+{
+ drv_fNewRxTelegramReceived = TRUE;
+}
+
+
+/*------------------------------------------------------------------------------
+** Init write message fragmentation
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to write fragmentation information
+** psMsg Pointer t0 start of message
+** iFragLength Fragment length
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void drv_WriteFragInit( WrMsgFragType* psFragHandle, UINT8* psMsg , UINT16 iMsgSize, UINT16 iFragLength )
+{
+ psFragHandle->iNumBytesLeft = iMsgSize;
+ psFragHandle->iFragLength = iFragLength;
+ psFragHandle->pbCurrPtr = psMsg;
+}
+
+
+/*------------------------------------------------------------------------------
+** Get current write message fragment
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to write fragmentation information
+** pbBuffer Pointer to destination buffer
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void drv_GetWriteFrag( WrMsgFragType* const psFragHandle , UINT8* const pbBuffer )
+{
+ /*
+ ** Copy the message into the MOSI frame buffer.
+ */
+ ABCC_ASSERT( psFragHandle->iNumBytesLeft > 0 );
+
+ ABCC_PORT_MemCpy( pbBuffer,
+ psFragHandle->pbCurrPtr,
+ psFragHandle->iFragLength );
+}
+
+
+/*------------------------------------------------------------------------------
+** Update to next Write fragment. Returns TRUE if if nothing to send.
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to write fragmentation information
+** pbBuffer Pointer to destination buffer
+** Returns:
+** TRUE if the whole message is sent .
+**------------------------------------------------------------------------------
+*/
+static BOOL drv_PrepareNextWriteFrag( WrMsgFragType* const psFragHandle )
+{
+ BOOL fFragDone = FALSE;
+
+ if( psFragHandle->iNumBytesLeft > 0 )
+ {
+ psFragHandle->pbCurrPtr += psFragHandle->iFragLength;
+ psFragHandle->iNumBytesLeft -= psFragHandle->iFragLength;
+ }
+
+ if ( psFragHandle->iNumBytesLeft <= 0 )
+ {
+ fFragDone = TRUE;
+ }
+ return fFragDone;
+}
+
+/*------------------------------------------------------------------------------
+** Check if write message sending is in progress
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to write fragmentation information
+** Returns:
+** TRUE if sending is ongoing.
+**------------------------------------------------------------------------------
+*/
+static BOOL drv_isWrMsgSendingInprogress( WrMsgFragType* const psFragHandle )
+{
+ return ( psFragHandle->pbCurrPtr != 0 );
+}
+
+
+/*------------------------------------------------------------------------------
+** Init read message fragmentation.
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to write fragmentation information
+** psMsg Pointer to start of message
+** iFragLength Fragment length
+** iMaxMsgLength MAximum lenth of message
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void drv_InitReadFrag( RdMsgFragType* psFragHandle, UINT8* psMsg , UINT16 iFragLength, UINT16 iMaxMsgLength )
+{
+ psFragHandle->iNumBytesReceived = 0;
+ psFragHandle->iFragLength = iFragLength;
+ psFragHandle->pbCurrPtr = psMsg;
+ psFragHandle->iMaxLength = iMaxMsgLength;
+}
+
+
+/*------------------------------------------------------------------------------
+** Add read message fragment
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to write fragmentation information
+** pbBuffer Pointer to source buffer
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void drv_AddReadFrag( RdMsgFragType* const psFragHandle , UINT8* const pbBuffer )
+{
+ if( ( psFragHandle->iNumBytesReceived + psFragHandle->iFragLength ) > psFragHandle->iMaxLength )
+ {
+ /*
+ ** Message size exceeds buffer.
+ */
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_RDMSG_SIZE_ERR, 0 );
+
+ return;
+ }
+
+ /*
+ ** Copy the message into buffer.
+ */
+ psFragHandle->iNumBytesReceived += psFragHandle->iFragLength;
+
+ ABCC_PORT_MemCpy( psFragHandle->pbCurrPtr,
+ pbBuffer,
+ psFragHandle->iFragLength );
+
+ psFragHandle->pbCurrPtr += psFragHandle->iFragLength;
+}
+
+
+/*------------------------------------------------------------------------------
+** Check if read message receiving is in progress
+**------------------------------------------------------------------------------
+** Arguments:
+** psFragHandle Pointer to read fragmentation information
+** Returns:
+** TRUE if the.
+**------------------------------------------------------------------------------
+*/
+static BOOL drv_isRdMsgReceiveInprogress( RdMsgFragType* const psFragHandle )
+{
+ return (psFragHandle->pbCurrPtr != 0 );
+}
+
+
+static void drv_WdTimeoutHandler( void )
+{
+ fWdTmo = TRUE;
+ ABCC_CbfWdTimeout();
+}
+
+
+static void drv_TelegramTimeoutHandler( void )
+{
+ fTelegramTmo = TRUE;
+}
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+void ABCC_DrvSerInit( UINT8 bOpmode )
+{
+ fSendWriteMessageEndMark = FALSE;
+
+ /*
+ ** Initialize privates and states.
+ */
+ ABCC_ASSERT_ERR( ( bOpmode > 8 ) && ( bOpmode < 13 ), ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+
+ drv_psReadMessage = 0;
+ drv_psWriteMessage = 0;
+
+ drv_bNbrOfCmds = 0;
+ drv_eState = SM_SER_INIT;
+
+ drv_iWritePdSize = 0;
+ drv_iReadPdSize = 0;
+
+ drv_iTxFrameSize = 17 + drv_iWritePdSize;
+ drv_iRxFrameSize = 17 + drv_iReadPdSize;
+
+
+ drv_bpRdPd = NULL;
+
+ drv_sTxTelegram.bControl = 0;
+ drv_sRxTelegram.bStatus = 0;
+ drv_bStatus = 0;
+
+ drv_InitReadFrag(&sRxFragHandle,0,0,0);
+ drv_WriteFragInit( &sTxFragHandle ,0 ,0 ,0 );
+
+ drv_fNewRxTelegramReceived = FALSE;
+ drv_fNewReadMessage = FALSE;
+
+ xTelegramTmoHandle = ABCC_TimerCreate( drv_TelegramTimeoutHandler );
+ fTelegramTmo = FALSE;
+
+ switch ( bOpmode )
+ {
+ case 9: /* 19200 baud */
+ iTelegramTmoMs = 350;
+ break;
+ case 10: /* 57600 baud */
+ iTelegramTmoMs = 120;
+ break;
+ case 11: /* 115200 baud */
+ iTelegramTmoMs = 60;
+ break;
+ case 12: /* 625000 baud */
+ iTelegramTmoMs = 20;
+ break;
+ default:
+ ABCC_ASSERT(FALSE);
+ }
+
+ xWdTmoHandle = ABCC_TimerCreate( drv_WdTimeoutHandler );
+ fWdTmo = FALSE;
+
+ /*
+ ** Register the PONG indicator for the physical serial driver.
+ */
+ ABCC_SYS_SerRegDataReceived( drv_RxTelegramReceived );
+}
+
+/*------------------------------------------------------------------------------
+** Handles preparation and sending of TX telegram
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** -
+**------------------------------------------------------------------------------
+*/
+void ABCC_DrvSerRunDriverTx( void )
+{
+ UINT16 iCrc;
+ BOOL fHandleWriteMsg = FALSE;
+
+ ABCC_PORT_UseCritical();
+
+ if( drv_eState == SM_SER_RDY_TO_SEND_PING )
+ {
+ drv_eState = SM_SER_WAITING_FOR_PONG;
+ drv_sTxTelegram.bControl &= ABP_CTRL_T_BIT;
+
+ if ( !fTelegramTmo )
+ {
+ /*
+ ** Everything is OK. Reset retransmission and toggle the T bit.
+ */
+ drv_sTxTelegram.bControl ^= ABP_CTRL_T_BIT;
+
+ ABCC_PORT_EnterCritical();
+
+ if ( ( drv_psWriteMessage != 0 ) && !drv_isWrMsgSendingInprogress( &sTxFragHandle ) )
+ {
+ drv_psWriteMessage->sHeader.bReserved = (UINT8)( iLeTOi( drv_psWriteMessage->sHeader.iDataSize ) );
+ drv_WriteFragInit(&sTxFragHandle ,&drv_psWriteMessage->sHeader.bSourceId, (UINT16)drv_psWriteMessage->sHeader.bReserved + 8, SER_MSG_FRAG_LEN );
+ }
+
+ ABCC_PORT_ExitCritical();
+ }
+
+ fTelegramTmo = FALSE;
+
+ /*---------------------------------------------------------------------------
+ ** Write message handling.
+ **---------------------------------------------------------------------------
+ */
+
+ if ( drv_isWrMsgSendingInprogress( &sTxFragHandle ) )
+ {
+ fHandleWriteMsg = TRUE;
+ }
+
+
+ drv_sTxTelegram.bControl &= ~ABP_CTRL_M_BIT;
+
+ if ( fHandleWriteMsg )
+ {
+ if ( !fSendWriteMessageEndMark )
+ {
+ drv_GetWriteFrag( &sTxFragHandle, drv_sTxTelegram.abWrMsg );
+ drv_sTxTelegram.bControl |= ABP_CTRL_M_BIT;
+ }
+ }
+
+ if( drv_bNbrOfCmds > 0 )
+ {
+ drv_sTxTelegram.bControl |= ABP_CTRL_R_BIT;
+ }
+
+ drv_bpRdPd = NULL;
+
+ /*
+ ** Apply the CRC checksum.
+ */
+ iCrc = CRC_Crc16( (UINT8*)&drv_sTxTelegram, drv_iTxFrameSize );
+
+ drv_sTxTelegram.abData[ drv_iWritePdSize + 1] = (UINT8)(iCrc & 0xFF );
+ drv_sTxTelegram.abData[ drv_iWritePdSize ] = (UINT8)(iCrc >> 8 );
+
+ /*
+ ** Send TX telegram and received Rx telegram.
+ */
+ ABCC_TimerStart( xTelegramTmoHandle, iTelegramTmoMs );
+ ABCC_SYS_SerSendReceive( (UINT8*)&drv_sTxTelegram, (UINT8*)&drv_sRxTelegram, drv_iTxFrameSize + SER_CRC_LEN, drv_iRxFrameSize + SER_CRC_LEN );
+ }
+}
+
+
+/*------------------------------------------------------------------------------
+** Handle the reception of the Rx telegram
+**------------------------------------------------------------------------------
+** Arguments:
+** psResp: Pointer to the response message.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+ABP_MsgType* ABCC_DrvSerRunDriverRx( void )
+{
+ UINT16 iCalcCrc;
+ UINT16 iReceivedCrc;
+
+ ABP_MsgType* psWriteMsg = NULL;
+
+ if ( drv_eState == SM_SER_WAITING_FOR_PONG )
+ {
+ if( !drv_fNewRxTelegramReceived )
+ {
+ if ( fTelegramTmo )
+ {
+ ABCC_SYS_SerRestart();
+ drv_eState = SM_SER_RDY_TO_SEND_PING;
+ }
+
+ /*
+ ** Nothing has happened. No pong was received.
+ */
+ return NULL;
+ }
+
+ /*
+ ** Telegram received
+ */
+ drv_fNewRxTelegramReceived = FALSE;
+
+
+ iReceivedCrc = CRC_Crc16( (UINT8*)&drv_sRxTelegram, drv_iRxFrameSize );
+
+ /*
+ ** Read the CRC that is sent with the telegram.
+ */
+ iCalcCrc = (UINT16)drv_sRxTelegram.abData[ drv_iReadPdSize ] << 8 ;
+ iCalcCrc |= (UINT16)drv_sRxTelegram.abData[ drv_iReadPdSize + 1];
+
+ if( ( ( drv_bStatus & ABP_CTRL_T_BIT ) ==
+ ( drv_sRxTelegram.bStatus & ABP_CTRL_T_BIT ) ) ||
+ ( iCalcCrc != iReceivedCrc ) )
+ {
+ ABCC_SYS_SerRestart();
+ return NULL;
+ }
+
+ if( fWdTmo )
+ {
+ ABCC_CbfWdTimeoutRecovered();
+ }
+
+ /*
+ ** Correct telgram received
+ */
+ ABCC_TimerStop( xTelegramTmoHandle );
+ fTelegramTmo = FALSE;
+
+ ABCC_TimerStop( xWdTmoHandle );
+ fWdTmo = FALSE;
+
+ /*
+ ** Restart watchdog
+ */
+ ABCC_TimerStart( xWdTmoHandle, ABCC_CFG_WD_TIMEOUT_MS );
+
+ /*
+ ** Save the current anybus status.
+ */
+ drv_bStatus = drv_sRxTelegram.bStatus;
+ drv_bpRdPd = drv_sRxTelegram.abData;
+
+ /*---------------------------------------------------------------------------
+ ** Write message handling.
+ **---------------------------------------------------------------------------
+ */
+ if ( drv_isWrMsgSendingInprogress( &sTxFragHandle ) )
+ {
+ /*
+ ** End mark is succesfully sent
+ */
+ if ( fSendWriteMessageEndMark )
+ {
+ fSendWriteMessageEndMark = FALSE;
+ drv_WriteFragInit(&sTxFragHandle ,0 ,0 ,0);
+ psWriteMsg = drv_psWriteMessage;
+
+ /*
+ ** Update the application flow control.
+ */
+ if ( ( drv_psWriteMessage->sHeader.bCmd & ABP_MSG_HEADER_C_BIT ) == 0 )
+ {
+ drv_bNbrOfCmds++;
+ }
+
+ drv_psWriteMessage = 0;
+ }
+ else
+ {
+ fSendWriteMessageEndMark = drv_PrepareNextWriteFrag(&sTxFragHandle );
+ }
+ }
+ /*---------------------------------------------------------------------------
+ ** Read message handling
+ ** --------------------------------------------------------------------------
+ */
+
+ if( drv_bStatus & ABP_STAT_M_BIT )
+ {
+
+ if ( !drv_isRdMsgReceiveInprogress( &sRxFragHandle ) )
+ {
+ if( drv_psReadMessage == NULL )
+ {
+ DrvSerSetMsgReceiverBuffer( ABCC_MemAlloc() );
+
+ if( drv_psReadMessage == NULL )
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_OUT_OF_MSG_BUFFERS, 0 );
+ return( NULL );
+ }
+ }
+
+ /*
+ ** Start receiving on legacy start position which corresponds to &drv_psReadMessage->sHeader.bSourceId
+ */
+ drv_InitReadFrag(&sRxFragHandle, &drv_psReadMessage->sHeader.bSourceId, SER_MSG_FRAG_LEN, ABCC_CFG_MAX_MSG_SIZE + 8 );
+ }
+
+ drv_AddReadFrag(&sRxFragHandle, drv_sRxTelegram.abRdMsg);
+
+ }
+ else
+ {
+ if ( drv_isRdMsgReceiveInprogress( &sRxFragHandle ) )
+ {
+ /*
+ ** Empty message endmarker received
+ ** Copy old message format size parameter to Large message format used by the driver
+ */
+ drv_psReadMessage->sHeader.iDataSize = iTOiLe( (UINT16)drv_psReadMessage->sHeader.bReserved );
+
+ /*
+ ** Update the application flow control.
+ */
+ if ( drv_psReadMessage->sHeader.bCmd & ABP_MSG_HEADER_C_BIT )
+ {
+ drv_bNbrOfCmds--;
+ }
+ drv_fNewReadMessage = TRUE;
+ drv_InitReadFrag(&sRxFragHandle ,0,0,0);
+ }
+ }
+ drv_eState = SM_SER_RDY_TO_SEND_PING;
+ }
+ else if (drv_eState == SM_SER_INIT )
+ {
+ ABCC_TimerStart( xWdTmoHandle, ABCC_CFG_WD_TIMEOUT_MS );
+ drv_eState = SM_SER_RDY_TO_SEND_PING;
+ }
+ return psWriteMsg;
+}
+
+
+UINT16 ABCC_DrvSerISR( void )
+{
+ return 0;
+}
+
+
+BOOL ABCC_DrvSerWriteMessage( ABP_MsgType* psWriteMsg )
+{
+ ABCC_PORT_UseCritical();
+ ABCC_ASSERT( psWriteMsg );
+
+ ABCC_PORT_EnterCritical();
+ ABCC_ASSERT(drv_psWriteMessage == NULL );
+
+ drv_psWriteMessage = psWriteMsg;
+ ABCC_PORT_ExitCritical();
+
+ /*
+ ** The serial driver owns the buffer.
+ */
+ return( FALSE );
+}
+
+void ABCC_DrvSerWriteProcessData( void* pxProcessData )
+{
+ (void)pxProcessData;
+ /*
+ ** Nothing needs to be done here since the buffer is already updated by the application
+ */
+}
+
+
+BOOL ABCC_DrvSerIsReadyForWriteMessage( void )
+{
+ BOOL fRdyForWrMsg = FALSE;
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ if ( drv_psWriteMessage == NULL )
+ {
+ fRdyForWrMsg = TRUE;
+ }
+ ABCC_PORT_ExitCritical();
+ return fRdyForWrMsg;
+}
+
+
+BOOL ABCC_DrvSerIsReadyForCmd( void )
+{
+ return ( pnABCC_DrvISReadyForWriteMessage() && ( drv_bStatus & ABP_STAT_R_BIT ) );
+}
+
+void ABCC_DrvSerSetNbrOfCmds( UINT8 bNbrOfCmds )
+{
+ drv_bNbrOfCmds = bNbrOfCmds;
+}
+
+void ABCC_DrvSerSetAppStatus( ABP_AppStatusType eAppStatus )
+{
+ (void)eAppStatus;
+}
+
+void ABCC_DrvSerSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize)
+{
+ /*
+ ** Update lengths dependent on pd sizes
+ */
+ drv_iWritePdSize = iWritePdSize;
+ drv_iReadPdSize = iReadPdSize;
+ drv_iTxFrameSize = 17 + drv_iWritePdSize;
+ drv_iRxFrameSize = 17 + drv_iReadPdSize;
+}
+
+static void DrvSerSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg )
+{
+ /*
+ ** The buffer can be NULL if we are out of msg resources.
+ ** We can not start a new ping-pong before this is resolved.
+ */
+ drv_psReadMessage = psReadMsg;
+}
+
+
+UINT16 ABCC_DrvSerGetIntStatus( void )
+{
+ ABCC_ERROR(ABCC_SEV_FATAL, ABCC_EC_INTSTATUS_NOT_SUPPORTED_BY_DRV_IMPL, 0);
+
+ return 0;
+}
+
+UINT8 ABCC_DrvSerGetAnybusState( void )
+{
+ return drv_bStatus & 0x7;
+}
+
+
+UINT8* ABCC_DrvSerReadProcessData( void )
+{
+ return drv_bpRdPd;
+}
+
+
+ABP_MsgType* ABCC_DrvSerReadMessage( void )
+{
+ ABP_MsgType* psMsg = NULL;
+
+ if ( drv_fNewReadMessage )
+ {
+ psMsg = drv_psReadMessage;
+ drv_fNewReadMessage = FALSE;
+ drv_psReadMessage = NULL;
+ }
+ return psMsg;
+}
+
+
+void ABCC_DrvSerSetIntMask( const UINT16 iIntMask )
+{
+ (void)iIntMask;
+ /*
+ ** Not possible to set interrupt mask for serial driver.
+ */
+}
+
+UINT8* ABCC_DrvSerGetWrPdBuffer( void )
+{
+ /*
+ ** Return position to WrPd position in tx telegraam
+ */
+ return drv_sTxTelegram.abData;
+}
+
+
+UINT16 ABCC_DrvSerGetModCap( void )
+{
+ ABCC_ERROR( ABCC_SEV_WARNING , ABCC_EC_MODCAP_NOT_SUPPORTED_BY_DRV_IMPL, 0);
+ return 0;
+}
+
+UINT16 ABCC_DrvSerGetLedStatus( void )
+{
+ ABCC_ERROR( ABCC_SEV_WARNING , ABCC_EC_MODCAP_NOT_SUPPORTED_BY_DRV_IMPL, 0);
+ return 0;
+}
+
+BOOL ABCC_DrvSerIsReadyForWrPd( void )
+{
+ if ( drv_eState == SM_SER_RDY_TO_SEND_PING )
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL ABCC_DrvSerIsSupervised( void )
+{
+ /*
+ ** The Anybus supervision bit is stored in bit 3
+ */
+ return( ( drv_bStatus >> 3 ) & 1 );
+}
+
+UINT8 ABCC_DrvSerGetAnbStatus( void )
+{
+ return drv_bStatus & 0xf ;
+}
+#endif /* End of #if( ABCC_CFG_DRV_SERIAL ) */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/spi/abcc_crc32.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,98 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** Object containing implementations for Crc calculations.
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_SPI )
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_sys_adapt.h"
+
+const UINT16 aiBitReverseTable16[] = { 0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF };
+
+
+/*
+** Tables for generating the CRC32 checksum.
+*/
+const UINT32 crc_table32[] = { 0x4DBDF21CUL, 0x500AE278UL, 0x76D3D2D4UL, 0x6B64C2B0UL,
+ 0x3B61B38CUL, 0x26D6A3E8UL, 0x000F9344UL, 0x1DB88320UL,
+ 0xA005713CUL, 0xBDB26158UL, 0x9B6B51F4UL, 0x86DC4190UL,
+ 0xD6D930ACUL, 0xCB6E20C8UL, 0xEDB71064UL, 0xF0000000UL };
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+UINT32 CRC_Crc32( UINT16* piBufferStart, UINT16 iLength )
+{
+ UINT16 iCrcReverseByte;
+ UINT16 iCurrentWordVal;
+ UINT16 i;
+ UINT32 lCrc = 0x0;
+
+ for(i = 0; i < ( iLength >> 1 ); i++)
+ {
+ iCurrentWordVal = *piBufferStart;
+ iCurrentWordVal = iLeTOi( iCurrentWordVal );
+
+ iCrcReverseByte = (UINT16)( lCrc ^ aiBitReverseTable16[ (iCurrentWordVal >> 4 ) & 0xf ] );
+ lCrc = (lCrc >> 4) ^ crc_table32[ iCrcReverseByte & 0xf ];
+ iCrcReverseByte = (UINT16)( lCrc ^ aiBitReverseTable16[ iCurrentWordVal & 0xf ] );
+ lCrc = (lCrc >> 4) ^ crc_table32[ iCrcReverseByte & 0xf ];
+
+ iCrcReverseByte = (UINT16)( lCrc ^ aiBitReverseTable16[ (iCurrentWordVal >> 12 ) & 0xf ] );
+ lCrc = (lCrc >> 4) ^ crc_table32[ iCrcReverseByte & 0xf ];
+ iCrcReverseByte = (UINT16)( lCrc ^ aiBitReverseTable16[ ( iCurrentWordVal >> 8 ) & 0xf ] );
+ lCrc = (lCrc >> 4) ^ crc_table32[ iCrcReverseByte & 0xf ];
+
+ piBufferStart++;
+ }
+
+ lCrc = ( (UINT32)aiBitReverseTable16[ (lCrc & 0x000000F0UL ) >> 4 ] ) |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0x0000000FUL ) ] ) << 4 |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0x0000F000UL ) >> 12 ] << 8) |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0x00000F00UL ) >> 8 ] << 12) |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0x00F00000UL ) >> 20 ] << 16) |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0x000F0000UL ) >> 16 ] << 20) |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0xF0000000UL ) >> 28 ] << 24) |
+ ( (UINT32)aiBitReverseTable16[ (lCrc & 0x0F000000UL ) >> 24 ] << 28);
+
+ return( lCrc );
+}
+
+#endif
+
+
+/*******************************************************************************
+** End of crc.c
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/spi/abcc_crc32.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,79 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** File Description: +** This is the public header file for the CRC calculation routines. +******************************************************************************** +******************************************************************************** +** Services: +** +** CRC_Crc32() - CRC32 checksum calculation function. +******************************************************************************** +******************************************************************************** +*/ + +#ifndef CRC32_H +#define CRC32_H + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** CRC_Crc32() +** +** Calculates a CRC32 checksum on the indicated bytes including transforming +** input bytes from LSB to MSB for the SPI use. +**------------------------------------------------------------------------------ +** Inputs: +** pbBufferStart - Where to start the calculation. +** iLength - The amount of bytes to include. +** +** Outputs: +** Returns - The calculated CRC32 checksum for the SPI. +** +** Usage: +** iCrc = CRC_Crc16( pbStart, 20 ); +**------------------------------------------------------------------------------ +*/ + +EXTFUNC UINT32 CRC_Crc32( UINT16* piBufferStart, UINT16 iLength ); + + + +#endif /* inclusion lock */ + +/******************************************************************************* +** End of abcc_crc32.h +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_drv/src/spi/abcc_drv_spi_if.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,412 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Driver version 4.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, this code can be ** +** modified, reproduced and distributed in binary form without any ** +** restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** Defines the generic driver interface implemented by each specific driver. +******************************************************************************** +******************************************************************************** +** Driver services: +** ABCC_DrvSpiInit() - Initialize driver privates and states to default values. +** ABCC_DrvSpiISR() - Calls in the interrupt context to acknowledge received interrupts. +** ABCC_DrvSpiExecute() - Drives the internal send/receive process if applicable +** ABCC_DrvSpiWriteMessage() - Writes a message. +** ABCC_DrvSpiWriteProcessData() - Writes current process data. +** ABCC_DrvSpiIsReadyForWriteMessage() - Checks if the driver is ready to send a new write message. +** ABCC_DrvSpiIsReadyForCmd() - Checks if the Anybus is ready to receive a new command message. +** ABCC_DrvSpiSetNbrOfCmds() - Sets the number of simultaneous commands that is supported by the application. +** ABCC_DrvSpiSetAppStatus() - Sets the current application status. +** ABCC_DrvSpiSetPdSize() - Sets the current process data size. +** ABCC_DrvSpiSetMsgReceiverBuffer() - Sets the message receiver buffer. +** ABCC_DrvSpiSetIntMask() - Set interrupt mask +** ABCC_DrvSpiGetWrPdBuffer() - Get wrpd buffer +** ABCC_DrvSpiGetModCap() - Read module capability +** ABCC_DrvSpiGetLedStat() - Read led status +** ABCC_DrvSpiGetIntStatus() - Get current interrupt status +** ABCC_DrvSpiGetAnybusState() - Get current Anybus state +** ABCC_DrvSpiReadProcessData() - Get read process data if any. +** ABCC_DrvSpiReadMessage() - Get read message if any. +** ABCC_DrvSpiRegisterWd() - Function to call when Wd timeOuts +** ABCC_DrvSpiIsSuperviced() - Is the network supervised +******************************************************************************** +******************************************************************************** +*/ + +#ifndef PHY_DRV_SPI_IF_H_ +#define PHY_DRV_SPI_IF_H_ + +#include "abcc_drv_cfg.h" +#include "abcc_td.h" +#include "abp.h" + +#if( ABCC_CFG_DRV_SPI ) +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + + + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Initializes the driver to default values. +** Must be called before the driver is used. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiInit( UINT8 bOpmode ); + + +/*------------------------------------------------------------------------------ +** Calls in the interrupt context to acknowledge received interrupts. +** +** Remarks: +** The ISR routine will clear all pending interrupts. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Acknowledged interrupts. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSpiISR( void ); + + +/*------------------------------------------------------------------------------ +** Drives the internal send process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiRunDriverTx( void ); + +/*------------------------------------------------------------------------------ +** Drives the internal receive process. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to successfully sent write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvSpiRunDriverRx( void ); + + +/*------------------------------------------------------------------------------ +** Writes a message to the driver. +**------------------------------------------------------------------------------ +** Arguments: +** psWriteMsg: Pointer to message. +** +** Returns: +** True: Message was successfully written and can be deallocated +** immediately. +** False: Message was not yet written and cannot be deallocated. +** The psWriteMsg pointer is owned by the driver until the +** message is written and the pointer is returned in the +** driver execution response. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSpiWriteMessage( ABP_MsgType* psWriteMsg ); + + +/*------------------------------------------------------------------------------ +** Writes current process data. +** The data is copied before returning from the method. +**------------------------------------------------------------------------------ +** Arguments: +** pxProcessData: Pointer to process data to be sent. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiWriteProcessData( void* pxProcessData ); + +/*------------------------------------------------------------------------------ +** Checks if the driver is in the correct state for writing process data to the anybus +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is in correct state to send WrPd +** False: Driver is not in correct state to send Wrpd +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSpiIsReadyForWrPd( void ); + + +/*------------------------------------------------------------------------------ +** Checks if the driver is ready to send a new write message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: Driver is ready to send a new write message. +** False: Driver is not ready to send a new write message. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSpiIsReadyForWriteMessage( void ); + + +/*------------------------------------------------------------------------------ +** The host application checks if the Anybus is ready to receive a new command +** message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** True: OK to send new command. +** False: NOK to send new command. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSpiIsReadyForCmd( void ); + + +/*------------------------------------------------------------------------------ +** Sets the number of simultaneous commands that is supported by the application. +**------------------------------------------------------------------------------ +** Arguments: +** bNbrOfCmds: Number of commands that the application is ready to receive. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiSetNbrOfCmds( UINT8 bNbrOfCmds ); + + +/*------------------------------------------------------------------------------ +** Sets the current application status. +** Note! This information is not supported by all protocols. +**------------------------------------------------------------------------------ +** Arguments: +** eAppStatus: Current application status. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiSetAppStatus( ABP_AppStatusType eAppStatus ); + + +/*------------------------------------------------------------------------------ +** Sets the current process data size. +**------------------------------------------------------------------------------ +** Arguments: +** iReadPdSize: Size of read process data (bytes) +** iWritePdSize: Size of write process data (bytes) +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize ); + + +/*------------------------------------------------------------------------------ +** Sets the receiver buffer, to be used for the next read message. +**------------------------------------------------------------------------------ +** Arguments: +** psReadMsg: Pointer where next read message will be put. +** psReadMsg is not allowed to contain a NULL value. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg ); + + +/*------------------------------------------------------------------------------ +** Sets Interrupt mask according to h_aci.h. +**------------------------------------------------------------------------------ +** Arguments: +** iIntMask: Interrupt mask set according to h_aci.h. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void ABCC_DrvSpiSetIntMask( const UINT16 iIntMask ); + + +/*------------------------------------------------------------------------------ +** Get WrpdBuffer for the user to update. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Pointer to WrPd buffer. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvSpiGetWrPdBuffer( void ); + + +/*------------------------------------------------------------------------------ +** Read module capabillity +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSpiGetModCap( void ); + + +/*------------------------------------------------------------------------------ +** Read module capability +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** Module capability. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSpiGetLedStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus interrupt status. +** +** Remarks: +** The ABCC_DrvISR() function will clear all pending interrupts. This +** function must be called before ABCC_DrvISR() or it will always return 0. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus interrupt status. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT16 ABCC_DrvSpiGetIntStatus( void ); + + +/*------------------------------------------------------------------------------ +** Gets the Anybus state. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** The Anybus state. +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvSpiGetAnybusState( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read process data. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read process data; or NULL if no process data to read +** was available. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void* ABCC_DrvSpiReadProcessData( void ); + + +/*------------------------------------------------------------------------------ +** Reads the read message. +**------------------------------------------------------------------------------ +** Arguments: +** None. +** +** Returns: +** A pointer to the read message; or NULL if no message is available. +** The pointer, if not NULL, will point to the buffer previously set by +** calling ABCC_DrvSetMsgReceiverBuffer(). +**------------------------------------------------------------------------------ +*/ +EXTFUNC ABP_MsgType* ABCC_DrvSpiReadMessage( void ); + +/*------------------------------------------------------------------------------ +** Returns supervision bit in status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** TRUE: The device is supervised by another network device. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL ABCC_DrvSpiIsSupervised( void ); + + +/*------------------------------------------------------------------------------ +** Returns anybus status register. +**------------------------------------------------------------------------------ +** Arguments: +** - +** +** Returns: +** Anybus status register +**------------------------------------------------------------------------------ +*/ +EXTFUNC UINT8 ABCC_DrvSpiGetAnbStatus( void ); + + +#endif /* ABCC_CFG_DRV_SPI */ + +#endif /* inclusion lock */ + +/******************************************************************************* +** End of drv_if.h +******************************************************************************** +*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/spi/abcc_handler_spi.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,149 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** This file implements the ABCC_DunDriver() and ABCC_ISR() routine for SPI
+** operating mode.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+
+#if( ABCC_CFG_DRV_SPI )
+
+#include "abcc_td.h"
+#include "../abcc_drv_if.h"
+#include "abp.h"
+#include "abcc.h"
+#include "../abcc_link.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_debug_err.h"
+#include "../abcc_handler.h"
+#include "../abcc_timer.h"
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Functions
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ABCC_RunDriver()
+**------------------------------------------------------------------------------
+*/
+ABCC_ErrorCodeType ABCC_SpiRunDriver( void )
+{
+ ABCC_MainStateType eMainState;
+
+ eMainState = ABCC_GetMainState();
+
+ if ( eMainState < ABCC_DRV_SETUP )
+ {
+ if ( eMainState != ABCC_DRV_ERROR )
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_INCORRECT_STATE, 0);
+ ABCC_SetMainStateError();
+ }
+ return( ABCC_EC_INCORRECT_STATE );
+ }
+
+ ABCC_CheckWrPdUpdate();
+ ABCC_LinkCheckSendMessage();
+
+ /*
+ ** Send MOSI frame
+ */
+ pnABCC_DrvRunDriverTx();
+
+#if( ABCC_CFG_SYNC_MEASUREMENT_IP )
+ /*
+ ** We have now finished sending data to the Anybus and thus we end the
+ ** sync measurement.
+ */
+ if( fAbccUserSyncMeasurementIp )
+ {
+ ABCC_SYS_GpioReset();
+ fAbccUserSyncMeasurementIp = FALSE;
+ }
+#endif
+
+ /*
+ ** Handle received MISO frame
+ */
+ ABCC_LinkRunDriverRx();
+
+ ABCC_TriggerRdPdUpdate();
+ ABCC_TriggerAnbStatusUpdate();
+ ABCC_TriggerReceiveMessage();
+
+ return( ABCC_EC_NO_ERROR );
+ /* end of AnybusMain() */
+}
+
+#if( ABCC_CFG_INT_ENABLED )
+void ABCC_SpiISR()
+{
+ ABCC_MainStateType eMainState;
+
+ eMainState = ABCC_GetMainState();
+
+ if ( eMainState < ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ return;
+ }
+
+ if ( eMainState == ABCC_DRV_WAIT_COMMUNICATION_RDY )
+ {
+ ABCC_SetReadyForCommunication();
+ return;
+ }
+
+ ABCC_CbfEvent( 0 );
+}
+#else
+void ABCC_SpiISR()
+{
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_INTERNAL_ERROR, 0);
+}
+#endif
+#endif /* ABCC_CFG_DRV_SPI */
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_drv/src/spi/abcc_spi_drv.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,904 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Driver version 4.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** File Description:
+** SPI driver implementation
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_drv_cfg.h"
+#include "abcc.h"
+
+#if( ABCC_CFG_DRV_SPI )
+
+#include "abcc_td.h"
+#include "../abcc_debug_err.h"
+#include "abcc_sys_adapt.h"
+#include "../abcc_timer.h"
+#include "../abcc_drv_if.h"
+#include "../abcc_mem.h"
+#include "../abcc_handler.h"
+#include "abcc_crc32.h"
+#include "abcc_sys_adapt_spi.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+#define ABCC_MSG_HEADER_TYPE_SIZEOF 12
+
+/*------------------------------------------------------------------------------
+** Since the masking of control registers are endian dependent since
+** we operating on the mosi and misu structures that are little endian
+-------------------------------------------------------------------------------*/
+#ifdef ABCC_SYS_BIG_ENDIAN
+static const UINT16 iSpiCtrlWrPdWalid = ABP_SPI_CTRL_WRPD_VALID << 8;
+static const UINT16 iSpiCtrlCmdCntShift = 9;
+static const UINT16 iSpiCtrlCmdCnt = ABP_SPI_CTRL_CMDCNT << 8;
+static const UINT16 iSpiCtrl_M = ABP_SPI_CTRL_M << 8;
+static const UINT16 iSpiCtrlLastFrag = ABP_SPI_CTRL_LAST_FRAG << 8;
+static const UINT16 iSpiCtrl_T = ABP_SPI_CTRL_T << 8;
+
+static const UINT16 iSpiStatusWrMsgFull = ABP_SPI_STATUS_WRMSG_FULL;
+static const UINT16 iSpiStatusCmdCnt = ABP_SPI_STATUS_CMDCNT;
+static const UINT16 iSpiStatusCmdCntShift = 1;
+static const UINT16 iSpiStatus_M = ABP_SPI_STATUS_M;
+static const UINT16 iSpiStatusLastFrag = ABP_SPI_STATUS_LAST_FRAG;
+static const UINT16 iSpiStatusNewPd = ABP_SPI_STATUS_NEW_PD;
+
+#else
+static const UINT16 iSpiCtrlWrPdWalid = ABP_SPI_CTRL_WRPD_VALID;
+static const UINT16 iSpiCtrlCmdCntShift = 1;
+static const UINT16 iSpiCtrlCmdCnt = ABP_SPI_CTRL_CMDCNT;
+static const UINT16 iSpiCtrl_M = ABP_SPI_CTRL_M;
+static const UINT16 iSpiCtrlLastFrag = ABP_SPI_CTRL_LAST_FRAG;
+static const UINT16 iSpiCtrl_T = ABP_SPI_CTRL_T;
+
+static const UINT16 iSpiStatusWrMsgFull = ABP_SPI_STATUS_WRMSG_FULL << 8;
+static const UINT16 iSpiStatusCmdCnt = ABP_SPI_STATUS_CMDCNT << 8;
+static const UINT16 iSpiStatusCmdCntShift = 9;
+static const UINT16 iSpiStatus_M = ABP_SPI_STATUS_M << 8;
+static const UINT16 iSpiStatusLastFrag = ABP_SPI_STATUS_LAST_FRAG << 8;
+static const UINT16 iSpiStatusNewPd = ABP_SPI_STATUS_NEW_PD << 8;
+#endif
+
+
+
+
+/*------------------------------------------------------------------------------
+** Help defines.
+** Note: They are in words and not bytes.
+**------------------------------------------------------------------------------
+*/
+
+#define NUM_BYTES_2_WORDS(x) ( ( (x) + 1 ) >> 1 )
+
+
+#define SPI_DEFAULT_PD_LEN 0
+#define CRC_WORD_LEN_IN_WORDS 2
+#define SPI_FRAME_SIZE_EXCLUDING_DATA (7)
+
+#if ABCC_CFG_SPI_MSG_FRAG_LEN > ABCC_CFG_MAX_MSG_SIZE
+#error spi fragmentation length cannot exceed max msg size
+#endif
+#define MAX_PAYLOAD_WORD_LEN ( ( NUM_BYTES_2_WORDS( ABCC_CFG_SPI_MSG_FRAG_LEN ) ) + ( NUM_BYTES_2_WORDS( ABCC_CFG_MAX_PROCESS_DATA_SIZE ) ) + ( CRC_WORD_LEN_IN_WORDS ) )
+
+
+
+#define INSERT_SPI_CTRL_CMDCNT( ctrl, cmdcnt) ctrl = ( ( ctrl ) & ~iSpiCtrlCmdCnt ) | ( ( cmdcnt ) << iSpiCtrlCmdCntShift )
+#define EXTRACT_SPI_STATUS_CMDCNT( status ) ( ( ( status ) & iSpiStatusCmdCnt ) >> iSpiStatusCmdCntShift )
+#define SPI_BASE_FRAME_WORD_LEN 5 /* Frame length excluding MSG and PD data */
+
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+
+
+/*------------------------------------------------------------------------------
+** SPI MOSI structure (7044 - ABCC40).
+**------------------------------------------------------------------------------
+*/
+
+typedef struct drv_SpiMosiFrameType
+{
+ UINT16 iSpiControl;
+ UINT16 iMsgLen;
+ UINT16 iPdLen;
+ UINT16 iIntMaskAppStatus;
+ UINT16 iData[ MAX_PAYLOAD_WORD_LEN ];
+ UINT16 dummy;
+} drv_SpiMosiFrameType;
+
+
+/*------------------------------------------------------------------------------
+** SPI MISO structure
+**------------------------------------------------------------------------------
+*/
+typedef struct
+{
+ UINT16 iReserved;
+ UINT16 iLedStat;
+ UINT16 iSpiStatusAnbStatus;
+ UINT16 iNetTime[ 2 ];
+ UINT16 iData[ MAX_PAYLOAD_WORD_LEN ];
+} drv_SpiMisoFrameType;
+
+
+/*------------------------------------------------------------------------------
+** Message fragmentation info types.
+**------------------------------------------------------------------------------
+*/
+typedef struct
+{
+ ABP_MsgType* psWriteMsg; /* Pointer to the write message. */
+ UINT16* puCurrPtr; /* Pointer to the current fragment. */
+ INT16 iNumWordsLeft; /* Number of words left to send. */
+ UINT16 iCurrFragLength; /* Current fragmention block length. */
+} drv_SpiWriteMsgFragInfoType;
+
+
+typedef struct
+{
+ ABP_MsgType* psReadMsg; /* Pointer to the receive message buffer. */
+ UINT16* puCurrPtr; /* Pointer to the current position in receive buffer. */
+ UINT16 iNumWordsReceived; /* Number of words received. */
+} drv_SpiReadMsgFragInfoType;
+
+
+/*------------------------------------------------------------------------------
+** Internal SPI states.
+**------------------------------------------------------------------------------
+*/
+typedef enum
+{
+ SM_SPI_INIT = 0,
+ SM_SPI_RDY_TO_SEND_MOSI,
+ SM_SPI_WAITING_FOR_MISO
+} drv_SpiStateType;
+
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** MISO privates.
+**------------------------------------------------------------------------------
+*/
+static drv_SpiMisoFrameType spi_drv_sMisoFrame; /* Place holder for the MISO frame. */
+static drv_SpiReadMsgFragInfoType spi_drv_sReadFragInfo; /* Read message info. */
+static BOOL spi_drv_fNewMisoReceived; /* MISO received flag. */
+static UINT8 spi_drv_bAnbStatus; /* Latest received anb status. */
+static UINT16 spi_drv_iLedStatus; /* Latest received anb status. */
+static UINT8 spi_drv_bAnbCmdCnt; /* Latest correct received cmd count */
+static UINT8* spi_drv_bpRdPd; /* Pointer to latest correctly received RdPd */
+
+static ABP_MsgType* spi_drv_psReadMessage; /* Pointer to the read message. */
+
+
+
+/*------------------------------------------------------------------------------
+** MOSI privates.
+**------------------------------------------------------------------------------
+*/
+static drv_SpiMosiFrameType spi_drv_sMosiFrame; /* Place holder for the MISO frame. */
+static drv_SpiWriteMsgFragInfoType spi_drv_sWriteFragInfo; /* Write message info. */
+static UINT8 spi_drv_bNbrOfCmds; /* Number of commands support by the application. */
+static UINT8 spi_drv_bNextAppStatus; /* Appstatus to be sent in next MOSI frame */
+static UINT8 spi_drv_bNextIntMask; /* Intmask to be sent in next MOSI frame */
+
+
+/*------------------------------------------------------------------------------
+** General privates.
+**------------------------------------------------------------------------------
+*/
+static UINT16 spi_drv_iPdOffset; /* Offset in payload where the PD is located. */
+static UINT16 spi_drv_iCrcOffset; /* Offset in payload where the CRC is located. */
+
+static UINT16 spi_drv_iPdSize; /* PD size in spiFrame. */
+static UINT16 spi_drv_iWritePdSize; /* Current write PD size. */
+static UINT16 spi_drv_iReadPdSize; /* Current read PD size. */
+
+static UINT16 spi_drv_iSpiFrameSize; /* Current Spi frame size. */
+static BOOL spi_drv_fRetransmit; /* Indicate retransmission. */
+
+static drv_SpiStateType spi_drv_eState; /* SPI driver state. */
+static ABCC_TimerHandle xWdTmoHandle;
+static BOOL fWdTmo; /* Current wd timeout status */
+
+static UINT16 spi_drv_iMsgLen; /* Message length ( in words ) */
+
+
+
+
+
+/*******************************************************************************
+** Private forward declarations.
+********************************************************************************
+*/
+static void spi_drv_DataReceived( void );
+static void spi_drv_ResetReadFragInfo( void );
+static void spi_drv_ResetWriteFragInfo( void );
+
+static void DrvSpiSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg );
+
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+
+/*------------------------------------------------------------------------------
+** Handles preparation and transmission of the MOSI frame.
+** Depending on the physical implementation of the SPI transaction this method
+** could be blocking until the MISO is received.
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** Driver status.
+**------------------------------------------------------------------------------
+*/
+void ABCC_DrvSpiRunDriverTx( void )
+{
+ UINT32 lCrc;
+ BOOL fHandleWriteMsg = FALSE;
+ UINT16 iRdyForCmd;
+
+ ABCC_PORT_UseCritical();
+
+ if (spi_drv_eState == SM_SPI_RDY_TO_SEND_MOSI )
+ {
+ spi_drv_eState = SM_SPI_WAITING_FOR_MISO;
+
+ if ( !spi_drv_fRetransmit )
+ {
+ /*
+ ** Everything is OK. Reset retransmission and toggle the T bit.
+ */
+ spi_drv_sMosiFrame.iSpiControl ^= iSpiCtrl_T;
+ }
+
+ spi_drv_fRetransmit = FALSE;
+
+ /*---------------------------------------------------------------------------
+ ** Write message handling.
+ **---------------------------------------------------------------------------
+ */
+ ABCC_PORT_EnterCritical();
+ if (spi_drv_sWriteFragInfo.psWriteMsg != NULL )
+ {
+ fHandleWriteMsg = TRUE;
+ }
+ ABCC_PORT_ExitCritical();
+
+ if ( fHandleWriteMsg )
+ {
+ ABCC_ASSERT( spi_drv_sWriteFragInfo.puCurrPtr );
+ /*
+ ** Write the message to be sent.
+ */
+ spi_drv_sMosiFrame.iSpiControl |= iSpiCtrl_M;
+
+ if( spi_drv_sWriteFragInfo.iNumWordsLeft <= spi_drv_iMsgLen )
+ {
+ spi_drv_sMosiFrame.iSpiControl |= iSpiCtrlLastFrag;
+ spi_drv_sWriteFragInfo.iCurrFragLength = spi_drv_sWriteFragInfo.iNumWordsLeft;
+ }
+ else
+ {
+ /*
+ ** This is not the last fragment.
+ */
+ spi_drv_sMosiFrame.iSpiControl &= ~iSpiCtrlLastFrag;
+ spi_drv_sWriteFragInfo.iCurrFragLength = spi_drv_iMsgLen;
+ }
+
+ /*
+ ** Copy the message into the MOSI frame buffer.
+ */
+ ABCC_PORT_MemCpy( (void*)spi_drv_sMosiFrame.iData,
+ (void*)spi_drv_sWriteFragInfo.puCurrPtr,
+ spi_drv_sWriteFragInfo.iCurrFragLength << 1 );
+ }
+ else
+ {
+ /*
+ ** There is no message fragment to be sent.
+ */
+ spi_drv_sMosiFrame.iSpiControl &= ~iSpiCtrl_M;
+ spi_drv_sMosiFrame.iSpiControl &= ~iSpiCtrlLastFrag;
+ }
+
+ iRdyForCmd = 0;
+ if ( spi_drv_bNbrOfCmds > 3 )
+ {
+ iRdyForCmd = 3;
+ }
+ else
+ {
+ iRdyForCmd = spi_drv_bNbrOfCmds & 0x3;
+ }
+ INSERT_SPI_CTRL_CMDCNT(spi_drv_sMosiFrame.iSpiControl, iRdyForCmd );
+
+
+ ABCC_SetLowAddrOct( spi_drv_sMosiFrame.iIntMaskAppStatus, spi_drv_bNextAppStatus );
+ ABCC_SetHighAddrOct( spi_drv_sMosiFrame.iIntMaskAppStatus, spi_drv_bNextIntMask );
+ spi_drv_bpRdPd = NULL;
+
+
+ /*
+ ** Apply the CRC checksum.
+ */
+ lCrc = CRC_Crc32( (UINT16*)&spi_drv_sMosiFrame, spi_drv_iSpiFrameSize*2 - 6 );
+ lCrc = lTOlLe( lCrc );
+
+ ABCC_PORT_MemCpy( &spi_drv_sMosiFrame.iData[ spi_drv_iCrcOffset ],
+ &lCrc,
+ ABP_UINT32_SIZEOF );
+ /*
+ ** Send the MOSI frame.
+ */
+ ABCC_SYS_SpiSendReceive( &spi_drv_sMosiFrame, &spi_drv_sMisoFrame, spi_drv_iSpiFrameSize << 1 );
+ }
+ else if ( spi_drv_eState == SM_SPI_INIT )
+ {
+ ABCC_TimerStart( xWdTmoHandle, ABCC_CFG_WD_TIMEOUT_MS );
+ spi_drv_eState = SM_SPI_RDY_TO_SEND_MOSI;
+ }
+}
+
+
+/*------------------------------------------------------------------------------
+** Handle the reception of the MISO frame.
+**------------------------------------------------------------------------------
+** Arguments:
+** psResp: Pointer to the response message.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+ABP_MsgType* ABCC_DrvSpiRunDriverRx( void )
+{
+ UINT32 lRecievedCrc;
+ UINT32 lCalculatedCrc;
+ ABP_MsgType* psWriteMsg = NULL;
+
+ if( spi_drv_eState == SM_SPI_WAITING_FOR_MISO )
+ {
+ if( !spi_drv_fNewMisoReceived )
+ {
+ /*
+ ** Nothing has happened. No MISO was received.
+ */
+ return psWriteMsg;
+ }
+ else
+ {
+ spi_drv_fNewMisoReceived = FALSE;
+ }
+
+ lCalculatedCrc = CRC_Crc32( (UINT16*)&spi_drv_sMisoFrame, spi_drv_iSpiFrameSize*2 - 4 );
+ lCalculatedCrc = lLeTOl( lCalculatedCrc );
+
+ ABCC_PORT_MemCpy( &lRecievedCrc,
+ &spi_drv_sMisoFrame.iData[ spi_drv_iCrcOffset ],
+ ABP_UINT32_SIZEOF );
+
+ if( lCalculatedCrc != lRecievedCrc )
+ {
+ /*
+ ** We will request a retransmit if the data is corrupt.
+ */
+ spi_drv_fRetransmit = TRUE;
+ spi_drv_eState = SM_SPI_RDY_TO_SEND_MOSI;
+ return NULL;
+ }
+
+ /*
+ ** Restart watchdog
+ */
+ if( fWdTmo )
+ {
+ ABCC_CbfWdTimeoutRecovered();
+ }
+
+ ABCC_TimerStop( xWdTmoHandle );
+ fWdTmo = FALSE;
+ ABCC_TimerStart( xWdTmoHandle, ABCC_CFG_WD_TIMEOUT_MS );
+
+
+ /*
+ ** Save the current anybus status.
+ */
+ spi_drv_bAnbStatus = ABCC_GetLowAddrOct( spi_drv_sMisoFrame.iSpiStatusAnbStatus );
+ spi_drv_iLedStatus = iLeTOi( spi_drv_sMisoFrame.iLedStat );
+
+ spi_drv_bAnbCmdCnt = (UINT8)EXTRACT_SPI_STATUS_CMDCNT( spi_drv_sMisoFrame.iSpiStatusAnbStatus );
+
+ if( spi_drv_sMisoFrame.iSpiStatusAnbStatus & iSpiStatusNewPd )
+ {
+ /*
+ ** Report the new process data.
+ */
+ spi_drv_bpRdPd = (UINT8*)&spi_drv_sMisoFrame.iData[ spi_drv_iPdOffset ];
+ }
+
+ /*---------------------------------------------------------------------------
+ ** Write message handling.
+ **---------------------------------------------------------------------------
+ */
+ if( spi_drv_sWriteFragInfo.iCurrFragLength != 0 )
+ {
+ /*
+ ** Write the message to be sent.
+ */
+ if( !( spi_drv_sMisoFrame.iSpiStatusAnbStatus & iSpiStatusWrMsgFull ) )
+ {
+ /*
+ ** Write message was received.
+ ** Update the write fragmentation information.
+ */
+ spi_drv_sWriteFragInfo.puCurrPtr += spi_drv_sWriteFragInfo.iCurrFragLength;
+ spi_drv_sWriteFragInfo.iNumWordsLeft -= spi_drv_sWriteFragInfo.iCurrFragLength;
+ spi_drv_sWriteFragInfo.iCurrFragLength = 0;
+
+ if( spi_drv_sWriteFragInfo.iNumWordsLeft <= 0 )
+ {
+ psWriteMsg = (ABP_MsgType*)spi_drv_sWriteFragInfo.psWriteMsg;
+
+ spi_drv_ResetWriteFragInfo();
+
+ if( ( ABCC_GetLowAddrOct( ( (ABP_MsgType16*)psWriteMsg )->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT ) == 0)
+ {
+ spi_drv_bNbrOfCmds++;
+ }
+ }
+ }
+ }
+
+ /*---------------------------------------------------------------------------
+ ** Read message handling
+ ** --------------------------------------------------------------------------
+ */
+ if( spi_drv_sMisoFrame.iSpiStatusAnbStatus & iSpiStatus_M )
+ {
+ /*
+ ** Read message was received.
+ ** Update the read fragmentation information.
+ */
+
+ if( spi_drv_sReadFragInfo.puCurrPtr == 0 )
+ {
+ DrvSpiSetMsgReceiverBuffer( ABCC_MemAlloc() );
+
+ if( spi_drv_sReadFragInfo.puCurrPtr == 0 )
+ {
+ ABCC_ERROR( ABCC_SEV_WARNING, ABCC_EC_OUT_OF_MSG_BUFFERS, 0 );
+ return( NULL );
+ }
+ }
+
+ if( ( ( spi_drv_sReadFragInfo.iNumWordsReceived + spi_drv_iMsgLen ) << 1 ) >
+ ( ABCC_CFG_MAX_MSG_SIZE + ABCC_MSG_HEADER_TYPE_SIZEOF ) )
+ {
+ /*
+ ** Message size exceeds buffer.
+ */
+ ABCC_ERROR( ABCC_SEV_FATAL, ABCC_EC_RDMSG_SIZE_ERR, 0 );
+
+ return( NULL );
+ }
+
+ ABCC_PORT_MemCpy( spi_drv_sReadFragInfo.puCurrPtr,
+ spi_drv_sMisoFrame.iData,
+ spi_drv_iMsgLen << 1 );
+
+ spi_drv_sReadFragInfo.puCurrPtr += spi_drv_iMsgLen;
+ spi_drv_sReadFragInfo.iNumWordsReceived += spi_drv_iMsgLen;
+
+ if( spi_drv_sMisoFrame.iSpiStatusAnbStatus & iSpiStatusLastFrag )
+ {
+ /*
+ ** Last fragment of the read message. Return the message.
+ ** Update the application flow control.
+ */
+ if( ABCC_GetLowAddrOct( ( (ABP_MsgType16*)spi_drv_sReadFragInfo.psReadMsg)->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT )
+ {
+ spi_drv_bNbrOfCmds--;
+ }
+
+ spi_drv_psReadMessage = spi_drv_sReadFragInfo.psReadMsg;
+ spi_drv_ResetReadFragInfo();
+ }
+ }
+
+ /*
+ ** Clear the valid pd for the next frame.
+ */
+ spi_drv_sMosiFrame.iSpiControl &= ~iSpiCtrlWrPdWalid;
+ spi_drv_eState = SM_SPI_RDY_TO_SEND_MOSI;
+ }
+ else if( spi_drv_eState == SM_SPI_INIT )
+ {
+ spi_drv_eState = SM_SPI_RDY_TO_SEND_MOSI;
+ }
+
+ return psWriteMsg;
+} /* end of spi_drv_HandleMiso() */
+
+
+/*------------------------------------------------------------------------------
+** Callback from the physical layer to indicate that a MISO frame was received.
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void spi_drv_DataReceived( void )
+{
+ spi_drv_fNewMisoReceived = TRUE;
+}
+
+/*------------------------------------------------------------------------------
+** Reset the read fragmentation information.
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void spi_drv_ResetReadFragInfo( void )
+{
+ spi_drv_sReadFragInfo.iNumWordsReceived = 0;
+ spi_drv_sReadFragInfo.psReadMsg = NULL;
+ spi_drv_sReadFragInfo.puCurrPtr = NULL;
+}
+
+
+/*------------------------------------------------------------------------------
+** Reset the write fragmentation information.
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void spi_drv_ResetWriteFragInfo( void )
+{
+ ABCC_PORT_UseCritical();
+
+ spi_drv_sWriteFragInfo.iNumWordsLeft = 0;
+ spi_drv_sWriteFragInfo.iCurrFragLength = 0;
+ spi_drv_sWriteFragInfo.puCurrPtr = NULL;
+
+ ABCC_PORT_EnterCritical();
+ spi_drv_sWriteFragInfo.psWriteMsg = NULL;
+ ABCC_PORT_ExitCritical();
+}
+
+
+/*------------------------------------------------------------------------------
+** Watchdog timeouthandler
+**------------------------------------------------------------------------------
+** Arguments:
+** None.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void drv_WdTimeoutHandler( void )
+{
+ fWdTmo = TRUE;
+ ABCC_CbfWdTimeout();
+}
+
+
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+void ABCC_DrvSpiInit( UINT8 bOpmode )
+{
+
+ UINT16 i;
+ /*
+ ** Initialize privates and states.
+ */
+ ABCC_ASSERT_ERR( bOpmode == 1, ABCC_SEV_FATAL, ABCC_EC_INCORRECT_OPERATING_MODE, (UINT32)bOpmode );
+
+ spi_drv_sMosiFrame.iSpiControl = 0;
+ for ( i = 0; i < MAX_PAYLOAD_WORD_LEN; i++ )
+ {
+ spi_drv_sMosiFrame.iData[ i ] = 0;
+ spi_drv_sMisoFrame.iData[ i ] = 0;
+ }
+
+
+ spi_drv_ResetReadFragInfo();
+ spi_drv_fNewMisoReceived = FALSE;
+ spi_drv_bAnbStatus = 0;
+ spi_drv_psReadMessage = 0;
+ spi_drv_ResetWriteFragInfo();
+ spi_drv_sMosiFrame.iIntMaskAppStatus = 0;
+ spi_drv_bNbrOfCmds = 0;
+ spi_drv_eState = SM_SPI_INIT;
+ spi_drv_iPdSize = SPI_DEFAULT_PD_LEN;
+ spi_drv_iWritePdSize = SPI_DEFAULT_PD_LEN;
+ spi_drv_iReadPdSize = SPI_DEFAULT_PD_LEN;
+ spi_drv_iPdOffset = NUM_BYTES_2_WORDS( ABCC_CFG_SPI_MSG_FRAG_LEN );
+ spi_drv_iCrcOffset = NUM_BYTES_2_WORDS( ABCC_CFG_SPI_MSG_FRAG_LEN ) + SPI_DEFAULT_PD_LEN;
+ spi_drv_iSpiFrameSize = SPI_FRAME_SIZE_EXCLUDING_DATA + spi_drv_iCrcOffset;
+ spi_drv_fRetransmit = FALSE;
+ spi_drv_iMsgLen = 0;
+
+ spi_drv_iMsgLen = NUM_BYTES_2_WORDS( ABCC_CFG_SPI_MSG_FRAG_LEN );
+ spi_drv_sMosiFrame.iMsgLen = iTOiLe( spi_drv_iMsgLen );
+
+ spi_drv_sMosiFrame.iPdLen = iTOiLe( spi_drv_iPdSize );
+ spi_drv_bNextAppStatus = 0;
+ spi_drv_bNextIntMask = 0;
+ spi_drv_bpRdPd = NULL;
+ spi_drv_bAnbCmdCnt = 0;
+ xWdTmoHandle = ABCC_TimerCreate( drv_WdTimeoutHandler );
+ fWdTmo = FALSE;
+
+ /*
+ ** Register the MISO indicator for the physical SPI driver.
+ */
+ ABCC_SYS_SpiRegDataReceived( spi_drv_DataReceived );
+
+#if( ABCC_CFG_SYNC_MEASUREMENT_IP )
+ /*
+ ** Initialise sync measurement flag
+ */
+ fAbccUserSyncMeasurementIp = FALSE;
+#endif
+}
+
+BOOL ABCC_DrvSpiWriteMessage( ABP_MsgType* psWriteMsg )
+{
+ ABCC_PORT_UseCritical();
+ ABCC_ASSERT( psWriteMsg );
+
+ ABCC_PORT_EnterCritical();
+ ABCC_ASSERT(spi_drv_sWriteFragInfo.psWriteMsg == NULL );
+ spi_drv_sWriteFragInfo.puCurrPtr = (UINT16*)psWriteMsg;
+ spi_drv_sWriteFragInfo.iNumWordsLeft = NUM_BYTES_2_WORDS( iLeTOi( psWriteMsg->sHeader.iDataSize ) + ABCC_MSG_HEADER_TYPE_SIZEOF );
+ spi_drv_sWriteFragInfo.psWriteMsg = psWriteMsg;
+ ABCC_PORT_ExitCritical();
+
+ /*
+ ** The SPI driver still owns the buffer.
+ */
+ return( FALSE );
+}
+
+
+void ABCC_DrvSpiWriteProcessData( void* pxProcessData )
+{
+ (void)pxProcessData;
+ if( spi_drv_eState == SM_SPI_RDY_TO_SEND_MOSI )
+ {
+ spi_drv_sMosiFrame.iSpiControl |= iSpiCtrlWrPdWalid;
+ }
+ else
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_SPI_OP_NOT_ALLOWED_DURING_SPI_TRANSACTION,0);
+ }
+}
+
+BOOL ABCC_DrvSpiIsReadyForWriteMessage( void )
+{
+ BOOL fRdyForWrMsg = FALSE;
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ if ( spi_drv_sWriteFragInfo.psWriteMsg == NULL )
+ {
+ fRdyForWrMsg = TRUE;
+ }
+ ABCC_PORT_ExitCritical();
+ return fRdyForWrMsg;
+}
+
+
+BOOL ABCC_DrvSpiIsReadyForCmd( void )
+{
+ return ( pnABCC_DrvISReadyForWriteMessage() && ( spi_drv_bAnbCmdCnt > 0 ) );
+}
+
+
+void ABCC_DrvSpiSetNbrOfCmds( UINT8 bNbrOfCmds )
+{
+ spi_drv_bNbrOfCmds = bNbrOfCmds;
+}
+
+
+void ABCC_DrvSpiSetAppStatus( ABP_AppStatusType eAppStatus )
+{
+ spi_drv_bNextAppStatus = eAppStatus;
+}
+
+
+void ABCC_DrvSpiSetPdSize( const UINT16 iReadPdSize, const UINT16 iWritePdSize)
+{
+ if( spi_drv_eState == SM_SPI_RDY_TO_SEND_MOSI )
+ {
+ /*
+ ** Use the largest PD data size since the PD cannot be fragmented.
+ */
+ spi_drv_iWritePdSize = NUM_BYTES_2_WORDS( iWritePdSize );
+ spi_drv_iReadPdSize = NUM_BYTES_2_WORDS( iReadPdSize );
+
+ spi_drv_iPdSize = spi_drv_iWritePdSize;
+ if( spi_drv_iReadPdSize > spi_drv_iWritePdSize )
+ {
+ spi_drv_iPdSize = spi_drv_iReadPdSize;
+ }
+
+ /*
+ ** Update the CRC position and the total frame size since the process data
+ ** size might have changed.
+ */
+ spi_drv_iCrcOffset = spi_drv_iPdOffset + spi_drv_iPdSize;
+ spi_drv_iSpiFrameSize = SPI_FRAME_SIZE_EXCLUDING_DATA + spi_drv_iCrcOffset;
+ spi_drv_sMosiFrame.iPdLen = iTOiLe( spi_drv_iPdSize );
+ }
+ else
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_SPI_OP_NOT_ALLOWED_DURING_SPI_TRANSACTION,0);
+ }
+}
+
+static void DrvSpiSetMsgReceiverBuffer( ABP_MsgType* const psReadMsg )
+{
+ if ( spi_drv_sReadFragInfo.puCurrPtr == NULL )
+ {
+ spi_drv_sReadFragInfo.psReadMsg = psReadMsg;
+ spi_drv_sReadFragInfo.puCurrPtr = (UINT16*)psReadMsg;
+ spi_drv_sReadFragInfo.iNumWordsReceived = 0;
+ }
+ else
+ {
+ ABCC_ERROR(ABCC_SEV_WARNING, ABCC_EC_SPI_OP_NOT_ALLOWED_DURING_SPI_TRANSACTION,0);
+ }
+}
+
+
+UINT16 ABCC_DrvSpiGetIntStatus( void )
+{
+ ABCC_ERROR(ABCC_SEV_FATAL, ABCC_EC_INTSTATUS_NOT_SUPPORTED_BY_DRV_IMPL, 0);
+
+ return 0xFFFF;
+}
+
+
+UINT8 ABCC_DrvSpiGetAnybusState( void )
+{
+ return spi_drv_bAnbStatus & 0x7;
+}
+
+
+void* ABCC_DrvSpiReadProcessData( void )
+{
+ UINT8* pxRdPd = NULL;
+
+ if( spi_drv_eState == SM_SPI_RDY_TO_SEND_MOSI )
+ {
+ pxRdPd = spi_drv_bpRdPd;
+ }
+ return pxRdPd;
+}
+
+
+ABP_MsgType* ABCC_DrvSpiReadMessage( void )
+{
+ ABP_MsgType* psRdMsg = NULL;
+
+ if( spi_drv_eState == SM_SPI_RDY_TO_SEND_MOSI )
+ {
+ if ( spi_drv_psReadMessage != NULL )
+ {
+ psRdMsg = spi_drv_psReadMessage;
+ spi_drv_psReadMessage = NULL;
+ }
+ }
+ return psRdMsg;
+}
+
+void ABCC_DrvSpiSetIntMask( const UINT16 iIntMask )
+{
+ spi_drv_bNextIntMask = (UINT8)iIntMask;
+}
+
+
+void* ABCC_DrvSpiGetWrPdBuffer( void )
+{
+ return &spi_drv_sMosiFrame.iData[ spi_drv_iPdOffset ];
+}
+
+
+UINT16 ABCC_DrvSpiGetModCap( void )
+{
+ ABCC_ERROR( ABCC_SEV_WARNING , ABCC_EC_MODCAP_NOT_SUPPORTED_BY_DRV_IMPL, 0);
+ return 0;
+}
+
+UINT16 ABCC_DrvSpiGetLedStatus( void )
+{
+ return spi_drv_iLedStatus;
+}
+
+BOOL ABCC_DrvSpiIsReadyForWrPd( void )
+{
+ if ( spi_drv_eState == SM_SPI_RDY_TO_SEND_MOSI )
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOL ABCC_DrvSpiIsSupervised( void )
+{
+ /*
+ ** The Anybus supervision bis is stored in bit 3
+ */
+ return ( spi_drv_bAnbStatus >> 3 ) & 1;
+}
+
+UINT8 ABCC_DrvSpiGetAnbStatus( void )
+{
+ return (UINT8)spi_drv_bAnbStatus & 0xf;
+}
+
+
+#endif
+
+
+
+
+
+/*******************************************************************************
+** End of spi_drv.c
+********************************************************************************
+*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/ad_obj.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,1788 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Implementation of the AD object.
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_td.h"
+#include "abcc_sw_port.h"
+#include "abcc_drv_cfg.h"
+#include "abcc_obj_cfg.h"
+#include "abp.h"
+#include "abcc_ad_if.h"
+#include "abcc.h"
+#include "appl_abcc_handler.h"
+#include "abcc_sys_adapt.h"
+#include "ad_obj.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+#if( AD_MAX_NUM_WRITE_ADI_TO_MAP > AD_MAX_NUM_READ_ADI_TO_MAP )
+#define AD_MAX_OF_READ_WRITE_TO_MAP AD_MAX_NUM_WRITE_ADI_TO_MAP
+#else
+#define AD_MAX_OF_READ_WRITE_TO_MAP AD_MAX_NUM_READ_ADI_TO_MAP
+#endif
+#endif
+
+/*
+** Value used in ad_MapType as ADI index when ADI 0 is mapped.
+*/
+#define AD_MAP_PAD_INDEX ( 0xfffe )
+
+/*
+** Invalid ADI index.
+*/
+#define AD_INVALID_ADI_INDEX ( 0xffff )
+
+/*
+** Default number of sub-elements
+*/
+#define AD_DEFAULT_NUM_SUB_ELEMS ( 1 )
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Type with mapping information for a single ADI
+**------------------------------------------------------------------------------
+** iAdiIndex - Index to ADI entry table.
+** bNumElements - Number of mapped elements.
+** bStartIndex - Element start index for the mapping
+**------------------------------------------------------------------------------
+*/
+typedef struct ad_Map
+{
+ UINT16 iAdiIndex;
+ UINT8 bNumElements;
+ UINT8 bStartIndex;
+}
+ad_MapType;
+
+/*------------------------------------------------------------------------------
+** Type with mapping information for a specific direction (read/write).
+**------------------------------------------------------------------------------
+** paiMappedAdiList - Pointer to list of all mapped items.
+** iNumMappedAdi - Number of mapped ADI:s
+** iMaxNumMappedAdi - Maximum number of mapped ADI:s.
+** iPdSize - Current process data size in octets.
+**------------------------------------------------------------------------------
+*/
+typedef struct ad_MapInfo
+{
+ ad_MapType* paiMappedAdiList;
+ UINT16 iNumMappedAdi;
+ UINT16 iMaxNumMappedAdi;
+ UINT16 iPdSize;
+}
+ad_MapInfoType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+static BOOL ad_fDoNetworkEndianSwap = FALSE;
+static const AD_DefaultMapType* ad_asDefaultMap = NULL;
+static const AD_AdiEntryType* ad_asADIEntryList = NULL;
+static UINT16 ad_iNumOfADIs;
+static UINT16 ad_iHighestInstanceNumber;
+static ad_MapType ad_PdReadMapping[ AD_MAX_NUM_READ_ADI_TO_MAP ];
+static ad_MapType ad_PdWriteMapping[ AD_MAX_NUM_WRITE_ADI_TO_MAP ];
+static ad_MapInfoType ad_ReadMapInfo;
+static ad_MapInfoType ad_WriteMapInfo;
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Converts number of octet offset to byte offset.
+**------------------------------------------------------------------------------
+*/
+#ifdef ABCC_SYS_16_BIT_CHAR
+#define OctetToByteOffset( x ) ( ( x ) >> 1 )
+#else
+#define OctetToByteOffset( x ) ( x )
+#endif
+
+/*------------------------------------------------------------------------------
+** Checks if a ABP data type is either a bit or pad type.
+**------------------------------------------------------------------------------
+*/
+#define Is_BITx_Or_PADx( type ) ( ABP_Is_PADx( type ) || ABP_Is_BITx( type ) )
+
+/*------------------------------------------------------------------------------
+** The bit variable is converted to whole octets and added to the octet variable.
+** The remaining bits are saved to the bit variable.
+** For a 16 bit char system the number of octets are kept even.
+** Note that both input variables are updated.
+**------------------------------------------------------------------------------
+*/
+#ifdef ABCC_SYS_16_BIT_CHAR
+#define AddBitsToOctetSize( octet, bits ) \
+do \
+{ \
+ (octet) += (bits >> 4 ) << 1; \
+ (bits) %= 16; \
+} \
+while( 0 )
+#else
+#define AddBitsToOctetSize( octet, bits ) \
+do \
+{ \
+ (octet) += (bits) >> 3; \
+ (bits) %= 8; \
+} \
+while( 0 )
+#endif
+
+/*------------------------------------------------------------------------------
+** Calculates the bit offset to the startindex element in the ADI.
+**------------------------------------------------------------------------------
+*/
+#define CalcStartindexBitOffset( bDataType, iStartIndex ) \
+ ABCC_GetDataTypeSizeInBits( bDataType ) * ( iStartIndex )
+
+
+/*------------------------------------------------------------------------------
+** Add octet variable and bit variable and round up to nearest octet.
+**------------------------------------------------------------------------------
+*/
+#define SizeInOctets( octet, bits ) ( (octet) + ( (bits) + 7 ) / 8 )
+
+/*------------------------------------------------------------------------------
+** Convert bit offset to octet offset.
+**------------------------------------------------------------------------------
+*/
+#define BitToOctetOffset( bitOffset ) ( (bitOffset) >> 3 )
+
+/*------------------------------------------------------------------------------
+** Copies a 16 bit values from a source to a destination. Each value will be
+** endian swapped. The function support octet alignment.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxDest - Base pointer to the destination.
+** iDestOctetOffset - Octet offset to the destination where the copy will
+** begin.
+** pxSrc - Bsse pointer to source data.
+** iSrcOctetOffset - Octet offset to the source where the copy will begin.
+** iNumElem - Number of 16 bit values to copy.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void Copy16WithEndianSwap( void* pxDest, UINT16 iDestOctetOffset,
+ void* pxSrc, UINT16 iSrcOctetOffset,
+ UINT16 iNumElem )
+{
+ UINT16 i;
+ UINT16 iConv;
+
+ for( i = 0; i < iNumElem; i++ )
+ {
+ ABCC_PORT_Copy16( &iConv, 0, pxSrc, iSrcOctetOffset + ( i << 1 ) );
+ iConv = ABCC_iEndianSwap( iConv );
+ ABCC_PORT_Copy16( pxDest, iDestOctetOffset + ( i << 1 ), &iConv, 0 );
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Copies a 32 bit values from a source to a destination. Each value will be
+** endian swapped. The function support octet alignment.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxDest - Base pointer to the destination.
+** iDestOctetOffset - Octet offset to the destination where the copy will
+** begin.
+** pxSrc - Bsse pointer to source data.
+** iSrcOctetOffset - Octet offset to the source where the copy will begin.
+** iNumElem - Number of 32 bit values to copy.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void Copy32WithEndianSwap( void* pxDest, UINT16 iDestOctetOffset,
+ void* pxSrc, UINT16 iSrcOctetOffset,
+ UINT16 iNumElem )
+{
+ UINT16 i;
+ UINT32 lConv;
+
+ for( i = 0; i < iNumElem; i++ )
+ {
+ ABCC_PORT_Copy32( &lConv, 0, pxSrc, iSrcOctetOffset + ( i << 2 ) );
+ lConv = ABCC_lEndianSwap( lConv );
+ ABCC_PORT_Copy32( pxDest, iDestOctetOffset + ( i << 2 ), &lConv, 0 );
+ }
+}
+
+
+/*------------------------------------------------------------------------------
+** Copies a 64 bit values from a source to a destination. Each value will be
+** endian swapped. The function support octet alignment.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxDest - Base pointer to the destination.
+** iDestOctetOffset - Octet offset to the destination where the copy will
+** begin.
+** pxSrc - Bsse pointer to source data.
+** iSrcOctetOffset - Octet offset to the source where the copy will begin.
+** iNumElem - Number of 64 bit values to copy.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_64BIT_ADI_SUPPORT )
+static void Copy64WithEndianSwap( void* pxDest, UINT16 iDestOctetOffset,
+ void* pxSrc, UINT16 iSrcOctetOffset,
+ UINT16 iNumElem )
+{
+ UINT16 i;
+ UINT64 lConv;
+
+ for( i = 0; i < iNumElem; i++ )
+ {
+ ABCC_PORT_Copy64( &lConv, 0, pxSrc, iSrcOctetOffset + ( i << 3 ) );
+ lConv = ABCC_lEndianSwap64( lConv );
+ ABCC_PORT_Copy64( pxDest, iDestOctetOffset + ( i << 3 ), &lConv, 0 );
+ }
+}
+#endif
+
+/*------------------------------------------------------------------------------
+** Calculates size of ADI rounded up to nearest octet.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry.
+**
+** Returns:
+** Size in octets.
+**------------------------------------------------------------------------------
+*/
+static UINT16 GetAdiSizeInOctets( const AD_AdiEntryType* psAdiEntry )
+{
+ UINT16 iSize;
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ UINT16 i;
+
+ if( psAdiEntry->psStruct != NULL )
+ {
+ iSize = 0;
+ for( i = 0; i < psAdiEntry->bNumOfElements; i++ )
+ {
+ iSize +=
+ ABCC_GetDataTypeSizeInBits( psAdiEntry->psStruct[ i ].bDataType );
+ }
+ }
+ else
+#endif
+ {
+ iSize = ABCC_GetDataTypeSizeInBits( psAdiEntry->bDataType ) *
+ psAdiEntry->bNumOfElements ;
+ }
+ iSize = ( iSize + 7 ) / 8;
+ return( iSize );
+}
+
+/*------------------------------------------------------------------------------
+** Calculates map size of of an ADI mapping item, in bits.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry.
+** bNumElem - Number of elements
+** bElemStartIndex - First element index.
+**
+** Returns:
+** Size in bits.
+**------------------------------------------------------------------------------
+*/
+static UINT16 GetAdiMapSizeInBits( const AD_AdiEntryType* psAdiEntry,
+ UINT8 bNumElem,
+ UINT8 bElemStartIndex )
+{
+ UINT16 iSize;
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ UINT16 i;
+ if( psAdiEntry->psStruct != NULL )
+ {
+ iSize = 0;
+ for( i = bElemStartIndex; i < ( bNumElem + bElemStartIndex ) ; i++ )
+ {
+ iSize +=
+ ABCC_GetDataTypeSizeInBits( psAdiEntry->psStruct[ i ].bDataType );
+ }
+ }
+ else
+ {
+ iSize = ABCC_GetDataTypeSizeInBits( psAdiEntry->bDataType ) * bNumElem ;
+ }
+#else
+ (void)bElemStartIndex;
+ iSize = ABCC_GetDataTypeSizeInBits( psAdiEntry->bDataType ) * bNumElem ;
+#endif
+
+ return( iSize );
+}
+
+/*------------------------------------------------------------------------------
+** Calculates total map size in octets.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMap - Pointer to mapping information. The size is
+** calculated based on the on the mapping list provided
+** in the structure. The iPdSize member is updated with
+** the new size.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void UpdateMapSize( ad_MapInfoType* psMap )
+{
+ UINT16 iMapIndex;
+ UINT16 iAdiIndex;
+
+ psMap->iPdSize = 0;
+ for( iMapIndex = 0; iMapIndex < psMap->iNumMappedAdi; iMapIndex++ )
+ {
+ iAdiIndex = psMap->paiMappedAdiList[ iMapIndex ].iAdiIndex;
+ if( iAdiIndex != AD_MAP_PAD_INDEX )
+ {
+ psMap->iPdSize +=
+ GetAdiMapSizeInBits( &ad_asADIEntryList[ iAdiIndex ],
+ psMap->paiMappedAdiList[ iMapIndex ].bNumElements,
+ psMap->paiMappedAdiList[ iMapIndex ].bStartIndex );
+ }
+ else
+ {
+ psMap->iPdSize += psMap->paiMappedAdiList[ iMapIndex ].bNumElements;
+ }
+ }
+ psMap->iPdSize = SizeInOctets( 0, psMap->iPdSize );
+}
+
+/*------------------------------------------------------------------------------
+** Find ADI entry table index for the specified instance number.
+**------------------------------------------------------------------------------
+** Arguments:
+** iInstance - Instance number.
+**
+** Returns:
+** 0 - 0xfffe - Index in ADI entry table.
+** AD_INVALID_ADI_INDEX - Instance was not found.
+**------------------------------------------------------------------------------
+*/
+static UINT16 GetAdiIndex( UINT16 iInstance )
+{
+ UINT16 i;
+ UINT16 iIndex;
+
+ iIndex = AD_INVALID_ADI_INDEX;
+
+ if( iInstance == 0 )
+ {
+ return( AD_MAP_PAD_INDEX );
+ }
+
+ for( i = 0; i < ad_iNumOfADIs; i++ )
+ {
+ if( ad_asADIEntryList[ i ].iInstance == iInstance )
+ {
+ iIndex = i;
+ break;
+ }
+ }
+
+ return( iIndex );
+}
+
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+/*------------------------------------------------------------------------------
+** Process of remap command.
+**------------------------------------------------------------------------------
+** Arguments:
+** ABP_MsgType - Pointer to remap command.
+** psCurrMap - Pointer to current mapping. Will hold the new
+** mapping when processing is done.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+static void RemapProcessDataCommand( ABP_MsgType* psMsg,
+ ad_MapInfoType* psCurrMap )
+{
+
+ UINT16 iAdi;
+ UINT16 iMsgIndex;
+ UINT16 iAddItemIndex;
+ UINT16 iMapIndex;
+ UINT16 bStartOfRemap;
+ UINT8 bErrCode;
+ UINT16 iItemsToRemove;
+ UINT16 iItemsToAdd;
+ UINT16 iDataSize;
+ ad_MapType sMap;
+
+ iDataSize = 1;
+ bStartOfRemap = ABCC_GetMsgCmdExt( psMsg );
+
+ ABCC_GetMsgData16( psMsg, &iItemsToRemove, 0);
+ ABCC_GetMsgData16( psMsg, &iItemsToAdd, 2);
+
+ /*
+ ** A lot of sanity checks first since all actions of the command shall
+ ** either be carried out or rejected.
+ */
+ if( ABCC_GetMsgDataSize( psMsg ) < 4 )
+ {
+ /*
+ ** Not enough data provided
+ */
+ bErrCode = ABP_ERR_NOT_ENOUGH_DATA;
+ }
+ else if( bStartOfRemap > psCurrMap->iNumMappedAdi )
+ {
+ /*
+ ** Not an allowed mapping number
+ */
+ bErrCode = ABP_ERR_INV_CMD_EXT_0;
+ }
+ else if( ( bStartOfRemap + iItemsToRemove ) > psCurrMap->iNumMappedAdi )
+ {
+ /*
+ ** Cannot remove more than currently is mapped
+ */
+ bErrCode = ABP_ERR_OUT_OF_RANGE;
+ }
+ else if( ( psCurrMap->iNumMappedAdi + iItemsToAdd - iItemsToRemove ) >
+ psCurrMap->iMaxNumMappedAdi )
+ {
+ /*
+ ** This will result in more maps than we can handle
+ */
+ bErrCode = ABP_ERR_NO_RESOURCES;
+ }
+ else if( ABCC_GetMsgDataSize( psMsg ) < 4 + ( iItemsToAdd * 4 ) )
+ {
+ bErrCode = ABP_ERR_NOT_ENOUGH_DATA;
+ }
+ else if( ABCC_GetMsgDataSize( psMsg ) > 4 + ( iItemsToAdd * 4 ) )
+ {
+ bErrCode = ABP_ERR_TOO_MUCH_DATA;
+ }
+ else
+ {
+ bErrCode = ABP_ERR_NO_ERROR;
+ }
+
+ /*
+ ** Check New ADI:s
+ */
+ if( bErrCode == ABP_ERR_NO_ERROR )
+ {
+ iAddItemIndex = 0;
+ iMsgIndex = 4;
+ while( ( bErrCode == ABP_ERR_NO_ERROR ) && ( iAddItemIndex < iItemsToAdd ) )
+ {
+ ABCC_GetMsgData16( psMsg, &iAdi, iMsgIndex );
+ sMap.iAdiIndex = GetAdiIndex( iAdi );
+ iMsgIndex += 2;
+ ABCC_GetMsgData8( psMsg, &sMap.bStartIndex, iMsgIndex++ );
+ ABCC_GetMsgData8( psMsg, &sMap.bNumElements, iMsgIndex++ );
+
+ if( sMap.iAdiIndex != AD_MAP_PAD_INDEX )
+ {
+ if( ( sMap.bStartIndex + sMap.bNumElements ) >
+ ad_asADIEntryList[ sMap.iAdiIndex ].bNumOfElements )
+ {
+ bErrCode = ABP_ERR_OBJ_SPECIFIC;
+ /*
+ ** ABP_APPD_ERR_INVALID_NUM_ELEMENTS
+ */
+ ABCC_SetMsgData8( psMsg, 0x02, 1 );
+ iDataSize = 2;
+ }
+ }
+ iAddItemIndex++;
+ }
+ }
+
+ if( bErrCode == ABP_ERR_NO_ERROR )
+ {
+ /*
+ ** Move ADI if required
+ */
+ if( ( iItemsToRemove != iItemsToAdd ) &&
+ ( iItemsToRemove < ( psCurrMap->iNumMappedAdi - bStartOfRemap ) ) )
+ {
+ INT16 iItemsToMove;
+ UINT16 iMoveFrom;
+ UINT16 iMoveTo;
+ UINT16 iIndex;
+
+ /*
+ ** Data needs to be moved
+ */
+ iMoveFrom = bStartOfRemap + iItemsToRemove;
+ iMoveTo = bStartOfRemap + iItemsToAdd;
+ iItemsToMove = psCurrMap->iNumMappedAdi - bStartOfRemap - iItemsToRemove;
+
+ if( iItemsToRemove > iItemsToAdd )
+ {
+ for( iIndex = 0; iIndex < iItemsToMove; iIndex++ )
+ {
+ psCurrMap->paiMappedAdiList[ iMoveTo + iIndex ] =
+ psCurrMap->paiMappedAdiList[ iMoveFrom + iIndex ];
+ }
+ }
+ else
+ {
+ for( iIndex = iItemsToMove ; iIndex > 0 ; iIndex-- )
+ {
+ psCurrMap->paiMappedAdiList[ iMoveTo + iIndex - 1 ] =
+ psCurrMap->paiMappedAdiList[ iMoveFrom + iIndex - 1 ];
+ }
+ }
+ }
+
+ iMapIndex = bStartOfRemap;
+ psCurrMap->iNumMappedAdi -= iItemsToRemove;
+ psCurrMap->iNumMappedAdi += iItemsToAdd;
+
+ iMsgIndex = 4;
+ for( iAddItemIndex = 0; iAddItemIndex < iItemsToAdd; iAddItemIndex++ )
+ {
+ ABCC_GetMsgData16( psMsg, &iAdi, iMsgIndex );
+ psCurrMap->paiMappedAdiList[ iMapIndex ].iAdiIndex = GetAdiIndex( iAdi );
+ iMsgIndex += 2;
+ ABCC_GetMsgData8( psMsg, &psCurrMap->paiMappedAdiList[ iMapIndex ].bStartIndex, iMsgIndex++ );
+ ABCC_GetMsgData8( psMsg, &psCurrMap->paiMappedAdiList[ iMapIndex ].bNumElements, iMsgIndex++ );
+ iMapIndex++;
+ }
+
+ UpdateMapSize( psCurrMap );
+
+ ABCC_SetMsgData16(psMsg, psCurrMap->iPdSize, 0);
+ ABP_SetMsgResponse( psMsg, 2 );
+ ABCC_SendRemapRespMsg( psMsg, ad_ReadMapInfo.iPdSize,
+ ad_WriteMapInfo.iPdSize);
+ }
+ else
+ {
+ ABP_SetMsgErrorResponse( psMsg, iDataSize, bErrCode );
+ ABCC_SendRespMsg(psMsg );
+ }
+}
+#endif
+
+
+/*------------------------------------------------------------------------------
+** Copy bit data. Any alignment is allowed.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxDest - Destination base pointer.
+** iDestBitOffset - Bit offset relative destination pointer.
+** pxSrc - Source base pointer.
+** iSrcBitOffset - Bit offset relative source pointer.
+** bDataType - Data type according to ABP_<X> types in abp.h
+** iNumElem - Number of elements to copy.
+**
+** Returns:
+** Size of copied data in bits.
+**------------------------------------------------------------------------------
+*/
+static UINT16 CopyBitData( void* pxDest,
+ UINT16 iDestBitOffset,
+ void* pxSrc,
+ UINT16 iSrcBitOffset,
+ UINT8 bDataType,
+ UINT16 iNumElem )
+{
+ UINT8 bCopySize;
+ UINT16 i;
+ UINT16 iSetBitSize = 0;
+ UINT32 lBitMask;
+ UINT32 lSrc;
+ UINT32 lDest;
+ UINT16 iSrcOctetOffset;
+ UINT16 iDestOctetOffset;
+
+ iSrcOctetOffset = 0;
+ iDestOctetOffset = 0;
+
+ if( ABP_Is_PADx( bDataType ) )
+ {
+ /*
+ ** This is only a pad. No copy is done.
+ */
+ iSetBitSize += bDataType - ABP_PAD0;
+ }
+ else
+ {
+ /*
+ ** Separate offsets into octets and bits.
+ */
+ AddBitsToOctetSize( iSrcOctetOffset, iSrcBitOffset );
+ AddBitsToOctetSize( iDestOctetOffset, iDestBitOffset );
+
+ /*
+ ** Calculate number of bits to be set.
+ */
+ iSetBitSize += ( ( bDataType - ABP_BIT1 ) + 1 );
+
+ for( i = 0; i < iNumElem; i++ )
+ {
+ /*
+ ** Calculate the number of octets that has to be copied
+ ** to include both destination bit offset and bit size.
+ */
+ bCopySize = ( iSetBitSize + iDestBitOffset + 7 ) / 8;
+
+ /*
+ ** Copy parts to be manipulated into local 32 bit variables to
+ ** guarantee correct alignment.
+ */
+ ABCC_PORT_CopyOctets( &lSrc, 0, pxSrc, iSrcOctetOffset ,
+ ABP_UINT32_SIZEOF );
+ ABCC_PORT_CopyOctets( &lDest, 0, pxDest, iDestOctetOffset, bCopySize );
+
+ /*
+ ** Bit data types crossing octet boundaries are always little endian.
+ */
+ lSrc = lLeTOl( lSrc );
+ lDest = lLeTOl( lDest );
+
+ /*
+ ** Calculate bit mask and align it with destination bit offset.
+ */
+ lBitMask = ( (UINT32)1 << iSetBitSize ) - 1;
+ lBitMask <<= iDestBitOffset;
+
+ /*
+ ** Align source bits with destination bits
+ */
+ if( iSrcBitOffset < iDestBitOffset )
+ {
+ lSrc <<= iDestBitOffset - iSrcBitOffset;
+ }
+ else
+ {
+ lSrc >>= iSrcBitOffset - iDestBitOffset;
+ }
+
+ /*
+ ** Clear destinations bits and mask source bits an insert source bits
+ ** into destination bit position.
+ */
+ lDest &= ~lBitMask;
+ lSrc &= lBitMask;
+ lDest |= lSrc;
+
+ /*
+ ** Restore endian.
+ */
+ lDest = lTOlLe( lDest );
+
+ /*
+ ** Copy local updated data into final destination.
+ */
+ ABCC_PORT_CopyOctets( pxDest, iDestOctetOffset, &lDest, 0, bCopySize );
+
+ /*
+ ** Update bit offsets to next bit field.
+ */
+ iSrcBitOffset += iSetBitSize;
+ AddBitsToOctetSize( iSrcOctetOffset, iSrcBitOffset );
+ iDestBitOffset += iSetBitSize;
+ AddBitsToOctetSize( iDestOctetOffset, iDestBitOffset );
+ }
+ iSetBitSize *= iNumElem;
+ }
+ return( iSetBitSize );
+}
+
+/*------------------------------------------------------------------------------
+** Copy value (single element or parts of an array) of a specific type
+** from a specified source to a destination. If the host platform endian
+** differs from network endian a swap will be done.
+** NOTE!! For all non-bit data types the source and destination must be octet
+** aligned.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxDst - Destination base pointer.
+** iDestBitOffset - Bit offset relative destination pointer.
+** pxSrc - Source base pointer.
+** iSrcBitOffset - Bit offset relative source pointer.
+** bDataType - Data type according to ABP_<X> types in abp.h
+** iNumElem - Number of elements to copy.
+**
+** Returns:
+** Size of copied data in bits.
+**------------------------------------------------------------------------------
+*/
+static UINT16 CopyValue( void* pxDst,
+ UINT16 iDestBitOffset,
+ void* pxSrc ,
+ UINT16 iSrcBitOffset,
+ UINT8 bDataType,
+ UINT16 iNumElem )
+{
+ UINT8 bDataTypeSizeInOctets;
+ UINT16 iBitSetSize;
+
+ if( Is_BITx_Or_PADx( bDataType ) )
+ {
+ iBitSetSize = CopyBitData( pxDst,
+ iDestBitOffset,
+ pxSrc,
+ iSrcBitOffset,
+ bDataType,
+ iNumElem );
+ }
+ else
+ {
+ bDataTypeSizeInOctets = ABCC_GetDataTypeSize( bDataType );
+
+ if( ad_fDoNetworkEndianSwap )
+ {
+ switch( bDataTypeSizeInOctets )
+ {
+ case 1:
+ ABCC_PORT_CopyOctets( pxDst, BitToOctetOffset( iDestBitOffset ),
+ pxSrc, BitToOctetOffset( iSrcBitOffset ),
+ iNumElem );
+ break;
+
+ case 2:
+ Copy16WithEndianSwap( pxDst, BitToOctetOffset( iDestBitOffset ),
+ pxSrc, BitToOctetOffset( iSrcBitOffset ),
+ iNumElem );
+ break;
+
+ case 4:
+ Copy32WithEndianSwap( pxDst, BitToOctetOffset( iDestBitOffset ),
+ pxSrc, BitToOctetOffset( iSrcBitOffset ),
+ iNumElem );
+ break;
+
+ #if( ABCC_CFG_64BIT_ADI_SUPPORT )
+ case 8:
+ Copy64WithEndianSwapImpl( pxDst, BitToOctetOffset( iDestBitOffset ),
+ pxSrc, BitToOctetOffset( iSrcBitOffset ),
+ iNumElem );
+ break;
+ #endif
+ default:
+ break;
+ }
+ }
+ else
+ {
+ ABCC_PORT_CopyOctets( pxDst, BitToOctetOffset( iDestBitOffset ),
+ pxSrc, BitToOctetOffset( iSrcBitOffset ),
+ bDataTypeSizeInOctets * iNumElem );
+ }
+
+ iBitSetSize = ( iNumElem * bDataTypeSizeInOctets ) << 3;
+ }
+
+ return( iBitSetSize );
+}
+
+
+
+/*------------------------------------------------------------------------------
+** Get min, max or default value(s) for an ADI. If the ADI is a structured ADI
+** all default values will have the same format as the structure describes.
+** The result is in network endian format.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry
+** pxDest - Destination pointer
+** eMinMaxDefault - Get min, max or default value described by
+** AD_MinMaxDefaultIndexType
+** piOctetSize - Size in octets of the written default values
+**
+** Returns:
+** ABP error code.
+**------------------------------------------------------------------------------
+*/
+#if( AD_IA_MIN_MAX_DEFAULT_ENABLE )
+static UINT8 GetMinMaxDefault( const AD_AdiEntryType* psAdiEntry,
+ void* pxDest,
+ AD_MinMaxDefaultIndexType eMinMaxDefault,
+ UINT16* piBitSize)
+{
+ UINT16 iSrcBitOffset;
+
+ *piBitSize = 0;
+
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if( psAdiEntry->psStruct != NULL )
+ {
+ UINT16 i;
+
+ for(i = 0; i < psAdiEntry->bNumOfElements; i++ )
+ {
+ if( psAdiEntry->psStruct[ i ].uData.sVOID.pxValueProps != NULL )
+ {
+ iSrcBitOffset = CalcStartindexBitOffset( psAdiEntry->psStruct[ i ].bDataType, (UINT16)eMinMaxDefault );
+
+ *piBitSize += CopyValue( pxDest,
+ *piBitSize,
+ psAdiEntry->psStruct[ i ].uData.sVOID.pxValueProps,
+ iSrcBitOffset,
+ psAdiEntry->psStruct[ i ].bDataType,
+ 1 );
+ }
+ else
+ {
+ *piBitSize = 0;
+ return( ABP_ERR_INV_CMD_EXT_0 );
+ }
+ }
+ }
+ else
+#endif
+ {
+ if( psAdiEntry->uData.sVOID.pxValueProps != NULL )
+ {
+ iSrcBitOffset = CalcStartindexBitOffset( psAdiEntry->bDataType,
+ (UINT16)eMinMaxDefault );
+
+ *piBitSize += CopyValue( pxDest,
+ *piBitSize,
+ psAdiEntry->uData.sVOID.pxValueProps,
+ iSrcBitOffset,
+ psAdiEntry->bDataType,
+ 1 );
+ }
+ else
+ {
+ *piBitSize = 0;
+ return( ABP_ERR_INV_CMD_EXT_0 );
+ }
+ }
+ return( ABP_ERR_NO_ERROR );
+}
+#endif
+
+/*------------------------------------------------------------------------------
+** Get ADI of any data type. The read ADI will have network endian format.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry
+** pxDest - Destination base pointer.
+** bNumElements - Number of elements to read.
+** bStartIndex - Index to first element to read.
+** piDestBitOffset - Pointer to destination bit offset.
+** This offset will be incremented according to the size
+** of the read.
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void GetAdiValue( const AD_AdiEntryType* psAdiEntry,
+ void* pxDest,
+ UINT8 bNumElements,
+ UINT8 bStartIndex,
+ UINT16* piDestBitOffset )
+{
+ UINT16 iSrcBitOffset;
+
+#if( ABCC_CFG_ADI_GET_SET_CALLBACK )
+ /*
+ ** If a get callback is registered the user is notified that the ADI shall be
+ ** updated.
+ */
+ if( psAdiEntry->pnGetAdiValue != NULL )
+ {
+ psAdiEntry->pnGetAdiValue( psAdiEntry,
+ bNumElements,
+ bStartIndex );
+ }
+#endif
+
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if( psAdiEntry->psStruct != NULL )
+ {
+ UINT16 i;
+
+ i = 0;
+
+ /*
+ ** For structures each element is handled separately.
+ */
+ for( i = bStartIndex; i < bNumElements + bStartIndex; i++ )
+ {
+ iSrcBitOffset = psAdiEntry->psStruct[ i ].bBitOffset;
+
+ *piDestBitOffset += CopyValue( pxDest,
+ *piDestBitOffset,
+ psAdiEntry->psStruct[ i ].uData.sVOID.pxValuePtr,
+ iSrcBitOffset,
+ psAdiEntry->psStruct[ i ].bDataType,
+ psAdiEntry->psStruct[ i ].iNumSubElem );
+ }
+ }
+ else
+#endif
+ {
+ iSrcBitOffset = CalcStartindexBitOffset( psAdiEntry->bDataType, bStartIndex );
+ *piDestBitOffset += CopyValue( pxDest,
+ *piDestBitOffset,
+ psAdiEntry->uData.sVOID.pxValuePtr,
+ iSrcBitOffset,
+ psAdiEntry->bDataType,
+ bNumElements );
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Set ADI of any data type. The provided data must have network endian format.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to ADI entry.
+** pxData - Source base pointer.
+** bNumElements - Number of elements to write.
+** bStartIndex - Index to first element to write.
+** piSrcBitOffset - Pointer to source bit offset.
+** This offset will be incremented according to the size
+** written.
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void SetAdiValue( const AD_AdiEntryType* psAdiEntry,
+ void* pxData,
+ UINT8 bNumElements,
+ UINT8 bStartIndex,
+ UINT16* piSrcBitOffset )
+{
+ UINT16 iDestBitOffset;
+
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if( psAdiEntry->psStruct != NULL )
+ {
+ UINT16 i;
+
+ /*
+ ** For structures each element is handled separately.
+ */
+ for( i = bStartIndex; i < bNumElements + bStartIndex; i++ )
+ {
+ iDestBitOffset = psAdiEntry->psStruct[ i ].bBitOffset;
+ *piSrcBitOffset += CopyValue( psAdiEntry->psStruct[ i ].uData.sVOID.pxValuePtr,
+ iDestBitOffset,
+ pxData,
+ *piSrcBitOffset,
+ psAdiEntry->psStruct[ i ].bDataType,
+ psAdiEntry->psStruct[ i ].iNumSubElem );
+ }
+ }
+ else
+#endif
+ {
+ iDestBitOffset = CalcStartindexBitOffset( psAdiEntry->bDataType, bStartIndex );
+ *piSrcBitOffset += CopyValue( psAdiEntry->uData.sVOID.pxValuePtr,
+ iDestBitOffset,
+ pxData,
+ *piSrcBitOffset,
+ psAdiEntry->bDataType,
+ bNumElements );
+ }
+#if( ABCC_CFG_ADI_GET_SET_CALLBACK )
+ if( psAdiEntry->pnSetAdiValue != NULL )
+ {
+ /*
+ ** If a set callback is registered the user is notified that the ADI is
+ ** updated.
+ */
+ psAdiEntry->pnSetAdiValue( psAdiEntry,
+ bNumElements,
+ bStartIndex );
+ }
+#endif
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+EXTFUNC AD_ErrType AD_Init( const AD_AdiEntryType* psAdiEntry,
+ UINT16 iNumAdi,
+ const AD_DefaultMapType* psDefaultMap )
+{
+ UINT16 iMapIndex = 0;
+ UINT16 iAdiIndex = 0;
+ UINT8 bNumElem;
+ UINT8 bElemStartIndex;
+ /*
+ ** In this context we should initialize the AD object to be prepared for
+ ** startup.
+ */
+ ad_asADIEntryList = psAdiEntry;
+ ad_asDefaultMap = psDefaultMap;
+
+ ad_iNumOfADIs = iNumAdi;
+ ad_iHighestInstanceNumber = 0;
+
+ ad_ReadMapInfo.paiMappedAdiList = ad_PdReadMapping;
+ ad_ReadMapInfo.iPdSize = 0;
+ ad_ReadMapInfo.iNumMappedAdi = 0;
+ ad_ReadMapInfo.iMaxNumMappedAdi = AD_MAX_NUM_READ_ADI_TO_MAP;
+
+ ad_WriteMapInfo.paiMappedAdiList = ad_PdWriteMapping;
+ ad_WriteMapInfo.iPdSize = 0;
+ ad_WriteMapInfo.iNumMappedAdi = 0;
+ ad_WriteMapInfo.iMaxNumMappedAdi = AD_MAX_NUM_WRITE_ADI_TO_MAP;
+
+ if( ad_asDefaultMap != NULL )
+ {
+ while( ad_asDefaultMap[ iMapIndex ].eDir != PD_END_MAP )
+ {
+ iAdiIndex = GetAdiIndex( ad_asDefaultMap[ iMapIndex ].iInstance );
+
+ if( iAdiIndex == AD_INVALID_ADI_INDEX )
+ {
+ return AD_UNKNOWN_ADI;
+ }
+
+ bNumElem = ad_asDefaultMap[ iMapIndex ].bNumElem;
+ bElemStartIndex = ad_asDefaultMap[ iMapIndex ].bElemStartIndex;
+
+ if( iAdiIndex != AD_MAP_PAD_INDEX )
+ {
+ if( ad_asDefaultMap[ iMapIndex ].bNumElem == AD_DEFAULT_MAP_ALL_ELEM )
+ {
+ bNumElem = ad_asADIEntryList[ iAdiIndex ].bNumOfElements;
+ bElemStartIndex = 0;
+ }
+ }
+
+ if( ad_asDefaultMap[ iMapIndex ].eDir == PD_READ )
+ {
+ if( ad_ReadMapInfo.iNumMappedAdi >= ad_ReadMapInfo.iMaxNumMappedAdi )
+ {
+ return AD_TOO_MANY_READ_MAPPINGS;
+ }
+
+ ad_ReadMapInfo.paiMappedAdiList[ ad_ReadMapInfo.iNumMappedAdi ].bNumElements = bNumElem;
+ ad_ReadMapInfo.paiMappedAdiList[ ad_ReadMapInfo.iNumMappedAdi ].bStartIndex = bElemStartIndex;
+ ad_ReadMapInfo.paiMappedAdiList[ ad_ReadMapInfo.iNumMappedAdi ].iAdiIndex = iAdiIndex;
+ ad_ReadMapInfo.iNumMappedAdi++;
+ }
+ else
+ {
+ if( ad_WriteMapInfo.iNumMappedAdi >= ad_WriteMapInfo.iMaxNumMappedAdi )
+ {
+ return AD_TOO_MANY_WRITE_MAPPINGS;
+ }
+
+ ad_WriteMapInfo.paiMappedAdiList[ ad_WriteMapInfo.iNumMappedAdi ].bNumElements = bNumElem;
+ ad_WriteMapInfo.paiMappedAdiList[ ad_WriteMapInfo.iNumMappedAdi ].bStartIndex = bElemStartIndex;
+ ad_WriteMapInfo.paiMappedAdiList[ ad_WriteMapInfo.iNumMappedAdi ].iAdiIndex = iAdiIndex;
+ ad_WriteMapInfo.iNumMappedAdi++;
+ }
+ iMapIndex++;
+ }
+ }
+
+ UpdateMapSize( &ad_WriteMapInfo );
+ UpdateMapSize( &ad_ReadMapInfo );
+
+ if( ad_ReadMapInfo.iPdSize > ABCC_CFG_MAX_PROCESS_DATA_SIZE )
+ {
+ return AD_PD_READ_SIZE_ERR;
+ }
+
+ if( ad_WriteMapInfo.iPdSize > ABCC_CFG_MAX_PROCESS_DATA_SIZE )
+ {
+ return AD_PD_WRITE_SIZE_ERR;
+ }
+
+ for( iAdiIndex = 0; iAdiIndex < ad_iNumOfADIs; iAdiIndex++ )
+ {
+ if( ad_asADIEntryList[ iAdiIndex ].iInstance > ad_iHighestInstanceNumber )
+ {
+ ad_iHighestInstanceNumber = ad_asADIEntryList[ iAdiIndex ].iInstance;
+ }
+ }
+
+ return AD_NO_ERROR;
+}
+
+const AD_AdiEntryType* AD_GetAdiInstEntry( UINT16 iInstance )
+{
+ UINT16 i;
+ const AD_AdiEntryType* psEntry = NULL;
+
+ i = GetAdiIndex( iInstance );
+ if( i != 0xffff )
+ {
+ psEntry = &ad_asADIEntryList[ i ];
+ }
+ return( psEntry );
+}
+
+void AD_ProcObjectRequest( ABP_MsgType* psMsgBuffer )
+{
+ const AD_AdiEntryType* psAdiEntry;
+ UINT16 iMsgBitOffset;
+ UINT16 iItemSize;
+ UINT16 iTemp;
+ UINT16 iDataSize;
+ UINT8 bErrCode;
+
+ iMsgBitOffset = 0;
+ iDataSize = 0;
+ bErrCode = ABP_ERR_NO_ERROR;
+
+ if( iLeTOi( psMsgBuffer->sHeader.iInstance ) == ABP_INST_OBJ )
+ {
+ /*
+ ** A request to the object instance.
+ */
+ switch( ABCC_GetMsgCmdBits( psMsgBuffer ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ switch( ABCC_GetMsgCmdExt0( psMsgBuffer ) )
+ {
+ case ABP_OA_NAME:
+ ABCC_SetMsgString( psMsgBuffer, "Application data",16 ,0 );
+ iDataSize = 16;
+ break;
+
+ case ABP_OA_REV:
+ ABCC_SetMsgData8( psMsgBuffer, 1, 0 );
+ iDataSize = ABP_OA_REV_DS;
+ break;
+
+ case ABP_OA_NUM_INST:
+ ABCC_SetMsgData16( psMsgBuffer, ad_iNumOfADIs, 0 );
+ iDataSize = ABP_OA_NUM_INST_DS;
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+ ABCC_SetMsgData16( psMsgBuffer, ad_iHighestInstanceNumber, 0 );
+ iDataSize = ABP_OA_HIGHEST_INST_DS;
+ break;
+
+ case ABP_APPD_OA_NR_READ_PD_MAPPABLE_INSTANCES:
+ {
+ UINT16 iIndex;
+ UINT16 iCnt = 0;
+
+ for( iIndex=0; iIndex < ad_iNumOfADIs; iIndex++ )
+ {
+ if( ad_asADIEntryList[iIndex ].bDesc & ABP_APPD_DESCR_MAPPABLE_READ_PD )
+ {
+ iCnt++;
+ }
+ }
+ ABCC_SetMsgData16( psMsgBuffer, iCnt, 0 );
+ iDataSize = ABP_UINT16_SIZEOF;
+ }
+ break;
+
+ case ABP_APPD_OA_NR_WRITE_PD_MAPPABLE_INSTANCES:
+ {
+ UINT16 iIndex;
+ UINT16 iCnt = 0;
+
+ for( iIndex=0; iIndex < ad_iNumOfADIs; iIndex++ )
+ {
+ if( ad_asADIEntryList[ iIndex ].bDesc & ABP_APPD_DESCR_MAPPABLE_WRITE_PD )
+ {
+ iCnt++;
+ }
+ }
+ ABCC_SetMsgData16( psMsgBuffer, iCnt, 0 );
+ iDataSize = ABP_UINT16_SIZEOF;
+ }
+ break;
+
+ default:
+ /*
+ ** Unsupported attribute.
+ */
+ bErrCode = ABP_ERR_INV_CMD_EXT_0;
+ break;
+ }
+ break;
+
+ case ABP_APPD_CMD_GET_INST_BY_ORDER:
+ iTemp = ABCC_GetMsgCmdExt( psMsgBuffer );
+
+ if( ( iTemp == 0 ) ||
+ ( iTemp > ad_iNumOfADIs ) )
+ {
+ /*
+ ** Requested order number does not exist.
+ */
+ bErrCode = ABP_ERR_INV_CMD_EXT_0;
+ }
+ else
+ {
+ ABCC_SetMsgData16( psMsgBuffer,
+ ad_asADIEntryList[ iTemp - 1 ].iInstance,
+ 0 );
+ iDataSize = ABP_UINT16_SIZEOF;
+ }
+ break;
+
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+ case ABP_APPD_REMAP_ADI_WRITE_AREA:
+ RemapProcessDataCommand( psMsgBuffer, &ad_WriteMapInfo );
+ psMsgBuffer = NULL;
+ break;
+
+ case ABP_APPD_REMAP_ADI_READ_AREA:
+ RemapProcessDataCommand( psMsgBuffer, &ad_ReadMapInfo );
+ psMsgBuffer = NULL;
+ break;
+#endif
+ case ABP_APPD_GET_INSTANCE_NUMBERS:
+
+ if( ABCC_GetMsgCmdExt0( psMsgBuffer ) != 0 )
+ {
+ bErrCode = ABP_ERR_INV_CMD_EXT_0;
+ }
+ else
+ {
+ UINT16 iStartingOrder;
+ UINT16 iReqInstances;
+ UINT16 i;
+ UINT16 ii;
+
+ ABCC_GetMsgData16( psMsgBuffer, &iStartingOrder, 0 );
+ ABCC_GetMsgData16( psMsgBuffer, &iReqInstances, 2 );
+
+ switch( ABCC_GetMsgCmdExt1( psMsgBuffer ) )
+ {
+ case ABP_APPD_LIST_TYPE_ALL:
+ iDataSize = 0;
+ for ( i = 0; ( i < iReqInstances ) && ( iStartingOrder + i <= ad_iNumOfADIs ); i++ )
+ {
+ ABCC_SetMsgData16( psMsgBuffer,
+ ad_asADIEntryList[ iStartingOrder + i - 1 ].iInstance,
+ iDataSize );
+ iDataSize += ABP_UINT16_SIZEOF;
+ }
+ break;
+
+ case ABP_APPD_LIST_TYPE_RD_PD_MAPPABLE:
+ iDataSize = 0;
+ for ( i = 0, ii = 1; ( ii < ( iStartingOrder + iReqInstances ) ) && ( i < ad_iNumOfADIs ); i++ )
+ {
+ if( ad_asADIEntryList[ i ].bDesc & ABP_APPD_DESCR_MAPPABLE_READ_PD )
+ {
+ if( ii >= iStartingOrder )
+ {
+ ABCC_SetMsgData16( psMsgBuffer,
+ ad_asADIEntryList[ i ].iInstance,
+ iDataSize );
+ iDataSize += ABP_UINT16_SIZEOF;
+ }
+ ii++;
+ }
+ }
+ break;
+
+ case ABP_APPD_LIST_TYPE_WR_PD_MAPPABLE:
+ iDataSize = 0;
+ for ( i = 0, ii = 1; ( ii < ( iStartingOrder + iReqInstances ) ) && ( i < ad_iNumOfADIs ); i++ )
+ {
+ if( ad_asADIEntryList[ i ].bDesc & ABP_APPD_DESCR_MAPPABLE_WRITE_PD )
+ {
+ if( ii >= iStartingOrder )
+ {
+ ABCC_SetMsgData16( psMsgBuffer, ad_asADIEntryList[ i ].iInstance, iDataSize );
+ iDataSize += ABP_UINT16_SIZEOF;
+ }
+ ii++;
+ }
+ }
+ break;
+
+ default:
+ bErrCode = ABP_ERR_INV_CMD_EXT_1;
+ break;
+ }
+ }
+ break;
+
+ default:
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ break;
+ }
+ }
+ else if( ( psAdiEntry = AD_GetAdiInstEntry( ABCC_GetMsgInstance( psMsgBuffer ) ) ) != NULL )
+ {
+ /*
+ ** The ADI instance was found. Now switch on command.
+ */
+ switch( ABCC_GetMsgCmdBits( psMsgBuffer ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ /*
+ ** Switch on attribute.
+ */
+ switch( ABCC_GetMsgCmdExt0( psMsgBuffer ) )
+ {
+ case ABP_APPD_IA_NAME:
+ if( psAdiEntry->pacName )
+ {
+ iDataSize = (UINT16)strlen( psAdiEntry->pacName );
+ ABCC_SetMsgString( psMsgBuffer,
+ psAdiEntry->pacName, iDataSize, 0 );
+ }
+ else
+ {
+ iDataSize = 0;
+ }
+ break;
+
+ case ABP_APPD_IA_DATA_TYPE:
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if( psAdiEntry->psStruct != NULL )
+ {
+ UINT16 i;
+
+ iDataSize = ABP_APPD_IA_DATA_TYPE_DS*psAdiEntry->bNumOfElements;
+ for ( i = 0; i < psAdiEntry->bNumOfElements; i++ )
+ {
+ ABCC_SetMsgData8( psMsgBuffer,
+ psAdiEntry->psStruct[i].bDataType, i );
+ }
+ }
+ else
+#endif
+ {
+ ABCC_SetMsgData8( psMsgBuffer, psAdiEntry->bDataType, 0 );
+ iDataSize = ABP_APPD_IA_DATA_TYPE_DS;
+ }
+ break;
+
+ case ABP_APPD_IA_NUM_ELEM:
+ ABCC_SetMsgData8( psMsgBuffer, psAdiEntry->bNumOfElements, 0 );
+ iDataSize = ABP_APPD_IA_NUM_ELEM_DS;
+ break;
+
+ case ABP_APPD_IA_DESCRIPTOR:
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if( psAdiEntry->psStruct != NULL )
+ {
+ UINT16 i;
+
+ iDataSize = ABP_APPD_IA_DESCRIPTOR_DS * psAdiEntry->bNumOfElements;
+ for ( i = 0; i < psAdiEntry->bNumOfElements; i++ )
+ {
+ ABCC_SetMsgData8( psMsgBuffer,
+ psAdiEntry->psStruct[i].bDesc, i );
+ }
+ }
+ else
+#endif
+ {
+ ABCC_SetMsgData8( psMsgBuffer, psAdiEntry->bDesc, 0 );
+ iDataSize = ABP_APPD_IA_DESCRIPTOR_DS;
+ }
+ break;
+
+ case ABP_APPD_IA_VALUE: /* Value. */
+ if( !( psAdiEntry->bDesc & ABP_APPD_DESCR_GET_ACCESS ) )
+ {
+ bErrCode = ABP_ERR_ATTR_NOT_GETABLE;
+ break;
+ }
+ ABCC_GetMsgDataPtr( psMsgBuffer )[ 0 ] = 0;
+
+ GetAdiValue( psAdiEntry, ABCC_GetMsgDataPtr( psMsgBuffer ),
+ psAdiEntry->bNumOfElements, 0,
+ &iMsgBitOffset);
+ iDataSize = SizeInOctets( 0, iMsgBitOffset );
+ break;
+#if( AD_IA_MIN_MAX_DEFAULT_ENABLE )
+ case ABP_APPD_IA_MAX_VALUE:
+ bErrCode = GetMinMaxDefault( psAdiEntry,
+ ABCC_GetMsgDataPtr( psMsgBuffer ),
+ AD_MAX_VALUE_INDEX,
+ &iDataSize );
+ iDataSize = SizeInOctets( 0, iDataSize );
+ break;
+ case ABP_APPD_IA_MIN_VALUE:
+ bErrCode = GetMinMaxDefault( psAdiEntry,
+ ABCC_GetMsgDataPtr( psMsgBuffer ),
+ AD_MIN_VALUE_INDEX,
+ &iDataSize );
+ iDataSize = SizeInOctets( 0, iDataSize );
+ break;
+ case ABP_APPD_IA_DFLT_VALUE:
+ bErrCode = GetMinMaxDefault( psAdiEntry,
+ ABCC_GetMsgDataPtr( psMsgBuffer ),
+ AD_DEFAULT_VALUE_INDEX,
+ &iDataSize );
+ iDataSize = SizeInOctets( 0, iDataSize );
+ break;
+#endif
+ case ABP_APPD_IA_NUM_SUB_ELEM:
+#if( ABCC_CFG_STRUCT_DATA_TYPE )
+ if( psAdiEntry->psStruct != NULL )
+ {
+ UINT16 i;
+
+ iDataSize = ABP_APPD_IA_NUM_SUB_ELEM_DS * psAdiEntry->bNumOfElements;
+ for ( i = 0; i < psAdiEntry->bNumOfElements; i++ )
+ {
+ ABCC_SetMsgData16( psMsgBuffer,
+ psAdiEntry->psStruct[i].iNumSubElem,
+ ( i * ABP_APPD_IA_NUM_SUB_ELEM_DS ) );
+ }
+ }
+ else
+#endif
+ {
+ ABCC_SetMsgData16( psMsgBuffer, AD_DEFAULT_NUM_SUB_ELEMS, 0 );
+ iDataSize = ABP_APPD_IA_NUM_SUB_ELEM_DS;
+ }
+ break;
+ default:
+ /*
+ ** Unsupported attribute.
+ */
+ bErrCode = ABP_ERR_INV_CMD_EXT_0;
+ break;
+ }
+ break;
+ case ABP_CMD_SET_ATTR:
+ switch( ABCC_GetMsgCmdExt0( psMsgBuffer ) )
+ {
+ case ABP_APPD_IA_NAME:
+ case ABP_APPD_IA_DATA_TYPE:
+ case ABP_APPD_IA_NUM_ELEM:
+ case ABP_APPD_IA_DESCRIPTOR:
+ /*
+ ** Attributes are not settable.
+ */
+ bErrCode = ABP_ERR_ATTR_NOT_SETABLE;
+ break;
+
+ case ABP_APPD_IA_VALUE:
+ if( !( psAdiEntry->bDesc & ABP_APPD_DESCR_SET_ACCESS ) )
+ {
+ bErrCode = ABP_ERR_ATTR_NOT_SETABLE;
+ break;
+ }
+
+ /*
+ ** Check the length of each array.
+ */
+ iItemSize = GetAdiSizeInOctets( psAdiEntry );
+ if( iLeTOi( psMsgBuffer->sHeader.iDataSize ) > iItemSize )
+ {
+ bErrCode = ABP_ERR_TOO_MUCH_DATA;
+ break;
+ }
+ else if( iLeTOi( psMsgBuffer->sHeader.iDataSize ) < iItemSize )
+ {
+ bErrCode = ABP_ERR_NOT_ENOUGH_DATA;
+ break;
+ }
+ /*
+ ** TODO Range check
+ */
+ if( FALSE )
+ {
+ bErrCode = ABP_ERR_OUT_OF_RANGE;
+ }
+ else
+ {
+ SetAdiValue( psAdiEntry, ABCC_GetMsgDataPtr( psMsgBuffer ),
+ psAdiEntry->bNumOfElements, 0,
+ &iMsgBitOffset);
+ /*
+ ** Success.
+ */
+ iDataSize = 0;
+ }
+ break;
+
+ default:
+ /*
+ ** Unsupported attribute.
+ */
+ bErrCode = ABP_ERR_INV_CMD_EXT_0;
+ break;
+ }
+ break;
+
+ case ABP_CMD_GET_ENUM_STR:
+ switch( ABCC_GetMsgCmdExt0( psMsgBuffer ) )
+ {
+ case ABP_APPD_IA_VALUE:
+ if( psAdiEntry->bDataType == ABP_ENUM )
+ {
+ if( ( psAdiEntry->uData.sENUM.psValueProps == NULL ) ||
+ ( psAdiEntry->uData.sENUM.psValueProps->pasEnumStrings == NULL ) )
+ {
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ }
+ else
+ {
+ UINT8 b = 0;
+
+ for( b = 0; b < psAdiEntry->uData.sENUM.psValueProps->bNumOfEnumStrings; b++ )
+ {
+ if( psAdiEntry->uData.sENUM.psValueProps->pasEnumStrings[ b ].eValue ==
+ ABCC_GetMsgCmdExt1( psMsgBuffer ) )
+ {
+ break;
+ }
+ }
+
+ if( b < psAdiEntry->uData.sENUM.psValueProps->bNumOfEnumStrings )
+ {
+ iDataSize = (UINT16)strlen( psAdiEntry->uData.sENUM.psValueProps->pasEnumStrings[ b ].acEnumStr );
+ ABCC_SetMsgString( psMsgBuffer,
+ psAdiEntry->uData.sENUM.psValueProps->pasEnumStrings[ b ].acEnumStr,
+ iDataSize, 0 );
+ }
+ else
+ {
+ /*
+ ** The enum value was not found in the string lookup.
+ */
+ bErrCode = ABP_ERR_OUT_OF_RANGE;
+ }
+ }
+ }
+ else
+ {
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ }
+ break;
+
+ default:
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ break;
+ }
+ break;
+ case ABP_CMD_GET_INDEXED_ATTR:
+ switch( ABCC_GetMsgCmdExt0( psMsgBuffer ) )
+ {
+ case ABP_APPD_IA_VALUE:
+ if( !( psAdiEntry->bDesc & ABP_APPD_DESCR_GET_ACCESS ) )
+ {
+ bErrCode = ABP_ERR_ATTR_NOT_GETABLE;
+ break;
+ }
+ else
+ {
+ GetAdiValue( psAdiEntry, ABCC_GetMsgDataPtr( psMsgBuffer ),
+ 1, ABCC_GetMsgCmdExt1( psMsgBuffer ),
+ &iMsgBitOffset );
+
+ iDataSize = SizeInOctets( 0, iMsgBitOffset );
+
+ if( iDataSize == 0 )
+ {
+ bErrCode = ABP_ERR_OUT_OF_RANGE;
+ }
+ }
+ break;
+
+ default:
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ break;
+ }
+ break;
+ case ABP_CMD_SET_INDEXED_ATTR:
+ switch( ABCC_GetMsgCmdExt0( psMsgBuffer ) )
+ {
+ case ABP_APPD_IA_VALUE:
+ if( !( psAdiEntry->bDesc & ABP_APPD_DESCR_SET_ACCESS ) )
+ {
+ bErrCode = ABP_ERR_ATTR_NOT_SETABLE;
+ break;
+ }
+ else
+ {
+ if( FALSE )
+ {
+ bErrCode = ABP_ERR_OUT_OF_RANGE;
+ }
+ else
+ {
+ SetAdiValue( psAdiEntry,
+ ABCC_GetMsgDataPtr( psMsgBuffer ),
+ 1, ABCC_GetMsgCmdExt1( psMsgBuffer ),
+ &iMsgBitOffset);
+ /*
+ ** Success.
+ */
+ iDataSize = 0;
+ }
+ }
+ break;
+
+ default:
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ break;
+ }
+ break;
+
+ default:
+ /*
+ ** Unsupported command.
+ */
+ bErrCode = ABP_ERR_UNSUP_CMD;
+ break;
+ }
+ }
+ else
+ {
+ /*
+ ** The instance was not found.
+ */
+ bErrCode = ABP_ERR_UNSUP_INST;
+ }
+
+ /*
+ ** Special handling. The remap response is already handled.
+ */
+ if( psMsgBuffer != NULL )
+ {
+ if( bErrCode == ABP_ERR_NO_ERROR )
+ {
+ ABP_SetMsgResponse( psMsgBuffer, iDataSize );
+ }
+ else
+ {
+ ABP_SetMsgErrorResponse( psMsgBuffer, 1, bErrCode );
+ }
+
+ ABCC_SendRespMsg( psMsgBuffer );
+ }
+}
+
+
+void AD_UpdatePdReadData( void* pxPdDataBuf )
+{
+ UINT16 i;
+ UINT16 iRdPdBitOffset;
+ const ad_MapType* AD_paiPdReadMap = ad_ReadMapInfo.paiMappedAdiList;
+
+ iRdPdBitOffset = 0;
+
+ if( AD_paiPdReadMap )
+ {
+ for ( i = 0; i < ad_ReadMapInfo.iNumMappedAdi; i++ )
+ {
+ if( AD_paiPdReadMap->iAdiIndex != AD_MAP_PAD_INDEX )
+ {
+ SetAdiValue( &ad_asADIEntryList[ AD_paiPdReadMap->iAdiIndex ],
+ pxPdDataBuf,
+ AD_paiPdReadMap->bNumElements,
+ AD_paiPdReadMap->bStartIndex,
+ &iRdPdBitOffset );
+ }
+ else
+ {
+ iRdPdBitOffset += AD_paiPdReadMap->bNumElements;
+ }
+
+ AD_paiPdReadMap++;
+ }
+ }
+}
+
+BOOL AD_UpdatePdWriteData( void* pxPdDataBuf )
+{
+ UINT16 i;
+ UINT16 iWrPdBitOffset;
+ const ad_MapType* paiPdWriteMap = ad_WriteMapInfo.paiMappedAdiList;
+
+ if( paiPdWriteMap )
+ {
+ iWrPdBitOffset = 0;
+
+ for( i = 0; i < ad_WriteMapInfo.iNumMappedAdi ; i++)
+ {
+ if( paiPdWriteMap->iAdiIndex != AD_MAP_PAD_INDEX )
+ {
+ GetAdiValue( &ad_asADIEntryList[ paiPdWriteMap->iAdiIndex ],
+ pxPdDataBuf,
+ paiPdWriteMap->bNumElements,
+ paiPdWriteMap->bStartIndex ,
+ &iWrPdBitOffset);
+ }
+ else
+ {
+ iWrPdBitOffset += paiPdWriteMap->bNumElements;
+ }
+ paiPdWriteMap++;
+ }
+ return( TRUE );
+ }
+ return( FALSE );
+}
+
+UINT16 AD_AdiMappingReq( const AD_AdiEntryType** ppsAdiEntry,
+ const AD_DefaultMapType** ppsDefaultMap )
+{
+ NetFormatType eNetFormat;
+ eNetFormat = ABCC_NetFormatType();
+#ifdef ABCC_SYS_BIG_ENDIAN
+ ad_fDoNetworkEndianSwap = ( eNetFormat == NET_LITTLEENDIAN ) ? TRUE : FALSE;
+#else
+ ad_fDoNetworkEndianSwap = ( eNetFormat == NET_LITTLEENDIAN ) ? FALSE : TRUE;
+#endif
+
+ *ppsAdiEntry = ad_asADIEntryList;
+ *ppsDefaultMap = ad_asDefaultMap;
+
+ return ad_iNumOfADIs;
+}
+
+void AD_RemapDone( void )
+{
+ /*
+ ** This Write Process Data update is to ensure that the write process data
+ ** is updated with the right content.
+ */
+ ABCC_TriggerWrPdUpdate();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/ad_obj.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,163 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Application Data Object 0xFE (ADI) - Public interfaces
+********************************************************************************
+********************************************************************************
+** Services :
+** AD_Init() - Initiate AD object.
+** AD_ProcObjectRequest() - Object request handling.
+** AD_RemapDone() - Remap finished.
+** AD_UpdatePdReadData() - Update of read process data.
+** AD_UpdatePdWriteData() - Update of write process data.
+********************************************************************************
+********************************************************************************
+*/
+#ifndef AD_OBJ_H
+#define AD_OBJ_H
+
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc_ad_if.h"
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+/*------------------------------------------------------------------------------
+** AD_NO_ERROR - All OK
+** AD_PD_REDA_SIZE_ERR - Total process data read size too large.
+** Check ABCC_CFG_MAX_PROCESS_DATA_SIZE.
+** AD_PD_WRITE_SIZE_ERR - Total process data write too large.
+** Check ABCC_CFG_MAX_PROCESS_DATA_SIZE.
+** AD_TOO_MANY_READ_MAPPINGS - Read process data map has too many entries.
+** Check AD_MAX_OF_READ_WRITE_TO_MAP.
+** AD_TOO_MANY_WRITE_MAPPINGS - Write process data map has too many entries.
+** Check AD_MAX_OF_WRITE_WRITE_TO_MAP.
+** AD_UNKNOWN_ADI - Requested ADI could not be found.
+**------------------------------------------------------------------------------
+*/
+typedef enum AD_Err
+{
+ AD_NO_ERROR = 0,
+ AD_PD_READ_SIZE_ERR,
+ AD_PD_WRITE_SIZE_ERR,
+ AD_TOO_MANY_READ_MAPPINGS,
+ AD_TOO_MANY_WRITE_MAPPINGS,
+ AD_UNKNOWN_ADI
+}
+AD_ErrType;
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+/*------------------------------------------------------------------------------
+** Initiates the AD object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psAdiEntry - Pointer to used ADI entry table.
+** iNumAdi - Number of ADI:s in ADI entry table.
+** psDefaultMap - Pointer to default map. Set to NULL if no default map
+** shall be used.
+**
+** Returns:
+** AD_ErrType
+**------------------------------------------------------------------------------
+*/
+EXTFUNC AD_ErrType AD_Init( const AD_AdiEntryType* psAdiEntry,
+ UINT16 iNumAdi,
+ const AD_DefaultMapType* psDefaultMap );
+
+/*------------------------------------------------------------------------------
+** Retrieve default mapping information from AD object. The AD objects also
+** prepares for network endian conversion if needed. The function may only be
+** called when requested by driver through the callback ABCC_CbfAdiMappingReq()
+**------------------------------------------------------------------------------
+** Arguments:
+** ppsAdiEntry - Pointer to retrieve ADI entry table.
+** NULL is returned if no default map is available.
+** ppsDefaultMap - Pointer to retrieve default map information.
+** NULL is returned if no default map is available.
+**
+** Returns:
+** Number of ADI:s in psAdiEntry table.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 AD_AdiMappingReq( const AD_AdiEntryType** ppsAdiEntry,
+ const AD_DefaultMapType** ppsDefaultMap );
+
+/*------------------------------------------------------------------------------
+** Indicate to AD object that the remap is finished
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+EXTFUNC void AD_RemapDone( void );
+#endif
+
+/*------------------------------------------------------------------------------
+** Process an object request against the Application Data Object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsgBuffer - Pointer to ABCC command message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void AD_ProcObjectRequest( ABP_MsgType* psMsgBuffer );
+
+/*------------------------------------------------------------------------------
+** Update AD object with new read process data received from the ABCC.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxPdDataBuf - Pointer read process data buffer.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void AD_UpdatePdReadData( void* pxPdDataBuf );
+
+/*------------------------------------------------------------------------------
+** Fetch write process data from AD object.
+**------------------------------------------------------------------------------
+** Arguments:
+** pxPdDataBuf - Pointer write process data buffer.
+**
+** Returns:
+** TRUE - Write process data buffer is updated.
+** FALSE - No update was made.
+**
+**------------------------------------------------------------------------------
+*/
+EXTFUNC BOOL AD_UpdatePdWriteData( void* pxPdDataBuf );
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/app_obj.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,610 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the APP object, containing the Application Object and
+** Application Instance.
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_obj_cfg.h"
+#include "app_obj.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if APP_OBJ_ENABLE
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define APP_OA_NAME_VALUE "Application"
+#define APP_OA_REV_VALUE 1
+#define APP_OA_NUM_INST_VALUE 1
+#define APP_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing an Application Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct app_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+app_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Structure describing an Application Data Instance.
+**------------------------------------------------------------------------------
+*/
+#if APP_IA_CONFIGURED_ENABLE || \
+ APP_IA_SUP_LANG_ENABLE || \
+ APP_IA_PAR_CRTL_SUM_ENABLE || \
+ APP_IA_HW_CONF_ADDR_ENABLE
+typedef struct app_Instance
+{
+#if APP_IA_CONFIGURED_ENABLE
+ BOOL fConfigured;
+#endif
+#if APP_IA_SUP_LANG_ENABLE
+ UINT8 abSupportedLanguages[ APP_IA_SUP_LANG_ARRAY_SIZE ];
+#endif
+#if APP_IA_PAR_CRTL_SUM_ENABLE
+ UINT8 abParameterControlSum[ 16 ];
+#endif
+#if APP_IA_HW_CONF_ADDR_ENABLE
+ BOOL fHardwareConfigurableAddress;
+#endif
+}
+app_InstanceType;
+#endif
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+#if APP_IA_SUP_LANG_ENABLE
+static const char* app_aacLanguages[ 5 ] =
+{
+ "English",
+ "Deutsch",
+ "Español",
+ "Italiano",
+ "Français"
+};
+#endif
+
+static const app_ObjectType app_sObject =
+{
+ APP_OA_NAME_VALUE, /* Name. */
+ APP_OA_REV_VALUE, /* Revision. */
+ APP_OA_NUM_INST_VALUE, /* Number of instances. */
+ APP_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+#if APP_IA_CONFIGURED_ENABLE || \
+ APP_IA_SUP_LANG_ENABLE || \
+ APP_IA_PAR_CRTL_SUM_ENABLE || \
+ APP_IA_HW_CONF_ADDR_ENABLE
+static app_InstanceType app_sInstance =
+{
+#if APP_IA_CONFIGURED_ENABLE
+ APP_IA_CONFIGURED_VALUE, /* Configured. */
+#endif
+#if APP_IA_SUP_LANG_ENABLE
+ APP_IA_SUP_LANG_VALUE, /* Supported languages. */
+#endif
+#if APP_IA_PAR_CRTL_SUM_ENABLE
+ APP_IA_PAR_CRTL_SUM_VALUE, /* Parameter control sum */
+#endif
+#if APP_IA_HW_CONF_ADDR_ENABLE
+ APP_IA_HW_CONF_ADDR_VALUE, /* Hardware configurable address */
+#endif
+};
+#endif
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Called to check if the requested reset is permitted by the application.
+**------------------------------------------------------------------------------
+** Arguments:
+** bResetType - Type of reset, see ABP_RESET_XXX defines.
+**
+** Returns:
+** BOOL - TRUE: Reset request is allowed.
+** FALSE: Reset request NOT allowed.
+**------------------------------------------------------------------------------
+*/
+BOOL IsResetRequestAllowed( UINT8 bResetType )
+{
+ switch( (ABP_ResetType)bResetType )
+ {
+ case ABP_RESET_POWER_ON:
+ case ABP_RESET_FACTORY_DEFAULT:
+ case ABP_RESET_POWER_ON_FACTORY_DEFAULT:
+
+ return( TRUE );
+
+ default:
+
+ return( FALSE );
+ }
+}
+
+/*------------------------------------------------------------------------------
+** This function will restore NVS parameters to their default values
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void RestoreToDefault( void )
+{
+ /*
+ ** Todo: PORTING ALERT!
+ ** Restore parameters stored in NVS to their default values
+ */
+}
+
+/*------------------------------------------------------------------------------
+** Function to set whether firmware is available or not in the candidate area.
+** This function sets the value to a NVS.
+**------------------------------------------------------------------------------
+** Arguments:
+** fFirmwareAvailable - TRUE/FALSE
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void SetCandidateFirmwareAvailable( BOOL fFirmwareAvailable )
+{
+ /*
+ ** Todo: PORTING ALERT!
+ ** Store value to NVS.
+ */
+ (void)fFirmwareAvailable;
+}
+
+/*------------------------------------------------------------------------------
+** The function that processes the commands to the Application Instance.
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ BOOL8 fFirmwareAvailable;
+ UINT16 iIndex;
+
+ fFirmwareAvailable = 0;
+ iIndex = 0;
+
+ (void)(fFirmwareAvailable);
+ (void)(iIndex);
+
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The requested instance does not exist.
+ ** Respond with a error.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if APP_IA_CONFIGURED_ENABLE
+ case ABP_APP_IA_CONFIGURED:
+
+ /*
+ ** The 'configured' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData8( psNewMessage, app_sInstance.fConfigured, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_APP_IA_CONFIGURED_DS );
+ break;
+#endif
+#if APP_IA_SUP_LANG_ENABLE
+ case ABP_APP_IA_SUP_LANG:
+
+ /*
+ ** The 'supported languages' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ for( iIndex = 0; iIndex < APP_IA_SUP_LANG_ARRAY_SIZE; iIndex++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, app_sInstance.abSupportedLanguages[ iIndex ], iIndex );
+ }
+ ABP_SetMsgResponse( psNewMessage, APP_IA_SUP_LANG_ARRAY_SIZE );
+ break;
+#endif
+#if APP_IA_SER_NUM_ENABLE
+ case ABP_APP_IA_SER_NUM:
+
+ /*
+ ** The 'serial number' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData32( psNewMessage, APP_IA_SER_NUM_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_APP_IA_SER_NUM_DS );
+ break;
+#endif
+#if APP_IA_PAR_CRTL_SUM_ENABLE
+ case ABP_APP_IA_PAR_CRTL_SUM:
+
+ /*
+ ** The 'parameter control sum' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ for( iIndex = 0; iIndex < 16; iIndex++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, app_sInstance.abParameterControlSum[ iIndex ], iIndex );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_APP_IA_PAR_CRTL_SUM_DS );
+ break;
+#endif
+#if APP_IA_FW_AVAILABLE_ENABLE
+ case ABP_APP_IA_FW_AVAILABLE:
+
+ /*
+ ** The 'candidate firmware available' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ fFirmwareAvailable = APP_GetCandidateFwAvailable();
+ ABCC_SetMsgData8( psNewMessage, fFirmwareAvailable, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_APP_IA_FW_AVAILABLE_DS );
+ break;
+#endif
+#if APP_IA_HW_CONF_ADDR_ENABLE
+ case ABP_APP_IA_HW_CONF_ADDR:
+
+ /*
+ ** The 'hardware configurable address' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData8( psNewMessage, app_sInstance.fHardwareConfigurableAddress, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_APP_IA_HW_CONF_ADDR_DS );
+ break;
+#endif
+ default:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+#if APP_IA_FW_AVAILABLE_ENABLE
+ case ABP_CMD_SET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_APP_IA_FW_AVAILABLE:
+
+ /*
+ ** Set the 'candidate firmware available' attribute
+ */
+ ABCC_GetMsgData8( psNewMessage, &fFirmwareAvailable, 0 );
+ SetCandidateFirmwareAvailable( fFirmwareAvailable );
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ break;
+
+ default:
+
+ /*
+ ** The attribute does not exist, or the attribute is not settable.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+#endif
+#if APP_IA_SUP_LANG_ENABLE
+ case ABP_CMD_GET_ENUM_STR:
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_APP_IA_SUP_LANG:
+ {
+ BOOL8 fLanguageSupported = FALSE;
+ UINT16 iStrLength;
+
+ for( iIndex = 0; iIndex < APP_IA_SUP_LANG_ARRAY_SIZE; iIndex++ )
+ {
+ if( app_sInstance.abSupportedLanguages[ iIndex ] == ABCC_GetMsgCmdExt1( psNewMessage ) )
+ {
+ /*
+ ** Copy the ENUM STR to a message.
+ */
+ fLanguageSupported = TRUE;
+ iStrLength = (UINT16)strlen( app_aacLanguages[ ABCC_GetMsgCmdExt1( psNewMessage ) ] );
+ ABCC_SetMsgString( psNewMessage,
+ app_aacLanguages[ ABCC_GetMsgCmdExt1( psNewMessage ) ],
+ iStrLength,
+ 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ }
+ }
+
+ if( !fLanguageSupported )
+ {
+ /*
+ ** The ENUM value was out of range.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_1 );
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** The attribute does not exist, or the attribute is not an ENUM.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+#endif
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End switch( command number ) */
+}
+
+/*------------------------------------------------------------------------------
+** The function that processes the commands to the Application Object
+** (instance 0).
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ UINT16 iStrLength;
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+
+ /*
+ ** The 'name' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ iStrLength = (UINT16)strlen( app_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, app_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+
+ case ABP_OA_REV:
+
+ /*
+ ** The 'revision' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData8( psNewMessage, app_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** The 'Number of Instances' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData16( psNewMessage, app_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** The 'Highest Instance Number' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData16( psNewMessage, app_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ case ABP_APP_CMD_RESET_REQUEST:
+ {
+ /*
+ ** Request a command reset.
+ */
+ if( !IsResetRequestAllowed( ABCC_GetMsgCmdExt1( psNewMessage ) ) )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_STATE );
+ }
+ else
+ {
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ }
+ break;
+ }
+ case ABP_CMD_RESET:
+ {
+ /*
+ ** Perform a reset.
+ */
+ APP_ProcResetRequest( ABCC_GetMsgCmdExt1( psNewMessage ) );
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ break;
+ }
+ case ABP_APP_CMD_CHANGE_LANG_REQUEST:
+
+ /*
+ ** Optionally implement the Change Language Request service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_APP_CMD_RESET_DIAGNOSTIC:
+
+ /*
+ ** Optionally implement the Reset Diagnostic service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ ** Respond with an error.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End switch( command number ) */
+
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void APP_HwConfAddress( BOOL fhwConfAddress )
+{
+#if APP_IA_HW_CONF_ADDR_ENABLE
+ app_sInstance.fHardwareConfigurableAddress = fhwConfAddress;
+#endif
+}
+
+BOOL APP_GetCandidateFwAvailable( void )
+{
+ /*
+ ** Todo: PORTING ALERT!
+ ** Read value from NVS.
+ */
+ return( FALSE );
+}
+
+void APP_ProcResetRequest( UINT8 bResetType )
+{
+ switch( bResetType )
+ {
+ case ABP_RESET_FACTORY_DEFAULT:
+ RestoreToDefault();
+ break;
+
+ case ABP_RESET_POWER_ON_FACTORY_DEFAULT:
+ RestoreToDefault();
+ APPL_Reset();
+ break;
+
+ case ABP_RESET_POWER_ON:
+ APPL_Reset();
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+void APP_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Process the Application data Object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Process the Application data Instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+
+}
+
+#endif /* APP_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/app_obj.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,118 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the APP object. +******************************************************************************** +******************************************************************************** +** Services: +** APP_GetCandidateFwAvailable() - Checks if there is an firmware available +** in the module's candidate area. +** APP_ProcResetRequest() - Performs a reset of the application +** APP_ProcessCmdMsg() - Processes commands sent to the APP object. +** APP_HwConfAddress() - Set attribute ABP_APP_IA_HW_CONF_ADDR. +******************************************************************************** +******************************************************************************** +*/ +#ifndef APP_OBJ_H +#define APP_OBJ_H + + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Call to check if there is firmware available in the candidate area. This +** function retrieves the value from a NVS. +**------------------------------------------------------------------------------ +** Arguments: +** None +** +** Returns: +** BOOL - TRUE: Firmware available in candidate area. +** FALSE: Firmware NOT available in candidate area. +**------------------------------------------------------------------------------ +*/ +EXTFUNC BOOL APP_GetCandidateFwAvailable( void ); + + +/*------------------------------------------------------------------------------ +** Set attribute ABP_APP_IA_HW_CONF_ADDR to indicate if the address is set by +** hardware switches or not. +**------------------------------------------------------------------------------ +** Arguments: +** fhwConfAddress: - TRUE if address is set by HW switches. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +EXTFUNC void APP_HwConfAddress( BOOL fhwConfAddress ); + + +/*------------------------------------------------------------------------------ +** Called to perform a reset upon request. +**------------------------------------------------------------------------------ +** Arguments: +** bResetType - Type of reset, see ABP_RESET_XXX defines. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void APP_ProcResetRequest( UINT8 bResetType ); + +/*------------------------------------------------------------------------------ +** The function that processes the commands sent to the APP object. +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +EXTFUNC void APP_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + + + + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/etn_obj.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,669 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the Ethernet Host object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_obj_cfg.h"
+#include "abcc.h"
+#include "etn_obj.h"
+#include "abp_etn.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if ETN_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define ETN_OA_NAME_VALUE "Ethernet"
+#define ETN_OA_REV_VALUE 2
+#define ETN_OA_NUM_INST_VALUE 1
+#define ETN_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** etn_ObjectType.
+** Structure describing an Ethernet Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct etn_ObjectType
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+etn_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+#if ETN_IA_NETWORK_STATUS_ENABLE
+static UINT16 etn_iNetworkStatus;
+#endif
+#if ETN_IA_IP_CONFIGURATION_ENABLE
+static ETN_IpConfigType etn_sIpConfig;
+#endif
+static const etn_ObjectType etn_sObject =
+{
+ ETN_OA_NAME_VALUE, /* Name. */
+ ETN_OA_REV_VALUE, /* Revision. */
+ ETN_OA_NUM_INST_VALUE, /* Number of instances. */
+ ETN_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void ETN_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet Object and it's Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Ethernet object Command
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Ethernet instance Command
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+#if ETN_IA_IP_CONFIGURATION_ENABLE
+void ETN_GetIpConfig( ETN_IpConfigType* psIpConfig )
+{
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ *psIpConfig = etn_sIpConfig;
+ }
+ ABCC_PORT_ExitCritical();
+}
+#endif /* #if ETN_IA_NETWORK_STATUS_ENABLE */
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to ETN Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ UINT16 iInstance;
+ UINT8 bAttribute;
+
+ iInstance = ABCC_GetMsgInstance( psNewMessage );
+ bAttribute = ABCC_GetMsgCmdExt0( psNewMessage );
+
+ /*
+ ** This function processes commands to the Ethernet Instance.
+ */
+ if( iInstance != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+
+ switch( bAttribute )
+ {
+#if ETN_IA_MAC_ADDRESS_ENABLE
+ case ABP_ETN_IA_MAC_ADDRESS:
+ {
+ UINT16 i;
+ UINT8 abMac[ 6 ];
+
+ /*
+ ** Copy the 1st Instance 1 attribute (MAC Address) to the message.
+ */
+
+ ABCC_PORT_MemCpy( abMac, ETN_IA_MAC_ADDRESS_VALUE, ABP_ETN_IA_MAC_ADDRESS_DS );
+
+ for( i = 0; i < ABP_ETN_IA_MAC_ADDRESS_DS; i++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_MAC_ADDRESS_DS );
+ break;
+ }
+#endif
+#if ETN_IA_ENABLE_HICP_ENABLE
+ case ABP_ETN_IA_ENABLE_HICP:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Enable HICP) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_HICP_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_HICP_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_WEB_ENABLE
+ case ABP_ETN_IA_ENABLE_WEB:
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Enable WEB) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_MOD_TCP_ENABLE
+ case ABP_ETN_IA_ENABLE_MOD_TCP:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Enable ModbusTCP) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_MOD_TCP_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_MOD_TCP_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE
+ case ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS:
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Enable WEB ADI access) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_ADI_ACCESS_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_FTP_ENABLE
+ case ABP_ETN_IA_ENABLE_FTP:
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Enable FTP) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_FTP_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_FTP_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_ADMIN_MODE_ENABLE
+ case ABP_ETN_IA_ENABLE_ADMIN_MODE:
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Enable admin mode) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_ADMIN_MODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_ADMIN_MODE_DS );
+ break;
+#endif
+#if ETN_IA_NETWORK_STATUS_ENABLE
+ case ABP_ETN_IA_NETWORK_STATUS:
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Network Status) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, etn_iNetworkStatus, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_NETWORK_STATUS_DS );
+ break;
+#endif
+#if ETN_IA_PORT1_MAC_ADDRESS_ENABLE
+ case ABP_ETN_IA_PORT1_MAC_ADDRESS:
+ {
+ UINT16 i;
+ UINT8 abMac[ 6 ];
+
+ /*
+ ** Copy the 9th Instance 1 attribute (Port 1 MAC Address) to the message.
+ */
+
+ ABCC_PORT_MemCpy( abMac, ETN_IA_PORT1_MAC_ADDRESS_VALUE, ABP_ETN_IA_PORT1_MAC_ADDRESS_DS );
+
+ for( i = 0; i < ABP_ETN_IA_PORT1_MAC_ADDRESS_DS; i++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT1_MAC_ADDRESS_DS );
+ break;
+ }
+#endif
+#if ETN_IA_PORT2_MAC_ADDRESS_ENABLE
+ case ABP_ETN_IA_PORT2_MAC_ADDRESS:
+ {
+ UINT16 i;
+ UINT8 abMac[ 6 ];
+
+ /*
+ ** Copy the 10th Instance 1 attribute (Port 2 MAC Address) to the message.
+ */
+
+ ABCC_PORT_MemCpy( abMac, ETN_IA_PORT2_MAC_ADDRESS_VALUE, ABP_ETN_IA_PORT2_MAC_ADDRESS_DS );
+
+ for( i = 0; i < ABP_ETN_IA_PORT2_MAC_ADDRESS_DS; i++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT2_MAC_ADDRESS_DS );
+ break;
+ }
+#endif
+#if ETN_IA_ENABLE_ACD_ENABLE
+ case ABP_ETN_IA_ENABLE_ACD:
+
+ /*
+ ** Copy the 11th Instance 1 attribute (Enable ACD) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_ACD_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_ACD_DS );
+ break;
+#endif
+#if ETN_IA_PORT1_STATE_ENABLE
+ case ABP_ETN_IA_PORT1_STATE:
+
+ /*
+ ** Copy the 12th Instance 1 attribute (Port 1 state) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_PORT1_STATE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT1_STATE_DS );
+ break;
+#endif
+#if ETN_IA_PORT2_STATE_ENABLE
+ case ABP_ETN_IA_PORT2_STATE:
+
+ /*
+ ** Copy the 13th Instance 1 attribute (Port 2 state) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_PORT2_STATE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_PORT2_STATE_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_WEB_UPDATE_ENABLE
+ case ABP_ETN_IA_ENABLE_WEB_UPDATE:
+
+ /*
+ ** Copy the 14th Instance 1 attribute (Enable web update) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_WEB_UPDATE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_WEB_UPDATE_DS );
+ break;
+#endif
+#if ETN_IA_ENABLE_HICP_RESET_ENABLE
+ case ABP_ETN_IA_ENABLE_HICP_RESET:
+
+ /*
+ ** Copy the 15th Instance 1 attribute (Enable HICP reset) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, ETN_IA_ENABLE_HICP_RESET_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_ENABLE_HICP_RESET_DS );
+ break;
+#endif
+#if ETN_IA_IP_CONFIGURATION_ENABLE
+ case ABP_ETN_IA_IP_CONFIGURATION:
+ {
+ UINT16 i;
+
+ /*
+ ** Copy the 16th Instance 1 attribute (IP configuration) to the message.
+ */
+
+ i = 0;
+ while( i < ABP_ETN_IA_IP_CONFIGURATION_DS )
+ {
+ ABCC_SetMsgData32( psNewMessage, etn_sIpConfig.alIpConfig[ ( i / ABP_UINT32_SIZEOF ) ], i );
+ i += ABP_UINT32_SIZEOF;
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_IP_CONFIGURATION_DS );
+ break;
+ }
+#endif
+#if ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE
+ case ABP_ETN_IA_IP_ADDRESS_BYTE_0_2:
+ {
+ UINT16 i;
+ UINT8 abIp[ 3 ];
+
+ /*
+ ** Copy the 17th Instance 1 attribute (IP address byte 0 to 2) to the message.
+ */
+
+ ABCC_PORT_MemCpy( abIp, ETN_IA_IP_ADDRESS_BYTE_0_2_VALUE, ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS );
+
+ for( i = 0; i < ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS; i++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, abIp[ i ], i );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_ETN_IA_IP_ADDRESS_BYTE_0_2_DS );
+ break;
+ }
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+
+ case ABP_CMD_SET_ATTR:
+
+ switch( bAttribute )
+ {
+#if ETN_IA_MAC_ADDRESS_ENABLE
+ case ABP_ETN_IA_MAC_ADDRESS:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_HICP_ENABLE
+ case ABP_ETN_IA_ENABLE_HICP:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_WEB_ENABLE
+ case ABP_ETN_IA_ENABLE_WEB:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_MOD_TCP_ENABLE
+ case ABP_ETN_IA_ENABLE_MOD_TCP:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_WEB_ADI_ACCESS_ENABLE
+ case ABP_ETN_IA_ENABLE_WEB_ADI_ACCESS:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_FTP_ENABLE
+ case ABP_ETN_IA_ENABLE_FTP:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_ADMIN_MODE_ENABLE
+ case ABP_ETN_IA_ENABLE_ADMIN_MODE:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_NETWORK_STATUS_ENABLE
+ case ABP_ETN_IA_NETWORK_STATUS:
+ {
+ /*
+ ** Set the 8th Instance 1 attribute (Network Status) to the message.
+ */
+
+ if( ABCC_GetMsgDataSize( psNewMessage ) > ABP_ETN_IA_NETWORK_STATUS_DS )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA );
+ break;
+ }
+ else if( ABCC_GetMsgDataSize( psNewMessage ) < ABP_ETN_IA_NETWORK_STATUS_DS )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA );
+ break;
+ }
+
+ ABCC_GetMsgData16( psNewMessage, &etn_iNetworkStatus, 0 );
+#if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK
+ ETN_SetAttrSuccessCallback( iInstance, bAttribute );
+#endif
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ break;
+ }
+#endif
+#if ETN_IA_PORT1_MAC_ADDRESS_ENABLE
+ case ABP_ETN_IA_PORT1_MAC_ADDRESS:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_PORT2_MAC_ADDRESS_ENABLE
+ case ABP_ETN_IA_PORT2_MAC_ADDRESS:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_ACD_ENABLE
+ case ABP_ETN_IA_ENABLE_ACD:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_PORT1_STATE_ENABLE
+ case ABP_ETN_IA_PORT1_STATE:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_PORT2_STATE_ENABLE
+ case ABP_ETN_IA_PORT2_STATE:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_WEB_UPDATE_ENABLE
+ case ABP_ETN_IA_ENABLE_WEB_UPDATE:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_ENABLE_HICP_RESET_ENABLE
+ case ABP_ETN_IA_ENABLE_HICP_RESET:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+#if ETN_IA_IP_CONFIGURATION_ENABLE
+ case ABP_ETN_IA_IP_CONFIGURATION:
+ {
+ UINT16 i;
+
+ /*
+ ** Set the 16th Instance 1 attribute (IP configuration) to the message.
+ */
+
+ if( ABCC_GetMsgDataSize( psNewMessage ) > ABP_ETN_IA_IP_CONFIGURATION_DS )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA );
+ break;
+ }
+ else if( ABCC_GetMsgDataSize( psNewMessage ) < ABP_ETN_IA_IP_CONFIGURATION_DS )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA );
+ break;
+ }
+
+ i = 0;
+ while( i < ABP_ETN_IA_IP_CONFIGURATION_DS )
+ {
+ ABCC_GetMsgData32( psNewMessage, &etn_sIpConfig.alIpConfig[ ( i / ABP_UINT32_SIZEOF ) ], i );
+ i += ABP_UINT32_SIZEOF;
+ }
+#if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK
+ ETN_SetAttrSuccessCallback( iInstance, bAttribute );
+#endif
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ break;
+ }
+#endif
+#if ETN_IA_IP_ADDRESS_BYTE_0_2_ENABLE
+ case ABP_ETN_IA_IP_ADDRESS_BYTE_0_2:
+
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+#endif
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the ETN Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( etn_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, etn_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, etn_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, etn_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, etn_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* ETN_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/etn_obj.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,119 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** This is the public header file for the Ethernet IO object.
+********************************************************************************
+********************************************************************************
+** Services:
+** ETN_ProcessCmdMsg() - Processes commands sent to the ETN object.
+**
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef ETN_H
+#define ETN_H
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure storing attribute #16 'IP configuration' data
+**------------------------------------------------------------------------------
+*/
+typedef union ETN_IpConfigType
+{
+ UINT32 alIpConfig[ 3 ];
+ struct
+ {
+ UINT32 lIpAddr;
+ UINT32 lSnMask;
+ UINT32 lGwAddr;
+ }
+ sAddr;
+}
+ETN_IpConfigType;
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands sent to the Ethernet object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+void ETN_ProcessCmdMsg( ABP_MsgType* psNewMessage );
+
+/*------------------------------------------------------------------------------
+** Processes commands sent to the Ethernet object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psIpConfig - Pointer to structure to store current IP configuration
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+void ETN_GetIpConfig( ETN_IpConfigType* psIpConfig );
+
+/*******************************************************************************
+** Callbacks
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Optional user callback function that needs to be implememted by user
+** if ETN_OBJ_USE_SET_ATTR_SUCCESS_CALLBACK is set to TRUE.
+**------------------------------------------------------------------------------
+** Arguments:
+** iInstance - Object instance number
+** bAttribute - Object instance attribute number
+**
+** Returns:
+** None.
+**------------------------------------------------------------------------------
+*/
+extern void ETN_SetAttrSuccessCallback( UINT16 iInstance, UINT8 bAttribute );
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/cop.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,360 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the CANopen Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_obj_cfg.h"
+#include "cop.h"
+#include "abp.h"
+#include "abp_cop.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if COP_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define COP_OA_NAME_VALUE "CANopen"
+#define COP_OA_REV_VALUE 1
+#define COP_OA_NUM_INST_VALUE 1
+#define COP_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing an CANopen Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct cop_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+cop_ObjectType;
+
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const cop_ObjectType cop_sObject =
+{
+ COP_OA_NAME_VALUE, /* Name. */
+ COP_OA_REV_VALUE, /* Revision. */
+ COP_OA_NUM_INST_VALUE, /* Number of instances. */
+ COP_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void COP_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the CANopen Object and its Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** The CANopen object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** The CANopen instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to COP Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the DeviceNet Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#ifdef COP_IA_VENDOR_ID_ENABLE
+ case ABP_COP_IA_VENDOR_ID:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Vendor ID) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, COP_IA_VENDOR_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_COP_IA_VENDOR_ID_DS );
+ break;
+#endif
+#ifdef COP_IA_PRODUCT_CODE_ENABLE
+ case ABP_COP_IA_PRODUCT_CODE:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Product code) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, COP_IA_PRODUCT_CODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_COP_IA_PRODUCT_CODE_DS );
+ break;
+#endif
+#ifdef COP_IA_REV_MAJOR_ENABLE
+ case ABP_COP_IA_MAJOR_REV:
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Major revision) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, COP_IA_REV_MAJOR_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_COP_IA_MAJOR_REV_DS );
+ break;
+#endif
+#ifdef COP_IA_REV_MINOR_ENABLE
+ case ABP_COP_IA_MINOR_REV:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Minor revision) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, COP_IA_REV_MINOR_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_COP_IA_MINOR_REV_DS );
+ break;
+#endif
+#ifdef COP_IA_SERIAL_NUMBER_ENABLE
+ case ABP_COP_IA_SERIAL_NUMBER:
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Serial number) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, COP_IA_SERIAL_NUMBER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_COP_IA_SERIAL_NUMBER_DS );
+ break;
+#endif
+#ifdef COP_IA_MANF_DEV_NAME_ENABLE
+ case ABP_COP_IA_MANF_DEV_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( COP_IA_MANF_DEV_NAME_VALUE );
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Manufacture device name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, COP_IA_MANF_DEV_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#ifdef COP_IA_MANF_HW_VER_ENABLE
+ case ABP_COP_IA_MANF_HW_VER:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( COP_IA_MANF_HW_VER_VALUE );
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Manufacture hardware version) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, COP_IA_MANF_HW_VER_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#ifdef COP_IA_MANF_SW_VER_ENABLE
+ case ABP_COP_IA_MANF_SW_VER:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( COP_IA_MANF_SW_VER_VALUE );
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Manufacture software version) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, COP_IA_MANF_SW_VER_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the COP Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the CANopen Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( cop_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, cop_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, cop_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, cop_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, cop_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+
+ } /* End of switch( Attribute number ) */
+
+ break;
+ }
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* COP_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/cop.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the CANopen Object. +******************************************************************************** +******************************************************************************** +** Services: +** COP_ProcessCmdMsg() - Processes commands sent to the COP object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef COP_H +#define COP_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Private Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the COP object +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +void COP_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/dev.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,438 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the DeviceNet Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_obj_cfg.h"
+#include "dev.h"
+#include "abp.h"
+#include "abp_dev.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if DEV_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define DEV_OA_NAME_VALUE "DeviceNet"
+#define DEV_OA_REV_VALUE 1
+#define DEV_OA_NUM_INST_VALUE 1
+#define DEV_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing an DeviceNet Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct dev_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+dev_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const dev_ObjectType dev_sObject =
+{
+ DEV_OA_NAME_VALUE, /* Name. */
+ DEV_OA_REV_VALUE, /* Revision. */
+ DEV_OA_NUM_INST_VALUE, /* Number of instances. */
+ DEV_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void DEV_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the DeviceNet Object and it's Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** DeviceNet object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** DeviceNet instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to DEV Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the DeviceNet Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if DEV_IA_VENDOR_ID_ENABLE
+ case ABP_DEV_IA_VENDOR_ID:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Vendor ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_VENDOR_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_VENDOR_ID_DS );
+ break;
+#endif
+#if DEV_IA_DEVICE_TYPE_ENABLE
+ case ABP_DEV_IA_DEVICE_TYPE:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Device type) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_DEVICE_TYPE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_DEVICE_TYPE_DS );
+ break;
+#endif
+#if DEV_IA_PRODUCT_CODE_ENABLE
+ case ABP_DEV_IA_PRODUCT_CODE:
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Product code) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_PRODUCT_CODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_PRODUCT_CODE_DS );
+ break;
+#endif
+#if DEV_IA_REVISION_ENABLE
+ case ABP_DEV_IA_REVISION:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Revision) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_REVISION_MAJOR_VALUE, 0 );
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_REVISION_MINOR_VALUE, 1 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_REVISION_DS );
+ break;
+#endif
+#if DEV_IA_SERIAL_NUMBER_ENABLE
+ case ABP_DEV_IA_SERIAL_NUMBER:
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Serial number) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, DEV_IA_SERIAL_NUMBER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_SERIAL_NUMBER_DS );
+ break;
+#endif
+#if DEV_IA_PRODUCT_NAME_ENABLE
+ case ABP_DEV_IA_PRODUCT_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( DEV_IA_PRODUCT_NAME_VALUE );
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Product name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, DEV_IA_PRODUCT_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if DEV_IA_PROD_INSTANCE_ENABLE
+ case ABP_DEV_IA_PROD_INSTANCE:
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Producing instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_PROD_INSTANCE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_PROD_INSTANCE_DS );
+ break;
+#endif
+#if DEV_IA_CONS_INSTANCE_ENABLE
+ case ABP_DEV_IA_CONS_INSTANCE:
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Consuming instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_CONS_INSTANCE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_CONS_INSTANCE_DS );
+ break;
+#endif
+#if DEV_IA_ADDRESS_FROM_NET_ENABLE
+ case ABP_DEV_IA_ADDRESS_FROM_NET:
+
+ /*
+ ** Copy the 9th Instance 1 attribute (Enable address from net) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_ADDRESS_FROM_NET_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_ADDRESS_FROM_NET_DS );
+ break;
+#endif
+#if DEV_IA_BAUD_RATE_FROM_NET_ENABLE
+ case ABP_DEV_IA_BAUD_RATE_FROM_NET:
+
+ /*
+ ** Copy the 10th Instance 1 attribute (Enable baud rate from net) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_BAUD_RATE_FROM_NET_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_BAUD_RATE_FROM_NET_DS );
+ break;
+#endif
+#if DEV_IA_ENABLE_APP_CIP_OBJECTS_ENABLE
+ case ABP_DEV_IA_ENABLE_APP_CIP_OBJECTS:
+
+ /*
+ ** Copy the 11th Instance 1 attribute (Enable CIP request forwarding) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_ENABLE_APP_CIP_OBJECTS_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_ENABLE_APP_CIP_OBJECTS_DS );
+ break;
+#endif
+#if DEV_IA_ENABLE_PARAM_OBJECT_ENABLE
+ case ABP_DEV_IA_ENABLE_PARAM_OBJECT:
+
+ /*
+ ** Copy the 12th Instance 1 attribute (Enable Parameter object) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_ENABLE_PARAM_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_ENABLE_PARAM_OBJECT_DS );
+ break;
+#endif
+#if DEV_IA_ENABLE_QUICK_CONNECT_ENABLE
+ case ABP_DEV_IA_ENABLE_QUICK_CONNECT:
+
+ /*
+ ** Copy the 13th Instance 1 attribute (Enable Quick Connect) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DEV_IA_ENABLE_QUICK_CONNECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_ENABLE_PARAM_OBJECT_DS );
+ break;
+#endif
+#if DEV_IA_PREPEND_PRODUCING_ENABLE
+ case ABP_DEV_IA_PREPEND_PRODUCING:
+
+ /*
+ ** Copy the 18th Instance 1 attribute (Prepend producing profile instance) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_PREPEND_PRODUCING_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_PREPEND_PRODUCING_DS );
+ break;
+#endif
+#if DEV_IA_PREPEND_CONSUMING_ENABLE
+ case ABP_DEV_IA_PREPEND_CONSUMING:
+
+ /*
+ ** Copy the 19th Instance 1 attribute (Prepend consuming profile instance) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_PREPEND_CONSUMING_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_PREPEND_CONSUMING_DS );
+ break;
+#endif
+#if DEV_IA_ABCC_ADI_OBJECT_ENABLE
+ case ABP_DEV_IA_ABCC_ADI_OBJECT:
+
+ /*
+ ** Copy the 20th Instance 1 attribute (ABCC ADI Object Number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DEV_IA_ABCC_ADI_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DEV_IA_ABCC_ADI_OBJECT_DS );
+ break;
+#endif
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the DEV Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the DeviceNet Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( dev_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, dev_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, dev_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, dev_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, dev_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+
+ } /* End of switch( Attribute number ) */
+
+ break;
+ }
+ case ABP_DEV_CMD_PROCESS_CIP_OBJ_REQUEST:
+
+ /*
+ ** Optionally implement the Process CIP Object Request service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* DEV_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/dev.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the DeviceNet Object. +******************************************************************************** +******************************************************************************** +** Services: +** DEV_ProcessCmdMsg() - Processes commands sent to the DEV object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef DEV_H +#define DEV_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the DEV object +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +void DEV_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/dpv1.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,577 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the PROFIBUS DPV1 IO Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_obj_cfg.h"
+#include "abcc.h"
+#include "dpv1.h"
+#include "abp_dpv1.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if DPV1_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+#define DPV1_PRM_STANDARD_BYTES 7
+#define DPV1_PRM_DPV1_STATUS_BYTES 3
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define DPV1_OA_NAME_VALUE "PROFIBUS DP-V1"
+#define DPV1_OA_REV_VALUE 4
+#define DPV1_OA_NUM_INST_VALUE 1
+#define DPV1_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** dpv1_ObjectType.
+** Structure describing an Profibus Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct dpv1_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+dpv1_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Structure describing the EtherNet/IP Instance 1 attributes.
+**------------------------------------------------------------------------------
+*/
+#if DPV1_IA_PRM_DATA_ENABLE || \
+ DPV1_IA_EXPECTED_CFG_DATA_ENABLE || \
+ DPV1_IA_IM_HEADER_ENABLE
+typedef struct dpv1_Instance
+{
+#if DPV1_IA_PRM_DATA_ENABLE
+ UINT8 abParamData[ DPV1_IA_PRM_DATA_ARRAY_SIZE ];
+#endif
+#if DPV1_IA_EXPECTED_CFG_DATA_ENABLE
+ UINT8 abExpectedCfgData[ DPV1_IA_EXPECTED_CFG_DATA_ARRAY_SIZE ];
+#endif
+#if DPV1_IA_IM_HEADER_ENABLE
+ UINT8 abIMheader[ DPV1_IA_IM_HEADER_ARRAY_SIZE];
+#endif
+}
+dpv1_InstanceType;
+#endif
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const dpv1_ObjectType dpv1_sObject =
+{
+ DPV1_OA_NAME_VALUE, /* Name. */
+ DPV1_OA_REV_VALUE, /* Revision. */
+ DPV1_OA_NUM_INST_VALUE, /* Number of instances. */
+ DPV1_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+#if DPV1_IA_PRM_DATA_ENABLE || \
+ DPV1_IA_EXPECTED_CFG_DATA_ENABLE || \
+ DPV1_IA_IM_HEADER_ENABLE
+static dpv1_InstanceType dpv1_sInstance =
+{
+#if DPV1_IA_PRM_DATA_ENABLE
+ DPV1_IA_PRM_DATA_VALUE,
+#endif
+#if DPV1_IA_EXPECTED_CFG_DATA_ENABLE
+ DPV1_IA_EXPECTED_CFG_DATA_VALUE,
+#endif
+#if DPV1_IA_IM_HEADER_ENABLE
+ DPV1_IA_IM_HEADER_VALUE,
+#endif
+};
+#endif
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void DPV1_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Profibus Object and it's Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Profibus object Command
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Profibus instance Command
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+
+/*------------------------------------------------------------------------------
+** Processes commands to DPV1 Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Profibus Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if DPV1_IA_IDENT_NUMBER_ENABLE
+ case ABP_DPV1_IA_IDENT_NUMBER:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Device ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DPV1_IA_IDENT_NUMBER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_IDENT_NUMBER_DS );
+ break;
+#endif
+#if DPV1_IA_PRM_DATA_ENABLE
+ case ABP_DPV1_IA_PRM_DATA:
+
+ /*
+ ** The Parameter data is not getable. It's only setable.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_GETABLE );
+ break;
+#endif
+#if DPV1_IA_EXPECTED_CFG_DATA_ENABLE
+ case ABP_DPV1_IA_EXPECTED_CFG_DATA:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Expected configuration) to the message.
+ */
+ for( iIndex = 0; iIndex < DPV1_IA_EXPECTED_CFG_DATA_ARRAY_SIZE; iIndex++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, dpv1_sInstance.abExpectedCfgData[ iIndex ], iIndex );
+ }
+ ABP_SetMsgResponse( psNewMessage, DPV1_IA_EXPECTED_CFG_DATA_ARRAY_SIZE );
+ break;
+ }
+#endif
+#if DPV1_IA_SSA_ENABLED_ENABLE
+ case ABP_DPV1_IA_SSA_ENABLED:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (SSA enabled) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DPV1_IA_SSA_ENABLED_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_SSA_ENABLED_DS );
+ break;
+#endif
+#if DPV1_IA_MANUFACTURER_ID_ENABLE
+ case ABP_DPV1_IA_MANUFACTURER_ID:
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Manufacturer ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DPV1_IA_MANUFACTURER_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_MANUFACTURER_ID_DS );
+ break;
+#endif
+#if DPV1_IA_ORDER_ID_ENABLE
+ case ABP_DPV1_IA_ORDER_ID:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( DPV1_IA_ORDER_ID_VALUE );
+
+ /*
+ ** The maximum number of elements allowed in the array should not be
+ ** checked here. It should be checked earlier...
+ */
+ if( iStrLength > ABP_DPV1_IA_ORDER_ID_DS )
+ {
+ iStrLength = ABP_DPV1_IA_ORDER_ID_DS;
+ }
+
+ /*
+ ** Copy the 9th Instance 1 attribute (IM Order ID) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, DPV1_IA_ORDER_ID_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if DPV1_IA_SERIAL_NO_ENABLE
+ case ABP_DPV1_IA_SERIAL_NO:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( DPV1_IA_SERIAL_NO_VALUE );
+
+ /*
+ ** The maximum number of elements allowed in the array should not be
+ ** checked here. It should be checked earlier...
+ */
+ if( iStrLength > ABP_DPV1_IA_SERIAL_NO_DS )
+ {
+ iStrLength = ABP_DPV1_IA_SERIAL_NO_DS;
+ }
+
+ /*
+ ** Copy the 10th Instance 1 attribute (IM Serial number) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, DPV1_IA_SERIAL_NO_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if DPV1_IA_HW_REV_ENABLE
+ case ABP_DPV1_IA_HW_REV:
+
+ /*
+ ** Copy the 11th Instance 1 attribute (IM Hardware revision) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DPV1_IA_HW_REV_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_HW_REV_DS );
+ break;
+#endif
+#if DPV1_IA_SW_REV_ENABLE
+ case ABP_DPV1_IA_SW_REV:
+
+ /*
+ ** Copy the 12th Instance 1 attribute (Software revision) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, DPV1_IA_SW_REV_SYMBOL_VALUE, 0 );
+ ABCC_SetMsgData8( psNewMessage, DPV1_IA_SW_REV_MAJOR_VALUE, 1 );
+ ABCC_SetMsgData8( psNewMessage, DPV1_IA_SW_REV_MINOR_VALUE, 2 );
+ ABCC_SetMsgData8( psNewMessage, DPV1_IA_SW_REV_BUILD_VALUE, 3 );
+
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_SW_REV_DS );
+ break;
+#endif
+#if DPV1_IA_REV_COUNTER_ENABLE
+ case ABP_DPV1_IA_REV_COUNTER:
+
+ /*
+ ** Copy the 13th Instance 1 attribute (Revision counter) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DPV1_IA_REV_COUNTER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_REV_COUNTER_DS );
+ break;
+#endif
+#if DPV1_IA_PROFILE_ID_ENABLE
+ case ABP_DPV1_IA_PROFILE_ID:
+
+ /*
+ ** Copy the 14th Instance 1 attribute (Profile ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DPV1_IA_PROFILE_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_PROFILE_ID_DS );
+ break;
+#endif
+#if DPV1_IA_PROFILE_SPEC_TYPE_ENABLE
+ case ABP_DPV1_IA_PROFILE_SPEC_TYPE:
+
+ /*
+ ** Copy the 15th Instance 1 attribute (Profile specific type) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, DPV1_IA_PROFILE_SPEC_TYPE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_DPV1_IA_PROFILE_SPEC_TYPE_DS );
+ break;
+#endif
+#if DPV1_IA_IM_HEADER_ENABLE
+ case ABP_DPV1_IA_IM_HEADER:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 18th Instance 1 attribute (IM header) to the message.
+ */
+ for( iIndex = 0; iIndex < DPV1_IA_IM_HEADER_ARRAY_SIZE; iIndex++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, dpv1_sInstance.abIMheader[ iIndex ], iIndex );
+ }
+ ABP_SetMsgResponse( psNewMessage, DPV1_IA_IM_HEADER_ARRAY_SIZE );
+ break;
+ }
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+#if DPV1_IA_PRM_DATA_ENABLE || DPV1_IA_EXPECTED_CFG_DATA_ENABLE
+ case ABP_CMD_SET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if DPV1_IA_PRM_DATA_ENABLE
+ case ABP_DPV1_IA_PRM_DATA:
+
+ /*
+ ** The data size is verified.
+ */
+ if( psNewMessage->sHeader.iDataSize > DPV1_IA_PRM_DATA_ARRAY_SIZE )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA );
+ }
+ else if( psNewMessage->sHeader.iDataSize < DPV1_PRM_STANDARD_BYTES )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_NOT_ENOUGH_DATA );
+ }
+ else
+ {
+ /*
+ ** If the application has defined user specific parameter data,
+ ** this is the place to check the data (from byte 10 and forth)
+ ** In this example we only update the attribute.
+ */
+ ABCC_PORT_MemCpy( dpv1_sInstance.abParamData, psNewMessage->abData, DPV1_PRM_STANDARD_BYTES + DPV1_PRM_DPV1_STATUS_BYTES );
+
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ }
+ break;
+#endif
+#if DPV1_IA_EXPECTED_CFG_DATA_ENABLE
+ case ABP_DPV1_IA_EXPECTED_CFG_DATA:
+
+ /*
+ ** The data size is verified.
+ */
+ if( psNewMessage->sHeader.iDataSize > DPV1_IA_EXPECTED_CFG_DATA_ARRAY_SIZE )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_TOO_MUCH_DATA );
+ }
+ else
+ {
+ ABCC_PORT_MemCpy( dpv1_sInstance.abExpectedCfgData, psNewMessage->abData, psNewMessage->sHeader.iDataSize );
+
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ }
+ break;
+#endif
+
+#if DPV1_IA_IDENT_NUMBER_ENABLE
+ case ABP_DPV1_IA_IDENT_NUMBER:
+#endif
+#if DPV1_IA_SSA_ENABLED_ENABLE
+ case ABP_DPV1_IA_SSA_ENABLED:
+#endif
+#if DPV1_IA_MANUFACTURER_ID_ENABLE
+ case ABP_DPV1_IA_MANUFACTURER_ID:
+#endif
+#if DPV1_IA_ORDER_ID_ENABLE
+ case ABP_DPV1_IA_ORDER_ID:
+#endif
+#if DPV1_IA_SERIAL_NO_ENABLE
+ case ABP_DPV1_IA_SERIAL_NO:
+#endif
+#if DPV1_IA_HW_REV_ENABLE
+ case ABP_DPV1_IA_HW_REV:
+#endif
+#if DPV1_IA_SW_REV_ENABLE
+ case ABP_DPV1_IA_SW_REV:
+#endif
+#if DPV1_IA_REV_COUNTER_ENABLE
+ case ABP_DPV1_IA_REV_COUNTER:
+#endif
+#if DPV1_IA_PROFILE_ID_ENABLE
+ case ABP_DPV1_IA_PROFILE_ID:
+#endif
+#if DPV1_IA_PROFILE_SPEC_TYPE_ENABLE
+ case ABP_DPV1_IA_PROFILE_SPEC_TYPE:
+#endif
+ /*
+ ** Unsettable attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_ATTR_NOT_SETABLE );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ }
+#endif
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the DPV1 Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Profibus Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( dpv1_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, dpv1_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, dpv1_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, dpv1_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, dpv1_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* DPV1_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/dpv1.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the Profibus DPV1 IO object. +******************************************************************************** +******************************************************************************** +** Services: +** DPV1_ProcessCmdMsg() - Processes commands sent to the DPV1 object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef DPV1_H +#define DPV1_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the Profibus object. +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +void DPV1_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/ect.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,552 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the EtherCAT ABCC Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_obj_cfg.h"
+#include "ect.h"
+#include "abp.h"
+#include "abp_ect.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if ECT_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define ECT_OA_NAME_VALUE "EtherCAT"
+#define ECT_OA_REV_VALUE 1
+#define ECT_OA_NUM_INST_VALUE 1
+#define ECT_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing the EtherCAT Instance 1 attribute 13 ADI Translation
+**------------------------------------------------------------------------------
+*/
+#if ECT_IA_ADI_TRANS_ENABLE
+typedef struct ect_Instance1AdiTranslation
+{
+ UINT16 iADIInstanceNumber;
+ UINT16 iADIObjectIndex;
+}
+ect_Instance1AdiTranslation;
+#endif
+
+/*------------------------------------------------------------------------------
+** Structure describing the EtherCAT Instance 1 attribute 15 Object Subindex
+** Translation
+**------------------------------------------------------------------------------
+*/
+#if ECT_IA_ADI_TRANS_ENABLE
+typedef struct ect_Instance1ObjSubTrans
+{
+ UINT16 iADIInstanceNumber;
+ UINT16 iADIObjectIndex;
+ UINT8 bADIObjectIndexSubindex;
+}
+ect_Instance1ObjSubTrans;
+#endif
+
+/*------------------------------------------------------------------------------
+** Structure describing the EtherCAT Instance 1 attributes.
+**------------------------------------------------------------------------------
+*/
+#if( ECT_IA_ENUM_ADIS_ENABLE || ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE || ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE || ECT_IA_ADI_TRANS_ENABLE || ECT_IA_OBJ_SUB_TRANS_ENABLE )
+typedef struct ect_Instance
+{
+#if ECT_IA_ENUM_ADIS_ENABLE
+ UINT16 aiEnumADIs[ ECT_IA_ENUM_ADIS_ARRAY_SIZE ];
+#endif
+#if ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE
+ UINT16 aiWrPdAssyInstTrans[ ECT_IA_WR_PD_ASSY_INST_TRANS_SIZE ];
+#endif
+#if ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE
+ UINT16 aiRdPdAssyInstTrans[ ECT_IA_RD_PD_ASSY_INST_TRANS_SIZE ];
+#endif
+#if ECT_IA_ADI_TRANS_ENABLE
+ ect_Instance1AdiTranslation asADITrans[ ECT_IA_ADI_TRANS_SIZE ];
+#endif
+#if ECT_IA_OBJ_SUB_TRANS_ENABLE
+ ect_Instance1ObjSubTrans asObjSubTrans[ ECT_IA_OBJ_SUB_TRANS_SIZE ];
+#endif
+}
+ect_InstanceType;
+#endif /* if( ECT_IA_ENUM_ADIS_ENABLE... */
+
+/*------------------------------------------------------------------------------
+** Structure describing a Powerlink Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct ect_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+ect_ObjectType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const ect_ObjectType ect_sObject =
+{
+ ECT_OA_NAME_VALUE, /* Name. */
+ ECT_OA_REV_VALUE, /* Revision. */
+ ECT_OA_NUM_INST_VALUE, /* Number of instances. */
+ ECT_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+#if( ECT_IA_ENUM_ADIS_ENABLE || ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE || ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE || ECT_IA_ADI_TRANS_ENABLE || ECT_IA_OBJ_SUB_TRANS_ENABLE )
+static const ect_InstanceType ect_sInstance =
+{
+#if ECT_IA_ENUM_ADIS_ENABLE
+ ECT_IA_ENUM_ADIS_VALUE,
+#endif
+#if ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE
+ ECT_IA_WR_PD_ASSY_INST_TRANS_VALUE,
+#endif
+#if ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE
+ ECT_IA_RD_PD_ASSY_INST_TRANS_VALUE,
+#endif
+#if ECT_IA_ADI_TRANS_ENABLE
+ ECT_IA_ADI_TRANS_VALUE,
+#endif
+#if ECT_IA_OBJ_SUB_TRANS_ENABLE
+ ECT_IA_OBJ_SUB_TRANS_VALUE
+#endif
+};
+
+#endif /* #if( ECT_IA_ENUM_ADIS_ENABLE...*/
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to ECT Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the EtherCAT Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+
+ return;
+ }
+
+ switch( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if ECT_IA_VENDOR_ID_ENABLE
+ case ABP_ECT_IA_VENDOR_ID:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Vendor ID) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, ECT_IA_VENDOR_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ECT_IA_VENDOR_ID_DS );
+ break;
+#endif
+#if ECT_IA_PRODUCT_CODE_ENABLE
+ case ABP_ECT_IA_PRODUCT_CODE:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Product code) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, ECT_IA_PRODUCT_CODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ECT_IA_PRODUCT_CODE_DS );
+ break;
+#endif
+#if ECT_IA_MAJOR_REV_ENABLE
+ case ABP_ECT_IA_MAJOR_REV:
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Revision high word) to the
+ ** message.
+ */
+ ABCC_SetMsgData16( psNewMessage, ECT_IA_REVISION_HW_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ECT_IA_MAJOR_REV_DS );
+ break;
+#endif
+#if ECT_IA_MINOR_REV_ENABLE
+ case ABP_ECT_IA_MINOR_REV:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Revision low word) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, ECT_IA_REVISION_LW_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ECT_IA_MINOR_REV_DS );
+ break;
+#endif
+#if ECT_IA_SERIAL_NUMBER_ENABLE
+ case ABP_ECT_IA_SERIAL_NUMBER:
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Serial number) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, ECT_IA_SERIAL_NUMBER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ECT_IA_SERIAL_NUMBER_DS );
+ break;
+#endif
+#if ECT_IA_MANF_DEVICE_NAME_ENABLE
+ case ABP_ECT_IA_MANF_DEV_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( ECT_IA_MANF_DEVICE_NAME_VALUE );
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Manufacturer device name) to the
+ ** message.
+ */
+ ABCC_SetMsgString( psNewMessage, ECT_IA_MANF_DEVICE_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if ECT_IA_MANF_HW_VERSION_ENABLE
+ case ABP_ECT_IA_MANF_HW_VER:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( ECT_IA_MANF_HW_VERSION_VALUE );
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Manufacturer hardware version) to
+ ** the message.
+ */
+ ABCC_SetMsgString( psNewMessage, ECT_IA_MANF_HW_VERSION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ }
+ break;
+#endif
+#if ECT_IA_MANF_SW_VERSION_ENABLE
+ case ABP_ECT_IA_MANF_SW_VER:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( ECT_IA_MANF_SW_VERSION_VALUE );
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Manufacturer software version) to
+ ** the message.
+ */
+ ABCC_SetMsgString( psNewMessage, ECT_IA_MANF_SW_VERSION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ }
+ break;
+#endif
+#if ECT_IA_ENUM_ADIS_ENABLE
+ case ABP_ECT_IA_ENUM_ADIS:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 9th Instance 1 attribute (ENUM ADIs) to the message.
+ */
+ for( iIndex = 0; iIndex < ECT_IA_ENUM_ADIS_ARRAY_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.aiEnumADIs[ iIndex ],
+ ( ABP_UINT16_SIZEOF * iIndex ) );
+ }
+
+ ABP_SetMsgResponse( psNewMessage, ( ECT_IA_ENUM_ADIS_ARRAY_SIZE * ABP_UINT16_SIZEOF ) );
+ break;
+ }
+#endif
+#if ECT_IA_DEVICE_TYPE_ENABLE
+ case ABP_ECT_IA_DEVICE_TYPE:
+
+ /*
+ ** Copy the 10th Instance 1 attribute (Device type) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, ECT_IA_DEVICE_TYPE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_ECT_IA_DEVICE_TYPE_DS );
+ break;
+#endif
+#if ECT_IA_WR_PD_ASSY_INST_TRANS_ENABLE
+ case ABP_ECT_IA_WR_PD_ASSY_INST_TRANS:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 11th Instance 1 attribute (Write PD assembly instance
+ ** translation) to the message.
+ */
+ for( iIndex = 0; iIndex < ECT_IA_WR_PD_ASSY_INST_TRANS_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.aiWrPdAssyInstTrans[ iIndex ],
+ ( ABP_UINT16_SIZEOF * iIndex ) );
+ }
+
+ ABP_SetMsgResponse( psNewMessage, ( ECT_IA_WR_PD_ASSY_INST_TRANS_SIZE * ABP_UINT16_SIZEOF ) );
+ break;
+ }
+#endif
+
+#if ECT_IA_RD_PD_ASSY_INST_TRANS_ENABLE
+ case ABP_ECT_IA_RD_PD_ASSY_INST_TRANS:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 12th Instance 1 attribute (Read PD assembly instance
+ ** translation) to the message.
+ */
+ for( iIndex = 0; iIndex < ECT_IA_RD_PD_ASSY_INST_TRANS_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.aiRdPdAssyInstTrans[ iIndex ],
+ ( ABP_UINT16_SIZEOF * iIndex ) );
+ }
+
+ ABP_SetMsgResponse( psNewMessage, ( ECT_IA_RD_PD_ASSY_INST_TRANS_SIZE * ABP_UINT16_SIZEOF ) );
+ break;
+ }
+#endif
+#if ECT_IA_ADI_TRANS_ENABLE
+ case ABP_ECT_IA_ADI_TRANS:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 13th Instance 1 attribute (ADI translation) to the message.
+ */
+ for( iIndex = 0; iIndex < ECT_IA_ADI_TRANS_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.asADITrans[ iIndex ].iADIInstanceNumber,
+ ( ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF ) * iIndex ) );
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.asADITrans[ iIndex ].iADIObjectIndex,
+ ( ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF ) * iIndex ) + ABP_UINT16_SIZEOF );
+ }
+
+ ABP_SetMsgResponse( psNewMessage, ( ECT_IA_ADI_TRANS_SIZE * ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF ) ) );
+ break;
+ }
+#endif
+#if ECT_IA_OBJ_SUB_TRANS_ENABLE
+ case ABP_ECT_IA_OBJ_SUB_TRANS:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 13th Instance 1 attribute (ADI translation) to the message.
+ */
+ for( iIndex = 0; iIndex < ECT_IA_OBJ_SUB_TRANS_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.asObjSubTrans[ iIndex ].iADIInstanceNumber,
+ ( ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF + ABP_UINT8_SIZEOF ) * iIndex ) );
+ ABCC_SetMsgData16( psNewMessage,
+ ect_sInstance.asObjSubTrans[ iIndex ].iADIObjectIndex,
+ ( ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF + ABP_UINT8_SIZEOF ) * iIndex ) + ABP_UINT16_SIZEOF );
+ ABCC_SetMsgData8( psNewMessage,
+ ect_sInstance.asObjSubTrans[ iIndex ].bADIObjectIndexSubindex,
+ ( ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF + ABP_UINT8_SIZEOF ) * iIndex ) + ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF );
+ }
+
+ ABP_SetMsgResponse( psNewMessage, ( ECT_IA_OBJ_SUB_TRANS_SIZE * ( ABP_UINT16_SIZEOF + ABP_UINT16_SIZEOF + ABP_UINT8_SIZEOF ) ) );
+ break;
+ }
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the ECT Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the EtherCAT Object
+ ** (Instance 0).
+ */
+ switch( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( ECT_OA_NAME_VALUE );
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgString( psNewMessage, ECT_OA_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+
+ ABCC_SetMsgData8( psNewMessage, ect_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_UINT8_SIZEOF );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, ect_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_UINT16_SIZEOF );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, ect_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_UINT16_SIZEOF );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+
+ } /* End of switch( Attribute number ) */
+
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void ECT_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the EtherCAT Object and its Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** EtherCAT object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** EtherCAT instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/ect.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** File Description: +** This is the public header file for the EtherCat object. +******************************************************************************** +******************************************************************************** +** Services: +** +** Public Services: +** ECT_ProcessCmdMsg() - Processes commands sent to the ECT object. +******************************************************************************** +******************************************************************************** +*/ +#ifndef ECT_H +#define ECT_H + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Private Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** void ECT_ProcessCmdMsg() +** Processes commands sent to the ECT object. +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +** +** Usage: +** ECT_ProcessCmdMsg( &sMessage ); +**------------------------------------------------------------------------------ +*/ +void ECT_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/eip.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,718 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the EtherNet/IP Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_obj_cfg.h"
+#include "eip.h"
+#include "abp.h"
+#include "abp_eip.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if EIP_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define EIP_OA_NAME_VALUE "EtherNet/IP"
+#define EIP_OA_REV_VALUE 2
+#define EIP_OA_NUM_INST_VALUE 1
+#define EIP_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing an Ethernet/IP Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct eip_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+eip_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Structure describing an EtherNet/IP Instance Map used for attribute 27 and 28.
+**------------------------------------------------------------------------------
+*/
+typedef struct eip_InstanceMap
+{
+ UINT16 iInstanceNumber;
+ UINT16 iInstanceSize;
+}
+eip_InstanceMapType;
+
+/*------------------------------------------------------------------------------
+** Structure describing the EtherNet/IP Instance 1 attributes.
+**------------------------------------------------------------------------------
+*/
+#if( EIP_IA_PROD_INSTANCE_ENABLE || EIP_IA_CONS_INSTANCE_ENABLE || EIP_IA_PROD_INSTANCE_MAP_ENABLE || EIP_IA_CONS_INSTANCE_MAP_ENABLE )
+typedef struct eip_Instance
+{
+#if EIP_IA_PROD_INSTANCE_ENABLE
+ UINT16 aiProducingInstanceNumber[ EIP_IA_PROD_INSTANCE_ARRAY_SIZE ];
+#endif
+#if EIP_IA_CONS_INSTANCE_ENABLE
+ UINT16 aiConsumingInstanceNumber[ EIP_IA_CONS_INSTANCE_ARRAY_SIZE ];
+#endif
+#if EIP_IA_PROD_INSTANCE_MAP_ENABLE
+ eip_InstanceMapType asProducingInstanceMap[ EIP_IA_PROD_INSTANCE_MAP_ARRAY_SIZE ];
+#endif
+#if EIP_IA_CONS_INSTANCE_MAP_ENABLE
+ eip_InstanceMapType asConsumingInstanceMap[ EIP_IA_CONS_INSTANCE_MAP_ARRAY_SIZE ];
+#endif
+}
+eip_InstanceType;
+#endif
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const eip_ObjectType eip_sObject =
+{
+ EIP_OA_NAME_VALUE, /* Name. */
+ EIP_OA_REV_VALUE, /* Revision. */
+ EIP_OA_NUM_INST_VALUE, /* Number of instances. */
+ EIP_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+#if( EIP_IA_PROD_INSTANCE_ENABLE || EIP_IA_CONS_INSTANCE_ENABLE || EIP_IA_PROD_INSTANCE_MAP_ENABLE || EIP_IA_CONS_INSTANCE_MAP_ENABLE )
+static const eip_InstanceType eip_sInstance =
+{
+#if EIP_IA_PROD_INSTANCE_ENABLE
+ EIP_IA_PROD_INSTANCE_VALUE, /* 7 Producing instance number. */
+#endif
+#if EIP_IA_CONS_INSTANCE_ENABLE
+ EIP_IA_CONS_INSTANCE_VALUE, /* 8 Consuming instance number. */
+#endif
+#if EIP_IA_PROD_INSTANCE_MAP_ENABLE
+ EIP_IA_PROD_INSTANCE_MAP_VALUE, /* 27 Producing Instance Map. */
+#endif
+#if EIP_IA_CONS_INSTANCE_MAP_ENABLE
+ EIP_IA_CONS_INSTANCE_MAP_VALUE, /* 28 Consuming Instance Map. */
+#endif
+};
+#endif
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void EIP_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet/IP Object and it's Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Ethernet/IP object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Ethernet/IP instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to EIP Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet/IP Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if EIP_IA_VENDOR_ID_ENABLE
+ case ABP_EIP_IA_VENDOR_ID:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Vendor ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_VENDOR_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_VENDOR_ID_DS );
+ break;
+#endif
+#if EIP_IA_DEVICE_TYPE_ENABLE
+ case ABP_EIP_IA_DEVICE_TYPE:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Device type) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_DEVICE_TYPE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_DEVICE_TYPE_DS );
+ break;
+#endif
+#if EIP_IA_PRODUCT_CODE_ENABLE
+ case ABP_EIP_IA_PRODUCT_CODE:
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Product code) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_PRODUCT_CODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_PRODUCT_CODE_DS );
+ break;
+#endif
+#if EIP_IA_REVISION_ENABLE
+ case ABP_EIP_IA_REVISION:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Revision) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_REVISION_MAJOR_VALUE, 0 );
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_REVISION_MINOR_VALUE, 1 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_REVISION_DS );
+ break;
+#endif
+#if EIP_IA_SERIAL_NUMBER_ENABLE
+ case ABP_EIP_IA_SERIAL_NUMBER:
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Serial number) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, EIP_IA_SERIAL_NUMBER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_SERIAL_NUMBER_DS );
+ break;
+#endif
+#if EIP_IA_PRODUCT_NAME_ENABLE
+ case ABP_EIP_IA_PRODUCT_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( EIP_IA_PRODUCT_NAME_VALUE );
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Product name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, EIP_IA_PRODUCT_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if EIP_IA_PROD_INSTANCE_ENABLE
+ case ABP_EIP_IA_PROD_INSTANCE:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Producing instance number) to the message.
+ */
+ for( iIndex = 0; iIndex < EIP_IA_PROD_INSTANCE_ARRAY_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage, eip_sInstance.aiProducingInstanceNumber[ iIndex ], 2 * iIndex );
+ }
+
+ /*
+ ** The value of ABP_EIP_IA_PROD_INSTANCE_DS is counted per element, and
+ ** should therefore be divided by 6 as long as ABP_EIP_IA_PROD_INSTANCE_DS
+ ** is defined to be multiplied by 6 in abp_eip.h as ( 6 * ABP_UINT16_SIZEOF ).
+ */
+ ABP_SetMsgResponse( psNewMessage, EIP_IA_PROD_INSTANCE_ARRAY_SIZE * ( ABP_EIP_IA_PROD_INSTANCE_DS / 6 ) );
+ break;
+ }
+#endif
+#if EIP_IA_CONS_INSTANCE_ENABLE
+ case ABP_EIP_IA_CONS_INSTANCE:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Consuming instance number) to the message.
+ */
+ for( iIndex = 0; iIndex < EIP_IA_CONS_INSTANCE_ARRAY_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage, eip_sInstance.aiConsumingInstanceNumber[ iIndex ], 2 * iIndex );
+ }
+
+ /*
+ ** The value of ABP_EIP_IA_CONS_INSTANCE_DS is counted per element, and
+ ** should therefore be divided by 6 as long as ABP_EIP_IA_CONS_INSTANCE_DS
+ ** is defined to be multiplied by 6 in abp_eip.h as ( 6 * ABP_UINT16_SIZEOF ).
+ */
+ ABP_SetMsgResponse( psNewMessage, EIP_IA_CONS_INSTANCE_ARRAY_SIZE * ( ABP_EIP_IA_CONS_INSTANCE_DS / 6 ) );
+ break;
+ }
+#endif
+#if EIP_IA_COMM_SETTINGS_FROM_NET_ENABLE
+ case ABP_EIP_IA_COMM_SETTINGS_FROM_NET:
+
+ /*
+ ** Copy the 9th Instance 1 attribute (Enable communication settings from net) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_COMM_SETTINGS_FROM_NET_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_COMM_SETTINGS_FROM_NET_DS );
+ break;
+#endif
+#if EIP_IA_ENABLE_APP_CIP_OBJECTS_ENABLE
+ case ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS:
+
+ /*
+ ** Copy the 11th Instance 1 attribute (Enable CIP request forwarding) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_ENABLE_APP_CIP_OBJECTS_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS_DS );
+ break;
+#endif
+#if EIP_IA_ENABLE_PARAM_OBJECT_ENABLE
+ case ABP_EIP_IA_ENABLE_PARAM_OBJECT:
+
+ /*
+ ** Copy the 12th Instance 1 attribute (Enable Parameter object) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_ENABLE_PARAM_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_ENABLE_PARAM_OBJECT_DS );
+ break;
+#endif
+#if EIP_IA_INPUT_INSTANCE_OBJECT_ENABLE
+ case ABP_EIP_IA_INPUT_INSTANCE_OBJECT:
+
+ /*
+ ** Copy the 13th Instance 1 attribute (Input only heartbeat instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_INPUT_INSTANCE_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_INPUT_INSTANCE_DS );
+ break;
+#endif
+#if EIP_IA_LISTEN_INSTANCE_OBJECT_ENABLE
+ case ABP_EIP_IA_LISTEN_INSTANCE_OBJECT:
+
+ /*
+ ** Copy the 14th Instance 1 attribute (Listen only heartbeat instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_LISTEN_INSTANCE_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_LISTEN_INSTANCE_DS );
+ break;
+#endif
+#if EIP_IA_CONFIG_INSTANCE_ENABLE
+ case ABP_EIP_IA_CONFIG_INSTANCE:
+
+ /*
+ ** Copy the 15th Instance 1 attribute (Assembly object Configuration instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_CONFIG_INSTANCE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_CONFIG_INSTANCE_DS );
+ break;
+#endif
+#if EIP_IA_DISABLE_STRICT_IO_MATCH_ENABLE
+ case ABP_EIP_IA_DISABLE_STRICT_IO_MATCH:
+
+ /*
+ ** Copy the 16th Instance 1 attribute (Disable Strict IO match) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_DISABLE_STRICT_IO_MATCH_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_DISABLE_STRICT_IO_MATCH_DS );
+ break;
+#endif
+#if EIP_IA_ENABLE_UNCONNECTED_SEND_ENABLE
+ case ABP_EIP_IA_ENABLE_UNCONNECTED_SEND:
+
+ /*
+ ** Copy the 17th Instance 1 attribute (Enable unconnected routing) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_ENABLE_UNCONNECTED_SEND_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_ENABLE_UNCONNECTED_SEND_DS );
+ break;
+#endif
+#if EIP_IA_INPUT_EXT_INSTANCE_OBJECT_ENABLE
+ case ABP_EIP_IA_INPUT_EXT_INSTANCE_OBJECT:
+
+ /*
+ ** Copy the 18th Instance 1 attribute (Input only extended heartbeat instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_INPUT_EXT_INSTANCE_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_INPUT_EXT_INSTANCE_DS );
+ break;
+#endif
+#if EIP_IA_LISTEN_EXT_INSTANCE_OBJECT_ENABLE
+ case ABP_EIP_IA_LISTEN_EXT_INSTANCE_OBJECT:
+
+ /*
+ ** Copy the 19th Instance 1 attribute (Listen only extended heartbeat instance number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_LISTEN_EXT_INSTANCE_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_LISTEN_EXT_INSTANCE_DS );
+ break;
+#endif
+#if EIP_IA_IF_LABEL_PORT_1_ENABLE
+ case ABP_EIP_IA_IF_LABEL_PORT_1:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the 20th Instance 1 attribute (Interface label port 1) to the message.
+ */
+ iStrLength = (UINT16)strlen( EIP_IA_IF_LABEL_PORT_1_VALUE );
+ ABCC_SetMsgString( psNewMessage, EIP_IA_IF_LABEL_PORT_1_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if EIP_IA_IF_LABEL_PORT_2_ENABLE
+ case ABP_EIP_IA_IF_LABEL_PORT_2:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the 21st Instance 1 attribute (Interface label port 2) to the message.
+ */
+ iStrLength = (UINT16)strlen( EIP_IA_IF_LABEL_PORT_2_VALUE );
+ ABCC_SetMsgString( psNewMessage, EIP_IA_IF_LABEL_PORT_2_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if EIP_IA_IF_LABEL_PORT_INT_ENABLE
+ case ABP_EIP_IA_IF_LABEL_PORT_INT:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the 22nd Instance 1 attribute (Interface label internal port) to the message.
+ */
+ iStrLength = (UINT16)strlen( EIP_IA_IF_LABEL_PORT_INT_VALUE );
+ ABCC_SetMsgString( psNewMessage, EIP_IA_IF_LABEL_PORT_INT_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_ENABLE
+ case ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT:
+
+ /*
+ ** Copy the 23rd Instance 1 attribute (Enable CIP request forwarding extended) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_ENABLE_APP_CIP_OBJECTS_EXT_DS );
+ break;
+#endif
+#if EIP_IA_PREPEND_PRODUCING_ENABLE
+ case ABP_EIP_IA_PREPEND_PRODUCING:
+
+ /*
+ ** This attribute was deprecated and removed from Anybus CompactCom 40.
+ ** Copy the 24th Instance 1 attribute (Prepend producing profile instance) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_PREPEND_PRODUCING_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_PREPEND_PRODUCING_DS );
+ break;
+#endif
+#if EIP_IA_PREPEND_CONSUMING_ENABLE
+ case ABP_EIP_IA_PREPEND_CONSUMING:
+
+ /*
+ ** This attribute was deprecated and removed from Anybus CompactCom 40.
+ ** Copy the 25th Instance 1 attribute (Prepend consuming profile instance) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_PREPEND_CONSUMING_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_PREPEND_CONSUMING_DS );
+ break;
+#endif
+#if EIP_IA_ENABLE_EIP_QC_ENABLE
+ case ABP_EIP_IA_ENABLE_EIP_QC:
+
+ /*
+ ** Copy the 26th Instance 1 attribute (Enable EtherNet/IP QuickConnect) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_ENABLE_EIP_QC_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_ENABLE_EIP_QC_DS );
+ break;
+#endif
+#if EIP_IA_PROD_INSTANCE_MAP_ENABLE
+ case ABP_EIP_IA_PROD_INSTANCE_MAP:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** This attribute was deprecated and removed from Anybus CompactCom 40.
+ ** Copy the 27th Instance 1 attribute (Producing Instance Map) to the message.
+ */
+ for( iIndex = 0; iIndex < EIP_IA_PROD_INSTANCE_MAP_ARRAY_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage, eip_sInstance.asProducingInstanceMap[ iIndex ].iInstanceNumber, 4 * iIndex );
+ ABCC_SetMsgData16( psNewMessage, eip_sInstance.asProducingInstanceMap[ iIndex ].iInstanceSize, ( 4 * iIndex ) + 2 );
+ }
+
+ /*
+ ** The value of ABP_EIP_IA_PROD_INSTANCE_MAP_DS is counted per element, and
+ ** should therefore be divided by 6 as long as ABP_EIP_IA_PROD_INSTANCE_MAP_DS
+ ** is defined to be multiplied by 6 in abp_eip.h as ( 6 * 2 * ABP_UINT16_SIZEOF ).
+ */
+ ABP_SetMsgResponse( psNewMessage, EIP_IA_PROD_INSTANCE_MAP_ARRAY_SIZE * ( ABP_EIP_IA_PROD_INSTANCE_MAP_DS / 6 ) );
+ break;
+ }
+#endif
+#if EIP_IA_CONS_INSTANCE_MAP_ENABLE
+ case ABP_EIP_IA_CONS_INSTANCE_MAP:
+ {
+ UINT16 iIndex;
+
+ /*
+ ** This attribute was deprecated and removed from Anybus CompactCom 40.
+ ** Copy the 28th Instance 1 attribute (Consuming Instance Map) to the message.
+ */
+ for( iIndex = 0; iIndex < EIP_IA_CONS_INSTANCE_MAP_ARRAY_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData16( psNewMessage, eip_sInstance.asConsumingInstanceMap[ iIndex ].iInstanceNumber, 4 * iIndex );
+ ABCC_SetMsgData16( psNewMessage, eip_sInstance.asConsumingInstanceMap[ iIndex ].iInstanceSize, ( 4 * iIndex ) + 2 );
+ }
+
+ /*
+ ** The value of ABP_EIP_IA_CONS_INSTANCE_MAP_DS is counted per element, and
+ ** should therefore be divided by 6 as long as ABP_EIP_IA_CONS_INSTANCE_MAP_DS
+ ** is defined to be multiplied by 6 in abp_eip.h as ( 6 * 2 * ABP_UINT16_SIZEOF ).
+ */
+ ABP_SetMsgResponse( psNewMessage, EIP_IA_CONS_INSTANCE_MAP_ARRAY_SIZE * ( ABP_EIP_IA_CONS_INSTANCE_MAP_DS / 6 ) );
+ break;
+ }
+#endif
+#if EIP_IA_IGNORE_SEQ_COUNT_CHECK_ENABLE
+ case ABP_EIP_IA_IGNORE_SEQ_COUNT_CHECK:
+
+ /*
+ ** Copy the 29th Instance 1 attribute (Ignore Sequence Count Check) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, EIP_IA_IGNORE_SEQ_COUNT_CHECK_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_IGNORE_SEQ_COUNT_CHECK_DS );
+ break;
+#endif
+#if EIP_IA_ABCC_ADI_OBJECT_ENABLE
+ case ABP_EIP_IA_ABCC_ADI_OBJECT:
+
+ /*
+ ** Copy the 30th Instance 1 attribute (ABCC ADI Object number) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EIP_IA_ABCC_ADI_OBJECT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EIP_IA_ABCC_ADI_OBJECT_DS );
+ break;
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the EIP Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet/IP Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( eip_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, eip_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, eip_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, eip_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, eip_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+
+ } /* End of switch( Attribute number ) */
+
+ break;
+ }
+ case ABP_EIP_CMD_PROCESS_CIP_OBJ_REQUEST:
+
+ /*
+ ** Optionally implement the Process CIP Object Request service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_EIP_CMD_SET_CONFIG_DATA:
+
+ /*
+ ** Optionally implement the Set Config Data service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_EIP_CMD_PROCESS_CIP_ROUTING_REQUEST:
+
+ /*
+ ** Optionally implement the CIP Routing Request service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_EIP_CMD_GET_CONFIG_DATA:
+
+ /*
+ ** Optionally implement the Get Config Data service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_EIP_CMD_PROCESS_CIP_OBJ_REQUEST_EXT:
+
+ /*
+ ** Optionally implement the Process CIP Object Request Extended service
+ ** here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* EIP_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/eip.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the EtherNet/IP Object. +******************************************************************************** +******************************************************************************** +** Services: +** EIP_ProcessCmdMsg() - Processes commands sent to the EIP object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef EIP_H +#define EIP_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the EIP object +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +void EIP_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/epl.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,392 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the Ethernet POWERLINK ABCC Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_obj_cfg.h"
+#include "epl.h"
+#include "abp.h"
+#include "abp_epl.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if EPL_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define EPL_OA_NAME_VALUE "POWERLINK"
+#define EPL_OA_REV_VALUE 1
+#define EPL_OA_NUM_INST_VALUE 1
+#define EPL_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing a Powerlink Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct epl_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+epl_ObjectType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const epl_ObjectType epl_sObject =
+{
+ EPL_OA_NAME_VALUE, /* Name. */
+ EPL_OA_REV_VALUE, /* Revision. */
+ EPL_OA_NUM_INST_VALUE, /* Number of instances. */
+ EPL_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to EPL Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet POWERLINK Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+
+ return;
+ }
+
+ switch( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if EPL_IA_VENDOR_ID_ENABLE
+ case ABP_EPL_IA_VENDOR_ID:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Vendor ID) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, EPL_IA_VENDOR_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_VENDOR_ID_DS );
+ break;
+#endif
+#if EPL_IA_PRODUCT_CODE_ENABLE
+ case ABP_EPL_IA_PRODUCT_CODE:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Product code) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, EPL_IA_PRODUCT_CODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_PRODUCT_CODE_DS );
+ break;
+#endif
+#if EPL_IA_REVISION_HW_ENABLE
+ case ABP_EPL_IA_MAJOR_REV:
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Revision high word) to the
+ ** message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EPL_IA_REVISION_HW_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_MAJOR_REV_DS );
+ break;
+#endif
+#if EPL_IA_REVISION_LW_ENABLE
+ case ABP_EPL_IA_MINOR_REV:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Revision low word) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, EPL_IA_REVISION_LW_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_MINOR_REV_DS );
+ break;
+#endif
+#if EPL_IA_SERIAL_NUMBER_ENABLE
+ case ABP_EPL_IA_SERIAL_NUMBER:
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Serial number) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, EPL_IA_SERIAL_NUMBER_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_SERIAL_NUMBER_DS );
+ break;
+#endif
+#if EPL_IA_MANF_DEVICE_NAME_ENABLE
+ case ABP_EPL_IA_MANF_DEV_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( EPL_IA_MANF_DEVICE_NAME_VALUE );
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Manufacturer device name) to the
+ ** message.
+ */
+ ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_DEVICE_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+#if EPL_IA_MANF_HW_VERSION_ENABLE
+ case ABP_EPL_IA_MANF_HW_VER:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( EPL_IA_MANF_HW_VERSION_VALUE );
+
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Manufacturer hardware version) to
+ ** the message.
+ */
+ ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_HW_VERSION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ }
+ break;
+#endif
+#if EPL_IA_MANF_SW_VERSION_ENABLE
+ case ABP_EPL_IA_MANF_SW_VER:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( EPL_IA_MANF_SW_VERSION_VALUE );
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Manufacturer software version) to
+ ** the message.
+ */
+ ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_SW_VERSION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ }
+ break;
+#endif
+#if EPL_IA_DEVICE_TYPE_ENABLE
+ case ABP_EPL_IA_DEVICE_TYPE:
+
+ /*
+ ** Copy the 10th Instance 1 attribute (Device type) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, EPL_IA_DEVICE_TYPE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_EPL_IA_DEVICE_TYPE_DS );
+ break;
+#endif
+#if EPL_IA_MANF_NAME_ENABLE
+ case ABP_EPL_IA_MANF_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( EPL_IA_MANF_NAME_VALUE );
+
+ /*
+ ** Copy the 14th Instance 1 attribute (Manufacturer name) to the
+ ** message.
+ */
+ ABCC_SetMsgString( psNewMessage, EPL_IA_MANF_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the EPL Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet POWERLINK Object
+ ** (Instance 0).
+ */
+ switch( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( EPL_OA_NAME_VALUE );
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgString( psNewMessage, EPL_OA_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+
+ ABCC_SetMsgData8( psNewMessage, epl_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_UINT8_SIZEOF );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, epl_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_UINT16_SIZEOF );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, epl_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_UINT16_SIZEOF );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+
+ } /* End of switch( Attribute number ) */
+
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void EPL_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Ethernet POWERLINK Object and
+ ** its Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Ethernet POWERLINK object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Ethernet POWERLINK instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/epl.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the Ethernet Powerlink Object. +******************************************************************************** +******************************************************************************** +** Services: +** EPL_ProcessCmdMsg() - Processes commands sent to the EPL object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef EPL_H +#define EPL_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Private Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the EPL object. +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a received message addressing the EPL object. +** +** Returns: +** None +**------------------------------------------------------------------------------ +*/ +void EPL_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/mod.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,397 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the Modbus Object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "abcc_obj_cfg.h"
+#include "mod.h"
+#include "abp.h"
+#include "abp_mod.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if MOD_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define MOD_OA_NAME_VALUE "Modbus"
+#define MOD_OA_REV_VALUE 1
+#define MOD_OA_NUM_INST_VALUE 1
+#define MOD_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing an Modbus Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct mod_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+mod_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const mod_ObjectType mod_sObject =
+{
+ MOD_OA_NAME_VALUE, /* Name. */
+ MOD_OA_REV_VALUE, /* Revision. */
+ MOD_OA_NUM_INST_VALUE, /* Number of instances. */
+ MOD_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void MOD_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Modbus Object and its Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Modbus object Command.
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Modbus instance Command.
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to Modbus Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ UINT16 iIndex;
+ UINT16 iStrLength;
+
+ (void)iIndex;
+ (void)iStrLength;
+
+ /*
+ ** This function processes commands to the Modbus Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if MOD_IA_VENDOR_NAME_ENABLE
+ case ABP_MOD_IA_VENDOR_NAME:
+
+ iStrLength = (UINT16)strlen( MOD_IA_VENDOR_NAME_VALUE );
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Vendor name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_VENDOR_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_PRODUCT_CODE_ENABLE
+ case ABP_MOD_IA_PRODUCT_CODE:
+
+ iStrLength = (UINT16)strlen( MOD_IA_PRODUCT_CODE_VALUE );
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Product code) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_PRODUCT_CODE_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_REVISION_ENABLE
+ case ABP_MOD_IA_REVISION:
+
+ iStrLength = (UINT16)strlen( MOD_IA_REVISION_VALUE );
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Revision) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_REVISION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_VENDOR_URL_ENABLE
+ case ABP_MOD_IA_VENDOR_URL:
+
+ iStrLength = (UINT16)strlen( MOD_IA_VENDOR_URL_VALUE );
+
+ /*
+ ** Copy the 4th Instance 1 attribute (Vendor URL) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_VENDOR_URL_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_PRODUCT_NAME_ENABLE
+ case ABP_MOD_IA_PRODUCT_NAME:
+
+ iStrLength = (UINT16)strlen( MOD_IA_PRODUCT_NAME_VALUE );
+
+ /*
+ ** Copy the 5th Instance 1 attribute (Product name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_PRODUCT_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_MODEL_NAME_ENABLE
+ case ABP_MOD_IA_MODEL_NAME:
+
+ iStrLength = (UINT16)strlen( MOD_IA_MODEL_NAME_VALUE );
+
+ /*
+ ** Copy the 6th Instance 1 attribute (Model name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_MODEL_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_USER_APP_NAME_ENABLE
+ case ABP_MOD_IA_USER_APP_NAME:
+
+ iStrLength = (UINT16)strlen( MOD_IA_USER_APP_NAME_VALUE );
+
+ /*
+ ** Copy the 7th Instance 1 attribute (User application name) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, MOD_IA_USER_APP_NAME_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+#endif
+#if MOD_IA_DEVICE_ID_ENABLE
+ case ABP_MOD_IA_DEVICE_ID:
+
+ /*
+ ** Copy the 8th Instance 1 attribute (Device ID) to the message.
+ */
+ for( iIndex = 0; iIndex < MOD_IA_DEVICE_ID_ARRAY_SIZE; ++iIndex )
+ {
+ ABCC_SetMsgData8( psNewMessage, MOD_IA_DEVICE_ID_VALUE[ iIndex ], iIndex );
+ }
+
+ ABP_SetMsgResponse( psNewMessage, MOD_IA_DEVICE_ID_ARRAY_SIZE );
+ break;
+#endif
+#if MOD_IA_ADI_INDEXING_BITS_ENABLE
+ case ABP_MOD_IA_ADI_INDEXING_BITS:
+ /*
+ ** Copy the 9th Instance 1 attribute (No. of ADI indexing bits) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, MOD_IA_ADI_INDEXING_BITS_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_MOD_IA_ADI_INDEXING_BITS_DS );
+ break;
+#endif
+#if MOD_IA_MESSAGE_FORWARDING_ENABLE
+ case ABP_MOD_IA_MESSAGE_FORWARDING:
+ /*
+ ** Copy the 10th Instance 1 attribute (Enable Modbus Message forwarding) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, MOD_IA_MESSAGE_FORWARDING_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_MOD_IA_MESSAGE_FORWARDING_DS );
+ break;
+#endif
+#if MOD_IA_RW_OFFSET_ENABLE
+ case ABP_MOD_IA_RW_OFFSET:
+ /*
+ ** Copy the 11th Instance 1 attribute (Modbus read/write registers command offset) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, MOD_IA_RW_OFFSET_READ_VALUE, 0 );
+ ABCC_SetMsgData16( psNewMessage, MOD_IA_RW_OFFSET_WRITE_VALUE, 2 );
+ ABP_SetMsgResponse( psNewMessage, ABP_MOD_IA_RW_OFFSET_DS );
+ break;
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+
+/*------------------------------------------------------------------------------
+** Processes commands to the Modbus Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Modbus Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( mod_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, mod_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, mod_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, mod_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, mod_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+
+ } /* End of switch( Attribute number ) */
+
+ break;
+ }
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* MOD_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/mod.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the Modbus Object. +******************************************************************************** +******************************************************************************** +** Services: +** EIP_ProcessCmdMsg() - Processes commands sent to the Modbus object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef MOD_H +#define MOD_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the Modbus object +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +void MOD_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/nw_obj/prt.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,593 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Source file for the Profinet IO object.
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc_sys_adapt.h"
+#include "abcc_obj_cfg.h"
+#include "abcc.h"
+#include "prt.h"
+#include "abp_pnio.h"
+#include "string.h"
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+
+#if PRT_OBJ_ENABLE
+
+/*******************************************************************************
+** Defines
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define PRT_OA_NAME_VALUE "PROFINET IO"
+#define PRT_OA_REV_VALUE 1
+#define PRT_OA_NUM_INST_VALUE 1
+#define PRT_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** prt_ObjectType.
+** Structure describing an ProfiNet Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct prt_ObjectType
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+prt_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage );
+static void ObjectCommand( ABP_MsgType* psNewMessage );
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const prt_ObjectType prt_sObject =
+{
+ PRT_OA_NAME_VALUE, /* Name. */
+ PRT_OA_REV_VALUE, /* Revision. */
+ PRT_OA_NUM_INST_VALUE, /* Number of instances. */
+ PRT_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+void PRT_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Profinet Object and it's Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Profinet object Command
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Profinet instance Command
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to PRT Instances
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Profinet Instance.
+ */
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The Instance does not exist.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+ return;
+ }
+
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if PRT_IA_DEVICE_ID_ENABLE
+ case ABP_PNIO_IA_DEVICE_ID:
+
+ /*
+ ** Copy the 1st Instance 1 attribute (Device ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_DEVICE_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_DEVICE_ID_DS );
+ break;
+#endif
+#if PRT_IA_VENDOR_ID_ENABLE
+ case ABP_PNIO_IA_VENDOR_ID:
+
+ /*
+ ** Copy the 2nd Instance 1 attribute (Vendor ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_VENDOR_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_VENDOR_ID_DS );
+ break;
+#endif
+#if PRT_IA_STATION_TYPE_ENABLE
+ case ABP_PNIO_IA_STATION_TYPE:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( PRT_IA_STATION_TYPE_VALUE );
+
+ /*
+ ** The maximum number of elements allowed in the array should not be
+ ** checked here. It should be checked earlier...
+ */
+ if( iStrLength > ABP_PNIO_IA_STATION_TYPE_DS )
+ {
+ iStrLength = ABP_PNIO_IA_STATION_TYPE_DS;
+ }
+
+ /*
+ ** Copy the 3rd Instance 1 attribute (Station Type) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, PRT_IA_STATION_TYPE_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if PRT_IA_MAX_AR_ENABLE
+ case ABP_PNIO_IA_MAX_AR:
+
+ /*
+ ** Copy the 4th Instance 1 attribute (MaxAr) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, PRT_IA_MAX_AR_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_MAX_AR_DS );
+ break;
+#endif
+#if PRT_IA_RTM_ENABLE
+ case ABP_PNIO_IA_RTM:
+
+ /*
+ ** Copy the 7th Instance 1 attribute (Record Data Transparent Mode) to the message.
+ */
+ ABCC_SetMsgData32( psNewMessage, PRT_IA_RTM_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_RTM_DS );
+ break;
+#endif
+#if PRT_IA_IM_ORDER_ID_ENABLE
+ case ABP_PNIO_IA_IM_ORDER_ID:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( PRT_IA_IM_ORDER_ID_VALUE );
+
+ /*
+ ** The maximum number of elements allowed in the array should not be
+ ** checked here. It should be checked earlier...
+ */
+ if( iStrLength > ABP_PNIO_IA_IM_ORDER_ID_DS )
+ {
+ iStrLength = ABP_PNIO_IA_IM_ORDER_ID_DS;
+ }
+
+ /*
+ ** Copy the 8th Instance 1 attribute (IM Order ID) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, PRT_IA_IM_ORDER_ID_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if PRT_IA_IM_SERIAL_NBR_ENABLE
+ case ABP_PNIO_IA_IM_SERIAL_NBR:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( PRT_IA_IM_SERIAL_NBR_VALUE );
+
+ /*
+ ** The maximum number of elements allowed in the array should not be
+ ** checked here. It should be checked earlier...
+ */
+ if( iStrLength > ABP_PNIO_IA_IM_SERIAL_NBR_DS )
+ {
+ iStrLength = ABP_PNIO_IA_IM_SERIAL_NBR_DS;
+ }
+
+ /*
+ ** Copy the 9th Instance 1 attribute (IM Serial number) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, PRT_IA_IM_SERIAL_NBR_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if PRT_IA_IM_HW_REV_ENABLE
+ case ABP_PNIO_IA_IM_HW_REV:
+
+ /*
+ ** Copy the 10th Instance 1 attribute (IM Hardware revision) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_IM_HW_REV_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_HW_REV_DS );
+ break;
+#endif
+#if PRT_IA_IM_SW_REV_ENABLE
+ case ABP_PNIO_IA_IM_SW_REV:
+
+ /*
+ ** Copy the 11th Instance 1 attribute (Software revision) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_IM_SW_REV_SYMBOL_VALUE, 0 );
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_IM_SW_REV_MAJOR_VALUE, 1 );
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_IM_SW_REV_MINOR_VALUE, 2 );
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_IM_SW_REV_BUILD_VALUE, 3 );
+
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_SW_REV_DS );
+ break;
+#endif
+#if PRT_IA_IM_REV_CNT_ENABLE
+ case ABP_PNIO_IA_IM_REV_CNT:
+
+ /*
+ ** Copy the 12th Instance 1 attribute (IM Revision Counter) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_IM_REV_CNT_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_REV_CNT_DS );
+ break;
+#endif
+#if PRT_IA_IM_PROFILE_ID_ENABLE
+ case ABP_PNIO_IA_IM_PROFILE_ID:
+
+ /*
+ ** Copy the 13th Instance 1 attribute (IM Profile ID) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_IM_PROFILE_ID_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_PROFILE_ID_DS );
+ break;
+#endif
+#if PRT_IA_IM_PROFILE_SPEC_TYPE_ENABLE
+ case ABP_PNIO_IA_IM_PROFILE_SPEC_TYPE:
+
+ /*
+ ** Copy the 14th Instance 1 attribute (IM Profile Specific Type) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_IM_PROFILE_SPEC_TYPE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_PROFILE_SPEC_TYPE_DS );
+ break;
+#endif
+#if PRT_IA_IM_VER_ENABLE
+ case ABP_PNIO_IA_IM_VER:
+
+ /*
+ ** Copy the 15th Instance 1 attribute (IM Version) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_IM_VER_MAJOR_VALUE, 0 );
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_IM_VER_MINOR_VALUE, 1 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_VER_DS );
+ break;
+#endif
+#if PRT_IA_IM_SUPPORTED_ENABLE
+ case ABP_PNIO_IA_IM_SUPPORTED:
+
+ /*
+ ** Copy the 16th Instance 1 attribute (IM Supported) to the message.
+ */
+ ABCC_SetMsgData16( psNewMessage, PRT_IA_IM_SUPPORTED_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_IM_SUPPORTED_DS );
+ break;
+#endif
+#if PRT_IA_PORT1_MAC_ADDRESS_ENABLE
+ case ABP_PNIO_IA_PORT1_MAC_ADDRESS:
+ {
+ UINT16 i;
+ UINT8 abMac[ 6 ];
+
+ /*
+ ** Copy the 17th Instance 1 attribute (Port 1 MAC Address) to the message.
+ */
+
+ ABCC_PORT_MemCpy( abMac, PRT_IA_PORT1_MAC_ADDRESS_VALUE, 6 );
+
+ for( i = 0; i < 6; i++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_PORT1_MAC_ADDRESS_DS );
+ break;
+ }
+#endif
+#if PRT_IA_PORT2_MAC_ADDRESS_ENABLE
+ case ABP_PNIO_IA_PORT2_MAC_ADDRESS:
+ {
+ UINT16 i;
+ UINT8 abMac[ 6 ];
+
+ /*
+ ** Copy the 18th Instance 1 attribute (Port 2 MAC Address) to the message.
+ */
+
+ ABCC_PORT_MemCpy( abMac, PRT_IA_PORT2_MAC_ADDRESS_VALUE, 6 );
+
+ for( i = 0; i < 6; i++ )
+ {
+ ABCC_SetMsgData8( psNewMessage, abMac[ i ], i );
+ }
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_PORT2_MAC_ADDRESS_DS );
+ break;
+ }
+#endif
+#if PRT_IA_SYSTEM_DESCRIPTION_ENABLE
+ case ABP_PNIO_IA_SYSTEM_DESCRIPTION:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( PRT_IA_SYSTEM_DESCRIPTION_VALUE );
+
+ /*
+ ** Copy the 19th Instance 1 attribute (System description) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, PRT_IA_SYSTEM_DESCRIPTION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if PRT_IA_INTERFACE_DESCRIPTION_ENABLE
+ case ABP_PNIO_IA_INTERFACE_DESCRIPTION:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( PRT_IA_INTERFACE_DESCRIPTION_VALUE );
+ /*
+ ** Copy the 20th Instance 1 attribute (Interface Description) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, PRT_IA_INTERFACE_DESCRIPTION_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if PRT_IA_MOD_ID_ASSIGN_MODE_ENABLE
+ case ABP_PNIO_IA_MOD_ID_ASSIGN_MODE:
+
+ /*
+ ** Copy the 21st Instance 1 attribute (Module ID Assignment Mode) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_MOD_ID_ASSIGN_MODE_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_MOD_ID_ASSIGN_MODE_DS );
+ break;
+#endif
+#if PRT_IA_SYSTEM_CONTACT_ENABLE
+ case ABP_PNIO_IA_SYSTEM_CONTACT:
+ {
+ UINT16 iStrLength;
+
+ iStrLength = (UINT16)strlen( PRT_IA_SYSTEM_CONTACT_VALUE );
+
+ /*
+ ** Copy the 22nd Instance 1 attribute (System contact) to the message.
+ */
+ ABCC_SetMsgString( psNewMessage, PRT_IA_SYSTEM_CONTACT_VALUE, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, iStrLength );
+ break;
+ }
+#endif
+#if PRT_IA_PROFIENERGY_FUNC_ENABLE
+ case ABP_PNIO_IA_PROFIENERGY_FUNC:
+
+ /*
+ ** Copy the 23rd Instance 1 attribute (PROFIenergy Functionality) to the message.
+ */
+ ABCC_SetMsgData8( psNewMessage, PRT_IA_PROFIENERGY_FUNC_VALUE, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_PNIO_IA_PROFIENERGY_FUNC_DS );
+ break;
+#endif
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the PRT Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ /*
+ ** This function processes commands to the Profinet Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+ {
+ UINT16 iStrLength;
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ iStrLength = (UINT16)strlen( prt_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, prt_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+ }
+
+ case ABP_OA_REV:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData8( psNewMessage, prt_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, prt_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** Copy the attribute to a message.
+ */
+ ABCC_SetMsgData16( psNewMessage, prt_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ case ABP_PNIO_CMD_GET_RECORD:
+
+ /*
+ ** Optionally implement the Get Record service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_PNIO_CMD_SET_RECORD:
+
+ /*
+ ** Optionally implement the Set Record service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_PNIO_CMD_GET_IM_RECORD:
+
+ /*
+ ** Optionally implement the Get IM Record service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_PNIO_CMD_SET_IM_RECORD:
+
+ /*
+ ** Optionally implement the Set IM Record service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ case ABP_PNIO_CMD_AR_CHECK_IND:
+
+ /*
+ ** Optionally implement the AR Check Ind. service here.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+#endif /* PRT_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Generic/abcc_obj/nw_obj/prt.h Thu May 12 19:04:45 2016 +0000 @@ -0,0 +1,71 @@ +/******************************************************************************* +******************************************************************************** +** ** +** ABCC Starter Kit version 2.01.01 (2015-12-14) ** +** ** +** Delivered with: ** +** ABCC Driver 4.01.01 (2015-12-14) ** +** ABP 7.16.01 (2015-10-14) ** +** */ +/******************************************************************************* +******************************************************************************** +** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** +** ** +** This code is the property of HMS Industrial Networks AB. ** +** The source code may not be reproduced, distributed, or used without ** +** permission. When used together with a product from HMS, permission is ** +** granted to modify, reproduce and distribute the code in binary form ** +** without any restrictions. ** +** ** +** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** +** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** +** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** +** THAT DEFECTS IN IT CAN BE CORRECTED. ** +******************************************************************************** +******************************************************************************** +** This is the public header file for the Profinet IO object. +******************************************************************************** +******************************************************************************** +** Services: +** PRT_ProcessCmdMsg() - Processes commands sent to the PRT object. +** +******************************************************************************** +******************************************************************************** +*/ + +#ifndef PRT_H +#define PRT_H + +/******************************************************************************* +** Constants +******************************************************************************** +*/ + +/******************************************************************************* +** Typedefs +******************************************************************************** +*/ + +/******************************************************************************* +** Public Globals +******************************************************************************** +*/ + +/******************************************************************************* +** Public Services +******************************************************************************** +*/ + +/*------------------------------------------------------------------------------ +** Processes commands sent to the Profinet object. +**------------------------------------------------------------------------------ +** Arguments: +** psNewMessage - Pointer to a ABP_MsgType message. +** +** Returns: +** None. +**------------------------------------------------------------------------------ +*/ +void PRT_ProcessCmdMsg( ABP_MsgType* psNewMessage ); + +#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/sync_obj.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,685 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Implementation of the SYNC object.
+********************************************************************************
+********************************************************************************
+*/
+#include "abcc_td.h"
+#include "abcc_sw_port.h"
+#include "abcc_drv_cfg.h"
+#include "abcc_obj_cfg.h"
+#include "abp.h"
+#include "abp_sync.h"
+#include "abcc_ad_if.h"
+#include "abcc.h"
+#include "abcc_port.h"
+#include "appl_abcc_handler.h"
+#include "abcc_sys_adapt.h"
+#include "sync_obj.h"
+
+#if SYNC_OBJ_ENABLE
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Object attribute values
+**------------------------------------------------------------------------------
+*/
+#define SYNC_OA_NAME_VALUE "Sync"
+#define SYNC_OA_REV_VALUE 1
+#define SYNC_OA_NUM_INST_VALUE 1
+#define SYNC_OA_HIGHEST_INST_VALUE 1
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing a SYNC Object.
+**------------------------------------------------------------------------------
+*/
+typedef struct sync_Object
+{
+ const char* pcName;
+ UINT8 bRevision;
+ UINT16 iNumberOfInstances;
+ UINT16 iHighestInstanceNo;
+}
+sync_ObjectType;
+
+/*------------------------------------------------------------------------------
+** Structure describing an SYNC Instance.
+**------------------------------------------------------------------------------
+*/
+typedef struct sync_Instance
+{
+#if SYNC_IA_CYCLE_TIME_ENABLE
+ UINT32 lCycleTime;
+#endif
+#if SYNC_IA_OUTPUT_VALID_ENABLE
+ UINT32 lOutputValidTime;
+#endif
+#if SYNC_IA_INPUT_CAPTURE_ENABLE
+ UINT32 lInputCaptureTime;
+#endif
+#if SYNC_IA_OUTPUT_PROCESSING_ENABLE
+ UINT32 lOutputProcessingTime;
+#endif
+#if SYNC_IA_INPUT_PROCESSING_ENABLE
+ UINT32 lInputProcessingTime;
+#endif
+#if SYNC_IA_MIN_CYCLE_TIME_ENABLE
+ UINT32 lMinCycleTime;
+#endif
+#if SYNC_IA_SYNC_MODE_ENABLE
+ UINT16 iSyncMode;
+#endif
+}
+sync_InstanceType;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+static const sync_ObjectType sync_sObject =
+{
+ SYNC_OA_NAME_VALUE, /* Name. */
+ SYNC_OA_REV_VALUE, /* Revision. */
+ SYNC_OA_NUM_INST_VALUE, /* Number of instances. */
+ SYNC_OA_HIGHEST_INST_VALUE /* Highest instance number. */
+};
+
+static sync_InstanceType sync_sInstance =
+{
+#if SYNC_IA_CYCLE_TIME_ENABLE
+ SYNC_IA_CYCLE_TIME_VALUE,
+#endif
+#if SYNC_IA_OUTPUT_VALID_ENABLE
+ SYNC_IA_OUTPUT_VALID_VALUE,
+#endif
+#if SYNC_IA_INPUT_CAPTURE_ENABLE
+ SYNC_IA_INPUT_CAPTURE_VALUE,
+#endif
+#if SYNC_IA_OUTPUT_PROCESSING_ENABLE
+ SYNC_IA_OUTPUT_PROCESSING_VALUE,
+#endif
+#if SYNC_IA_INPUT_PROCESSING_ENABLE
+ SYNC_IA_INPUT_PROCESSING_VALUE,
+#endif
+#if SYNC_IA_MIN_CYCLE_TIME_ENABLE
+ SYNC_IA_MIN_CYCLE_TIME_VALUE,
+#endif
+#if SYNC_IA_SYNC_MODE_ENABLE
+ SYNC_IA_SYNC_MODE_VALUE,
+#endif
+};
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void UpdateAppStatus( void );
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Processes commands to the Sync Instance
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void InstanceCommand( ABP_MsgType* psNewMessage )
+{
+ UINT32 lCycleTimeNs;
+ UINT16 iSyncMode;
+ UINT8 bAnbState;
+
+ ABCC_PORT_UseCritical();
+
+ if( ABCC_GetMsgInstance( psNewMessage ) != 1 )
+ {
+ /*
+ ** The requested instance does not exist.
+ ** Respond with a error.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_INST );
+
+ return;
+ }
+
+ switch( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if SYNC_IA_CYCLE_TIME_ENABLE
+ case ABP_SYNC_IA_CYCLE_TIME:
+
+ /*
+ ** The 'cycle time' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData32( psNewMessage, sync_sInstance.lCycleTime, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_CYCLE_TIME_DS );
+ break;
+#endif
+#if SYNC_IA_OUTPUT_VALID_ENABLE
+ case ABP_SYNC_IA_OUTPUT_VALID:
+
+ /*
+ ** The 'output valid' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData32( psNewMessage, sync_sInstance.lOutputValidTime, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_OUTPUT_VALID_DS );
+
+ break;
+#endif
+#if SYNC_IA_INPUT_CAPTURE_ENABLE
+ case ABP_SYNC_IA_INPUT_CAPTURE:
+
+ /*
+ ** The 'input capture' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData32( psNewMessage, sync_sInstance.lInputCaptureTime, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_INPUT_CAPTURE_DS );
+
+ break;
+#endif
+#if SYNC_IA_OUTPUT_PROCESSING_ENABLE
+ case ABP_SYNC_IA_OUTPUT_PROCESSING:
+
+ /*
+ ** The 'output processing' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData32( psNewMessage, sync_sInstance.lOutputProcessingTime, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_OUTPUT_PROCESSING_DS );
+
+ break;
+#endif
+#if SYNC_IA_INPUT_PROCESSING_ENABLE
+ case ABP_SYNC_IA_INPUT_PROCESSING:
+
+ /*
+ ** The 'input processing' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData32( psNewMessage, sync_sInstance.lInputProcessingTime, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_INPUT_PROCESSING_DS );
+
+ break;
+#endif
+#if SYNC_IA_MIN_CYCLE_TIME_ENABLE
+ case ABP_SYNC_IA_MIN_CYCLE_TIME:
+
+ /*
+ ** The 'min cycle time' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData32( psNewMessage, sync_sInstance.lMinCycleTime, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_MIN_CYCLE_TIME_DS );
+
+ break;
+#endif
+#if SYNC_IA_SYNC_MODE_ENABLE
+ case ABP_SYNC_IA_SYNC_MODE:
+
+ /*
+ ** The 'sync mode' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData16( psNewMessage, sync_sInstance.iSyncMode, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, (UINT8)ABP_SYNC_IA_SYNC_MODE_DS );
+
+ break;
+#endif
+#if SYNC_IA_SUPPORTED_SYNC_MODES_ENABLE
+ case ABP_SYNC_IA_SUPPORTED_SYNC_MODES:
+
+ /*
+ ** The 'supported sync modes' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_SetMsgData16( psNewMessage, SYNC_IA_SUPPORTED_SYNC_MODES_VALUE, 0 );
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, ABP_SYNC_IA_SUPPORTED_SYNC_MODES_DS );
+
+ break;
+#endif
+ default:
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+
+ break;
+ }
+ break;
+ }
+ case ABP_CMD_SET_ATTR:
+ {
+ bAnbState = ABCC_AnbState();
+
+ /*
+ ** It shall only be possible to set the attributes if the Anybus state
+ ** is not equal to Idle or Process active.
+ */
+ if( ( bAnbState == ABP_ANB_STATE_IDLE ) ||
+ ( bAnbState == ABP_ANB_STATE_PROCESS_ACTIVE ) )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_STATE );
+
+ break;
+ }
+
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+#if SYNC_IA_CYCLE_TIME_ENABLE
+ case ABP_SYNC_IA_CYCLE_TIME:
+
+ ABCC_GetMsgData32( psNewMessage, &lCycleTimeNs, 0 );
+
+ ABCC_PORT_EnterCritical();
+ {
+ if( lCycleTimeNs < sync_sInstance.lMinCycleTime )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_VAL_TOO_LOW );
+ }
+ else
+ {
+ /*
+ ** Set the 'cycle time' attribute
+ */
+ sync_sInstance.lCycleTime = lCycleTimeNs;
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ UpdateAppStatus();
+ }
+ }
+ ABCC_PORT_ExitCritical();
+
+ break;
+#endif
+#if SYNC_IA_OUTPUT_VALID_ENABLE
+ case ABP_SYNC_IA_OUTPUT_VALID:
+
+ /*
+ ** Set the 'output valid' attribute
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_GetMsgData32( psNewMessage, &sync_sInstance.lOutputValidTime, 0 );
+ UpdateAppStatus();
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, 0 );
+
+ break;
+#endif
+#if SYNC_IA_INPUT_CAPTURE_ENABLE
+ case ABP_SYNC_IA_INPUT_CAPTURE:
+
+ /*
+ ** Set the 'input capture' attribute
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ ABCC_GetMsgData32( psNewMessage, &sync_sInstance.lInputCaptureTime, 0 );
+ UpdateAppStatus();
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, 0 );
+
+ break;
+#endif
+#if SYNC_IA_SYNC_MODE_ENABLE
+ case ABP_SYNC_IA_SYNC_MODE:
+
+ ABCC_GetMsgData16( psNewMessage, &iSyncMode, 0 );
+
+ if( (SYNC_SyncModeType)iSyncMode > SYNC_MODE_SYNCHRONOUS )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_VAL_TOO_HIGH );
+ }
+ else if( !( SYNC_IA_SUPPORTED_SYNC_MODES_VALUE & ( 1 << iSyncMode ) ) )
+ {
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_OUT_OF_RANGE );
+ }
+ else
+ {
+ /*
+ ** Set the 'sync mode' attribute
+ */
+ ABCC_PORT_EnterCritical();
+ {
+ sync_sInstance.iSyncMode = iSyncMode;
+ UpdateAppStatus();
+ }
+ ABCC_PORT_ExitCritical();
+
+ ABP_SetMsgResponse( psNewMessage, 0 );
+ }
+
+ break;
+#endif
+ default:
+
+ /*
+ ** The attribute does not exist, or the attribute is not settable.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Processes commands to the SYNC Object (Instance 0)
+**------------------------------------------------------------------------------
+** Arguments:
+** psNewMessage - Pointer to a ABP_MsgType message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ObjectCommand( ABP_MsgType* psNewMessage )
+{
+ UINT16 iStrLength;
+
+ /*
+ ** This function processes commands to the Sync Object (Instance 0).
+ */
+ switch ( ABCC_GetMsgCmdBits( psNewMessage ) )
+ {
+ case ABP_CMD_GET_ATTR:
+ {
+ switch( ABCC_GetMsgCmdExt0( psNewMessage ) )
+ {
+ case ABP_OA_NAME:
+
+ /*
+ ** The 'name' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ iStrLength = (UINT16)strlen( sync_sObject.pcName );
+ ABCC_SetMsgString( psNewMessage, sync_sObject.pcName, iStrLength, 0 );
+ ABP_SetMsgResponse( psNewMessage, (UINT8)iStrLength );
+ break;
+
+ case ABP_OA_REV:
+
+ /*
+ ** The 'revision' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData8( psNewMessage, sync_sObject.bRevision, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_REV_DS );
+ break;
+
+ case ABP_OA_NUM_INST:
+
+ /*
+ ** The 'Number of Instances' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData16( psNewMessage, sync_sObject.iNumberOfInstances, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_NUM_INST_DS );
+ break;
+
+ case ABP_OA_HIGHEST_INST:
+
+ /*
+ ** The 'Highest Instance Number' attribute is requested.
+ ** Copy the attribute to a response message.
+ */
+ ABCC_SetMsgData16( psNewMessage, sync_sObject.iHighestInstanceNo, 0 );
+ ABP_SetMsgResponse( psNewMessage, ABP_OA_HIGHEST_INST_DS );
+ break;
+
+ default:
+
+ /*
+ ** Unsupported attribute.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_INV_CMD_EXT_0 );
+ break;
+ }
+ break;
+ }
+ default:
+
+ /*
+ ** Unsupported command.
+ */
+ ABP_SetMsgErrorResponse( psNewMessage, 1, ABP_ERR_UNSUP_CMD );
+ break;
+
+ } /* End of switch( Command number ) */
+}
+
+/*------------------------------------------------------------------------------
+** Validates the timing parameters set by the Anybus module and sets the
+** correct value to the Application status register.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void UpdateAppStatus( void )
+{
+ if( (SYNC_SyncModeType)sync_sInstance.iSyncMode == SYNC_MODE_NONSYNCHRONOUS )
+ {
+ ABCC_SetAppStatus( ABP_APPSTAT_NO_ERROR );
+ }
+ else if( ( sync_sInstance.lCycleTime < sync_sInstance.lOutputValidTime ) ||
+ ( sync_sInstance.lCycleTime < ( sync_sInstance.lInputCaptureTime +
+ sync_sInstance.lInputProcessingTime) ) )
+ {
+ ABCC_SetAppStatus( ABP_APPSTAT_SYNC_CFG_ERR );
+ }
+ else
+ {
+ ABCC_SetAppStatus( ABP_APPSTAT_NOT_SYNCED );
+ }
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+UINT32 SYNC_GetCycleTime( void )
+{
+ UINT32 lCycleTimeNs;
+
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ lCycleTimeNs = sync_sInstance.lCycleTime;
+ }
+ ABCC_PORT_ExitCritical();
+
+ return( lCycleTimeNs );
+}
+
+UINT32 SYNC_GetInputCaptureTime( void )
+{
+ UINT32 lInputCaptureTimeNs;
+
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ lInputCaptureTimeNs = sync_sInstance.lInputCaptureTime;
+ }
+ ABCC_PORT_ExitCritical();
+
+ return( lInputCaptureTimeNs );
+}
+
+SYNC_SyncModeType SYNC_GetMode( void )
+{
+ return( (SYNC_SyncModeType)sync_sInstance.iSyncMode );
+}
+
+UINT32 SYNC_GetOutputValidTime( void )
+{
+ UINT32 lOutputValidTimeNs;
+
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ lOutputValidTimeNs = sync_sInstance.lOutputValidTime;
+ }
+ ABCC_PORT_ExitCritical();
+
+ return( lOutputValidTimeNs );
+}
+
+void SYNC_ProcessCmdMsg( ABP_MsgType* psNewMessage )
+{
+ if( ABCC_GetMsgInstance( psNewMessage ) == ABP_INST_OBJ )
+ {
+ /*
+ ** Process the Sync object command
+ */
+ ObjectCommand( psNewMessage );
+ }
+ else
+ {
+ /*
+ ** Process the Sync instance command
+ */
+ InstanceCommand( psNewMessage );
+ }
+
+ ABCC_SendRespMsg( psNewMessage );
+}
+
+void SYNC_SetInputProcessingTime( UINT32 lInputProcTimeNs )
+{
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ sync_sInstance.lInputProcessingTime = lInputProcTimeNs;
+ }
+ ABCC_PORT_ExitCritical();
+}
+
+void SYNC_SetMinCycleTime( UINT32 lMinCycleTimeNs )
+{
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ sync_sInstance.lMinCycleTime = lMinCycleTimeNs;
+ }
+ ABCC_PORT_ExitCritical();
+}
+
+void SYNC_SetOutputProcessingTime( UINT32 lOutputProcTimeNs )
+{
+ ABCC_PORT_UseCritical();
+
+ ABCC_PORT_EnterCritical();
+ {
+ sync_sInstance.lOutputProcessingTime = lOutputProcTimeNs;
+ }
+ ABCC_PORT_ExitCritical();
+}
+
+#endif /* SYNC_OBJ_ENABLE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/abcc_obj/sync_obj.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,173 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Sync Object 0xEE - Public interfaces
+********************************************************************************
+********************************************************************************
+** Services:
+** SYNC_GetCycleTime() - Returns the set cycle time
+** SYNC_GetInputCaptureTime() - Returns the set input capture time
+** SYNC_GetMode() - Returns the set sync mode
+** SYNC_GetOutputValidTime() - Returns the set output valid time
+** SYNC_ProcessCmdMsg() - Processes a message addressed to this
+** object
+** SYNC_SetInputProcessingTime() - Set the input processing time
+** SYNC_SetMinCycleTime() - Set the minimum allowed cycle time
+** SYNC_SetOutputProcessingTime() - Set the output processing time
+********************************************************************************
+********************************************************************************
+*/
+#ifndef SYNC_OBJ_H
+#define SYNC_OBJ_H
+
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc_ad_if.h"
+
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structure describing the sync modes of attribute 7, 'Sync mode'.
+**------------------------------------------------------------------------------
+*/
+typedef enum SYNC_SyncMode
+{
+ SYNC_MODE_NONSYNCHRONOUS = 0,
+ SYNC_MODE_SYNCHRONOUS = 1
+}
+SYNC_SyncModeType;
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Get the currently configured cycle time
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Cycle time in nanoseconds
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT32 SYNC_GetCycleTime( void );
+
+/*------------------------------------------------------------------------------
+** Get the currently configured input capture time
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Input capture time in nanoseconds
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT32 SYNC_GetInputCaptureTime( void );
+
+/*------------------------------------------------------------------------------
+** Get the currently configured sync mode
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Sync mode of type SYNC_SyncModeType.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC SYNC_SyncModeType SYNC_GetMode( void );
+
+/*------------------------------------------------------------------------------
+** Get the currently configured output valid time
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** Output valid time in nanoseconds
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT32 SYNC_GetOutputValidTime( void );
+
+/*------------------------------------------------------------------------------
+** Process an object request against the SYNC Object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsgBuffer - Pointer to ABCC command message.
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void SYNC_ProcessCmdMsg( ABP_MsgType* psNewMessage );
+
+/*------------------------------------------------------------------------------
+** Updates the input processing time reported to the ABCC upon request.
+** This value may be changed in runtime to reflect the timing required for the
+** current process data map.
+**------------------------------------------------------------------------------
+** Arguments:
+** lInputProcTimeNs - Input processing time in nanoseconds
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void SYNC_SetInputProcessingTime( UINT32 lInputProcTimeNs );
+
+/*------------------------------------------------------------------------------
+** Updates the minimum cycle time reported to the ABCC upon request.
+** This value may be changed in runtime to reflect the timing required for the
+** current process data map.
+**------------------------------------------------------------------------------
+** Arguments:
+** lMinCycleTimeNs - Minimum cycle time in nanoseconds
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void SYNC_SetMinCycleTime( UINT32 lMinCycleTimeNs );
+
+/*------------------------------------------------------------------------------
+** Updates the output processing time reported to the ABCC upon request.
+** This value may change in runtime to reflect the timing required for the
+** current process data map.
+**------------------------------------------------------------------------------
+** Arguments:
+** lOutputProcTimeNs - Output processing time in nanoseconds
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void SYNC_SetOutputProcessingTime( UINT32 lOutputProcTimeNs );
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_abcc_handler.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,1180 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** This is an example implementation of the application abcc handler.
+** It includes the following section:
+** 1. ADI definition and default mappings
+** 2. ABCC driver callback implementations (process data, default mapping ...)
+** 3. State machine implementation for message sequencing, e.g. during user init
+** or reading exception state
+** 4. ABCC handler main function to be called from the main loop, including a main
+** state machine for handling startup and restart of the ABCC.
+********************************************************************************
+********************************************************************************
+*/
+
+#include <stdio.h>
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc.h"
+#include "ad_obj.h"
+#include "abcc_port.h"
+
+#include "ad_obj.h" /* Application data object: 254 */
+#include "app_obj.h" /* Application object: 255 */
+#include "appl_abcc_handler.h"
+#include "abcc_port.h"
+#include "etn_obj.h"
+#include "sync_obj.h"
+
+#include "eip.h"
+#include "prt.h"
+#include "epl.h"
+#include "dpv1.h"
+#include "ect.h"
+#include "dev.h"
+#include "mod.h"
+#include "cop.h"
+
+#include "abcc_obj_cfg.h"
+#include "appl_adi_config.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Maximum start up time when the module is upgrading its firmware
+**------------------------------------------------------------------------------
+*/
+#define APPL_FW_UPGRADE_STARTUP_TIME_MS ( 2 * 60 * (UINT32)1000 )
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ABCC Handler states
+**------------------------------------------------------------------------------
+*/
+typedef enum appl_AbccHandlerState
+{
+ APPL_INIT,
+ APPL_WAITCOM,
+ APPL_RUN,
+ APPL_SHUTDOWN,
+ APPL_ABCCRESET,
+ APPL_DEVRESET,
+ APPL_HALT
+}
+appl_AbccHandlerStateType;
+
+/*------------------------------------------------------------------------------
+** States of the User initialization state machine
+**------------------------------------------------------------------------------
+*/
+typedef enum APPL_AbccUserInitState
+{
+ APPL_ABCC_USER_INIT_IDLE,
+ APPL_ABCC_USER_INIT_NODE_ID,
+ APPL_ABCC_USER_INIT_IP_ADDR,
+ APPL_ABCC_USER_INIT_BAUD_RATE,
+ APPL_ABCC_USER_INIT_COMPLETE,
+ APPL_ABCC_USER_INIT_DONE
+}
+appl_AbccUserInitStateType;
+
+/*------------------------------------------------------------------------------
+** States of the Exception state machine
+**------------------------------------------------------------------------------
+*/
+typedef enum appl_ReadExceptionState
+{
+ APPL_NO_EXCEPTION = 0,
+ APPL_READ_EXCEPTION,
+ APPL_READ_EXCEPTION_INFO,
+ APPL_READ_EXCEPTION_DONE
+}
+appl_ReadExceptionStateType;
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Current state of the ABCC
+**------------------------------------------------------------------------------
+*/
+static appl_AbccHandlerStateType appl_eAbccHandlerState = APPL_INIT;
+
+/*------------------------------------------------------------------------------
+** Current anybus state
+**------------------------------------------------------------------------------
+*/
+static volatile ABP_AnbStateType appl_eAnbState = ABP_ANB_STATE_SETUP;
+
+/*------------------------------------------------------------------------------
+** Network Node address.
+**------------------------------------------------------------------------------
+*/
+static UINT8 appl_bNwNodeAddress;
+static UINT8 appl_bLastSetNwNodeAddress;
+
+/*------------------------------------------------------------------------------
+** Network IP address.
+**------------------------------------------------------------------------------
+*/
+static UINT8 appl_abNwIpAddress[ 4 ] = { 192, 168, 0, 0 };
+static UINT8 appl_bLastSetNwIpAddress;
+
+/*------------------------------------------------------------------------------
+** Common address variables (used for both node address and IP address depending
+** on network type).
+**------------------------------------------------------------------------------
+*/
+static BOOL appl_fSetAddr = FALSE;
+
+/*------------------------------------------------------------------------------
+** Network baud rate.
+**------------------------------------------------------------------------------
+*/
+static UINT8 appl_bNwBaudRate;
+static UINT8 appl_bLastSetNwBaudRate;
+static BOOL appl_fSetBaudRate = FALSE;
+
+/*------------------------------------------------------------------------------
+** Flags to keep track of if the network type supports node ID/IP address
+** and/or baud rate to be set.
+**------------------------------------------------------------------------------
+*/
+static BOOL appl_fNwSupportsNodeId;
+static BOOL appl_fNwSupportsBaudRate;
+
+/*------------------------------------------------------------------------------
+** ABCC User init state machine globals
+**------------------------------------------------------------------------------
+*/
+static BOOL appl_fUserInitWaitForResp = FALSE;
+static appl_AbccUserInitStateType appl_eUserInitState = APPL_ABCC_USER_INIT_IDLE;
+
+/*------------------------------------------------------------------------------
+** ABCC Exception state machine globals
+**------------------------------------------------------------------------------
+*/
+static BOOL appl_fExceptionWaitForResp = FALSE;
+static volatile appl_ReadExceptionStateType appl_eReadExceptionState = APPL_NO_EXCEPTION;
+
+/*------------------------------------------------------------------------------
+** Set to TRUE when an unexpected error occur. The main state machine will
+** return APPL_MODULE_UNEXPECTED_ERROR when this flag is set.
+**------------------------------------------------------------------------------
+*/
+static BOOL appl_fUnexpectedError = FALSE;
+
+/*------------------------------------------------------------------------------
+** Event flags used by application to invoke the corresponding
+** ABCC_Trigger<event_action> function from the desired context. The flag will
+** be set to TRUE in ABCC_CbfEvent().
+**------------------------------------------------------------------------------
+*/
+static volatile BOOL appl_fMsgReceivedEvent = FALSE;
+static volatile BOOL appl_fRdPdReceivedEvent = FALSE;
+static volatile BOOL appl_fTransmitMsgEvent = FALSE;
+static volatile BOOL appl_fAbccStatusEvent = FALSE;
+
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void ReadException( void );
+static void HandleExceptionResp( ABP_MsgType* psMsg );
+static void HandleExceptionInfoResp( ABP_MsgType* psMsg );
+static void HandleUserInitResp( ABP_MsgType* psMsg );
+static void HandleResp( ABP_MsgType* psMsg );
+static BOOL SetSw1Sw2NcInstance( UINT16 iInstance,
+ UINT8 bValue,
+ ABCC_MsgHandlerFuncType pnMsgHandler );
+static BOOL SetIpAddressNcInstance( ABCC_MsgHandlerFuncType pnMsgHandler );
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This is the trigger call for reading exception information from the ABCC.
+** It is triggered when ABP_ANB_STATE_EXCEPTION is entered in
+** ABCC_CbfAnbStatusChanged().
+** Both Exception and Exception info attribute is read from the Anybus object.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void ReadException( void )
+{
+ appl_eReadExceptionState = APPL_READ_EXCEPTION;
+}
+
+/*------------------------------------------------------------------------------
+** State machine used to execute the reading of exception cause
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void RunExceptionSM( void )
+{
+ ABP_MsgType* psMsg;
+
+ if( !appl_fExceptionWaitForResp )
+ {
+ switch( appl_eReadExceptionState )
+ {
+ case APPL_NO_EXCEPTION:
+ case APPL_READ_EXCEPTION_DONE:
+
+ break;
+
+ case APPL_READ_EXCEPTION:
+
+ psMsg = ABCC_GetCmdMsgBuffer();
+
+ if( psMsg != NULL )
+ {
+ appl_fExceptionWaitForResp = TRUE;
+ ABCC_GetAttribute( psMsg, ABP_OBJ_NUM_ANB, 1, ABP_ANB_IA_EXCEPTION, ABCC_GetNewSourceId() );
+ if( ABCC_SendCmdMsg( psMsg, HandleExceptionResp ) != ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+ appl_fExceptionWaitForResp = FALSE;
+
+ return;
+ }
+ }
+
+ break;
+
+ case APPL_READ_EXCEPTION_INFO:
+
+ psMsg = ABCC_GetCmdMsgBuffer();
+
+ if( psMsg != NULL )
+ {
+ appl_fExceptionWaitForResp = TRUE;
+ ABCC_GetAttribute( psMsg, ABP_OBJ_NUM_NW, 1, ABP_NW_IA_EXCEPTION_INFO, ABCC_GetNewSourceId() );
+ if( ABCC_SendCmdMsg( psMsg, HandleExceptionInfoResp ) != ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+ appl_fExceptionWaitForResp = FALSE;
+
+ return;
+ }
+ }
+
+ break;
+
+ default:
+
+ break;
+ }
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Response handler to the command reading the Exception attribute of the
+** Anybus object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to the received response message
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void HandleExceptionResp( ABP_MsgType* psMsg )
+{
+ UINT8 bException;
+
+ if( ABCC_VerifyMessage( psMsg ) != ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+ return;
+ }
+
+ ABCC_GetMsgData8( psMsg, &bException, 0 );
+ ABCC_PORT_DebugPrint( ( "Exception Code: %X:\n\n", bException ) );
+
+ appl_eReadExceptionState++;
+ appl_fExceptionWaitForResp = FALSE;
+
+ (void)bException;
+}
+
+/*------------------------------------------------------------------------------
+** Response handler to the command reading the Exception info attribute of the
+** Anybus object.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to the received response message
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void HandleExceptionInfoResp( ABP_MsgType* psMsg )
+{
+ UINT8 bExceptionInfo;
+
+ if( ABCC_VerifyMessage( psMsg ) != ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+ return;
+ }
+
+ ABCC_GetMsgData8( psMsg, &bExceptionInfo, 0 );
+ ABCC_PORT_DebugPrint( ( "Exception Info: %X:\n\n", bExceptionInfo ) );
+
+ appl_eReadExceptionState++;
+ appl_fExceptionWaitForResp = FALSE;
+
+ (void)bExceptionInfo;
+}
+
+/*------------------------------------------------------------------------------
+** State machine used to execute the user initialization during the Anybus
+** Setup state.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void RunUserInitSM( void )
+{
+ if( !appl_fUserInitWaitForResp )
+ {
+ switch( appl_eUserInitState )
+ {
+ case APPL_ABCC_USER_INIT_IDLE:
+ case APPL_ABCC_USER_INIT_DONE:
+
+ break;
+
+ case APPL_ABCC_USER_INIT_NODE_ID:
+
+ if( appl_fNwSupportsNodeId &&
+ appl_fSetAddr )
+ {
+ appl_fUserInitWaitForResp = TRUE;
+
+ if( SetSw1Sw2NcInstance( ABP_NC_INST_NUM_SW1,
+ appl_bNwNodeAddress,
+ HandleUserInitResp ) )
+ {
+ appl_bLastSetNwNodeAddress = appl_bNwNodeAddress;
+ }
+ else
+ {
+ appl_fUserInitWaitForResp = FALSE;
+ }
+ }
+ else
+ {
+ appl_eUserInitState++;
+ }
+
+ break;
+
+ case APPL_ABCC_USER_INIT_IP_ADDR:
+
+ if( ( !appl_fNwSupportsNodeId ) &&
+ ( appl_fSetAddr ) &&
+ ( appl_abNwIpAddress[ 3 ] != 0 ) )
+ {
+ appl_fUserInitWaitForResp = TRUE;
+
+ if( SetIpAddressNcInstance( HandleUserInitResp ) )
+ {
+ appl_bLastSetNwIpAddress = appl_abNwIpAddress[ 3 ];
+ }
+ else
+ {
+ appl_fUserInitWaitForResp = FALSE;
+ }
+ }
+ else
+ {
+ appl_eUserInitState++;
+ }
+
+ break;
+
+ case APPL_ABCC_USER_INIT_BAUD_RATE:
+
+ if( appl_fNwSupportsBaudRate &&
+ appl_fSetBaudRate )
+ {
+ appl_fUserInitWaitForResp = TRUE;
+
+ if( SetSw1Sw2NcInstance( ABP_NC_INST_NUM_SW2,
+ appl_bNwBaudRate,
+ HandleUserInitResp ) )
+ {
+ appl_bLastSetNwBaudRate = appl_bNwBaudRate;
+ }
+ else
+ {
+ appl_fUserInitWaitForResp = FALSE;
+ }
+ }
+ else
+ {
+ appl_eUserInitState++;
+ }
+
+ break;
+
+ case APPL_ABCC_USER_INIT_COMPLETE:
+
+ ABCC_UserInitComplete();
+ appl_eUserInitState++;
+
+ break;
+
+ default:
+
+ break;
+ }
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Use this function to set a value to NC instance 1 (Switch 1) or 2 (Switch 2).
+**------------------------------------------------------------------------------
+** Arguments:
+** iInstance - NC instance to set (ABP_NC_INST_NUM_SW1 or
+** ABP_NC_INST_NUM_SW2).
+** bValue - Value to be set.
+** pnMsgHandler - Pointer to the function to handle the response message.
+**
+** Returns:
+** TRUE - Set command was successfully sent.
+** FALSE - Failed to send command.
+**------------------------------------------------------------------------------
+*/
+static BOOL SetSw1Sw2NcInstance( UINT16 iInstance,
+ UINT8 bValue,
+ ABCC_MsgHandlerFuncType pnMsgHandler )
+{
+ ABP_MsgType* psMsg;
+
+ psMsg = ABCC_GetCmdMsgBuffer();
+
+ if( psMsg != NULL )
+ {
+ appl_fUserInitWaitForResp = TRUE;
+ ABCC_SetByteAttribute( psMsg, ABP_OBJ_NUM_NC,
+ iInstance,
+ ABP_NC_VAR_IA_VALUE,
+ bValue,
+ ABCC_GetNewSourceId() );
+
+ if( ABCC_SendCmdMsg( psMsg, pnMsgHandler ) !=
+ ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+
+ return( FALSE );
+ }
+ }
+ else
+ {
+ return( FALSE );
+ }
+
+ return( TRUE );
+}
+
+/*------------------------------------------------------------------------------
+** Use this function to set the value stored in appl_abNwIpAddress to the IP
+** address NC instance (instance 3).
+**------------------------------------------------------------------------------
+** Arguments:
+** pnMsgHandler - Pointer to the function to handle the response message.
+**
+** Returns:
+** TRUE - Set command was successfully sent.
+** FALSE - Failed to send command.
+**------------------------------------------------------------------------------
+*/
+static BOOL SetIpAddressNcInstance( ABCC_MsgHandlerFuncType pnMsgHandler )
+{
+ ABP_MsgType* psMsg;
+
+ psMsg = ABCC_GetCmdMsgBuffer();
+
+ if( psMsg != NULL )
+ {
+ ABCC_SetMsgHeader( psMsg,
+ ABP_OBJ_NUM_NC,
+ 3,
+ ABP_NC_VAR_IA_VALUE,
+ ABP_CMD_SET_ATTR,
+ 4,
+ ABCC_GetNewSourceId() );
+
+ ABCC_SetMsgString( psMsg, (char*)&appl_abNwIpAddress[ 0 ], 4, 0 );
+
+ if( ABCC_SendCmdMsg( psMsg, pnMsgHandler ) !=
+ ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+
+ return( FALSE );
+ }
+ }
+ else
+ {
+ return( FALSE );
+ }
+
+ return( TRUE );
+}
+
+/*------------------------------------------------------------------------------
+** Checks if the IP address/node address and/or baud rate has changes
+** and sets the updated values to the corresponding network configuration
+** instances if it has.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void UpdateSwitchValues( void )
+{
+ /*
+ ** Check if the IP address/node address has been changed and take appropriate
+ ** action depending on network type.
+ */
+ if( ( appl_bLastSetNwIpAddress != appl_abNwIpAddress[ 3 ] ) &&
+ ( appl_abNwIpAddress[ 3 ] != 0 ) &&
+ ( !appl_fNwSupportsNodeId ) &&
+ ( appl_fSetAddr ) )
+ {
+ if( SetIpAddressNcInstance( HandleResp ) )
+ {
+ appl_bLastSetNwIpAddress = appl_abNwIpAddress[ 3 ];
+ }
+ }
+ else if( ( appl_bLastSetNwNodeAddress != appl_bNwNodeAddress ) &&
+ ( appl_fNwSupportsNodeId ) &&
+ ( appl_fSetAddr ) )
+ {
+ if( SetSw1Sw2NcInstance( ABP_NC_INST_NUM_SW1,
+ appl_bNwNodeAddress,
+ HandleResp ) )
+ {
+ appl_bLastSetNwNodeAddress = appl_bNwNodeAddress;
+ }
+ }
+
+ /*
+ ** Check if baud rate has changed and if a baud rate can be set for the
+ ** current network type.
+ */
+ if( ( appl_bLastSetNwBaudRate != appl_bNwBaudRate ) &&
+ ( appl_fNwSupportsBaudRate ) &&
+ ( appl_fSetBaudRate ) )
+ {
+ if( SetSw1Sw2NcInstance( ABP_NC_INST_NUM_SW2,
+ appl_bNwBaudRate,
+ HandleResp ) )
+ {
+ appl_bLastSetNwBaudRate = appl_bNwBaudRate;
+ }
+ }
+}
+
+/*------------------------------------------------------------------------------
+** Response handler to the commands sent by the User initialization state
+** machine.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to the received response message
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void HandleUserInitResp( ABP_MsgType* psMsg )
+{
+ if( ABCC_VerifyMessage( psMsg ) != ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+ return;
+ }
+
+ appl_fUserInitWaitForResp = FALSE;
+ appl_eUserInitState++;
+}
+
+/*------------------------------------------------------------------------------
+** Generic response handler, log error if an error was returned by the ABCC.
+**------------------------------------------------------------------------------
+** Arguments:
+** psMsg - Pointer to the received response message
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void HandleResp( ABP_MsgType* psMsg )
+{
+ if( ABCC_VerifyMessage( psMsg ) != ABCC_EC_NO_ERROR )
+ {
+ APPL_UnexpectedError();
+ return;
+ }
+}
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+APPL_AbccHandlerStatusType APPL_HandleAbcc( void )
+{
+ static APPL_AbccHandlerStatusType eModuleStatus = APPL_MODULE_NO_ERROR;
+ UINT32 lStartupTimeMs;
+ ABCC_CommunicationStateType eAbccComState;
+
+ switch( appl_eAbccHandlerState )
+ {
+ case APPL_INIT:
+
+ eModuleStatus = APPL_MODULE_NO_ERROR;
+ appl_eUserInitState = APPL_ABCC_USER_INIT_IDLE;
+ appl_fUserInitWaitForResp = FALSE;
+ appl_eReadExceptionState = APPL_NO_EXCEPTION;
+ appl_fExceptionWaitForResp = FALSE;
+ appl_fMsgReceivedEvent = FALSE;
+ appl_fRdPdReceivedEvent = FALSE;
+ appl_fTransmitMsgEvent = FALSE;
+ appl_fAbccStatusEvent = FALSE;
+
+ if( !ABCC_ModuleDetect() )
+ {
+ eModuleStatus = APPL_MODULE_NOT_DETECTED;
+ }
+
+ if( eModuleStatus == APPL_MODULE_NO_ERROR )
+ {
+ /*
+ ** Init application data object
+ */
+ if( AD_Init( APPL_asAdiEntryList,
+ APPL_GetNumAdi(),
+ APPL_asAdObjDefaultMap ) != AD_NO_ERROR )
+ {
+ eModuleStatus = APPL_MODULE_UNEXPECTED_ERROR ;
+ }
+
+#if APP_OBJ_ENABLE
+ if( APP_GetCandidateFwAvailable() == TRUE )
+ {
+ lStartupTimeMs = APPL_FW_UPGRADE_STARTUP_TIME_MS;
+ }
+ else
+#endif
+ {
+ /*
+ ** Default time will be used
+ */
+ lStartupTimeMs = 0;
+ }
+
+ if( ABCC_StartDriver( lStartupTimeMs ) == ABCC_EC_NO_ERROR )
+ {
+ ABCC_HWReleaseReset();
+ appl_eAbccHandlerState = APPL_WAITCOM;
+ }
+ else
+ {
+ eModuleStatus = APPL_MODULE_NOT_ANSWERING;
+ }
+ }
+
+ if( eModuleStatus != APPL_MODULE_NO_ERROR )
+ {
+ appl_eAbccHandlerState = APPL_HALT;
+ }
+
+ break;
+
+ case APPL_WAITCOM:
+
+ eAbccComState = ABCC_isReadyForCommunication();
+
+ if( eAbccComState == ABCC_READY_FOR_COMMUNICATION )
+ {
+ appl_eAbccHandlerState = APPL_RUN;
+ }
+ else if( eAbccComState == ABCC_COMMUNICATION_ERROR )
+ {
+ appl_eAbccHandlerState = APPL_HALT;
+ eModuleStatus = APPL_MODULE_NOT_ANSWERING;
+ }
+ break;
+
+ case APPL_RUN:
+ /*------------------------------------------------------------------------
+ ** Handle events indicated in ABCC_CbfEvent()callback function.
+ ** Note that these events could be handled from any chosen context but in
+ ** in this application it is done from main loop context.
+ **------------------------------------------------------------------------
+ */
+ if( appl_fRdPdReceivedEvent )
+ {
+ appl_fRdPdReceivedEvent = FALSE;
+ ABCC_TriggerRdPdUpdate();
+ }
+
+ if( appl_fMsgReceivedEvent )
+ {
+ appl_fMsgReceivedEvent = FALSE;
+ ABCC_TriggerReceiveMessage();
+ }
+
+ if( appl_fTransmitMsgEvent )
+ {
+ appl_fTransmitMsgEvent = FALSE;
+ ABCC_TriggerTransmitMessage();
+ }
+
+ if( appl_fAbccStatusEvent )
+ {
+ appl_fAbccStatusEvent = FALSE;
+ ABCC_TriggerAnbStatusUpdate();
+ }
+ /*
+ ** End event handling.
+ */
+
+#if SYNC_OBJ_ENABLE
+ if( SYNC_GetMode() == SYNC_MODE_NONSYNCHRONOUS )
+ {
+ ABCC_TriggerWrPdUpdate();
+ }
+#else
+ /*
+ ** Always update write process data
+ */
+ ABCC_TriggerWrPdUpdate();
+#endif
+
+ ABCC_RunDriver();
+
+ if( appl_eAnbState == ABP_ANB_STATE_SETUP )
+ {
+ RunUserInitSM();
+ }
+ else if( appl_eAnbState == ABP_ANB_STATE_EXCEPTION )
+ {
+ RunExceptionSM();
+ }
+ else
+ {
+ UpdateSwitchValues();
+ }
+
+ break;
+
+ case APPL_SHUTDOWN:
+
+ ABCC_HWReset();
+ eModuleStatus = APPL_MODULE_SHUTDOWN;
+ appl_eAbccHandlerState = APPL_HALT;
+
+ break;
+
+ case APPL_ABCCRESET:
+
+ ABCC_HWReset();
+ appl_eAbccHandlerState = APPL_INIT;
+ eModuleStatus = APPL_MODULE_NO_ERROR;
+ break;
+
+ case APPL_DEVRESET:
+
+ ABCC_HWReset();
+ eModuleStatus = APPL_MODULE_RESET;
+ appl_eAbccHandlerState = APPL_HALT;
+
+ break;
+
+ case APPL_HALT:
+
+ break;
+
+ default:
+
+ break;
+ }
+
+ if( appl_fUnexpectedError )
+ {
+ return( APPL_MODULE_UNEXPECTED_ERROR );
+ }
+
+ return( eModuleStatus );
+}
+
+void APPL_SetAddress( UINT8 bSwitchValue )
+{
+ /*
+ ** HW switch 1 will the last octet in the IP address
+ ** for applicable networks ( 192.168.0.X )
+ */
+ appl_abNwIpAddress[ 3 ] = bSwitchValue;
+ appl_fSetAddr = TRUE;
+
+ /*
+ ** Switch 1 is node address for applicable networks
+ */
+ appl_bNwNodeAddress = bSwitchValue;
+
+ /*
+ ** Indicate to application object that the address is set by HW switches
+ */
+#if APP_OBJ_ENABLE
+ APP_HwConfAddress( TRUE );
+#endif
+}
+
+void APPL_SetBaudrate( UINT8 bSwitchValue )
+{
+ appl_bNwBaudRate = bSwitchValue;
+
+ appl_fSetBaudRate = TRUE;
+}
+
+void APPL_UnexpectedError( void )
+{
+ appl_fUnexpectedError = TRUE;
+}
+
+void APPL_RestartAbcc( void )
+{
+ appl_eAbccHandlerState = APPL_ABCCRESET;
+}
+
+void APPL_Shutdown( void )
+{
+ appl_eAbccHandlerState = APPL_SHUTDOWN;
+}
+
+
+void APPL_Reset( void )
+{
+ appl_eAbccHandlerState = APPL_DEVRESET;
+}
+
+UINT16 ABCC_CbfAdiMappingReq( const AD_AdiEntryType** const ppsAdiEntry,
+ const AD_DefaultMapType** const ppsDefaultMap )
+{
+ return AD_AdiMappingReq( ppsAdiEntry, ppsDefaultMap );
+}
+
+BOOL ABCC_CbfUpdateWriteProcessData( void* pxWritePd )
+{
+
+ /*
+ ** AD_UpdatePdWriteData is a general function that updates all ADI:s according
+ ** to current map.
+ ** If the ADI mapping is fixed there is potential for doing that in a more
+ ** optimized way, for example by using memcpy.
+ */
+ return( AD_UpdatePdWriteData( pxWritePd ) );
+}
+
+#if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
+void ABCC_CbfRemapDone( void )
+{
+ AD_RemapDone();
+}
+#endif
+
+void ABCC_CbfNewReadPd( void* pxReadPd )
+{
+ /*
+ ** AD_UpdatePdReadData is a general function that updates all ADI:s according
+ ** to current map.
+ ** If the ADI mapping is fixed there is potential for doing that in a more
+ ** optimized way, for example by using memcpy.
+ */
+ AD_UpdatePdReadData( pxReadPd );
+}
+
+void ABCC_CbfDriverError( ABCC_SeverityType eSeverity, ABCC_ErrorCodeType iErrorCode, UINT32 lAddInfo )
+{
+ (void)eSeverity;
+ (void)iErrorCode;
+ (void)lAddInfo;
+ ABCC_PORT_DebugPrint( ( "ERROR: Severity:%d Error code:%d, AddInfo:%d\n",
+ eSeverity, iErrorCode, lAddInfo ) );
+}
+
+void ABCC_CbfReceiveMsg( ABP_MsgType* psReceivedMsg )
+{
+ switch( ABCC_GetMsgDestObj( psReceivedMsg ) )
+ {
+#if EPL_OBJ_ENABLE
+ case ABP_OBJ_NUM_EPL:
+
+ EPL_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if EIP_OBJ_ENABLE
+ case ABP_OBJ_NUM_EIP:
+
+ EIP_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if PRT_OBJ_ENABLE
+ case ABP_OBJ_NUM_PNIO:
+
+ PRT_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if DPV1_OBJ_ENABLE
+ case ABP_OBJ_NUM_DPV1:
+
+ DPV1_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if DEV_OBJ_ENABLE
+ case ABP_OBJ_NUM_DEV:
+
+ DEV_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if MOD_OBJ_ENABLE
+ case ABP_OBJ_NUM_MOD:
+
+ MOD_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if COP_OBJ_ENABLE
+ case ABP_OBJ_NUM_COP:
+
+ COP_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if ETN_OBJ_ENABLE
+ case ABP_OBJ_NUM_ETN:
+
+ ETN_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if ECT_OBJ_ENABLE
+ case ABP_OBJ_NUM_ECT:
+
+ ECT_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+ case ABP_OBJ_NUM_APPD:
+
+ AD_ProcObjectRequest( psReceivedMsg );
+ break;
+
+#if APP_OBJ_ENABLE
+ case ABP_OBJ_NUM_APP:
+
+ APP_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+#if SYNC_OBJ_ENABLE
+ case ABP_OBJ_NUM_SYNC:
+
+ SYNC_ProcessCmdMsg( psReceivedMsg );
+ break;
+#endif
+
+ default:
+
+ /*
+ ** We have received a command to an unsupported object.
+ */
+ ABP_SetMsgErrorResponse( psReceivedMsg, 1, ABP_ERR_UNSUP_OBJ );
+ ABCC_SendRespMsg( psReceivedMsg );
+ break;
+ }
+}
+
+void ABCC_CbfWdTimeout( void )
+{
+ ABCC_PORT_DebugPrint( ( "ABCC watchdog timeout" ) );
+}
+
+void ABCC_CbfWdTimeoutRecovered( void )
+{
+ ABCC_PORT_DebugPrint( ( "ABCC watchdog recovered" ) );
+}
+
+#if ABCC_CFG_SYNC_ENABLE
+void ABCC_CbfSyncIsr( void )
+{
+ /*
+ ** Call application specific handling of sync event
+ */
+ APPL_SyncIsr();
+}
+#endif
+
+void ABCC_CbfEvent( UINT16 iEvents )
+{
+
+ /*
+ ** Set flag to indicate that an event has occurred and the corresponding
+ ** ABCC_Trigger<event_action> must be called. In the sample code the the
+ ** trigger function is called from main loop context.
+ */
+ if( iEvents & ABCC_ISR_EVENT_RDPD )
+ {
+ appl_fRdPdReceivedEvent = TRUE;
+ }
+
+ if( iEvents & ABCC_ISR_EVENT_RDMSG )
+ {
+ appl_fMsgReceivedEvent = TRUE;
+ }
+
+ if( iEvents & ABCC_ISR_EVENT_WRMSG )
+ {
+ appl_fTransmitMsgEvent = TRUE;
+ }
+
+ if( iEvents & ABCC_ISR_EVENT_STATUS )
+ {
+ appl_fAbccStatusEvent = TRUE;
+ }
+}
+
+void ABCC_CbfAnbStateChanged( ABP_AnbStateType eNewAnbState )
+{
+ static const char* AnbStateString[ 8 ] = { "ABP_ANB_STATE_SETUP",
+ "ABP_ANB_STATE_NW_INIT",
+ "ABP_ANB_STATE_WAIT_PROCESS",
+ "ABP_ANB_STATE_IDLE",
+ "ABP_ANB_STATE_PROCESS_ACTIVE",
+ "ABP_ANB_STATE_ERROR",
+ "",
+ "ABP_ANB_STATE_EXCEPTION" };
+ (void)AnbStateString[ 0 ];
+
+ appl_eAnbState = eNewAnbState;
+ ABCC_PORT_DebugPrint( ( "ANB_STATUS: %s \n" ,
+ AnbStateString[ appl_eAnbState ] ) );
+
+ switch( appl_eAnbState )
+ {
+ case ABP_ANB_STATE_PROCESS_ACTIVE:
+
+ ABCC_TriggerWrPdUpdate();
+ break;
+
+ case ABP_ANB_STATE_EXCEPTION:
+
+ /* Trigger message sequence for reading exception data */
+ ReadException();
+ break;
+
+ case ABP_ANB_STATE_ERROR:
+
+ /* Trigger message sequence for reading exception data */
+ break;
+
+ default:
+
+ break;
+ }
+}
+
+void ABCC_CbfUserInitReq( void )
+{
+ UINT16 iNetworkType;
+
+ iNetworkType = ABCC_NetworkType();
+
+ if( ( iNetworkType == ABP_NW_TYPE_DEV ) ||
+ ( iNetworkType == ABP_NW_TYPE_PDPV0 ) ||
+ ( iNetworkType == ABP_NW_TYPE_PDPV1 ) ||
+ ( iNetworkType == ABP_NW_TYPE_COP ) ||
+ ( iNetworkType == ABP_NW_TYPE_CNT ) ||
+ ( iNetworkType == ABP_NW_TYPE_CCL ) ||
+ ( iNetworkType == ABP_NW_TYPE_CPN ) ||
+ ( iNetworkType == ABP_NW_TYPE_ECT ) ||
+ ( iNetworkType == ABP_NW_TYPE_EPL ) )
+ {
+ appl_fNwSupportsNodeId = TRUE;
+ }
+ else
+ {
+ appl_fNwSupportsNodeId = FALSE;
+ }
+
+ if( ( iNetworkType == ABP_NW_TYPE_DEV ) ||
+ ( iNetworkType == ABP_NW_TYPE_COP ) ||
+ ( iNetworkType == ABP_NW_TYPE_CCL ) )
+ {
+ appl_fNwSupportsBaudRate = TRUE;
+ }
+ else
+ {
+ appl_fNwSupportsBaudRate = FALSE;
+ }
+
+ appl_eUserInitState++;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_abcc_handler.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,201 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** This is an example implementation of an application handler to control the
+** ABCC module. It has support to initialize, run and reset/shutdown the ABCC.
+** The state machine shall be executed cyclically and it returns its current
+** status after every execution.
+********************************************************************************
+********************************************************************************
+** Services:
+** APPL_HandleAbcc() - Runs the state machine controlling the
+** ABCC module
+** APPL_RestartAbcc() - Forces the state machine to restart the
+** ABCC module
+** APPL_Shutdown() - Forces the state machine to shut down the
+** ABCC module
+** APPL_Reset() - Forces the state machine to reset the
+** ABCC module
+** APPL_RestoreToDefault() - Restores any NVS parameter to its default
+** value
+** APPL_GetCandidateFwAvailable() - Call to check if there is a firmware in
+** the candidate area
+** APPL_SetCandidateFwAvailable() - Sets whether firmware is available in the
+** candidate area
+** APPL_IsResetRequestAllowed() - Check if a reset is allowed
+**
+** APPL_SetHwSwitch1Value() - Set switch 1 value
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef APPL_ABCC_HANDLER_H
+#define APPL_ABCC_HANDLER_H
+#include "abcc_td.h"
+#include "string.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Status reported by the ABCC handler controlling the ABCC module
+**------------------------------------------------------------------------------
+*/
+typedef enum APPL_AbccHandlerStatus
+{
+ APPL_MODULE_NO_ERROR, /* Module OK */
+ APPL_MODULE_NOT_DETECTED, /* No module plugged */
+ APPL_MODULE_NOT_SUPPORTED, /* Unsupported module detected */
+ APPL_MODULE_NOT_ANSWERING, /* Possible reasons: Wrong API selected, defect module */
+ APPL_MODULE_RESET, /* Reset requested from ABCC */
+ APPL_MODULE_SHUTDOWN, /* Shutdown requested */
+ APPL_MODULE_UNEXPECTED_ERROR /* Unexpected error occurred */
+}
+APPL_AbccHandlerStatusType;
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** This function shall be called on cyclic bases from the main loop to handle
+** the ABCC. It includes a state machine for handling reset, run, and shutdown
+** of the driver.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** State of the ABCC handler
+**------------------------------------------------------------------------------
+*/
+EXTFUNC APPL_AbccHandlerStatusType APPL_HandleAbcc( void );
+
+/*------------------------------------------------------------------------------
+** This function will force the ABCC handler to restart the ABCC module
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void APPL_RestartAbcc( void );
+
+/*------------------------------------------------------------------------------
+** This function will force the ABCC handler to shutdown the ABCC module
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void APPL_Shutdown( void );
+
+/*------------------------------------------------------------------------------
+** This function will force the ABCC handler to reset the ABCC
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void APPL_Reset( void );
+
+/*------------------------------------------------------------------------------
+** Application has encountered an unexpected error.
+** The abcc main state machine will halt and indicate error.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void APPL_UnexpectedError( void );
+
+/*------------------------------------------------------------------------------
+** Called to check if the requested reset is permitted by the application.
+**------------------------------------------------------------------------------
+** Arguments:
+** bResetType - Type of reset, see ABP_RESET_XXX defines.
+**
+** Returns:
+** BOOL - TRUE: Reset request is allowed.
+** FALSE: Reset request NOT allowed.
+**------------------------------------------------------------------------------
+*/
+EXTFUNC BOOL IsResetRequestAllowed( UINT8 bResetType );
+
+/*------------------------------------------------------------------------------
+** Set HW switch1 value to the application. The value is used to generate the
+** the node address or the IP address (192.168.0.X) depending on network.
+**
+** NOTE: For networks that uses an IP address and if this function is called
+** with address 0 no address will be set to the ABCC.
+**------------------------------------------------------------------------------
+** Arguments:
+** bSwitchValue - Switch 1 value
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void APPL_SetAddress( UINT8 bSwitchValue );
+
+/*------------------------------------------------------------------------------
+** Set HW switch2 value to the application. The value is used to generate the
+** baud rate for networks that implements network configuration object instance
+** 2.
+**------------------------------------------------------------------------------
+** Arguments:
+** bSwitchValue - Switch 2 value
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+EXTFUNC void APPL_SetBaudrate( UINT8 bSwitchValue );
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_adi_config.h Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,250 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This program is the property of HMS Industrial Networks AB. **
+** It may not be reproduced, distributed, or used without permission **
+** of an authorized company official. **
+********************************************************************************
+********************************************************************************
+** Header file for the Application data instances setup and the default map
+********************************************************************************
+********************************************************************************
+** Services:
+********************************************************************************
+********************************************************************************
+*/
+
+#ifndef APPL_ADI_CONFIG_H_
+#define APPL_ADI_CONFIG_H_
+
+#include "abcc_td.h"
+#include "abp.h"
+#include "abcc_drv_cfg.h"
+#include "abcc_ad_if.h"
+#include "abcc_obj_cfg.h"
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** There are 5 examples of ADI mappings:
+**
+** #define APPL_ADI_SETUP_BOARD_SPECIFIC
+** #define APPL_ADI_SETUP_SIMPLE_16
+** #define APPL_ADI_SETUP_SEPARATE_16
+** #define APPL_ADI_SETUP_ALL_TYPES
+** #define APPL_ADI_SETUP_SYNC
+**
+** The active setup is chosen by:
+** #define APPL_ACTIVE_ADI_SETUP
+**
+** Example: #define APPL_ACTIVE_ADI_SETUP APPL_ADI_SETUP_SIMPLE_16
+**
+** Below is a description of each example:
+**
+** For a more detailed description of ADI:s and ADI mapping,
+** see abcc_drv/inc/abcc_ad_if.h.
+** ---------------------------------------------------------------------
+** APPL_ADI_SETUP_BOARD_SPECIFIC : Designed for the HW platform of this
+** SW project.
+** ---------------------------------------------------------------------
+** APPL_ADI_SETUP_SIMPLE_16:
+** Implemented in appl_adimap_simple16.c
+**
+** AD instance 1: An array of 32 ABP_UINT16 (64 octets mapped to write process data)
+** AD instance 2: An array of 32 ABP_UINT16 (64 octets mapped to read process data)
+** Data is looped since the ADI:s are refering to the same variable.
+** ---------------------------------------------------------------------
+** APPL_ADI_SETUP_SEPARATE_16 ( Get/Set ADI callback example )
+** Implemented in appl_adimap_separate16.c
+** AD instance 10: An array of 32 ABP_UINT16 (64 octets mapped to read process data)
+** AD instance 11: An array of 32 ABP_UINT16 (64 octets mapped to write process data)
+** AD instance 12: ABP_UINT16 (not mapped to process data)
+**
+** ADI 10 triggers a callback each time a new value is written from the network.
+** The callback copies the data to ADI 11 ( looped to write process data )
+**
+** ADI 11 triggers a callback each time the value is read by the network.
+** The callback also increments ADI 12.
+** ---------------------------------------------------------------------
+** APPL_ADI_SETUP_ALL_TYPES ( structured ADI:s and bit data types )
+**
+** Implemented in appl_adimap_alltypes.c
+**
+** AD instance 20: ABP_UINT32 ( Mapped to read process data )
+** AD instance 21: ABP_UINT32 ( Mapped to write process data, loops ADI 20 )
+** AD instance 22: ABP_SINT32 ( Mapped to read process data )
+** AD instance 23: ABP_SINT32 ( Mapped to write process data, loops ADI 22 )
+** AD instance 24: ABP_UINT16 ( Mapped to read process data )
+** AD instance 25: ABP_UINT16 ( Mapped to write process data , loops ADI 24 )
+** AD instance 26: ABP_SINT16 ( Mapped to read process data )
+** AD instance 27: ABP_SINT16 ( Mapped to write process data, loops ADI 26 )
+** AD instance 28: ABP_BITS16 ( Mapped to read process data )
+** AD instance 29: ABP_BITS16 ( Mapped to write process data, loops ADI 28 )
+** AD instance 30: ABP_UINT8 ( Mapped to read process data )
+** AD instance 31: ABP_UINT8 ( Mapped to write process data, loops ADI 30 )
+** AD instance 32: ABP_SINT8 ( Mapped to read process data )
+** AD instance 33: ABP_SINT8 ( Mapped to write process data, loops ADI 32 )
+** AD instance 34: ABP_UINT8 ( Mapped to read process data )
+** AD instance 35: ABP_UINT8 ( Mapped to write process data, loops ADI 34 )
+** AD instance 36: ABP_BIT7 ( Mapped to read process data )
+** AD instance 37: ABP_BIT7 ( Mapped to write process data, loops ADI 36 )
+** AD instance 38: Structure ( Mapped to read process data )
+** AD instance 39: Structure ( Mapped to write process data, loops ADI 38 )
+**
+** THe structure has the following members:
+**
+** Index 0: ABP_UINT32
+** Index 1: ABP_SINT32
+** Index 2: ABP_UINT16
+** Index 3: ABP_SINT16
+** Index 4: ABP_BITS16
+** Index 5: ABP_UINT8
+** Index 6: ABP_SINT8
+** Index 7: ABP_BITS8
+** Index 8: ABP_PAD8
+** Index 9: ABP_BIT1
+** Index 10: ABP_BIT2
+** Index 11: ABP_BIT3
+** Index 12: ABP_BIT4
+** Index 13: ABP_BIT5
+** Index 14: ABP_BIT6
+** Index 15: ABP_BIT7
+** Index 16: ABP_PAD4
+**
+**
+** Note!
+** - The content of the PAD bits are undefined.
+** ---------------------------------------------------------------------
+** APPL_ADI_SETUP_SYNC : Shows an example of how to handle the ADIs when
+** running a sync application.
+** - The sync example requires the following setup in abcc_drv_cfg.h
+** Using sync signal as source:
+** #define ABCC_CFG_SYNC_ENABLE ( TRUE )
+** #define ABCC_CFG_USE_ABCC_SYNC_SIGNAL ( TRUE )
+** or
+** Using ABCC interrupt:
+** #define ABCC_CFG_SYNC_ENABLE ( TRUE )
+** #define ABCC_CFG_USE_ABCC_SYNC_SIGNAL ( FALSE )
+** #define ABCC_CFG_INT_ENABLED ( TRUE )
+**
+**------------------------------------------------------------------------------
+*/
+#define APPL_ADI_SETUP_BOARD_SPECIFIC 0
+#define APPL_ADI_SETUP_SIMPLE_16 1
+#define APPL_ADI_SETUP_SEPARATE_16 2
+#define APPL_ADI_SETUP_ALL_TYPES 3
+#define APPL_ADI_SETUP_SYNC 4
+
+/*------------------------------------------------------------------------------
+** Active ADI setup to use
+**------------------------------------------------------------------------------
+*/
+#ifdef USE_BOARD_SPECIFIC_ADI_SETUP
+#define APPL_ACTIVE_ADI_SETUP APPL_ADI_SETUP_BOARD_SPECIFIC
+#else
+#define APPL_ACTIVE_ADI_SETUP APPL_ADI_SETUP_SIMPLE_16
+#endif
+
+/*------------------------------------------------------------------------------
+** If structured data types is used i.e. psStruct != NULL (see example below),
+** this define could be used to indicate that the ABP_TYPE member in
+** AD_AdiEntryType is don't care.
+**
+** { 0x60, "Struct", DONT_CARE, 17, DESC, { { NULL, NULL } }, psStruct }
+**------------------------------------------------------------------------------
+*/
+#define DONT_CARE 0
+
+/*------------------------------------------------------------------------------
+** Access descriptor for the ADIs
+**------------------------------------------------------------------------------
+*/
+#define APPL_READ_MAP_READ_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \
+ ABP_APPD_DESCR_MAPPABLE_READ_PD )
+
+#define APPL_READ_MAP_WRITE_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \
+ ABP_APPD_DESCR_SET_ACCESS | \
+ ABP_APPD_DESCR_MAPPABLE_READ_PD )
+
+#define APPL_WRITE_MAP_READ_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \
+ ABP_APPD_DESCR_MAPPABLE_WRITE_PD )
+
+#define APPL_NOT_MAP_READ_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \
+ ABP_APPD_DESCR_MAPPABLE_WRITE_PD )
+
+#define APPL_NOT_MAP_WRITE_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \
+ ABP_APPD_DESCR_SET_ACCESS )
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** List of Application data instances
+**------------------------------------------------------------------------------
+*/
+EXTFUNC const AD_AdiEntryType APPL_asAdiEntryList[];
+
+/*------------------------------------------------------------------------------
+** Default process data map
+**------------------------------------------------------------------------------
+*/
+EXTFUNC const AD_DefaultMapType APPL_asAdObjDefaultMap[];
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Returns the number of defined Application data instances
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** UINT16 - Number of Application data instances
+**------------------------------------------------------------------------------
+*/
+EXTFUNC UINT16 APPL_GetNumAdi( void );
+
+/*------------------------------------------------------------------------------
+** Interrupt service routine for sync event. There are 2 ways to detect a sync
+** event.
+** 1. Set the SYNCIEN in the ABCC interrupt mask register and call this
+** function from the ABCC_CbfEvent() callback function.
+** 2. Use the the separate sync signal available on the ABCC host connector
+** interface connected to an external interrupt. This is recommended for high
+** performance applications.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+#if SYNC_OBJ_ENABLE
+EXTFUNC void APPL_SyncIsr( void );
+#endif
+
+#endif /* inclusion lock */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_adimap_alltypes.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,270 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Example of an ADI setup with 11 ADIs covering all data types and structures.
+**
+** In abcc_drv_cfg.h make sure that the following definitions are set to:
+** ABCC_CFG_STRUCT_DATA_TYPE ( TRUE )
+** ABCC_CFG_ADI_GET_SET_CALLBACK ( FALSE )
+********************************************************************************
+********************************************************************************
+*/
+
+#include "appl_adi_config.h"
+
+#if ( APPL_ACTIVE_ADI_SETUP == APPL_ADI_SETUP_ALL_TYPES )
+
+#if ( !ABCC_CFG_STRUCT_DATA_TYPE || ABCC_CFG_ADI_GET_SET_CALLBACK )
+ #error ABCC_CFG_ADI_GET_SET_CALLBACK must be set to FALSE and ABCC_CFG_STRUCT_DATA_TYPE set to TRUE in order to run this example
+#endif
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ADI variables
+**------------------------------------------------------------------------------
+*/
+typedef struct APPL_Adi
+{
+ UINT32 lUint32;
+ INT32 lInt32;
+ UINT16 iUint16;
+ INT16 iInt16;
+ UINT16 iBit16;
+ UINT8 bUint8;
+ INT8 bInt8;
+ UINT8 bBit8;
+ UINT8 bBitTypes[ 4 ];
+ UINT16 iBitTypes[ 2 ];
+}
+APPL_AdiType;
+
+UINT32 appl_lUint32;
+INT32 appl_lInt32;
+UINT16 appl_iUint16;
+INT16 appl_iInt16;
+UINT16 appl_iBit16;
+UINT8 appl_bUint8;
+INT8 appl_bInt8;
+UINT8 appl_bBit8;
+
+UINT8 bBitTypes[ 4 ];
+UINT16 iBitTypes[ 2 ];
+
+APPL_AdiType APPL_StructAdi;
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Structured ADI #1
+**------------------------------------------------------------------------------
+*/
+static const AD_StructDataType appl_AdiReadStruct[] =
+{
+ /* Index: 0 */ { ABP_UINT32, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.lUint32, NULL } } },
+ /* Index: 1 */ { ABP_SINT32, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.lInt32, NULL } } },
+ /* Index: 2 */ { ABP_UINT16, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.iUint16, NULL } } },
+ /* Index: 3 */ { ABP_SINT16, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.iInt16, NULL } } },
+ /* Index: 4 */ { ABP_BITS16, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.iBit16, NULL } } },
+ /* Index: 5 */ { ABP_UINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.bInt8, NULL } } },
+ /* Index: 6 */ { ABP_SINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.bUint8, NULL } } },
+ /* Index: 7 */ { ABP_BITS8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.bBit8, NULL } } },
+ /* Index: 8 */ { ABP_PAD8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { NULL, NULL } } },
+#ifdef ABCC_SYS_16_BIT_CHAR
+ /* Index: 9 */ { ABP_BIT1, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 10 */ { ABP_BIT2, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 1, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 11 */ { ABP_BIT3, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 3, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 12 */ { ABP_BIT4, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 6, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 13 */ { ABP_BIT5, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 10, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 14 */ { ABP_BIT6, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 15, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 15 */ { ABP_BIT7, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 5, { { &APPL_StructAdi.iBitTypes[ 1 ], NULL } } },
+ /* Index: 16 */ { ABP_PAD4, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 4, { { NULL, NULL } } }
+#else
+ /* Index: 9 */ { ABP_BIT1, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 0, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 10 */ { ABP_BIT2, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 1, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 11 */ { ABP_BIT3, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 3, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 12 */ { ABP_BIT4, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 6, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 13 */ { ABP_BIT5, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 2, { { &APPL_StructAdi.bBitTypes[ 1 ], NULL } } },
+ /* Index: 14 */ { ABP_BIT6, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 7, { { &APPL_StructAdi.bBitTypes[ 1 ], NULL } } },
+ /* Index: 15 */ { ABP_BIT7, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 5, { { &APPL_StructAdi.bBitTypes[ 2 ], NULL } } },
+ /* Index: 16 */ { ABP_PAD4, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, 4, { { NULL , NULL } } }
+#endif
+};
+
+/*------------------------------------------------------------------------------
+** Structured ADI #2
+**------------------------------------------------------------------------------
+*/
+static const AD_StructDataType appl_AdiWriteStruct[] =
+{
+ /* Index: 0 */ { ABP_UINT32, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.lUint32, NULL } } },
+ /* Index: 1 */ { ABP_SINT32, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.lInt32, NULL } } },
+ /* Index: 2 */ { ABP_UINT16, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.iUint16, NULL } } },
+ /* Index: 3 */ { ABP_SINT16, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.iInt16, NULL } } },
+ /* Index: 4 */ { ABP_BITS16, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.iBit16, NULL } } },
+ /* Index: 5 */ { ABP_UINT8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.bInt8, NULL } } },
+ /* Index: 6 */ { ABP_SINT8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.bUint8, NULL } } },
+ /* Index: 7 */ { ABP_BITS8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.bBit8, NULL } } },
+ /* Index: 8 */ { ABP_PAD8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { NULL, NULL } } },
+#ifdef ABCC_SYS_16_BIT_CHAR
+ /* Index: 9 */ { ABP_BIT1, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 10 */ { ABP_BIT2, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 1, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 11 */ { ABP_BIT3, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 3, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 12 */ { ABP_BIT4, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 6, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 13 */ { ABP_BIT5, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 10, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 14 */ { ABP_BIT6, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 15, { { &APPL_StructAdi.iBitTypes[ 0 ], NULL } } },
+ /* Index: 15 */ { ABP_BIT7, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 5, { { &APPL_StructAdi.iBitTypes[ 1 ], NULL } } },
+ /* Index: 16 */ { ABP_PAD4, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 4, { { NULL, NULL } } }
+#else
+ /* Index: 9 */ { ABP_BIT1, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 0, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 10 */ { ABP_BIT2, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 1, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 11 */ { ABP_BIT3, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 3, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 12 */ { ABP_BIT4, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 6, { { &APPL_StructAdi.bBitTypes[ 0 ], NULL } } },
+ /* Index: 13 */ { ABP_BIT5, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 2, { { &APPL_StructAdi.bBitTypes[ 1 ], NULL } } },
+ /* Index: 14 */ { ABP_BIT6, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 7, { { &APPL_StructAdi.bBitTypes[ 1 ], NULL } } },
+ /* Index: 15 */ { ABP_BIT7, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 5, { { &APPL_StructAdi.bBitTypes[ 2 ], NULL } } },
+ /* Index: 16 */ { ABP_PAD4, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, 4, { { NULL , NULL } } }
+#endif
+};
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** ADI table mixing normal types and structured data types.
+**------------------------------------------------------------------------------
+*/
+
+/*---------------------------------------------------------------------------------------------------
+** iInstance | pabName | bDataType | bNumOfElements | bDesc | pxValuePtr | pxValuePropPtr | psStruct
+**---------------------------------------------------------------------------------------------------
+*/
+const AD_AdiEntryType APPL_asAdiEntryList[] =
+{
+ { 20, "ABP_UINT32_READ", ABP_UINT32, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_lUint32, NULL } }, NULL },
+ { 21, "ABP_UINT32_WRITE", ABP_UINT32, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_lUint32, NULL } }, NULL },
+ { 22, "ABP_SINT32_READ", ABP_SINT32, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_lInt32, NULL } }, NULL },
+ { 23, "ABP_SINT32_WRITE", ABP_SINT32, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_lInt32, NULL } }, NULL },
+ { 24, "ABP_UINT16_READ", ABP_UINT16, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_iUint16, NULL } }, NULL },
+ { 25, "ABP_UINT16_WRITE", ABP_UINT16, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_iUint16, NULL } }, NULL },
+ { 26, "ABP_SINT16_READ", ABP_SINT16, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_iInt16, NULL } }, NULL },
+ { 27, "ABP_SINT16_WRITE", ABP_SINT16, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_iInt16, NULL } }, NULL },
+ { 28, "ABP_BITS16_READ", ABP_BITS16, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_iBit16, NULL } }, NULL },
+ { 29, "ABP_BITS16_WRITE", ABP_BITS16, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_iBit16, NULL } }, NULL },
+ { 30, "ABP_UINT8_READ", ABP_UINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_bUint8, NULL } }, NULL },
+ { 31, "ABP_UINT8_WRITE", ABP_UINT8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_bUint8, NULL } }, NULL },
+ { 32, "ABP_SINT8_READ", ABP_SINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_bInt8, NULL } }, NULL },
+ { 33, "ABP_SINT8_WRITE", ABP_SINT8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_bInt8, NULL } }, NULL },
+ { 34, "ABP_UINT8_READ", ABP_PAD8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { NULL, NULL } }, NULL },
+ { 35, "ABP_UINT8_WRITE", ABP_PAD8, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { NULL, NULL } }, NULL },
+ { 36, "ABP_BIT7_READ", ABP_BIT7, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_bBit8, NULL } }, NULL },
+ { 37, "ABP_BIT7_WRITE", ABP_BIT7, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_bBit8, NULL } }, NULL },
+ { 38, "Struct_READ", ABP_UINT8, 17, APPL_READ_MAP_WRITE_ACCESS_DESC, { { NULL, NULL } }, appl_AdiReadStruct },
+ { 39, "Struct_WRITE", ABP_UINT8, 17, APPL_WRITE_MAP_READ_ACCESS_DESC, { { NULL, NULL } }, appl_AdiWriteStruct }
+};
+
+/*------------------------------------------------------------------------------
+** Map all adi:s in both directions. Both whole ADI:s and individual elements
+** are mapped.
+** -----------------------------------------------------------------------------
+** 1. AD instance | 2. Direction | 3. Num elements | 4. Start index |
+**------------------------------------------------------------------------------
+*/
+const AD_DefaultMapType APPL_asAdObjDefaultMap[] =
+{
+ { 20, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 21, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 22, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 23, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 24, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 25, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 26, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 27, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 28, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 29, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 30, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 31, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 32, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 33, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 34, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 35, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 36, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { AD_MAP_PAD_ADI, PD_READ, 1, 0 },
+ { 37, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { AD_MAP_PAD_ADI, PD_WRITE, 1, 0 },
+ { 38, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 39, PD_WRITE, 1, 0 },
+ { 39, PD_WRITE, 1, 1 },
+ { 39, PD_WRITE, 1, 2 },
+ { 39, PD_WRITE, 1, 3 },
+ { 39, PD_WRITE, 1, 4 },
+ { 39, PD_WRITE, 1, 5 },
+ { 39, PD_WRITE, 1, 6 },
+ { 39, PD_WRITE, 1, 7 },
+ { 39, PD_WRITE, 1, 8 },
+ { 39, PD_WRITE, 1, 9 },
+ { 39, PD_WRITE, 1, 10 },
+ { 39, PD_WRITE, 1, 11 },
+ { 39, PD_WRITE, 1, 12 },
+ { 39, PD_WRITE, 1, 13 },
+ { 39, PD_WRITE, 1, 14 },
+ { 39, PD_WRITE, 1, 15 },
+ { 39, PD_WRITE, 1, 16 },
+ { AD_DEFAULT_MAP_END_ENTRY }
+};
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+UINT16 APPL_GetNumAdi( void )
+{
+ return( sizeof( APPL_asAdiEntryList ) / sizeof( AD_AdiEntryType ) );
+}
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_adimap_separate16.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,150 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Example of an ADI setup with 32 ADIs each one holding a 16 bit value.
+**
+** In abcc_drv_cfg.h make sure that the following definitions are set to:
+** ABCC_CFG_STRUCT_DATA_TYPE ( FALSE )
+** ABCC_CFG_ADI_GET_SET_CALLBACK ( TRUE )
+********************************************************************************
+********************************************************************************
+*/
+
+#include "appl_adi_config.h"
+
+#if ( APPL_ACTIVE_ADI_SETUP == APPL_ADI_SETUP_SEPARATE_16 )
+
+#if( ABCC_CFG_STRUCT_DATA_TYPE || !ABCC_CFG_ADI_GET_SET_CALLBACK )
+ #error ABCC_CFG_ADI_GET_SET_CALLBACK must be set to TRUE and ABCC_CFG_STRUCT_DATA_TYPE set to FALSE in order to run this example
+#endif
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+/*------------------------------------------------------------------------------
+** Forward declarations
+**------------------------------------------------------------------------------
+*/
+static void SetAdi10Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex );
+static void GetAdi11Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex );
+
+/*------------------------------------------------------------------------------
+** Data holder for the ADI instances
+**------------------------------------------------------------------------------
+*/
+static UINT16 appl_aiUint16_10[ 32 ];
+static UINT16 appl_aiUint16_11[ 32 ];
+static UINT16 appl_Uint16_12 = 0;
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** 32 16-bit values individually
+** See abcc_ad_if.h for a more detailed description.
+**------------------------------------------------------------------------------
+*/
+/*-----------------------------------------------------------------------------------------------------------------------
+** iInstance | pabName | bDataType | bNumOfElements | bDesc | pxValuePtr | pxValuePropPtr| pnGetAdiValue | pnSetAdiValue
+**-----------------------------------------------------------------------------------------------------------------------
+*/
+const AD_AdiEntryType APPL_asAdiEntryList[] =
+{
+ { 10, "ABP_UINT16_SET", ABP_UINT16, 32, APPL_READ_MAP_WRITE_ACCESS_DESC, { { appl_aiUint16_10 ,NULL } }, NULL, SetAdi10Value },
+ { 11, "ABP_UINT16_GET", ABP_UINT16, 32, APPL_WRITE_MAP_READ_ACCESS_DESC, { { appl_aiUint16_11 ,NULL } }, GetAdi11Value, NULL },
+ { 12, "ABP_UINT16_COUNTER", ABP_UINT16, 1, APPL_NOT_MAP_WRITE_ACCESS_DESC, { { &appl_Uint16_12 ,NULL } }, NULL, NULL },
+};
+
+/*
+**------------------------------------------------------------------------------
+** Map all adi:s in both directions
+** See abcc_ad_if.h for a more detailed description.
+**------------------------------------------------------------------------------
+** 1. AD instance | 2. Direction | 3. Num elements | 4. Start index |
+**------------------------------------------------------------------------------
+*/
+const AD_DefaultMapType APPL_asAdObjDefaultMap[] =
+{
+ { 10, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 11, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { AD_DEFAULT_MAP_END_ENTRY }
+};
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+/*------------------------------------------------------------------------------
+** Callback of type ABCC_GetAdiValueFuncType. The function will be called when
+** the network reads ADI #11. It will increment the value of ADI#12 every time
+** this is done.
+**
+** ABCC_GetAdiValueFuncType is declared in abcc_ad_if.h
+**------------------------------------------------------------------------------
+*/
+static void GetAdi11Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex )
+{
+ appl_Uint16_12++;
+}
+/*------------------------------------------------------------------------------
+** Callback of type ABCC_SetAdiValueFuncType. The function will be called when
+** the network writes to ADI#10. It copies the changed values from ADI#10 to ADI#11.
+**
+** ABCC_SetAdiValueFuncType is declared in abcc_ad_if.h
+**------------------------------------------------------------------------------
+*/
+static void SetAdi10Value( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex )
+{
+ UINT8 index;
+ for( index = bStartIndex ; index < bStartIndex+bNumElements ; index++ )
+ {
+ appl_aiUint16_11[ index ] = appl_aiUint16_10[ index ];
+ }
+}
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+UINT16 APPL_GetNumAdi( void )
+{
+ return( sizeof( APPL_asAdiEntryList ) / sizeof( AD_AdiEntryType ) );
+}
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_adimap_simple16.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,122 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Example of an ADI setup with an array of 16 bit values
+**
+** In abcc_drv_cfg.h make sure that the following definitions are set to:
+** ABCC_CFG_STRUCT_DATA_TYPE ( FALSE )
+** ABCC_CFG_ADI_GET_SET_CALLBACK ( FALSE )
+********************************************************************************
+********************************************************************************
+*/
+
+#include "appl_adi_config.h"
+
+#if ( APPL_ACTIVE_ADI_SETUP == APPL_ADI_SETUP_SIMPLE_16 )
+
+#if ( ABCC_CFG_STRUCT_DATA_TYPE || ABCC_CFG_ADI_GET_SET_CALLBACK )
+ #error ABCC_CFG_ADI_GET_SET_CALLBACK must be set to FALSE and ABCC_CFG_STRUCT_DATA_TYPE set to FALSE in order to run this example
+#endif
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** Data holder for the ADI instances
+**------------------------------------------------------------------------------
+*/
+static UINT16 appl_aiUint16[ 32 ];
+
+/*------------------------------------------------------------------------------
+** Min, max and default value for appl_aiUint16
+**------------------------------------------------------------------------------
+*/
+static AD_UINT16Type appl_sUint16Prop = { { 0, 0xFFFF, 0 } };
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** 32 16-bit values as an array
+**------------------------------------------------------------------------------
+*/
+
+/*-------------------------------------------------------------------------------------------------------------
+** 1. iInstance | 2. pabName | 3. bDataType | 4. bNumOfElements | 5. bDesc | 6. pxValuePtr | 7. pxValuePropPtr
+**--------------------------------------------------------------------------------------------------------------
+*/
+const AD_AdiEntryType APPL_asAdiEntryList[] =
+{
+ { 0x1, "ABP_UINT16_WRITE", ABP_UINT16, 32, APPL_WRITE_MAP_READ_ACCESS_DESC, { { appl_aiUint16, &appl_sUint16Prop } } },
+ { 0x2, "ABP_UINT16_READ", ABP_UINT16, 32, APPL_READ_MAP_WRITE_ACCESS_DESC, { { appl_aiUint16, &appl_sUint16Prop } } }
+};
+
+/*------------------------------------------------------------------------------
+** Map all adi:s in both directions
+**------------------------------------------------------------------------------
+** 1. AD instance | 2. Direction | 3. Num elements | 4. Start index |
+**------------------------------------------------------------------------------
+*/
+const AD_DefaultMapType APPL_asAdObjDefaultMap[] =
+{
+ { 1, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 2, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { AD_DEFAULT_MAP_END_ENTRY }
+};
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+UINT16 APPL_GetNumAdi( void )
+{
+ return( sizeof( APPL_asAdiEntryList ) / sizeof( AD_AdiEntryType ) );
+}
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Generic/example_app/appl_adimap_sync.c Thu May 12 19:04:45 2016 +0000
@@ -0,0 +1,257 @@
+/*******************************************************************************
+********************************************************************************
+** **
+** ABCC Starter Kit version 2.01.01 (2015-12-14) **
+** **
+** Delivered with: **
+** ABCC Driver 4.01.01 (2015-12-14) **
+** ABP 7.16.01 (2015-10-14) **
+** */
+/*******************************************************************************
+********************************************************************************
+** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB **
+** **
+** This code is the property of HMS Industrial Networks AB. **
+** The source code may not be reproduced, distributed, or used without **
+** permission. When used together with a product from HMS, permission is **
+** granted to modify, reproduce and distribute the code in binary form **
+** without any restrictions. **
+** **
+** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT **
+** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR **
+** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR **
+** THAT DEFECTS IN IT CAN BE CORRECTED. **
+********************************************************************************
+********************************************************************************
+** Example of how to handle ADI values in a sync application.
+**
+** In abcc_drv_cfg.h make sure that the following definitions are set to:
+** ABCC_CFG_STRUCT_DATA_TYPE ( FALSE )
+** ABCC_CFG_ADI_GET_SET_CALLBACK ( FALSE )
+**
+** In abcc_identification.h make sure that the following definitions are set to:
+** SYNC_OBJ_ENABLE ( TRUE )
+**
+********************************************************************************
+********************************************************************************
+*/
+
+#include "abcc_td.h"
+#include "abcc.h"
+#include "appl_adi_config.h"
+#include "appl_abcc_handler.h"
+
+
+#if( APPL_ACTIVE_ADI_SETUP == APPL_ADI_SETUP_SYNC )
+
+#if( ABCC_CFG_STRUCT_DATA_TYPE || ABCC_CFG_ADI_GET_SET_CALLBACK )
+ #error ABCC_CFG_ADI_GET_SET_CALLBACK must be set to FALSE and ABCC_CFG_STRUCT_DATA_TYPE set to FALSE in order to run this example
+#endif
+
+#if( !SYNC_OBJ_ENABLE )
+ #error SYNC_OBJ_ENABLE must be set to TRUE in abcc_obj_cfg.h.h
+#endif
+
+
+#if( !ABCC_CFG_SYNC_ENABLE )
+ #error ABCC_CFG_SYNC_ENABLE in abcc_drv_cfg.h must be enabled
+#endif
+
+
+/*******************************************************************************
+** Constants
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Typedefs
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Private Globals
+********************************************************************************
+*/
+static void triggerAdiSyncOutputValid( void );
+static void triggerAdiSyncInputCapture( void );
+
+
+/*------------------------------------------------------------------------------
+** Data holder for the ADI instances
+**------------------------------------------------------------------------------
+*/
+
+/*
+** Latest received read process data linked to the ADI entry table.
+*/
+static UINT32 appl_lPendingOutput;
+
+/*
+** Represent the current value used by the hardware actuated at the latest sync
+** pulse.
+*/
+static UINT32 appl_lSyncOutput;
+
+/*
+** Represent the current input from the HW.
+*/
+static UINT32 appl_lSensorValue;
+
+/*
+** Represent the sampled appl_lSensorInput at the sync pulse. The variable is
+** linked to the ADI entry table.
+*/
+static UINT32 appl_lSyncInput;
+
+
+/*******************************************************************************
+** Public Globals
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** 32 bit input/output.
+**------------------------------------------------------------------------------
+*/
+const AD_AdiEntryType APPL_asAdiEntryList[] =
+{
+ { 50, "SyncOutput", ABP_UINT32, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &appl_lPendingOutput, NULL } } },
+ { 51, "SyncInput", ABP_UINT32, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &appl_lSyncInput, NULL } } },
+};
+
+/*------------------------------------------------------------------------------
+** Map all adi:s in both directions
+**------------------------------------------------------------------------------
+** 1. AD instance | 2. Direction | 3. Num elements | 4. Start index |
+**------------------------------------------------------------------------------
+*/
+const AD_DefaultMapType APPL_asAdObjDefaultMap[] =
+{
+ { 50, PD_READ, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { 51, PD_WRITE, AD_DEFAULT_MAP_ALL_ELEM, 0 },
+ { AD_DEFAULT_MAP_END_ENTRY }
+};
+
+/*******************************************************************************
+** Private Services
+********************************************************************************
+*/
+
+/*******************************************************************************
+** Public Services
+********************************************************************************
+*/
+
+/*------------------------------------------------------------------------------
+** When sync is used this function is called to indicate that the read
+** process data ADI:s shall be copied to the synchronized outputs.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void triggerAdiSyncOutputValid( void )
+{
+ /*
+ ** Copy the pending output to the SyncOutput.
+ ** In a real case the appl_lSyncOutput is not variable but a function
+ ** controlling e.g. a motor.
+ */
+ appl_lSyncOutput = appl_lPendingOutput;
+ (void)appl_lSyncOutput;
+}
+
+/*------------------------------------------------------------------------------
+** If sync is used this function is called to indicate that write process data
+** ADI:s shall be updated with the captured input.
+**------------------------------------------------------------------------------
+** Arguments:
+** None
+**
+** Returns:
+** None
+**------------------------------------------------------------------------------
+*/
+static void triggerAdiSyncInputCapture( void )
+{
+ /*
+ ** Copy the sensor to the sync input.
+ ** appl_lSensorValue represent for example a measured speed.
+ **
+ */
+ appl_lSyncInput = appl_lSensorValue;
+
+ /*
+ ** Always update the ABCC with the latest write process data at the end of
+ ** this function.
+ */
+ ABCC_TriggerWrPdUpdate();
+}
+
+
+void APPL_SyncIsr( void )
+{
+ /*
+ ** PORTING ALERT!
+ ** Some applications require a PLL being locked to the sync signal before
+ ** PROCESS_ACTIVE is entered. It is also possible to do measurement to verify
+ ** the cycle time before allowing PROCESS_ACTIVE.
+ ** Only ABP_APPSTAT_NO_ERROR will allow the ABCC to enter PROCESS_ACTIVE.
+ **
+ ** In those cases this call must be relocated.
+ ** In this example PROCESS_ACTIVE will be allowed as soon as the first sync
+ ** interrupt appears.
+ */
+ if( ABCC_GetAppStatus() != ABP_APPSTAT_NO_ERROR )
+ {
+ if( ABCC_GetAppStatus() == ABP_APPSTAT_NOT_SYNCED )
+ {
+ ABCC_SetAppStatus( ABP_APPSTAT_NO_ERROR );
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ /*
+ ** PORTING ALERT!
+ ** The OutputValidTime attribute in the sync object defines the time in
+ ** nano seconds that shall be waited from this point before actuating the ADI
+ ** values to the synchronized output.
+ ** This means that a timer shall be started here and when it expires
+ ** triggerAdiSyncOutputValid() shall be called.
+ ** In this example the output valid time is ignored and the function is
+ ** called directly (OutputValidTime = 0).
+ */
+ triggerAdiSyncOutputValid();
+
+ /*
+ ** PORTING ALERT!
+ ** The InputCaptureTime attribute in the sync object defines the time in
+ ** nano seconds that shall be waited from this point before capturing the
+ ** input data and send it to the ABCC.
+ ** This means that a timer shall be started here, and when it expires
+ ** triggerAdiSyncInputCapture() shall be called.
+ ** In this example the input capture time is ignored and the
+ ** function is called directly (InputCaptureTime = 0).
+ */
+ triggerAdiSyncInputCapture();
+}
+
+
+
+UINT16 APPL_GetNumAdi( void )
+{
+ return( sizeof( APPL_asAdiEntryList ) / sizeof( AD_AdiEntryType ) );
+}
+
+/*******************************************************************************
+** Tasks
+********************************************************************************
+*/
+
+#endif