⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spc3dps2.h

📁 pROFIBUS 从站源程序 SPC3 pROFIBUS 从站源程序 SPC3
💻 H
📖 第 1 页 / 共 3 页
字号:
/*
+-----------------------------------------------------------------------------+
| Project: D P S 2   w i t h   S P C 3                                        |
|                                                                             |
| File:   SPC3DPS2.C                                                          |
| Date:   24-Mar-1997                                                         |
| Version: V 1.4                                                              |
| Initial Editor:   Thomas Lang                                               |
+-----------------------------------------------------------------------------+
| Description:                                                                |
|  This file contains the declarations, required for use of the SPC3 with     |
|  DPS2-Interface.                                                            |
|                                                                             |
| Before #include "SPC3DPS2.H" must be defined:                               |
|  #define SPC3_INTEL_MODE !=0: Intel-Interface                               |
|                          ==0: Motorola-Interface                            |
|                                                                             |
|  ======================== for  SAB C165: ================================   |
|   #define SPC3_FAR if the SPC3 is located in FAR-address space              |
|   #define SPC3_NEAR if the SPC3 is located in NEAR-address space            |
|                                                                             |
|  ======================= for iNTEL 8032: ===============================    |
|   #define SPC3_DATA_XDATA if user-data in xdata-space                       |
|   #define SPC3_DATA_IDATA if user-data in idata-space                       |
|                           else generic pointers are used                    |
|                                                                             |
|  ===========================  general  ===================================  |
| Before #include "SPC3DPS2.H" may be defined:                                |
|  #define SPC3_NO_BASE_TYPES: The types UBYTE, UWORD, BYTE and WORD will     |
|                              not be declared                                |
|                                                                             |
+-----------------------------------------------------------------------------+
| following environments are supported                                        |
|  Processor: SAB C165                                                        |
|   Compiler: BSO Tasking 80166 C Cross-Compiler, V 4.0                       |
|  Processor: iNTEL 8032                                                      |
|   Compiler: Keil                                                            |
+-----------------------------------------------------------------------------+
|                      Copyright (C) SIEMENS AG, 1994                         |
|                          all rights reserved                                |
+-----------------------------------------------------------------------------+
| History:													        |
| V1.0,LT, first official version									   |
| V1.3,MM,25-Mar-1997, translation                                            |
|                                                                             |
+-----------------------------------------------------------------------------+
| Technical support:       Siemens Schnittstellencenter                       |
|                          AUT7 WKF B1 TDL2                                   |
|                                                                             |
|   Schmidt Xaver                   Mittelberger Martin                       |
|   Tel.: 0911/750-2079             Tel.: 0911/750-2072					    |
|																    |
|                   Fax.:         -2100							     	|
|                   Mailbox: 0911/737972								    |
|																   |
+-----------------------------------------------------------------------------+
*/
#define SPC3_INTEL_MODE   TRUE 
#ifndef SPC3_H__   /* include only once */
#define SPC3_H__

#ifndef TRUE
  #define TRUE  1
#endif
#ifndef FALSE
  #define FALSE 0
#endif

#ifndef SPC3_INTEL_MODE
  #error !!! FEHLER !!! SPC3_INTEL_MODE wurde nicht deklariert !!!
#endif  /* Ende fuer SPC3_INTEL_MODE  */


/*+-------------------------------------------------------------------------+
  |    C o m p i l e r - d e p e n d e n d     D e f i n i t i o n s        |
  +-------------------------------------------------------------------------+*/

/*------------------------ BSO Tasking C166-Compiler ------------------------*/
#ifdef  _C166
  #define _INTEL_COMP   /* iNTEL-mode */
  #define SPC3_DATA_ATTR
  #ifndef SPC3_NO_BASE_TYPES
	#ifndef SPC3_BASE_TYPES_DEF__
	  typedef unsigned char UBYTE;
	  typedef unsigned int UWORD;
	  typedef char BYTE;
	  typedef int WORD;
	  #define SPC3_BASE_TYPES_DEF__
	#endif    /* end SPC3_BASE_TYPES_DEF__ */
  #endif    /* end SPC3_NO_BASE_TYPES */
  #ifdef  SPC3_FAR
	#define SPC3_PTR_ATTR far
	typedef unsigned long SPC3_ADTYP;
  #else
	#ifdef SPC3_NEAR
	  #define SPC3_PTR_ATTR near
	  typedef unsigned int SPC3_ADTYP;
	  typedef unsigned short SPC3_OFFS;
	#else
	  #error !!! ERROR !!! neither SPC3_FAR nor SPC3_NEAR defined !!!
	#endif    /* end SPC3_NEAR */
  #endif    /* end SPC3_FAR */
/*--------------------- end  BSO Tasking C166-Compiler ----------------------*/
/*--------------------------- Keil 80C32-Compiler ---------------------------*/
#elif defined __C51__   /* Motorola-mode */
  #ifndef SPC3_NO_BASE_TYPES
	#ifndef SPC3_BASE_TYPES_DEF__
	  typedef unsigned char UBYTE;
	  typedef unsigned int UWORD;
	  typedef char BYTE;
	  typedef int WORD;
	  #define SPC3_BASE_TYPES_DEF__
	#endif    /* end SPC3_BASE_TYPES_DEF__ */
  #endif    /* end SPC3_NO_BASE_TYPES */
  #define SPC3_PTR_ATTR xdata
  #ifdef SPC3_DATA_XDATA
	#define SPC3_DATA_ATTR xdata
  #else
	#ifdef SPC3_DATA_IDATA
	  #define SPC3_DATA_ATTR idata
	#else
	  #define SPC3_DATA_ATTR
	#endif
  #endif
  typedef unsigned int SPC3_ADTYP;
  typedef unsigned short SPC3_OFFS;
  typedef unsigned int SPC3_PTR;
