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

📄 pb_if.h

📁 profibus dp主站于从站通信
💻 H
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************/
/*                                                                           */
/*                                SOFTING AG                                 */
/*                        Richard-Reitzner-Allee 6                           */
/*                              D-85540 Haar                                 */
/*                      Phone: (++49)-(0)89-45656-0                          */
/*                      Fax:   (++49)-(0)89-45656-399                        */
/*                                                                           */
/*                    Copyright (C) SOFTING AG 1995-2007                     */
/*                            All Rights Reserved                            */
/*                                                                           */
/*****************************************************************************/
/*****************************************************************************/
/*                   PROFIBUS APPLICATION PROGRAM INTERFACE                  */
/*                                                                           */
/*  Filename    : PB_IF.H                                                    */
/*  Version     : 5.43.0.00.release                                          */
/*  Date        : 30-October-2007                                            */
/*  Author      : SOFTING AG                                                 */
/*                                                                           */
/*  Description : This file contains the extern function declarations,       */
/*                defines and types of the PROFIBUS Communication Interface  */
/*                                                                           */
/*****************************************************************************/

#ifndef __PB_IF__
#define __PB_IF__


#pragma warning (disable : 4103)     /* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,2)
#else
#pragma pack(2)
#endif
#pragma warning (default : 4103)


/**********************************************************************************/
/* INTERFACE DEFINES                                                              */
/**********************************************************************************/
/* contants for DeviceTypes -(only used for WinNT/Win2K-Interface) -------------- */
/* --- DP Devices --------------------------------------------------------------- */
#define DEVICE_DP_MANAGEMENT     1
#define DEVICE_DP_SERVICE        2
#define DEVICE_DP_SLAVE_DATA     3
#define DEVICE_DP_MSAC           9

/* --- FDL Devices -------------------------------------------------------------- */
#define DEVICE_FDL_MANAGEMENT    4
#define DEVICE_FDL_SAP           5

/* --- FMS Devices -------------------------------------------------------------- */
#define DEVICE_FMS_MANAGEMENT    6
#define DEVICE_FMS_CR            7

/* --- Basic Management Device -------------------------------------------------- */
#define DEVICE_BASIC_MANAGEMENT  8


/* --- contants for IRQ values --------------------------------                   */
#define REQ_IRQ                  0xF0                  /* IND/CON IRQ is received */
#define ACK_IRQ                  0x0F                      /* acknowledge REQ/RES */
#define DP_SLAVE_IO_REQ_IRQ      0xE0              /* MASTER: DP-SLAVE-IO IND/REQ */
#define DP_SLAVE_IO_ACK_IRQ      0x0E  /* MASTER: DP-SLAVE-IO acknowldege IND/REQ */
#define DP_DATA_STOP_REQ_IRQ     0xD0  /* MASTER: data transfer stop REQ received */
#define DP_DATA_STOP_ACK_IRQ     0x0D   /* MASTER: data transfer stop Acknowldege */
#define TRC_REQ_IRQ              0xC0                    /* TRACE REQ is received */
#define TRC_ACK_IRQ              0x0C                        /* TRACE acknowledge */
#define EXCEPTION_REQ_IRQ        0xB0                        /* Exception Request */
#define EXCEPTION_ACK_IRQ        0x0B                    /* Exception Acknowledge */
#define DPS_SLAVE_INP_REQ_IRQ    0xA0            /* SLAVE: DP-SLAVE-INPUT request */
#define DPS_SLAVE_INP_ACK_IRQ    0x0A        /* SLAVE: DP-SLAVE-INPUT Acknowldege */
#define DPS_SLAVE_OUTP_REQ_IRQ   0x90           /* SLAVE: DP-SLAVE-OUTPUT request */
#define DPS_SLAVE_OUTP_ACK_IRQ   0x09       /* SLAVE: DP-SLAVE-OUTPUT Acknowldege */

/* --- contants to receive an indication or confirmation ------------------------ */
#define CON_IND_RECEIVED    0x0001              /* ind. or con. has been received */
#define NO_CON_IND_RECEIVED 0x0000                   /* nothing has been received */

/* --- values > CON_IND_RECEIVED are error returns (see pb_err.h)  -------------- */

/* --- OK return value ---------------------------------------------------------- */
#define E_OK                0                                        /* no errors */
/* --- values != E_OK are error returns (see pb_err.h) -------------------------- */

/* --- service result ----------------------------------------------------------- */
#define NEG                 0x01                  /* result for negative response */
#define POS                 0x00                  /* result for positive response */

/* --- service priority --------------------------------------------------------- */
#define LOW                 0x00                                 /* high priority */
#define HIGH                0x01                                  /* low priority */


/* --- service primitives ------------------------------------------------------- */
#define REQ                 0x00                             /* request primitive */
#define CON                 0x01                        /* confirmation primitive */
#define IND                 0x02                          /* indication primitive */
#define RES                 0x03                            /* response primitive */
#define RET                 0x04      /* return primitive not used by application */

/* --- layer identifiers -------------------------------------------------------- */
#define USR                 0x00                               /* identifier USER */
#define FMS                 0x01                                /* identifier FMS */
#define LLI                 0x02                                /* identifier LLI */
#define FDL                 0x03                                /* identifier FDL */
#define FM7                 0x04                                /* identifier FM7 */
#define FMB                 0x05                                /* identifier FMB */
#define FMS_USR             0x06                           /* identifier FMS-USER */
#define FM7_USR             0x07                           /* identifier FM7-USER */
#define FMB_USR             0x08                           /* identifier FMB-USER */
#define DPS                 0x09                                /* identifier DPS */
#define DPS_USR             0x0A                           /* identifier DPS-USER */
#define DP                  0x0B                                 /* identifier DP */
#define DP_USR              0x0C                            /* identifier DP-USER */
#define FDLIF               0x0D                              /* identifier FDLIF */
#define FDLIF_USR           0x0E                         /* identifier FDLIF-USER */

#define PAPI                0xF0               /* identifier Application-Layer-IF */

#if (PB_VER < 500)
#define FMA7                FM7                                /* identifier FMA7 */
#define FMA2                FMB                                /* identifier FMA2 */
#define FMA7_USR            FM7_USR                       /* identifier FMA7-USER */
#endif


/* --- identifiers for data description interface ------------------------------- */
/* --- 0x00 - 0x3F used by FMS -- (no identifiers defined) ---------------------- */

/* --- 0x40 - 0x7F reserved by management -- (no identifiers defined) ----------- */

/* --- 0x80 - 0x9F reserved by DP ----------------------------------------------- */
/* --- DP-MASTER ---------------------------------------------------------------- */
#define ID_DP_SLAVE_IO_IMAGE         0x80     /* MASTER: image for slave io datas */
#define ID_DP_STATUS_IMAGE           0x81       /* MASTER: image for status datas */
#define ID_DP_SLAVE_IO_CONFIG_IMAGE  0x82     /* MASTER: DPRAM layout of slave io */

/* --- DP-SLAVE ----------------------------------------------------------------- */
#define ID_DPS_SLAVE_INPUT_IMAGE     0x90   /* SLAVE: image for slave input datas */
#define ID_DPS_SLAVE_OUTPUT_IMAGE    0x91  /* SLAVE: image for slave output datas */
/* ---                               0x92            /* reserved for internal use */

/* --- 0xA0 - 0xEF reserved for future use --- (no identifiers defined) --------- */

/* --- 0xF0 - 0xFF reserved for diagonsis  -------------------------------------- */
#define ID_EXCEPTION_IMAGE           0xF0             /* image for exeption datas */
#define ID_FW_VERS_IMAGE             0xF1           /* image for firmware version */
#define ID_SERIAL_DEVICE_NUMBER      0xF2      /* image for serial device number  */
#define ID_TRACE_IMAGE               0xF3                /* image for TRACE datas */

/* --- idebtifier for end of data description list ------------------------------ */
#define EOF_DATA_DESCR_LIST          0x00         /* end of data description list */


/**********************************************************************************/
/* PROFI SERVICE DESCRIPTION BLOCK                                                */
/**********************************************************************************/

typedef struct _T_PROFI_SERVICE_DESCR
{
  USIGN16     comm_ref;                                /* communication reference */
  USIGN8      layer;                                          /* layer identifier */
  USIGN8      service;                                      /* service identifier */
  USIGN8      primitive;                                     /* service primitive */
  INT8        invoke_id;                                             /* invoke id */
  INT16       result;                              /* service result (POS or NEG) */
} T_PROFI_SERVICE_DESCR;


#ifdef WIN16
/**********************************************************************************/
/* PROFI INITIALIZATION DATA STRUCTURE                                            */
/**********************************************************************************/
typedef struct _T_PROFI_INIT
{
  USIGN32      dpr_address;                                        /* DPR address */
  INT16        io_port_address;                                /* IO port address */
  PB_BOOL      load_firmware;   /* PB_TRUE  for PROFI-IF
                                   PB_FALSE for PROFIboard,PROFIcard and PROFI104 */
  USIGN8       time_out;                          /* time out interval in seconds */
  CSTRING      *loader_file;                       /* loader file (PROFI-IF only) */
  CSTRING      *firmware_file;                    /* firmware file (PROFI-IF only */
  USIGN8       host_type;                                     /* for internal use */
  USIGN8       irq_vector;                                    /* IRQ line to host */
  USIGN8       dpr_access_mode;                 /* DPR access mode (8/16 Bit ...) */
  USIGN8       address_mode;                                 /* host address mode */
  USIGN8       poll_int_mode;                             /* host POLL / IRQ mode */
  USIGN8       cntrl_type;                                    /* for internal use */
  USIGN8       token_drive;           /* indicates the token drive (only PROFI-IF)*/
  USIGN8       reserved_1;                                            /* reserved */
  USIGN16      reserved_2;                                            /* reserved */
  USIGN16      reserved_3;                                            /* reserved */
 } T_PROFI_INIT;

/* --- macro to set T_PROFI_INIT data structure with default values ------------  */
#define _SET_PROFI_INIT_DEF_PARAM(init_param,a,b)                            \
             init_param.dpr_address      = a;                                \
             init_param.load_firmware    = PB_FALSE;                         \
             init_param.io_port_address  = b;                                \
             init_param.irq_vector       = (USIGN8)   0x00;                  \
             init_param.dpr_access_mode  = (USIGN8)   0x03;                  \
             init_param.address_mode     = (USIGN8)   0x0C;                  \
             init_param.poll_int_mode    = (USIGN8)   0x00;                  \
             init_param.time_out         = (USIGN8)   0x03
#endif


/************************************************************************/
/* Global function declarations using for 16/32BIT PROFIBUS API and for */
/* compatibility mode using WIN-NT PROFIBUS API                         */
/************************************************************************/

#ifndef PB_API_FUNC_NOT_USED

#ifdef __cplusplus
  extern "C" {
#endif


#ifndef UNDER_RTSS
#ifdef  WIN32
FUNCTION extern INT16 CALL_CONV profi_set_default
         (
           IN USIGN8  Board,
           IN USIGN8  Channel,
           IN USIGN32 ReadTimeout,
           IN USIGN32 WriteTimeout
         )
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION

This function is used to initialize the WIN32 PROFIBUS-API. The function function
has to be called before any other function of PROFIBUS-API is called.

IN:  Board          -> number of the PROFIBUS board (0..9)
IN:  Channel        -> channel number (0)
IN:  ReadTimeout    -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN:  Writetimeout   -> send timeout in ms (WAIT_FOREVER for infinite wait)

Possible return values:
- E_OK                             -> Interface is initialized
- E_IF_NO_CNTRL_RES                -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION  -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER      -> invalid initialize parameter
- E_IF_INVALID_VERSION             -> invalid version
- E_IF_NO_CNTRL_PRESENT            -> no controller present
- E_IF_INIT_FAILED                 -> initialization failed

-----------------------------------------------------------------------------*/
;

FUNCTION extern INT16 CALL_CONV profi_init
         (
           IN USIGN8  Board,
           IN USIGN32 ReadTimeout,
           IN USIGN32 WriteTimeout
         )
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION

This function is used to initialize the WIN32 PROFIBUS-API. The function function
has to be called before any other function of PROFIBUS-API is called.

IN:  Board          -> number of the PROFIBUS board (0..9)
IN:  Channel        -> channel number (0)
IN:  ReadTimeout    -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN:  Writetimeout   -> send timeout in ms (WAIT_FOREVER for infinite wait)

Possible return values:
- E_OK                             -> Interface is initialized
- E_IF_NO_CNTRL_RES                -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION  -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER      -> invalid initialize parameter
- E_IF_INVALID_VERSION             -> invalid version
- E_IF_NO_CNTRL_PRESENT            -> no controller present
- E_IF_INIT_FAILED                 -> initialization failed

-----------------------------------------------------------------------------*/
;
#endif


FUNCTION extern INT16 CALL_CONV init_profibus
        (
          IN  USIGN32  DprAdress,
          IN  USIGN16  IoPortAdress,
          IN  PB_BOOL  Dummy
        )

/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION

This function is used initialize the PROFIBUS-API with default values and start
the PROFIBUS controller. The function function has to be called before any other
function of PROFIBUS-API is called.

IN:  DprAdress         -> dummy
IN:  IoPortAdress      -> dummy
IN:  Dummy             -> dummy

Possible return values:

- E_OK                             -> Interface is initialized
- E_IF_NO_CNTRL_RES                -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION  -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER      -> invalid initialize parameter
- E_IF_INVALID_VERSION             -> invalid version
- E_IF_NO_CNTRL_PRESENT            -> no controller present
- E_IF_INIT_FAILED                 -> initialization failed
-----------------------------------------------------------------------------*/
;



FUNCTION extern INT16 CALL_CONV profi_end(VOID)

/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION

This function is used to shutdown the PROFIBUS-API and shutdown the PROFIBUS
controller.

Possible return values:
- E_OK

-----------------------------------------------------------------------------*/
;



FUNCTION extern INT16 CALL_CONV profi_snd_req_res
         (
          IN T_PROFI_SERVICE_DESCR * pSdb,
          IN VOID                  * pData,
          IN PB_BOOL                 dummy
         )

/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION

This function is used to send a Service-Request or a Service-Response
to the PROFIBUS controller.

IN:  pSdb                  -> pointer to SERVICE-DESCRIPTION-BLOCK
IN:  pData                 -> pointer to service specific data
IN:  dummy                 -> dummy


Possible return values:

- E_OK                           -> no error occured

- E_IF_INVALID_LAYER             -> invalid layer
- E_IF_INVALID_SERVICE           -> invalid service identifier
- E_IF_INVALID_PRIMITIVE         -> invalid service primitive
- E_IF_RESOURCE_UNAVAILABLE      -> no resource available
- E_IF_NO_PARALLEL_SERVICES      -> no parallel services allowed
- E_IF_SERVICE_CONSTR_CONFLICT   -> service temporarily not executable
- E_IF_SERVICE_NOT_SUPPORTED     -> service not supported in subset
- E_IF_SERVICE_NOT_EXECUTABLE    -> service not executable

- E_IF_NO_CNTRL_RES              -> controller does not respond  (CMI_TIMEOUT)

⌨️ 快捷键说明

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