dp_cfg.h
资源名称:Profibus.rar [点击查看]
上传用户:hualang
上传日期:2022-04-11
资源大小:104k
文件大小:21k
源码类别:
能源行业(电力石油煤炭)
开发平台:
C/C++
- /************************ Filename: dp_cfg.h ********************************/
- /* ========================================================================= */
- /* */
- /* 0000 000 000 00000 0 000 0 0 0 0000 */
- /* 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */
- /* 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Einsteinstra遝 6 */
- /* 0000 000 0 0 000 0 0 00000 0 0000 91074 Herzogenaurach */
- /* 0 00 0 0 0 0 0 0 0 0 0 */
- /* 0 0 0 0 0 0 0 0 0 0 0 0 0 Tel: ++49-9132-744-200 */
- /* 0 0 0 000 0 0 000 0 0 0 0 GmbH Fax: ++49-9132-744-204 */
- /* */
- /* ========================================================================= */
- /* */
- /* Function: Configuration file for VPC3+ */
- /* */
- /* ------------------------------------------------------------------------- */
- /* */
- /* Technical support: P. Fredehorst */
- /* Tel. : ++49-9132/744-214 */
- /* Fax. : -204 */
- /* eMail: pfredehorst@profichip.com */
- /* */
- /*****************************************************************************/
- /*****************************************************************************/
- /* contents:
- - compiler switches
- - user defines
- -
- - length of buffers
- - defines for MSAC2
- - defines for MSAC1
- - defines for ALARM
- - defines for ISOCHRON
- - defines for DXB PUBLISHER
- - defines for DXB SUBSCRIBER
- - Hardwaremode
- - Interruptevents
- - calculating area (do not edit this part)
- */
- /*****************************************************************************/
- /* reinclude protection */
- #ifndef DP_CFG_H
- #define DP_CFG_H
- #define MAX_DEV_NUM 1
- #define NET_A 0
- #define NET_B 1
- /*--------------------------------------------------------------------------*/
- /* profibus services */
- /*--------------------------------------------------------------------------*/
- /* todo: setup required services */
- /*------------------------------------------*/
- /* NOTICE: Only VPC3+/B supports DPV1, DPV2 */
- /*------------------------------------------*/
- /* DPV1 MSAC1 */
- #define DP_MSAC_C1
- /* DPV1 MSAC2 */
- #define DP_MSAC_C2
- /* DPV1 Alarms */
- #define DP_ALARM
- /* I&M - Identification & Maintenence Functions */
- //#define DPV1_IM_SUPP
- /* DPV2 */
- //#define DP_SUBSCRIBER
- //#define DP_DEBUG_ENABLE
- #define DP_TIMESTAMP //wusenlin add
- #ifdef DP_TIMESTAMP
- # define SIZE_TIMESTAMP 32
- #else
- # define SIZE_TIMESTAMP 0
- #endif
- /*---------------------------------------------------------------------------*/
- /* User defines */
- /*---------------------------------------------------------------------------*/
- #define BLACKFIN_SEG_MULDIV (SEG_MULDIV) //16位芯片,乘倍数
- #define BLACKFIN_MULTIPLER 1//memset按WORD为单位
- #define BFWORD2BYTE(wData) (wData&0xff)
- #define BFLONG2WORD(lData) (((lData>>8)&0xff00) | (lData&0xff))
- #define BFWORD2LONG(wData) (((wData<<8)&0xff0000)| (wData&0xff))
- /*-----------------------------------------------------------------------*/
- /* general slave parameter */
- /*-----------------------------------------------------------------------*/
- #define DP_ADDR ((UBYTE)GetSysCfgValue(ID_SYS_COMM1_ADDRESS)) // Slave address
- #define IDENT_NR ((UWORD)0x0A50) // PROFIBUS Ident Number
- #define USER_WD ((UWORD)0x01FF) // User Watchdog
- // set watchdog greater than 0x00FF, if serial printouts used
- // The UserWatchdog is only active in DataExchange. The UserWatchdog
- // isn't timebased, it's a counter of DataExchange-telegrams.
- /*-----------------------------------------------------------------------*/
- /* define buffer length */
- /*-----------------------------------------------------------------------*/
- #define DIN_BUFSIZE ((UBYTE)0x80) // Length of the DIn Buffer (Data Slave to Master) 0..244
- #define DOUT_BUFSIZE ((UBYTE)0x20) // Length of the DOut Buffer (Data Master to Slave) 0..244
- #define PRM_BUFSIZE ((UBYTE)0x40) // Length of the Parameter Buffer 7..244
- #define DIAG_BUFSIZE ((UBYTE)0x40) // Length of the Diagnosis Buffer 6..244
- #define CFG_BUFSIZE ((UBYTE)0x40) // Length of the Configuration Buffer 1..244
- #define SSA_BUFSIZE ((UBYTE)0x00) // Length of the Input Data in the Set_Slave_Address-Buffer 0 and 4..244
- // 0: SetSlaveAddress will be deactivated!
- /*-----------------------------------------------------------------------*/
- /* settings for MSAC_C1 */
- /*-----------------------------------------------------------------------*/
- #define C1_LEN ((UBYTE)0xF4) // Length of the MSAC_C1 Data
- // The parameter specifies the maximum length of user data including
- // Function_Num, Slot_number, Index, Length, transferred on the
- // MSAC_1 communication channel.
- // Type: Unsigned8 (0 .. 244)
- /*-----------------------------------------------------------------------*/
- /* settings for MSAC_C1 Alarm */
- /*-----------------------------------------------------------------------*/
- #define DP_ALARM_OVER_SAP50 // Alarm Acknowledge over SAP50
- /*-----------------------------------------------------------------------*/
- /* settings for MSAC_C2 */
- /*-----------------------------------------------------------------------*/
- #define DP_MSAC_C2_Time // enables time control for msac-c2
- #define C2_NUM_SAPS ((UBYTE)0x03) // Number of MSAC_C2 connections
- #define C2_LEN ((UBYTE)0xF4) // Length of MSAC_C2 Data
- // The parameter specifies the maximum length of an Initiate Request
- // PDU including the Function_Num to the Resource Manager.
- // The parameter specifies the maximum length of user data including
- // Function_Num, Slot_number, Index, Length, transferred on the
- // MSAC_2 communication channel.
- // Type: Unsigned8 (0,52.. 244)
- #define C2_FEATURES_SUPPORTED_1 ((UBYTE)0x01) // default: 0x01, Read and Write supported
- #define C2_FEATURES_SUPPORTED_2 ((UBYTE)0x00) // default: 0x00
- #define C2_PROFILE_FEATURES_1 ((UBYTE)0x00) // default: 0x00, vendor or profile specific
- #define C2_PROFILE_FEATURES_2 ((UBYTE)0x00) // default: 0x00, vendor or profile specific
- #define C2_PROFILE_NUMBER ((UWORD)0x0000) // default: 0x0000, vendor or profile specific
- /*-----------------------------------------------------------------------*/
- /* settings for DPV2 - Isochron Mode */
- /*-----------------------------------------------------------------------*/
- #define SYNCH_PULSEWIDTH ((UBYTE)0xFF) // Width of Synchpulse in 1/12祍
- /*-----------------------------------------------------------------------*/
- /* settings for DPV2 - DXB Subscriber */
- /*-----------------------------------------------------------------------*/
- #define MAX_LINK_SUPPORTED ((UBYTE)0x05) // Number of Links
- #define MAX_DATA_PER_LINK ((UBYTE)0x10) // maximal Number of Data per Link
- /*---------------------------------------------------------------------------*/
- /* set hardware modes */
- /*---------------------------------------------------------------------------*/
- #define DP_VPC3_4KB_MODE // (only VPC3+B, VPC3+C)
- /*-----------------------------------------------------------------------*/
- /* ModeRegister0 (7..0) ( page 15 ) */
- /*-----------------------------------------------------------------------*/
- //
- // bit 7 6 5 4 3 2 1 0
- // --------------------------------------------------------------------------
- // | Freeze | Sync | Early | Int_Pol | MinTSDR | Res | Dis_Stop | Dis_Start |
- // | supp. | supp.| RDY | | | | Control | Control |
- // --------------------------------------------------------------------------
- // 1 1 0 0 0 0 0 0 = 0xC0 // Default
- //
- //BIT 3 = CS_Supported
- //wusenlin CS功能测试
- #ifdef DP_TIMESTAMP
- # define INIT_VPC3_MODE_REG_L ((UBYTE)0xC8)
- #else
- # define INIT_VPC3_MODE_REG_L ((UBYTE)0xC0)
- #endif
- /*-----------------------------------------------------------------------*/
- /* ModeRegister0 (15..8) ( page 15 ) */
- /*-----------------------------------------------------------------------*/
- //
- // bit15 14 13 12 11 10 9 8
- // ------------------------------------------------------------------------------------
- // | Res | PrmCmd | Spec_Clear | Spec_Prm | SetExtPrm | User_Time | EOI_Time | DP |
- // | | Supp | Mode | Buf_Mode | Supp | Base | Base | Mode |
- // ------------------------------------------------------------------------------------
- // 0 0 1 0 0 1 1 1 = 0x27 // Default
- //
- #define INIT_VPC3_MODE_REG_H ((UBYTE)0x27)//0x27
- //注: Spec_Clear Mode =1 表示从站可以接收DU=0的Dxchange报文
- //以进入故障安全状态
- /*-----------------------------------------------------------------------*/
- /* ModeRegister2 (7..0) ( page 19 ) (only VPC3+B, VPC3+C) */
- /*-----------------------------------------------------------------------*/
- //
- // bit 7 6 5 4 3 2 1 0
- // --------------------------------------------------------------------------------------
- // | 4KB | No_Check | SYNC_ | SYNC_ | DX_Int_ | DX_Int_ | No_Check_ | NEW_GC_ |
- // | Mode | Prm_Reserved | Pol | ENA | Port | Mode | GC_RESERVED | Int_Mode |
- // --------------------------------------------------------------------------------------
- // 1 0 0 0 0 0 0 1 = 0x01 or 0x81
- //
- #ifdef DP_VPC3_4KB_MODE
- #define INIT_VPC3_MODE_REG_2 ((UBYTE)0x81)
- #else
- #define INIT_VPC3_MODE_REG_2 ((UBYTE)0x01)
- #endif
- /*---------------------------------------------------------------------------*/
- /* set interrupt indications */
- /*---------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------*/
- /* Interrupt Mask Register (7..0) ( page 23 ) */
- /*-----------------------------------------------------------------------*/
- // bit7 6 5 4 3 2 1 0
- // ----------------------------------------------------------------------------------------
- // | DXB | New_Ext | DXB_LINK | User_Timer | WD_DP | Baud_Rate | Go/Leave | MAC |
- // | OUT | PRM_Data | ERROR | Clock | Mode_Timeout | detect | DataEx | Reset |
- // ----------------------------------------------------------------------------------------
- // 1 0 1 1 1 1 1 0 = 0xBE // Default
- //
- //wusenlin
- #ifdef DP_TIMESTAMP
- # define INIT_VPC3_IND_L 0xFF//0xBF
- #else
- # define INIT_VPC3_IND_L 0xFE//0xBE
- #endif
- /*-----------------------------------------------------------------------*/
- /* Interrupt Mask Register (15..8) ( page 23 ) */
- /*-----------------------------------------------------------------------*/
- // bit 15 14 13 12 11 10 9 8
- // -----------------------------------------------------------------------------------
- // | REQ_PDU | POLL_END | DX_OUT | Diag_Buffer | New_PRM | NewCfg | NewSSA | NewGC |
- // | Ind | Ind | | Changed | Data | Data | Data | Command |
- // -----------------------------------------------------------------------------------
- // 1 1 1 1 1 1 0 0 = 0xFC // Default
- //
- #define INIT_VPC3_IND_H (0xFC)
- //#define INIT_VPC3_IND_H 0xDC
- /*---------------------------------------------------------------------------*/
- /* end of user defines */
- /*---------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------*/
- /* !!!!! do not edit this calculating part !!!!! */
- /*---------------------------------------------------------------------------*/
- // == Segmentation VPC3+ ===============================================================
- #ifdef DP_VPC3_4KB_MODE
- // 16 Byte segmentation
- #define SEG_OFFSET ((UBYTE)0x0F)
- #define SEG_MULDIV ((UBYTE)0x04)
- #define SEG_ADDBYTE ((UWORD)0xFFF0)
- #define SEG_ADDWORD ((UWORD)0xFFF0)
- #else
- // 8 Byte segmentation
- #define SEG_OFFSET ((UBYTE)0x07)
- #define SEG_MULDIV ((UBYTE)0x03)
- #define SEG_ADDBYTE ((UWORD)0xF8)
- #define SEG_ADDWORD ((UWORD)0xFFF8)
- #endif
- // == DPV1/DPV2 ========================================================================
- #define DP_C1_USE_RD_WR_SAP 0x01
- #define DP_C1_USE_ALARM_SAP 0x04
- // == MSAC1 ============================================================================
- #ifdef DP_ALARM
- #define DP_MSAC_C1
- #endif
- #ifdef DP_MSAC_C1
- #define DP_C1_LEN C1_LEN
- // == Alarm ========================================================================
- #ifdef DP_ALARM
- #ifdef DP_ALARM_OVER_SAP50
- #define DP_C1_SAPS ( DP_C1_USE_RD_WR_SAP | DP_C1_USE_ALARM_SAP )
- #else
- #define DP_C1_SAPS ( DP_C1_USE_RD_WR_SAP )
- #endif
- #else
- #define DP_C1_SAPS ( DP_C1_USE_RD_WR_SAP )
- #endif
- #else
- #define DP_C1_SAPS 0x00
- #define DP_C1_LEN ((UBYTE)0x00)
- #undef DP_ALARM
- #endif
- // == MSAC2 ============================================================================
- #ifdef DP_MSAC_C2
- #define DP_C2_NUM_SAPS C2_NUM_SAPS
- #define DP_C2_LEN C2_LEN
- #else
- #define DP_C2_NUM_SAPS ((UBYTE)0x00)
- #define DP_C2_LEN ((UBYTE)0x00)
- #endif
- // == Subscriber =======================================================================
- #ifdef DP_SUBSCRIBER
- #define DP_MAX_LINK_SUPPORTED MAX_LINK_SUPPORTED
- #define DP_MAX_DATA_PER_LINK MAX_DATA_PER_LINK
- #else
- #define DP_MAX_LINK_SUPPORTED 0
- #define DP_MAX_DATA_PER_LINK 0
- #endif
- // == Calculating FDL list =============================================================
- #if ( (defined DP_MSAC_C1) || (defined DP_MSAC_C2) )
- #define DP_FDL
- #endif
- #if (DP_C1_SAPS & DP_C1_USE_RD_WR_SAP)
- #define DP_TEMP_X1 1
- #else
- #define DP_TEMP_X1 0
- #endif
- #if (DP_C1_SAPS & DP_C1_USE_ALARM_SAP )
- #define DP_TEMP_X2 1
- #define SAP_50
- #else
- #define DP_TEMP_X2 0
- #endif
- #ifdef DP_MSAC_C1
- #define DP_TEMP_X (DP_TEMP_X1 + DP_TEMP_X2)
- #else
- #define DP_TEMP_X 0
- #endif
- #ifdef DP_MSAC_C2
- #define DP_MAX_SAPS (DP_TEMP_X + DP_C2_NUM_SAPS + 1 )
- #else
- #define DP_MAX_SAPS DP_TEMP_X
- #endif
- #define DP_ORG_LENGTH 0x40 // organizational parameter
- #if (defined (DP_FDL))
- #define FDL_SAP_MAX DP_MAX_SAPS
- /* length of vpc3-sap-list */
- #define SAP_LENGTH (((FDL_SAP_MAX*7)+SEG_OFFSET) & SEG_ADDBYTE)
- #else
- #define SAP_LENGTH 0x10
- #endif
- #ifdef DP_VPC3_4KB_MODE
- #define ASIC_RAM_LENGTH 0x1000
- #define ASIC_USER_RAM (ASIC_RAM_LENGTH - DP_ORG_LENGTH - SAP_LENGTH)
- #else
- #define ASIC_RAM_LENGTH 0x800
- #define ASIC_USER_RAM (ASIC_RAM_LENGTH - DP_ORG_LENGTH - SAP_LENGTH)
- #endif
- #define ISR_ENABLE_VPC3_INT_MAC_RESET 0
- #define ISR_ENABLE_VPC3_INT_GO_LEAVE_DATA_EX 0
- #define ISR_ENABLE_VPC3_INT_BAUDRATE_DETECT 0
- #define ISR_ENABLE_VPC3_INT_WD_DP_TIMEOUT 0
- #define ISR_ENABLE_VPC3_INT_USER_TIMER_CLOCK 0
- #define ISR_ENABLE_VPC3_INT_DXB_LINK_ERROR 0
- #define ISR_ENABLE_VPC3_INT_NEW_EXT_PRM_DATA 0
- #define ISR_ENABLE_VPC3_INT_DXB_OUT 0
- #define ISR_ENABLE_VPC3_INT_NEW_GC_COMMAND 0
- #define ISR_ENABLE_VPC3_INT_NEW_SSA_DATA 0
- #define ISR_ENABLE_VPC3_INT_NEW_CFG_DATA 0
- #define ISR_ENABLE_VPC3_INT_NEW_PRM_DATA 0
- #define ISR_ENABLE_VPC3_INT_DIAG_BUF_CHANGED 0
- #define ISR_ENABLE_VPC3_INT_DX_OUT 0
- #define ISR_ENABLE_VPC3_INT_RESERVED 0
- #define ISR_ENABLE_VPC3_INT_SERVICE_ERROR 0
- #if( INIT_VPC3_IND_L & 0x01 )
- #undef ISR_ENABLE_VPC3_INT_MAC_RESET
- #define ISR_ENABLE_VPC3_INT_MAC_RESET 1
- #endif
- #if( INIT_VPC3_IND_L & 0x02 )
- #undef ISR_ENABLE_VPC3_INT_GO_LEAVE_DATA_EX
- #define ISR_ENABLE_VPC3_INT_GO_LEAVE_DATA_EX 1
- #endif
- #if( INIT_VPC3_IND_L & 0x04 )
- #undef ISR_ENABLE_VPC3_INT_BAUDRATE_DETECT
- #define ISR_ENABLE_VPC3_INT_BAUDRATE_DETECT 1
- #endif
- #if( INIT_VPC3_IND_L & 0x08 )
- #undef ISR_ENABLE_VPC3_INT_WD_DP_TIMEOUT
- #define ISR_ENABLE_VPC3_INT_WD_DP_TIMEOUT 1
- #endif
- #if( INIT_VPC3_IND_L & 0x10 )
- #undef ISR_ENABLE_VPC3_INT_USER_TIMER_CLOCK
- #define ISR_ENABLE_VPC3_INT_USER_TIMER_CLOCK 1
- #endif
- #if( INIT_VPC3_IND_L & 0x20 )
- #undef ISR_ENABLE_VPC3_INT_DXB_LINK_ERROR
- #define ISR_ENABLE_VPC3_INT_DXB_LINK_ERROR 1
- #endif
- #if( INIT_VPC3_IND_L & 0x40 )
- #undef ISR_ENABLE_VPC3_INT_NEW_EXT_PRM_DATA
- #define ISR_ENABLE_VPC3_INT_NEW_EXT_PRM_DATA 1
- #endif
- #if( INIT_VPC3_IND_L & 0x80 )
- #undef ISR_ENABLE_VPC3_INT_DXB_OUT
- #define ISR_ENABLE_VPC3_INT_DXB_OUT 1
- #endif
- #if( INIT_VPC3_IND_H & 0x01 )
- #undef ISR_ENABLE_VPC3_INT_NEW_GC_COMMAND
- #define ISR_ENABLE_VPC3_INT_NEW_GC_COMMAND 1
- #endif
- #if( INIT_VPC3_IND_H & 0x02 )
- #undef ISR_ENABLE_VPC3_INT_NEW_SSA_DATA
- #define ISR_ENABLE_VPC3_INT_NEW_SSA_DATA 1
- #endif
- #if( INIT_VPC3_IND_H & 0x04 )
- #undef ISR_ENABLE_VPC3_INT_NEW_CFG_DATA
- #define ISR_ENABLE_VPC3_INT_NEW_CFG_DATA 1
- #endif
- #if( INIT_VPC3_IND_H & 0x08 )
- #undef ISR_ENABLE_VPC3_INT_NEW_PRM_DATA
- #define ISR_ENABLE_VPC3_INT_NEW_PRM_DATA 1
- #endif
- #if( INIT_VPC3_IND_H & 0x10 )
- #undef ISR_ENABLE_VPC3_INT_DIAG_BUF_CHANGED
- #define ISR_ENABLE_VPC3_INT_DIAG_BUF_CHANGED 1
- #endif
- #if( INIT_VPC3_IND_H & 0x20 )
- #undef ISR_ENABLE_VPC3_INT_DX_OUT
- #define ISR_ENABLE_VPC3_INT_DX_OUT 1
- #endif
- #if( INIT_VPC3_IND_H & 0x40 )
- #undef ISR_ENABLE_VPC3_INT_POLL_END_IND
- #define ISR_ENABLE_VPC3_INT_POLL_END_IND 1
- #endif
- #if( INIT_VPC3_IND_H & 0x80 )
- #undef ISR_ENABLE_VPC3_INT_FDL_IND
- #define ISR_ENABLE_VPC3_INT_FDL_IND 1
- #endif
- /*****************************************************************************/
- /* reinclude-protection */
- #else
- #pragma message "The header DP_CFG.H is included twice or more !"
- #endif
- /*****************************************************************************/
- /* Copyright (C) profichip GmbH 2004. Confidential. */
- /*****************************************************************************/