/*------------------------ end Keil 80C32-Compiler -------------------------*/
#else /* no supported compiler found */
  #error  !!! ERROR !!! Unknown compiler !!!
#endif  /*-- end Compiler-dependent Declarations */

/*---------------------------- helpmakros ----------------------------------*/
/*-- byte-swapping --*/
#if SPC3_INTEL_MODE
  /*-- SPC3 with iNTEL-interface --*/
  #define _IML  0   /* Interface-Motorola, Low-Byte */
  #define _IMH  1   /* Interface-Motorola, High-Byte */
  #ifndef _INTEL_COMP
	/*-- iNTEL-interface, but no iNTEL-Compiler */
	#define _SWAP_WORDS   /* words must be swapped */
  #endif
#else
  /*-- SPC3 with Motorola-interface --*/
  #define _IML  1   /* Interface-Motorola, High-Byte */
  #define _IMH  0   /* Interface-Motorola, Low-Byte */
  #ifdef _INTEL_COMP
	/*-- Motorola-interface, but iNTEL-Compiler */
	#define _SWAP_WORDS   /* words must be swapped */
  #endif
#endif

#ifdef  _SWAP_WORDS
  #define SWAP_W(WX)  (((WX)<<8) | (((WX)>>8)&0xff))
#else
  #define SWAP_W(WX)  (WX)
#endif

/*-- use of spec prm buf (for dps2_buf_init) --*/
#ifdef  DPS2_USE_SPEC_PRM_BUF
  #define _USE_SPEC_PRM_BUF__ TRUE
#else
  #define _USE_SPEC_PRM_BUF__ FALSE
#endif

/*-- NULL-pointer in SPC3-compatible memory-model --*/
#define SPC3_NIL    ((void SPC3_PTR_ATTR*)0)

/*+-------------------------------------------------------------------------+
  |           T y p e d e f s   a n d   S t r u c t u r e s                 |
  +-------------------------------------------------------------------------+*/

/*-- returncodes of SPC3_INIT();函数的返回值 --*/
enum SPC3_INIT_RET {SPC3_INIT_OK, SPC3_INITF_LESS_MEM, SPC3_INITF_NOFF,
					DPS2_INITF_DIN_DOUT_LEN, DPS2_INITF_DIAG_LEN,
					DPS2_INITF_PRM_LEN, DPS2_INITF_CFG_LEN, DPS2_INITF_SSA_LEN,
					FDL_INITF_IVP, FDL_INITF_SCNT };/*-- 见.U --*/
typedef struct {
  UBYTE DPRAM_IN[1024]; 
  UBYTE DPRAM_OUT[1021]; 
                }DPRAM;

/*-- struktur of the SPC3 --*/
typedef struct {
  /*-- start of the processor-registers --*/
  union {                       /* 0x00: Int.-Request-Register */
	UWORD w;
	UBYTE b[2];
	} int_req;
  union {                       /* 0x02: */
	union {                     /*  Int.-Register (read) */
	  UWORD w;
	  UBYTE b[2];/*#   */           
	  } com;
	union {                     /*  Int.-Acknowledge-Reg. (write) */
	  UWORD w;
	  UBYTE b[2];
	  } ack;
	} int_reg;
  union {                       /* 0x04: Interrupt-Mask- and Status-Reg. */
	UWORD mask;                 /*  Interrupt-Mask-Register (write) */
	UBYTE status[2];            /*  Status-Register (read) */
	} is_reg;
  UWORD mode_reg0;              /* 0x06 */
  union {  /*-- union x1 is for R/W */
	struct {  /*-- read-area */
	  UBYTE din_buffer_sm;      /* 0x08 见Buffer assignment of the DP_Din_Buffer_State_Machine*/
	  UBYTE new_din_buf_cmd;    /* 0x09 见The user makes a new DP Din buffer available in the N state.*/
	  UBYTE dout_buffer_sm;     /* 0x0a 见Buffer assignment of theDP_Dout_Puffer_State_Machine*/
	  UBYTE next_dout_buf_cmd;  /* 0x0b 见The user fetches the last DP Dout-Buffer from the N state.*/
	  } r;
	struct {  /*-- write-area */
	  UBYTE mode_reg1_s;        /* 0x08 */
	  UBYTE mode_reg1_r;        /* 0x09 */
	  UBYTE wd_baud_ctrl_val;   /* 0x0a Root value for baud rate monitoring*/
	  UBYTE mintsdr_val;        /* 0x0b MinTsdr time*/
	  } w;
	} x1;
  UBYTE diag_buffer_sm;         /* 0x0c */
  UBYTE new_diag_buffer_cmd;    /* 0x0d */
  UBYTE user_prm_data_ok;       /* 0x0e */
  UBYTE user_prm_data_nok;      /* 0x0f */
  UBYTE user_cfg_data_ok;       /* 0x10 */
  UBYTE user_cfg_data_nok;      /* 0x11 */
  UBYTE user_ddb_prm_data_ok;   /* 0x12 */
  UBYTE user_ddb_prm_data_nok;  /* 0x13 */
  UBYTE ssa_buffer_free_cmd;    /* 0x14 */
  UBYTE reserved_15;            /* 0x15 */
  /*-- start of the organizational parameters 组织参数区--*/
  UBYTE r_ts_adr;               /* 0x16 */
  UBYTE r_fdl_sap_list_ptr;     /* 0x17 */
  UWORD r_user_wd_value;        /* 0x18 */
  UBYTE r_len_dout_buf;         /* 0x1a */
  UBYTE r_dout_buf_ptr[3];      /* 0x1b */
  UBYTE r_len_din_buf;          /* 0x1e */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -