dp_if.h
上传用户:hualang
上传日期:2022-04-11
资源大小:104k
文件大小:107k
开发平台:

C/C++

  1. /************************** Filename: dp_if.h ********************************/
  2. /* ========================================================================= */
  3. /*                                                                           */
  4. /* 0000  000   000  00000 0  000  0   0 0 0000                               */
  5. /* 0   0 0  0 0   0 0     0 0   0 0   0 0 0   0                              */
  6. /* 0   0 0  0 0   0 0     0 0     0   0 0 0   0      Einsteinstra遝 6        */
  7. /* 0000  000  0   0 000   0 0     00000 0 0000       91074 Herzogenaurach    */
  8. /* 0     00   0   0 0     0 0     0   0 0 0                                  */
  9. /* 0     0 0  0   0 0     0 0   0 0   0 0 0          Tel: ++49-9132-744-200  */
  10. /* 0     0  0  000  0     0  000  0   0 0 0    GmbH  Fax: ++49-9132-744-204  */
  11. /*                                                                           */
  12. /* ========================================================================= */
  13. /*                                                                           */
  14. /* Description: VPC3+ structure.                                             */
  15. /*                                                                           */
  16. /* ------------------------------------------------------------------------- */
  17. /*                                                                           */
  18. /* Technical support:       P. Fredehorst                                    */
  19. /*                          Tel. : ++49-9132/744-214                         */
  20. /*                          Fax. :              -204                         */
  21. /*                          eMail: pfredehorst@profichip.com                 */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24. /*****************************************************************************/
  25. /* contents:
  26.     1.0 VPC3+
  27.     1.1     - register structure of VPC3+
  28.     1.2     - literals for interrupt register
  29.     1.3     - literals for status register
  30.     1.4     - literals for mode register 0
  31.     1.5     - literals for mode register 1
  32.     1.6     - literals for mode register 2
  33.     1.7     - basic macros for VPC3+
  34.     2.0 - prm data
  35.     2.1     - structure of prm data
  36.     2.2     - literals for DPV1 Status 1
  37.     2.3     - literals for DPV1 Status 2
  38.     2.4     - literals for DPV1 Status 3
  39.     2.5     - general defines for prm data
  40.     2.6     - literals for structured prm data
  41.     2.7     - returncodes for prm data
  42.     2.8     - macros for prm data
  43.     3.0 - cfg data
  44.     3.1     - standard format of cfg byte
  45.     3.2     - special format of cfg byte
  46.     3.3     - literals for cfg byte
  47.     3.4     - returncodes for cfg data
  48.     3.5     - literals for chk config data
  49.     3.6     - macros for cfg data
  50.     3.7     - structure for real cfg data
  51.     4.0 - input / output
  52.     4.1     - structure for calculated input-/output-length
  53.     4.2     - states for output buffer
  54.     4.3     - macros for input buffer
  55.     5.0 - set slave address
  56.     5.1     - structure
  57.     5.2     - macros
  58.     6.0 - global control telegram
  59.     6.1     - defines for GLOBAL CONTROL
  60.     6.2     - macros for global control
  61.     7.0 - diagnostic telegram
  62.     7.1     - defines
  63.     7.2     - structures
  64.     7.3     - macros
  65.     8.0 - subscriber
  66.     8.1     - structures
  67.     8.2     - macros
  68.     9.0 - isochron mode
  69.     9.1     - defines
  70.     9.2     - structures
  71.    10.0 - fdl layer
  72.    10.1     - SAPs (service access points) for MSAC1
  73.    10.2     - SAPs (service access points) for MSAC2
  74.    10.3     - structure of a FDL-indication-response-buffer-head
  75.    10.4     - structure of a FDL-sap-entry
  76.    10.5     - structure of a sap-control-block
  77.    10.6     - structure of a indication- or response-buffer
  78.    10.7     - structure of the immediate-response-pdu of the FDL-RM-SAP
  79.    10.8     - global structure of FDL state machine
  80.    10.9     - function-codes
  81.    10.A     - returncodes of FDL-services
  82.    10.B     - helpful macros
  83.    11.0 - DPV1
  84.    11.1     - return codes for DPV1 services
  85.    11.2     - errorcodes of DPV1 for ERROR_DECODE
  86.    11.3     - errorcodes of DPV1 for ERROR_CODE_1
  87.    11.4     - coding of abort
  88.    11.5     - Function Codes for DPV1
  89.    11.6     - general defines for DPV1
  90.    11.7     - structures for DPV1
  91.    11.8     - defines for ALARM
  92.    11.9     - structure of ALARM
  93.    12.0 - global system structure
  94.    13.0 - ERROR defines
  95. */
  96. /*****************************************************************************/
  97. /* reinclude protection */
  98. #ifndef DP_IF_H
  99. #define DP_IF_H
  100. #define BLACKFINDATATYPE unsigned char //UWORD
  101. #define BLACKFIN_WORDPTR BLACKFINDATATYPE*
  102. #define BLACKFINWORD     ULONG
  103. typedef struct  
  104. {
  105. struct
  106. {
  107. BLACKFINDATATYPE status;                   // 7E0H, FE0H
  108. BLACKFINDATATYPE command;
  109. BLACKFINDATATYPE cv_status1;
  110. BLACKFINDATATYPE cv_status2;
  111. BLACKFINDATATYPE cv_time_event[8];
  112. BLACKFINDATATYPE rd_time[4];
  113. BLACKFINDATATYPE cv_prev_time_event[8];    // 7F0H
  114. BLACKFINDATATYPE sync_interval[2];         // 7F8H
  115. }clock;
  116. BLACKFINDATATYPE reserved[2];                  // 7FAH
  117. BLACKFINDATATYPE error_cnt[4];                 // 7FCH     error counter
  118. // 7FDH
  119. // 7FEH
  120. // 7FFH
  121. }TClockSync;
  122. /*-----------------------------------------------------------------------------------------------------------*/
  123. /* 1.0 vpc3+                                                                                                 */
  124. /*-----------------------------------------------------------------------------------------------------------*/
  125. /*---------------------------------------------------------------------------*/
  126. /* 1.1 register structure of vpc3+                                           */
  127. /*---------------------------------------------------------------------------*/
  128. typedef struct
  129. {
  130.                                         // address  register
  131.                                         // -------------------------------------------------------------------
  132.     BLACKFINDATATYPE int_req1;                     // 000H     Interrupt request register 1
  133.     BLACKFINDATATYPE int_req2;                     // 001H     Interrupt request register 2
  134.     union
  135.     {
  136.         struct
  137.         {                               // [read]
  138.             BLACKFINDATATYPE int_reg1;             // 002H     Interrupt register 1
  139.             BLACKFINDATATYPE int_reg2;             // 003H     Interrupt register 2
  140.             BLACKFINDATATYPE status_L;             // 004H     status register b0..b7
  141.             BLACKFINDATATYPE status_H;             // 005H     status register b8..b15
  142.         }rd;
  143.         struct
  144.         {                               // [write]
  145.             BLACKFINDATATYPE int_ack1;             // 002H     Interrupt acknowledge register 1
  146.             BLACKFINDATATYPE int_ack2;             // 003H     Interrupt acknowledge register 2
  147.             BLACKFINDATATYPE int_mask_L;           // 004H     Interrupt mask register b0..b7
  148.             BLACKFINDATATYPE int_mask_H;           // 005H     Interrupt mask register b8..b15
  149.         }wr;
  150.     } isreg;
  151.     BLACKFINDATATYPE mode_reg0_L;                  // 006H     mode register0 b0..b7
  152.     BLACKFINDATATYPE mode_reg0_H;                  // 007H     mode register0 b8..b15
  153.     union
  154.     {
  155.         struct
  156.         {                               //          [read]
  157.             BLACKFINDATATYPE din_buffer_sm;        // 008H     buffer assignment of the DP_DIN_BUFFER state machine
  158.             BLACKFINDATATYPE new_din_buf_cmd;      // 009H     the user makes a new DP_DIN_BUFFER available in the N state
  159.             BLACKFINDATATYPE dout_buffer_sm;       // 00AH     buffer assignment of the DP_DOUT_BUFFER state machine
  160.             BLACKFINDATATYPE next_dout_buf_cmd;    // 00BH     the user fetches the last DP_DOUT_BUFFER from the N state
  161.             BLACKFINDATATYPE diag_buffer_sm;       // 00CH     buffer assignment for DP_DIAG_BUFFER state machine
  162.             BLACKFINDATATYPE new_diag_buf_cmd;     // 00DH     the user makes a new DP_DIAG_BUFFER available to the VPC3+
  163.             BLACKFINDATATYPE user_prm_data_ok;     // 00EH     positive acknowledge for received user parameter data
  164.             BLACKFINDATATYPE user_prm_data_nok;    // 00FH     negative acknowledge for received user parameter data
  165.             BLACKFINDATATYPE user_cfg_data_ok;     // 010H     positive acknowledge for received config data
  166.             BLACKFINDATATYPE user_cfg_data_nok;    // 011H     negative acknowledge for received config data
  167.             BLACKFINDATATYPE dxbout_buffer_sm;     // 012H     buffer assignment of the DXB_OUT_BUFFER state machine
  168.             BLACKFINDATATYPE next_dxb_buf_cmd;     // 013H     the user fetches the last DXB_OUT_BUFFER
  169.             BLACKFINDATATYPE ssa_buf_free_cmd;     // 014H     the user has fetched data from ssa buffer and enables buffer again
  170.             BLACKFINDATATYPE mode_reg1;            // 015H     current value of mode_reg1
  171.         } rd;
  172.         struct
  173.         {                               //          [write]
  174.             BLACKFINDATATYPE mode_reg1_s;          // 008H     set b0..b7 in mode_reg1
  175.             BLACKFINDATATYPE mode_reg1_r;          // 009H     reset b0..b7 in mode_reg1
  176.             BLACKFINDATATYPE wd_baud_ctrl;         // 00AH     root value for baud rate monitoring
  177.             BLACKFINDATATYPE mintsdr;              // 00BH     MinTsdr time
  178.             BLACKFINDATATYPE mode_reg2;            // 00CH     set b0..b7 in mode_reg2
  179.             BLACKFINDATATYPE sync_pw_reg;          // 00DH     sync pulse width register
  180.             BLACKFINDATATYPE sync_mode;            // 00EH
  181.             BLACKFINDATATYPE sync_group;           // 00FH
  182.             BLACKFINDATATYPE controlbyte_mask;     // 010H
  183.             BLACKFINDATATYPE groupselect_mask;     // 011H
  184.             BLACKFINDATATYPE reserved_12;          // 012H
  185.             BLACKFINDATATYPE reserved_13;          // 013H
  186.             BLACKFINDATATYPE reserved_14;          // 014H
  187.             BLACKFINDATATYPE reserved_15;          // 015H
  188.         } wr;
  189.    }ctrl_reg;
  190.    BLACKFINDATATYPE slave_addr;                    // 016H     setup VPC3+ station address
  191.    BLACKFINDATATYPE fdl_sap_list_ptr;              // 017H     pointer fdl_sap_list
  192.    BLACKFINDATATYPE user_wd_value[2];              // 018H     user watchdog value b0..b7
  193.                                         // 019H     user watchdog value b8..b15
  194.    BLACKFINDATATYPE len_dout_buf;                  // 01AH     length of dout buffers
  195.    BLACKFINDATATYPE dout_buf_ptr[3];               // 01BH     segment base address of dout_buffer [0]
  196.                                         // 01CH     segment base address of dout_buffer [1]
  197.                                         // 01DH     segment base address of dout_buffer [2]
  198.    BLACKFINDATATYPE len_din_buf;                   // 01EH     length of din buffers
  199.    BLACKFINDATATYPE din_buf_ptr[3];                // 01FH     segment base address of din_buffer [0]
  200.                                         // 020H     segment base address of din_buffer [1]
  201.                                         // 021H     segment base address of din_buffer [2]
  202.    BLACKFINDATATYPE len_dxb_out_buf;               // 022H     length of dxb buffers
  203.    BLACKFINDATATYPE dxb_out_buf_ptr1;              // 023H     segment base address of dxbout_buffer1
  204.    BLACKFINDATATYPE len_diag_buf[2];               // 024H     length of diag buffers [0]
  205.                                         // 025H     length of diag buffers [1]
  206.    BLACKFINDATATYPE diag_buf_ptr[2];               // 026H     segment base address of diag_buffer [0]
  207.                                         // 027H     segment base address of diag_buffer [1]
  208.    BLACKFINDATATYPE len_ctrl_buf[2];               // 028H     length of aux buffer 1
  209.                                         // 029H     length of aux buffer 2
  210.    BLACKFINDATATYPE aux_buf_sel;                   // 02AH     assignment for aux buffers 1/2
  211.    BLACKFINDATATYPE aux_buf_ptr[2];                // 02BH     segment base address of aux buffer 1
  212.                                         // 02CH     segment base address of aux buffer 2
  213.    BLACKFINDATATYPE len_ssa_buf;                   // 02DH     length of SET_SLAVE_ADDRESS buffer
  214.    BLACKFINDATATYPE ssa_buf_ptr;                   // 02EH     segment base address of SET_SLAVE_ADDRESS buffer
  215.    BLACKFINDATATYPE len_prm_data;                  // 02FH     max. length of input data in SET_PRM buffer
  216.    BLACKFINDATATYPE prm_buf_ptr;                   // 030H     segment base address of SET_PRM buffer
  217.    BLACKFINDATATYPE len_cfg_data;                  // 031H     length of input data in the CHECK_CONFIG buffer
  218.    BLACKFINDATATYPE cfg_buf_ptr;                   // 032H     segment base address of CHECK_CONFIG buffer
  219.    BLACKFINDATATYPE len_read_cfg_data;             // 033H     length of input data in the GET_CONFIG buffer
  220.    BLACKFINDATATYPE read_cfg_buf_ptr;              // 034H     segment base address of GET_CONFIG buffer
  221.    BLACKFINDATATYPE len_dxb_link_table_buf;        // 035H     length of dxb link table buffer
  222.    BLACKFINDATATYPE dxb_link_table_buf_ptr;        // 036H     segment base address of dxb link table buffer
  223.    BLACKFINDATATYPE len_dxb_link_status_buf;       // 037H     length of dxb link status buffer
  224.    BLACKFINDATATYPE dxb_link_status_buf_ptr;       // 038H     segment base address of dxb link status buffer
  225.    BLACKFINDATATYPE real_no_add_change;            // 039H     address changes
  226.    BLACKFINDATATYPE ident_low;                     // 03AH     IDENT_LOW
  227.    BLACKFINDATATYPE ident_high;                    // 03BH     IDENT_HIGH
  228.    BLACKFINDATATYPE gc_command;                    // 03CH     last global control command
  229.    BLACKFINDATATYPE len_spec_prm_buf;              // 03DH     length of SPEC_PRM buffer
  230.    BLACKFINDATATYPE dxb_out_buf_ptr2;              // 03EH     segment base address of dxbout_buffer2
  231.    BLACKFINDATATYPE dxb_out_buf_ptr3;              // 03FH     segment base address of dxbout_buffer3
  232.    BLACKFINDATATYPE sap_ctrl_list[SAP_LENGTH];     // 040H     SAP CONTROL BLOCK LIST
  233.    BLACKFINDATATYPE dpbuffer[ASIC_USER_RAM - SIZE_TIMESTAMP];       // VPC3: 040H...7F0H: ram area for dp buffers
  234.                                         // SPC3: 040H...5F0H
  235.  #ifdef DP_TIMESTAMP
  236.       TClockSync cs;
  237.  #endif//#ifdef DP_TIMESTAMP
  238. }  VPC3_STRUC;
  239. #define VPC3_STRUC_PTR    VPC3_STRUC VPC3_PTR
  240. extern VPC3_STRUC_PTR           p_Vpc3[MAX_DEV_NUM];     // structure for vpc3+
  241. /*---------------------------------------------------------------------------*/
  242. /* 1.2 literals for interrupt register                                       */
  243. /*---------------------------------------------------------------------------*/
  244. //low Byte
  245. #define VPC3_INT_MAC_RESET              ( ( UBYTE)0x01)  // VPC3 in offline state
  246. #define VPC3_INT_GO_LEAVE_DATA_EX       ( ( UBYTE)0x02)  // VPC3 has entered or left DATA_EX
  247. #define VPC3_INT_BAUDRATE_DETECT        ( ( UBYTE)0x04)  // VPC3 has detected Baudrate
  248. #define VPC3_INT_WD_DP_TIMEOUT          ( ( UBYTE)0x08)  // DP watchdog timeout
  249. #define VPC3_INT_USER_TIMER_CLOCK       ( ( UBYTE)0x10)  // time base for USER_TIMER_CLOCKS has run out
  250. #define VPC3_INT_DXB_LINK_ERROR         ( ( UBYTE)0x20)  // subscriber link error
  251. #define VPC3_INT_NEW_EXT_PRM_DATA       ( ( UBYTE)0x40)  // New EXT_PRM_DATA received
  252. #define VPC3_INT_DXB_OUT                ( ( UBYTE)0x80)  // NEW subscriber data received
  253. //high Byte
  254. #define VPC3_INT_NEW_GC_COMMAND         ( ( UBYTE)0x01)  // New Global control command received
  255. #define VPC3_INT_NEW_SSA_DATA           ( ( UBYTE)0x02)  // New SSA_DATA received
  256. #define VPC3_INT_NEW_CFG_DATA           ( ( UBYTE)0x04)  // New check_config received
  257. #define VPC3_INT_NEW_PRM_DATA           ( ( UBYTE)0x08)  // New prm_data received
  258. #define VPC3_INT_DIAG_BUF_CHANGED       ( ( UBYTE)0x10)  // diag_buffer has been changed
  259. #define VPC3_INT_DX_OUT                 ( ( UBYTE)0x20)  // New DOut_data received
  260. #define VPC3_INT_POLL_END_IND           ( ( UBYTE)0x40)  // DPV1
  261. #define VPC3_INT_FDL_IND                ( ( UBYTE)0x80)  // DPV1
  262. // -- events for interrupt event handler --------------------------------------
  263. #define VPC3_EV_MAC_RESET               ( ( UWORD)0x0001)
  264. #define VPC3_EV_GO_LEAVE_DATA_EX        ( ( UWORD)0x0002)
  265. #define VPC3_EV_BAUDRATE_DETECT         ( ( UWORD)0x0004)
  266. #define VPC3_EV_WD_DP_TIMEOUT           ( ( UWORD)0x0008)
  267. #define VPC3_EV_USER_TIMER_CLOCK        ( ( UWORD)0x0010)
  268. #define VPC3_EV_DXB_LINK_ERROR          ( ( UWORD)0x0020)
  269. #define VPC3_EV_NEW_EXT_PRM_DATA        ( ( UWORD)0x0040)
  270. #define VPC3_EV_DXB_OUT                 ( ( UWORD)0x0080)
  271. #define VPC3_EV_NEW_GC_COMMAND          ( ( UWORD)0x0100)
  272. #define VPC3_EV_NEW_SSA_DATA            ( ( UWORD)0x0200)
  273. #define VPC3_EV_NEW_CFG_DATA            ( ( UWORD)0x0400)
  274. #define VPC3_EV_NEW_PRM_DATA            ( ( UWORD)0x0800)
  275. #define VPC3_EV_DIAG_BUF_CHANGED        ( ( UWORD)0x1000)
  276. #define VPC3_EV_DX_OUT                  ( ( UWORD)0x2000)
  277. #define VPC3_EV_RESERVED                ( ( UWORD)0x4000)
  278. #define VPC3_EV_NEW_INPUT_DATA          ( ( UWORD)0x8000)
  279. /*---------------------------------------------------------------------------*/
  280. /* 1.3 literals for status register                                          */
  281. /*---------------------------------------------------------------------------*/
  282. #define VPC3_PASS_IDLE                  ( ( UBYTE)0x01)
  283. #define VPC3_DIAG_FLAG                  ( ( UBYTE)0x04)
  284. #define WAIT_PRM                        ( ( UBYTE)0x00)
  285. #define WAIT_CFG                        ( ( UBYTE)0x10)
  286. #define DATA_EX                         ( ( UBYTE)0x20)
  287. #define DP_ERROR                        ( ( UBYTE)0x30)
  288. #define BAUD_SEARCH                     ( ( UBYTE)0x00)
  289. #define BAUD_CONTROL                    ( ( UBYTE)0x40)
  290. #define DP_MODE                         ( ( UBYTE)0x80)
  291. #define WD_ERROR                        ( ( UBYTE)0xC0)
  292. #define BAUDRATE_MASK                   ( ( UBYTE)0x0F)
  293. #define BAUDRATE_12MBAUD                ( ( UBYTE)0x00)
  294. #define BAUDRATE_6MBAUD                 ( ( UBYTE)0x01)
  295. #define BAUDRATE_3MBAUD                 ( ( UBYTE)0x02)
  296. #define BAUDRATE_1_5MBAUD               ( ( UBYTE)0x03)
  297. #define BAUDRATE_500KBAUD               ( ( UBYTE)0x04)
  298. #define BAUDRATE_187_50KBAUD            ( ( UBYTE)0x05)
  299. #define BAUDRATE_93_75KBAUD             ( ( UBYTE)0x06)
  300. #define BAUDRATE_45_45KBAUD             ( ( UBYTE)0x07)
  301. #define BAUDRATE_19_20KBAUD             ( ( UBYTE)0x08)
  302. #define BAUDRATE_9_60KBAUD              ( ( UBYTE)0x09)
  303. #define BAUDRATE_AFTER_RESET            ( ( UBYTE)0xFF)
  304. #define AT_MASK                         ( ( UBYTE)0xF0)
  305. #define AT_VPC3                         ( ( UBYTE)0x00)
  306. #define AT_VPC3B                        ( ( UBYTE)0xB0)
  307. #define AT_VPC3C                        ( ( UBYTE)0xC0)
  308. #define AT_MPI12X ( ( UBYTE)0xD0)
  309. /*---------------------------------------------------------------------------*/
  310. /* 1.4 literals for mode register 0                                          */
  311. /*---------------------------------------------------------------------------*/
  312. //low Byte
  313. #define VPC3_DIS_START_CTRL             ( ( UBYTE)0x01)
  314. #define VPC3_DIS_STOP_CTRL              ( ( UBYTE)0x02)
  315. #define VPC3_FDL_DBB                    ( ( UBYTE)0x04)
  316. #define VPC3_MINTSDR                    ( ( UBYTE)0x08)
  317. #define VPC3_INT_POL_HIGH               ( ( UBYTE)0x10)
  318. #define VPC3_EARLY_RDY                  ( ( UBYTE)0x20)
  319. #define VPC3_SYNC_SUPP                  ( ( UBYTE)0x40)
  320. #define VPC3_FREEZE_SUPP                ( ( UBYTE)0x80)
  321. //high Byte
  322. #define VPC3_DP_MODE                    ( ( UBYTE)0x01)
  323. #define VPC3_EOI_TBASE_1ms              ( ( UBYTE)0x02)
  324. #define VPC3_USR_TBASE_10ms             ( ( UBYTE)0x04)
  325. #define VPC3_WD_TEST                    ( ( UBYTE)0x08)
  326. #define VPC3_SPEC_PRM_BUF_MODE          ( ( UBYTE)0x10)
  327. #define VPC3_SPEC_CLR_MODE              ( ( UBYTE)0x20)
  328. /*---------------------------------------------------------------------------*/
  329. /* 1.5 literals for mode register 1                                          */
  330. /*---------------------------------------------------------------------------*/
  331. #define VPC3_START                      ( ( UBYTE)0x01)
  332. #define VPC3_EOI                        ( ( UBYTE)0x02)
  333. #define VPC3_GO_OFFLINE                 ( ( UBYTE)0x04)
  334. #define VPC3_USER_LEAVE_MASTER          ( ( UBYTE)0x08)
  335. #define VPC3_EN_CHG_CFG_BUFFER          ( ( UBYTE)0x10)
  336. #define VPC3_RES_USER_WD                ( ( UBYTE)0x20)
  337. /*---------------------------------------------------------------------------*/
  338. /* 1.6 literals for mode register 2                                          */
  339. /*---------------------------------------------------------------------------*/
  340. #define VPC3_GC_INT_MODE                ( ( UBYTE)0x01)
  341. #define VPC3_NO_CHECK_GC_RESERVED       ( ( UBYTE)0x02)
  342. #define VPC3_DX_INT_MODE                ( ( UBYTE)0x04)
  343. #define VPC3_DX_INT_PORT                ( ( UBYTE)0x08)
  344. #define VPC3_SYNC_ENA                   ( ( UBYTE)0x10)
  345. #define VPC3_SYNC_POL                   ( ( UBYTE)0x20)
  346. #define VPC3_NO_CHECK_PRM_RESERVED      ( ( UBYTE)0x40)
  347. #define VPC3_4KB_MODE                   ( ( UBYTE)0x80)
  348. /*---------------------------------------------------------------------------*/
  349. /* 1.7 basic macros for VPC3+                                                */
  350. /*---------------------------------------------------------------------------*/
  351. // Startaddress of User-Area in VPC3-Format -----------------------------------
  352. #define VPC3_DP_BUF_START(dev_num) (UBYTE)(((VPC3_ADR)&p_Vpc3[dev_num]->dpbuffer - (VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num)) >> BLACKFIN_SEG_MULDIV)
  353. // Startaddress of FDL-List-Area in VPC3-Format -------------------------------
  354. #define VPC3_SAP_CTRL_LIST_START(dev_num) (UBYTE)(((VPC3_ADR)&p_Vpc3[dev_num]->sap_ctrl_list - (VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num)) >> BLACKFIN_SEG_MULDIV)
  355. // set HW-Mode ----------------------------------------------------------------
  356. #define VPC3_SET_HW_MODE_HIGH(dev_num,MODE_HIGH) p_Vpc3[dev_num]->mode_reg0_H = MODE_HIGH
  357. #define VPC3_SET_HW_MODE_LOW(dev_num,MODE_LOW)   p_Vpc3[dev_num]->mode_reg0_L = MODE_LOW
  358. // set interrupt indications --------------------------------------------------
  359. #define VPC3_SET_INDICATIONS_HIGH(dev_num,IND_HIGH) p_Vpc3[dev_num]->isreg.wr.int_mask_H = IND_HIGH
  360. #define VPC3_SET_INDICATIONS_LOW(dev_num,IND_LOW)   p_Vpc3[dev_num]->isreg.wr.int_mask_L = IND_LOW
  361. // -- Set Slave-Adresse -------------------------------------------------------
  362. #define VPC3_SET_STATION_ADDRESS(dev_num,ADDRESS) p_Vpc3[dev_num]->slave_addr = ADDRESS
  363. #define VPC3_GET_STATION_ADDRESS(dev_num)        p_Vpc3[dev_num]->slave_addr
  364. // -- Set min_TSDR ------------------------------------------------------------
  365. #define VPC3_SET_MINTSDR(dev_num,MINTSDR) p_Vpc3[dev_num]->ctrl_reg.wr.mintsdr = MINTSDR
  366. // -- Set Baud Control --------------------------------------------------------
  367. #define VPC3_SET_BAUD_CNTRL(dev_num,VALUE) p_Vpc3[dev_num]->ctrl_reg.wr.wd_baud_ctrl = VALUE
  368. //-- Ident-Nummer -------------------------------------------------------------
  369. //-- Set Ident-Number ---------------------------------------------------------
  370. #define VPC3_SET_IDENT_NUMBER_LOW(dev_num,NR) p_Vpc3[dev_num]->ident_low = NR
  371. #define VPC3_SET_IDENT_NUMBER_HIGH(dev_num,NR) p_Vpc3[dev_num]->ident_high = NR
  372. // -- address change service --------------------------------------------------
  373. #define VPC3_SET_ADD_CHG_DISABLE(dev_num) p_Vpc3[dev_num]->real_no_add_change  = 0xFF
  374. #define VPC3_SET_ADD_CHG_ENABLE(dev_num)  p_Vpc3[dev_num]->real_no_add_change  = 0x00
  375. //-- start VPC3 ---------------------------------------------------------------
  376. #define START_VPC3__(dev_num) p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_s = VPC3_START
  377. #define RESET_START_VPC3(dev_num) p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_r = VPC3_START
  378. //-- set VPC3 offline ---------------------------------------------------------
  379. #define GO_OFFLINE_VPC3(dev_num)  p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_s = VPC3_GO_OFFLINE
  380. // -- read State of DP-State Machine ------------------------------------------
  381. #define VPC3_GET_DP_STATE(dev_num) (p_Vpc3[dev_num]->isreg.rd.status_L & 0x30)
  382. // -- read WD-State Machine ---------------------------------------------------
  383. #define VPC3_GET_WD_STATE(dev_num) (p_Vpc3[dev_num]->isreg.rd.status_L & 0xC0)
  384. // -- read Baud-Rate ----------------------------------------------------------
  385. #define VPC3_GET_BAUDRATE(dev_num) (p_Vpc3[dev_num]->isreg.rd.status_H & BAUDRATE_MASK)
  386. // -- read ASIC-Type ----------------------------------------------------------
  387. #define VPC3_GET_ASIC_TYPE(dev_num) (p_Vpc3[dev_num]->isreg.rd.status_H & AT_MASK)
  388. // -- read VPC3-Offline/Passiv-Idle-State -------------------------------------
  389. #define VPC3_GET_OFF_PASS(dev_num)  (p_Vpc3[dev_num]->isreg.rd.status_L & VPC3_PASS_IDLE)
  390. // -- set DP StateMachine to WAIT_PRM -----------------------------------------
  391. #define VPC3_SET_USER_LEAVE_MASTER(dev_num) p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_s = VPC3_USER_LEAVE_MASTER
  392. // -- User-Watchdog -----------------------------------------------------------
  393. #define VPC3_SET_USER_WD_VALUE_HIGH(dev_num,VALUE_HIGH) p_Vpc3[dev_num]->user_wd_value[1] = VALUE_HIGH
  394. #define VPC3_SET_USER_WD_VALUE_LOW(dev_num,VALUE_LOW)   p_Vpc3[dev_num]->user_wd_value[0] = VALUE_LOW
  395. // -- Reset User-Watchdog -----------------------------------------------------
  396. #define VPC3_RESET_USER_WD(dev_num) p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_s = VPC3_RES_USER_WD
  397. // -- read out reasons for indications ( vpc3_neta_isr() vpc3_netb_isr()) --------------------------
  398. #define VPC3_GET_IND_MAC_RESET(dev_num)        (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_MAC_RESET)
  399. #define VPC3_GET_IND_GO_LEAVE_DATA_EX(dev_num) (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_GO_LEAVE_DATA_EX)
  400. #define VPC3_GET_IND_BAUDRATE_DETECT(dev_num)  (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_BAUDRATE_DETECT)
  401. #define VPC3_GET_IND_WD_DP_TIMEOUT(dev_num)    (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_WD_DP_TIMEOUT)
  402. #define VPC3_GET_IND_USER_TIMER_CLOCK(dev_num) (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_USER_TIMER_CLOCK)
  403. #define VPC3_GET_IND_DXB_LINK_ERROR(dev_num)   (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_DXB_LINK_ERROR)
  404. #define VPC3_GET_IND_NEW_EXT_PRM_DATA(dev_num) (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_NEW_EXT_PRM_DATA)
  405. #define VPC3_GET_IND_DXB_OUT(dev_num)          (p_Vpc3[dev_num]->isreg.rd.int_reg1 & VPC3_INT_DXB_OUT)
  406. #define VPC3_GET_IND_NEW_GC_COMMAND(dev_num)   (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_NEW_GC_COMMAND)
  407. #define VPC3_GET_IND_NEW_SSA_DATA(dev_num)     (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_NEW_SSA_DATA)
  408. #define VPC3_GET_IND_NEW_CFG_DATA(dev_num)     (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_NEW_CFG_DATA)
  409. #define VPC3_GET_IND_NEW_PRM_DATA(dev_num)     (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_NEW_PRM_DATA)
  410. #define VPC3_GET_IND_DIAG_BUF_CHANGED(dev_num) (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_DIAG_BUF_CHANGED)
  411. #define VPC3_GET_IND_DX_OUT(dev_num)           (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_DX_OUT)
  412. #define VPC3_GET_IND_POLL_END_IND(dev_num)     (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_POLL_END_IND)
  413. #define VPC3_GET_IND_FDL_IND(dev_num)          (p_Vpc3[dev_num]->isreg.rd.int_reg2 & VPC3_INT_FDL_IND)
  414. // -- Acknowledging the indication -------------------------------------------
  415. #define VPC3_CON_IND_MAC_RESET(dev_num)        p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_MAC_RESET
  416. #define VPC3_CON_IND_GO_LEAVE_DATA_EX(dev_num) p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_GO_LEAVE_DATA_EX
  417. #define VPC3_CON_IND_BAUDRATE_DETECT(dev_num)  p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_BAUDRATE_DETECT
  418. #define VPC3_CON_IND_WD_DP_TIMEOUT(dev_num)    p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_WD_DP_TIMEOUT
  419. #define VPC3_CON_IND_USER_TIMER_CLOCK(dev_num) p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_USER_TIMER_CLOCK
  420. #define VPC3_CON_IND_DXB_LINK_ERROR(dev_num)   p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_DXB_LINK_ERROR
  421. #define VPC3_CON_IND_NEW_EXT_PRM_DATA(dev_num) p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_NEW_EXT_PRM_DATA
  422. #define VPC3_CON_IND_DXB_OUT(dev_num)          p_Vpc3[dev_num]->isreg.wr.int_ack1 = VPC3_INT_DXB_OUT
  423. #define VPC3_CON_IND_NEW_GC_COMMAND(dev_num)   p_Vpc3[dev_num]->isreg.wr.int_ack2 = VPC3_INT_NEW_GC_COMMAND
  424. #define VPC3_CON_IND_NEW_SSA_DATA(dev_num)     p_Vpc3[dev_num]->isreg.wr.int_ack2 = VPC3_INT_NEW_SSA_DATA
  425. #define VPC3_CON_IND_DIAG_BUF_CHANGED(dev_num) p_Vpc3[dev_num]->isreg.wr.int_ack2 = VPC3_INT_DIAG_BUF_CHANGED
  426. #define VPC3_CON_IND_DX_OUT(dev_num)           p_Vpc3[dev_num]->isreg.wr.int_ack2 = VPC3_INT_DX_OUT
  427. #define VPC3_CON_IND_POLL_END_IND(dev_num)     p_Vpc3[dev_num]->isreg.wr.int_ack2 = VPC3_INT_POLL_END_IND
  428. #define VPC3_CON_IND_FDL_IND(dev_num)          p_Vpc3[dev_num]->isreg.wr.int_ack2 = VPC3_INT_FDL_IND
  429. // -- Ending the Indication ---------------------------------------------------
  430. #define VPC3_SET_EOI(dev_num) p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_s  = VPC3_EOI
  431. // poll read out reasons for indications --------------------------------------
  432. #define VPC3_POLL_IND_MAC_RESET(dev_num)           (p_Vpc3[dev_num]->int_req1 & VPC3_INT_MAC_RESET)
  433. #define VPC3_POLL_IND_BAUDRATE_DETECT(dev_num)     (p_Vpc3[dev_num]->int_req1 & VPC3_INT_BAUDRATE_DETECT)
  434. #define VPC3_POLL_IND_USER_TIMER_CLOCK(dev_num)    (p_Vpc3[dev_num]->int_req1 & VPC3_INT_USER_TIMER_CLOCK)
  435. #define VPC3_POLL_IND_GO_LEAVE_DATA_EX(dev_num)    (p_Vpc3[dev_num]->int_req1 & VPC3_INT_GO_LEAVE_DATA_EX)
  436. #define VPC3_POLL_IND_WD_DP_MODE_TIMEOUT(dev_num)  (p_Vpc3[dev_num]->int_req1 & VPC3_INT_WD_DP_MODE_TIMEOUT)
  437. #define VPC3_POLL_IND_NEW_EXT_PRM_DATA(dev_num)    (p_Vpc3[dev_num]->int_req1 & VPC3_INT_NEW_EXT_PRM_DATA)
  438. #define VPC3_POLL_IND_NEW_GC_COMMAND(dev_num)      (p_Vpc3[dev_num]->int_req2 & VPC3_INT_NEW_GC_COMMAND)
  439. #define VPC3_POLL_IND_NEW_SSA_DATA(dev_num)        (p_Vpc3[dev_num]->int_req2 & VPC3_INT_NEW_SSA_DATA)
  440. #define VPC3_POLL_IND_NEW_CFG_DATA(dev_num)        (p_Vpc3[dev_num]->int_req2 & VPC3_INT_NEW_CFG_DATA)
  441. #define VPC3_POLL_IND_NEW_PRM_DATA(dev_num)        (p_Vpc3[dev_num]->int_req2 & VPC3_INT_NEW_PRM_DATA)
  442. #define VPC3_POLL_IND_DIAG_BUFFER_CHANGED(dev_num) (p_Vpc3[dev_num]->int_req2 & VPC3_INT_DIAG_BUF_CHANGED)
  443. #define VPC3_POLL_IND_DX_OUT(dev_num)              (p_Vpc3[dev_num]->int_req2 & VPC3_INT_DX_OUT)
  444. #define VPC3_POLL_IND_POLL_END_IND(dev_num)        (p_Vpc3[dev_num]->int_req2 & VPC3_INT_POLL_END_IND)
  445. #define VPC3_POLL_IND_FDL_IND(dev_num)             (p_Vpc3[dev_num]->int_req2 & VPC3_INT_FDL_IND)
  446. #define VPC3_SET_IRR_1(dev_num,IRR_BYTE)            (p_Vpc3[dev_num]->int_req1 |= IRR_BYTE)
  447. #define VPC3_SET_IRR_2(dev_num,IRR_BYTE)            (p_Vpc3[dev_num]->int_req2 |= IRR_BYTE)
  448. #define DP_LOCK_IND(dev_num)                                                            
  449. {                                                                                
  450.       p_Vpc3[dev_num]->isreg.wr.int_mask_H = 0xFF;                                        
  451.                                                                                  
  452.       p_Vpc3[dev_num]->isreg.wr.int_mask_L = 0xFF;                                        
  453. }
  454. #define DP_UNLOCK_IND(dev_num)                                                          
  455. {                                                                                
  456.       p_Vpc3[dev_num]->isreg.wr.int_mask_H = dp_sys[dev_num].ind_high;                             
  457.                                                                                  
  458.       p_Vpc3[dev_num]->isreg.wr.int_mask_L = dp_sys[dev_num].ind_low;                              
  459. }
  460. /*-----------------------------------------------------------------------------------------------------------*/
  461. /* 2.0 parameter telegram                                                                                    */
  462. /*-----------------------------------------------------------------------------------------------------------*/
  463. /*---------------------------------------------------------------------------*/
  464. /* 2.1 structure of prm data                                                 */
  465. /*---------------------------------------------------------------------------*/
  466. /*
  467. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  468. |      7       |      6     |       5       |           4           |      3     |     2     |         1        |          0        |
  469. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  470. |   Lock_Req   | Unlock_Req |   Sync_Req    |       Freeze_Req      |    WD_On   |     0     |         0        |          0        |
  471. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  472. | WD_Fact_1 (1 bis 255)                                                                                                             |
  473. |-----------------------------------------------------------------------------------------------------------------------------------|
  474. | WD_Fact_2 (1 bis 255)                                                                                                             |
  475. |-----------------------------------------------------------------------------------------------------------------------------------|
  476. | Min. Station Delay Responder (min Tsdr)                                                                                           |
  477. |-----------------------------------------------------------------------------------------------------------------------------------|
  478. | Ident_Number (high)                                                                                                               |
  479. |-----------------------------------------------------------------------------------------------------------------------------------|
  480. | Ident_Number (low)                                                                                                                |
  481. |-----------------------------------------------------------------------------------------------------------------------------------|
  482. | Group_Ident                                                                                                                       |
  483. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  484. | DPV1_Enable  | Fail_Safe  | Publisher_En  |       reserved        |  res       |  WD_Base  | Dis_Stop_Control | Dis_Start_Control |
  485. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  486. | En_Pull_Plug | En_Process | En_Diagnostic | En_Manufacturer_Spec. | En_Status  | En_Update |    reserviert    | Chk_Cfg_Mode      |
  487. |    Alarm     |    Alarm   |    Alarm      |         Alarm         |   Alarm    |   Alarm   |                  |                   |
  488. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  489. |   PrmCmd     |  reserved  |   reserved    |       IsoM_Req        | Prm_Struct |                 Alarm_Mode                       |
  490. |--------------|------------|---------------|-----------------------|------------|-----------|------------------|-------------------|
  491. |                                                            User_Prm_Data                                                          |
  492. |-----------------------------------------------------------------------------------------------------------------------------------|
  493. */
  494. typedef struct
  495. {
  496.     BLACKFINDATATYPE station_state;
  497.     BLACKFINDATATYPE wd_fact_1;
  498.     BLACKFINDATATYPE wd_fact_2;
  499.     BLACKFINDATATYPE mintsdr;
  500.     BLACKFINDATATYPE pno_ident_high;
  501.     BLACKFINDATATYPE pno_ident_low;
  502.     BLACKFINDATATYPE group_ident;
  503.     BLACKFINDATATYPE dpv1_status_1;
  504.     BLACKFINDATATYPE dpv1_status_2;
  505.     BLACKFINDATATYPE dpv1_status_3;
  506.     BLACKFINDATATYPE user_data;
  507. }STRUC_PRM;
  508. #define VPC3_STRUC_PRM_PTR  STRUC_PRM PTR_ATTR *
  509. /*---------------------------------------------------------------------------*/
  510. /* 2.1 literals for Station State                                            */
  511. /*---------------------------------------------------------------------------*/
  512. #define STATION_STATE_WD_ON             ((UBYTE)0x08)
  513. /*---------------------------------------------------------------------------*/
  514. /* 2.2 literals for DPV1 Status 1                                            */
  515. /*---------------------------------------------------------------------------*/
  516. #define DPV1_STATUS_1_RESERVED_1        ( ( UBYTE)0x03)
  517. #define DPV1_STATUS_1_WD_BASE_1MS       ( ( UBYTE)0x04)
  518. #define DPV1_STATUS_1_RESERVED_2        ( ( UBYTE)0x08)
  519. #define DPV1_STATUS_1_RESERVED_3        ( ( UBYTE)0x10)
  520. #define DPV1_STATUS_1_PUBLISHER_ENABLE  ( ( UBYTE)0x20)
  521. #define DPV1_STATUS_1_FAIL_SAFE         ( ( UBYTE)0x40)
  522. #define DPV1_STATUS_1_DPV1_ENABLE       ( ( UBYTE)0x80)
  523. /*---------------------------------------------------------------------------*/
  524. /* 2.3 literals for DPV1 Status 2                                            */
  525. /*---------------------------------------------------------------------------*/
  526. #define DPV1_STATUS_2_CHECK_CFG_MODE    ( ( UBYTE)0x01)
  527. #define CHECK_CFG                       ( ( UBYTE)0x00)
  528. #define NO_CHECK_CFG                    ( ( UBYTE)0x01)
  529. #define DPV1_STATUS_2_RESERVED_4        ( ( UBYTE)0x02)
  530. #define ALARM_TYPE_UPDATE_VALUE         ( ( UBYTE)0x04)
  531. #define ALARM_TYPE_STATUS_VALUE         ( ( UBYTE)0x08)
  532. #define ALARM_TYPE_MANUFACTURER_VALUE   ( ( UBYTE)0x10)
  533. #define ALARM_TYPE_DIAGNOSTIC_VALUE     ( ( UBYTE)0x20)
  534. #define ALARM_TYPE_PROCESS_VALUE        ( ( UBYTE)0x40)
  535. #define ALARM_TYPE_PULLPLUG_VALUE       ( ( UBYTE)0x80)
  536. #define DPV1_STATUS_2_ALARM_TYPE_MASK   (    ALARM_TYPE_UPDATE_VALUE       
  537.                                           | ALARM_TYPE_STATUS_VALUE       
  538.                                           | ALARM_TYPE_MANUFACTURER_VALUE 
  539.                                           | ALARM_TYPE_DIAGNOSTIC_VALUE   
  540.                                           | ALARM_TYPE_PROCESS_VALUE      
  541.                                           | ALARM_TYPE_PULLPLUG_VALUE     
  542.                                         )
  543. #define ALARM_TYPE_NONE_VALUE           ( ( UBYTE)0x00)
  544. #define ALARM_TYPE_ALL_VALUE            ( ( UBYTE)0xFF)
  545. /*---------------------------------------------------------------------------*/
  546. /* 2.4 literals for DPV1 Status 3                                            */
  547. /*---------------------------------------------------------------------------*/
  548. #define DPV1_STATUS_3_ALARM_MODE_MASK   ( ( UBYTE)0x07)
  549. #define DPV1_STATUS_3_PRM_STRUCTURE     ( ( UBYTE)0x08)
  550. #define DPV1_STATUS_3_ISOM_REQUEST      ( ( UBYTE)0x10)
  551. #define DPV1_STATUS_3_RESERVED_UNUSED5  ( ( UBYTE)0x70)
  552. #define DPV1_STATUS_3_PRM_CMD           ( ( UBYTE)0x80)
  553. /*---------------------------------------------------------------------------*/
  554. /* 2.5 general defines for prm data                                          */
  555. /*---------------------------------------------------------------------------*/
  556. #define PRM_LEN_NORM                    ( ( UBYTE)0x07)
  557. #define PRM_LEN_DPV1                    ( ( UBYTE)0x0A)
  558. /*---------------------------------------------------------------------------*/
  559. /* 2.6 literals for structured prm data                                      */
  560. /*---------------------------------------------------------------------------*/
  561. #define PBC_PRMCMD                      ( ( UBYTE)0x02)
  562. #define PBC_DXB_LINKTABLE               ( ( UBYTE)0x03)
  563. #define PBC_ISOCHRON                    ( ( UBYTE)0x04)
  564. #define PBC_DXB_SUBSCRIBERTABLE         ( ( UBYTE)0x07)
  565. #define PBC_TIME_AR                     ( ( UBYTE)0x08)
  566. #define PBC_USER_PRM_DATA               ( ( UBYTE)0x81)
  567. typedef struct
  568. {
  569.     BLACKFINDATATYPE len;
  570.     BLACKFINDATATYPE command;
  571.     BLACKFINDATATYPE slot_nr;
  572.     BLACKFINDATATYPE index;
  573.     BLACKFINDATATYPE user_data;
  574. }STRUC_PRM_BLOCK;
  575. #define VPC3_STRUC_PRM_BLOCK_PTR  STRUC_PRM_BLOCK PTR_ATTR *
  576. /*---------------------------------------------------------------------------*/
  577. /* 2.7 returncodes prm data                                                  */
  578. /*---------------------------------------------------------------------------*/
  579. #define VPC3_PRM_FINISHED               ( ( UBYTE)0x00)
  580. #define VPC3_PRM_CONFLICT               ( ( UBYTE)0x01)
  581. #define VPC3_PRM_NOT_ALLOWED            ( ( UBYTE)0x03)
  582. /*---------------------------------------------------------------------------*/
  583. /* 2.8 macros for prm data                                                   */
  584. /*---------------------------------------------------------------------------*/
  585. // read length of prm-Data --------------------------------------------------
  586. #define VPC3_GET_PRM_LEN(dev_num)  BFWORD2BYTE(p_Vpc3[dev_num]->len_prm_data)
  587. // get pointer to prm-buffer ------------------------------------------------
  588. #define VPC3_GET_PRM_BUF_PTR(dev_num) (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->prm_buf_ptr) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  589. // acknowledge prm-data -----------------------------------------------------
  590. #define VPC3_SET_PRM_DATA_OK(dev_num)      BFWORD2BYTE(p_Vpc3[dev_num]->ctrl_reg.rd.user_prm_data_ok)
  591. #define VPC3_SET_PRM_DATA_NOT_OK(dev_num)  BFWORD2BYTE(p_Vpc3[dev_num]->ctrl_reg.rd.user_prm_data_nok)
  592. /*-----------------------------------------------------------------------------------------------------------*/
  593. /* 3.0 configuration telegram                                                                                */
  594. /*-----------------------------------------------------------------------------------------------------------*/
  595. /*---------------------------------------------------------------------------*/
  596. /* 3.1 standard format of cfg byte                                           */
  597. /*---------------------------------------------------------------------------*/
  598. //
  599. //        MSB                         LSB
  600. //       +---+---+---+---+---+---+---+---+
  601. //Bit-No | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  602. //       +---+---+---+---+---+---+---+---+
  603. //         |   |   |   |   |   |   |   |      meaning:
  604. //         |   |   |   |   |   |   |   |
  605. //         |   |   |   |   +---+---+---+----  length of data
  606. //         |   |   |   |                      00 1 byte resp. 1 word
  607. //         |   |   |   |                      .
  608. //         |   |   |   |                      .
  609. //         |   |   |   |                      15 16 byte resp. 16 words
  610. //         |   |   |   |
  611. //         |   |   |   |
  612. //         |   |   +---+--------------------  input/output
  613. //         |   |                              00 specific identifier formats
  614. //         |   |                              01 input
  615. //         |   |                              10 output
  616. //         |   |                              11 input-output
  617. //         |   |
  618. //         |   +----------------------------  length format 1)
  619. //         |                                   0 byte byte structure
  620. //         |                                   1 word word structure
  621. //         |
  622. //         +--------------------------------  consistency over
  623. //                                             0 byte or word
  624. //                                             1 whole length
  625. //
  626. /*---------------------------------------------------------------------------*/
  627. /* 3.2 special format of cfg byte                                            */
  628. /*---------------------------------------------------------------------------*/
  629. //
  630. //        MSB                         LSB
  631. //       +---+---+---+---+---+---+---+---+
  632. //Bit-No | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  633. //       +---+---+---+---+---+---+---+---+
  634. //         |   |   |   |   |   |   |   |      meaning:
  635. //         |   |   |   |   |   |   |   |
  636. //         |   |   |   |   |   |   |   |
  637. //         |   |   |   |   +---+---+---+----- length of manufacturer
  638. //         |   |   |   |                      specific data 2)
  639. //         |   |   |   |
  640. //         |   |   +---+--------------------- fixed to 00
  641. //         |   |
  642. //         +---+----------------------------- input/output
  643. //                                            00 free place
  644. //                                            01 it follows 1 length byte for inputs
  645. //                                            10 it follows 1 length byte for outputs
  646. //                                            11 it follows - 1 length byte for outputs
  647. //                                                          - 1 length byte for inputs
  648. //
  649. // -----------------------------------------------------------------------------
  650. // 2) The length information of the manufacturer specific data shall be interpreted as follows:
  651. //
  652. // In case of Chk_Cfg:
  653. //
  654. //   0             No manufacturer specific data follow; no data in Real_Cfg_Data.
  655. //   1 to 14       Manufacturer specific data of specified length follow;
  656. //                 these shall be identical with the data in Real_Cfg_Data.
  657. //   15            No manufacturer specific data follow;
  658. //                 the verification can be omitted
  659. //
  660. // In case of DDLM_Get_Cfg :
  661. //
  662. //   0             No manufacturer specific data follow
  663. //   1 to 14       Manufacturer specific data with specified length follow
  664. //   15            Not allowed
  665. // The structure of the length bytes is as follows:
  666. //
  667. //        MSB                         LSB
  668. //       +---+---+---+---+---+---+---+---+
  669. //Bit-No | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  670. //       +---+---+---+---+---+---+---+---+
  671. //         |   |   |   |   |   |   |   |      meaning:
  672. //         |   |   |   |   |   |   |   |
  673. //         |   |   +---+---+---+---+---+----- length of inputs/outputs
  674. //         |   |                              00 1 byte resp. 1 word
  675. //         |   |                              .
  676. //         |   |                              .
  677. //         |   |                              63 64 byte resp. 64 words
  678. //         |   |
  679. //         |   +----------------------------- Length format 3)
  680. //         |                                   0 byte byte structure
  681. //         |                                   1 word word structure
  682. //         |
  683. //         +--------------------------------- consistency over
  684. //                                             0 byte or word
  685. //                                             1 whole length
  686. /*---------------------------------------------------------------------------*/
  687. /* 3.3 literals for cfg-bytes                                                */
  688. /*---------------------------------------------------------------------------*/
  689. #define VPC3_CFG_IS_BYTE_FORMAT         ( ( UBYTE)0x30)
  690. #define VPC3_CFG_BF_LENGTH              ( ( UBYTE)0x0f)
  691. #define VPC3_CFG_LENGTH_IS_WORD_FORMAT  ( ( UBYTE)0x40)
  692. #define VPC3_CFG_BF_INP_EXIST           ( ( UBYTE)0x10)
  693. #define VPC3_CFG_BF_OUTP_EXIST          ( ( UBYTE)0x20)
  694. #define VPC3_CFG_SF_OUTP_EXIST          ( ( UBYTE)0x80)
  695. #define VPC3_CFG_SF_INP_EXIST           ( ( UBYTE)0x40)
  696. #define VPC3_CFG_SF_LENGTH              ( ( UBYTE)0x3f)
  697. /*---------------------------------------------------------------------------*/
  698. /* 3.4 returncodes cfg data                                                  */
  699. /*---------------------------------------------------------------------------*/
  700. #define VPC3_CFG_FINISHED               ( ( UBYTE)0x00)
  701. #define VPC3_CFG_CONFLICT               ( ( UBYTE)0x01)
  702. #define VPC3_CFG_NOT_ALLOWED            ( ( UBYTE)0x03)
  703. /*---------------------------------------------------------------------------*/
  704. /* 3.5 literals for chk config data                                          */
  705. /*---------------------------------------------------------------------------*/
  706. #define VPC3_CFG_OK                     ( ( UBYTE)0x00)
  707. #define VPC3_CFG_FAULT                  ( ( UBYTE)0x01)
  708. #define VPC3_CFG_UPDATE                 ( ( UBYTE)0x02)
  709. /*---------------------------------------------------------------------------*/
  710. /* 3.6 macros for cfg data                                                   */
  711. /*---------------------------------------------------------------------------*/
  712. // read length of cfg-buffers ----------------------------------------------
  713. #define VPC3_GET_READ_CFG_LEN(dev_num)   BFWORD2BYTE(p_Vpc3[dev_num]->len_read_cfg_data)
  714. #define VPC3_GET_CFG_LEN(dev_num)        BFWORD2BYTE(p_Vpc3[dev_num]->len_cfg_data)
  715. // set length of cfg-data --------------------------------------------------
  716. #define VPC3_SET_READ_CFG_LEN(dev_num,LEN)  p_Vpc3[dev_num]->len_read_cfg_data = LEN
  717. // get pointer to cfg-buffers ----------------------------------------------
  718. #define VPC3_GET_READ_CFG_BUF_PTR(dev_num) (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->read_cfg_buf_ptr) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  719. #define VPC3_GET_CFG_BUF_PTR(dev_num)      (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->cfg_buf_ptr) << BLACKFIN_SEG_MULDIV     )+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  720. // acknowledge cfg-data ----------------------------------------------------
  721. #define VPC3_SET_CFG_DATA_OK(dev_num)     vpc3_cfg_data_ok(dev_num)
  722. #define VPC3_SET_CFG_DATA_UPDATE(dev_num) vpc3_cfg_data_update(dev_num)
  723. #define VPC3_SET_CFG_DATA_NOT_OK(dev_num) vpc3_cfg_data_not_ok(dev_num)
  724. /*---------------------------------------------------------------------------*/
  725. /* 3.7 structure for real cfg data                                           */
  726. /*---------------------------------------------------------------------------*/
  727. // -- cfg structure -----------------------------------------------------------
  728. typedef struct
  729. {
  730.     UBYTE length;
  731.     UBYTE cfg_data[CFG_BUFSIZE];
  732. } CFG_STRUCT;
  733. /*-----------------------------------------------------------------------------------------------------------*/
  734. /* 4.0 input / output                                                                                        */
  735. /*-----------------------------------------------------------------------------------------------------------*/
  736. /*---------------------------------------------------------------------------*/
  737. /* 4.1 structure for calculated input-/output-length                         */
  738. /*---------------------------------------------------------------------------*/
  739. typedef struct
  740. {
  741.    UBYTE inp_data_len;               // calculated input length  (VPC3->DP-Master)
  742.    UBYTE outp_data_len;              // calculated output length (DP-Master->VPC3)
  743. }  VPC3_IO_DATA_LEN;
  744. /*---------------------------------------------------------------------------*/
  745. /* 4.2 states for output buffer                                              */
  746. /*---------------------------------------------------------------------------*/
  747. #define VPC3_NEW_DOUT_BUF               ((UBYTE)0x04)
  748. #define VPC3_DOUT_BUF_CLEARED           ((UBYTE)0x08)
  749. /*---------------------------------------------------------------------------*/
  750. /* 4.3 macros for input buffer                                               */
  751. /*---------------------------------------------------------------------------*/
  752. #define VPC3_INPUT_UPDATE(dev_num)             p_Vpc3[dev_num]->ctrl_reg.rd.new_din_buf_cmd
  753. /*-----------------------------------------------------------------------------------------------------------*/
  754. /* 5.0 set slave address                                                                                     */
  755. /*-----------------------------------------------------------------------------------------------------------*/
  756. /*---------------------------------------------------------------------------*/
  757. /* 5.1 structure                                                             */
  758. /*---------------------------------------------------------------------------*/
  759. typedef struct
  760. {
  761.     BLACKFINDATATYPE address;
  762.     BLACKFINDATATYPE ident_high;
  763.     BLACKFINDATATYPE ident_low;
  764.     BLACKFINDATATYPE no_add_chg;
  765.     BLACKFINDATATYPE user_data;
  766. }STRUC_SSA_BLOCK;
  767. #define VPC3_STRUC_SSA_BLOCK_PTR  STRUC_SSA_BLOCK PTR_ATTR *
  768. /*---------------------------------------------------------------------------*/
  769. /* 5.2 macros                                                                */
  770. /*---------------------------------------------------------------------------*/
  771. // -- read length of set-slave-address ----------------------------------------
  772. #define VPC3_GET_SSA_LEN(dev_num)  BFWORD2BYTE(p_Vpc3[dev_num]->len_ssa_buf)
  773. // -- get pointer to ssa buffer -----------------------------------------------
  774. #define VPC3_GET_SSA_BUF_PTR(dev_num) (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->ssa_buf_ptr) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  775. // -- acknowledge ssa commando ------------------------------------------------
  776. #define VPC3_FREE_SSA_BUF(dev_num) p_Vpc3[dev_num]->ctrl_reg.rd.ssa_buf_free_cmd
  777. /*-----------------------------------------------------------------------------------------------------------*/
  778. /* 6.0 global control telegram                                                                               */
  779. /*-----------------------------------------------------------------------------------------------------------*/
  780. /*---------------------------------------------------------------------------*/
  781. /* 6.1 defines for GLOBAL CONTROL                                            */
  782. /*---------------------------------------------------------------------------*/
  783. #define GC_OPERATE                      ((UBYTE)0x00)
  784. #define GC_CLEAR                        ((UBYTE)0x02)
  785. /*---------------------------------------------------------------------------*/
  786. /* 6.2 macros for global control                                             */
  787. /*---------------------------------------------------------------------------*/
  788. // -- read Global-Control-Command ---------------------------------------------
  789. #define VPC3_GET_GC_COMMAND(dev_num) BFWORD2BYTE(p_Vpc3[dev_num]->gc_command)
  790. /*-----------------------------------------------------------------------------------------------------------*/
  791. /* 7.0 diagnostic telegram                                                                                   */
  792. /*-----------------------------------------------------------------------------------------------------------*/
  793. /*---------------------------------------------------------------------------*/
  794. /* 7.1 defines                                                               */
  795. /*---------------------------------------------------------------------------*/
  796. #define EXT_DIAG_RESET                  ( ( UBYTE)0x00)
  797. #define EXT_DIAG_SET                    ( ( UBYTE)0x01)
  798. #define STAT_DIAG_RESET                 ( ( UBYTE)0x00)
  799. #define STAT_DIAG_SET                   ( ( UBYTE)0x02)
  800. #define EXT_STAT_DIAG_SET               ( ( UBYTE)0x03)
  801. #define DIAG_WAIT_FOR_ALARM             ( ( UBYTE)0x80)
  802. #define DIAG_REV_SIGN                   ( ( UBYTE)0xC0)
  803. #define DIAG_KEN_SIGN                   ( ( UBYTE)0x40)
  804. #define DIAG_CHN_SIGN                   ( ( UBYTE)0x80)
  805. #define DIAG_DEV_SIGN                   ( ( UBYTE)0x00)
  806. #define DIAG_TYPE_MASK                  ( ( UBYTE)0xC0)
  807. #define DIAG_TYPE_DEV                   ( ( UBYTE)0x00)
  808. #define DIAG_TYPE_KEN                   ( ( UBYTE)0x40)
  809. #define DIAG_TYPE_CHN                   ( ( UBYTE)0x80)
  810. #define DIAG_TYPE_REV                   ( ( UBYTE)0xC0)
  811. #define DIAG_NORM_DIAG_SIZE             ( ( UBYTE)0x06)
  812. #define DIAG_TYPE_CHN_SIZE              ( ( UBYTE)0x03)
  813. #define DIAG_TYPE_REV_SIZE              ( ( UBYTE)0x01)
  814. #define STATUS_DIAG_HEAD_SIZE           ( ( UBYTE)0x04)
  815. #define STATUS_TYPE_SIGN                ( ( UBYTE)0x80)
  816. #define STATUS_TYPE_STATUS_MESSAGE      ( ( UBYTE)0x01)
  817. #define STATUS_TYPE_MODUL_STATUS        ( ( UBYTE)0x02)
  818. #define STATUS_TYPE_PRM_COMMAND_ACK     ( ( UBYTE)0x1E)
  819. #define STATUS_TYPE_H_STATUS_MESSAGE    ( ( UBYTE)0x1F)
  820. #define STATUS_TYPE_MANU_MIN            ( ( UBYTE)0x20)
  821. #define STATUS_TYPE_MANU_MAX            ( ( UBYTE)0x7E)
  822. #define ALARM_TYPE_SIGN                 ( ( UBYTE)0x00)
  823. #define ALARM_DIAG_HEAD_SIZE            ( ( UBYTE)0x04)
  824. /*---------------------------------------------------------------------------*/
  825. /* 7.2 structures                                                            */
  826. /*---------------------------------------------------------------------------*/
  827. // -- revision diagnosis data -------------------------------------------------
  828. typedef struct
  829. {
  830.     UBYTE   sign_revision;
  831. } STRUC_REV_DIAG;
  832. // -- slot signed diagnosis data ----------------------------------------------
  833. typedef struct
  834. {
  835.     UBYTE   sign_len;
  836.     UBYTE   slots[1];
  837. } STRUC_KEN_DIAG;
  838. //defines for channel related diagnostic
  839. //        MSB                         LSB
  840. //       +---+---+---+---+---+---+---+---+
  841. //Bit-No | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  842. //       +---+---+---+---+---+---+---+---+
  843. //         |   |   |   |   |   |   |   |    meaning:
  844. //         |   |   |   |   |   |   |   |
  845. //         |   |   |   +---+---+---+---+--- error type
  846. //         |   |   |
  847. //         +---+---+----------------------- channel type
  848. //channel type of statuscode
  849. #define STATUS_1BIT                     ( ( UBYTE)0x20)
  850. #define STATUS_2BIT                     ( ( UBYTE)0x40)
  851. #define STATUS_4BIT                     ( ( UBYTE)0x60)
  852. #define STATUS_BYTE                     ( ( UBYTE)0x80)
  853. #define STATUS_WORD                     ( ( UBYTE)0xA0)
  854. #define STATUS_DWORD                    ( ( UBYTE)0xC0)
  855. //error type of statuscode ( PROFIBUS NORM)
  856. #define STATUS_SHORT_CIRCUIT            ( ( UBYTE)0x01)
  857. #define STATUS_UNDERVOLTAGE             ( ( UBYTE)0x02)
  858. #define STATUS_OVERVOLTAGE              ( ( UBYTE)0x03)
  859. #define STATUS_OVERLOAD                 ( ( UBYTE)0x04)
  860. #define STATUS_OVERTEMPERATURE          ( ( UBYTE)0x05)
  861. #define STATUS_LINE_BREAK               ( ( UBYTE)0x06)
  862. #define STATUS_UPPER_LIMIT_VALUE        ( ( UBYTE)0x07)
  863. #define STATUS_LOWER_LIMIT_VALUE        ( ( UBYTE)0x08)
  864. #define STATUS_ERROR                    ( ( UBYTE)0x09)
  865. #define STATUS_RESERVED_10              ( ( UBYTE)0x0A)
  866. #define STATUS_RESERVED_11              ( ( UBYTE)0x0B)
  867. #define STATUS_RESERVED_12              ( ( UBYTE)0x0C)
  868. #define STATUS_RESERVED_13              ( ( UBYTE)0x0D)
  869. #define STATUS_RESERVED_14              ( ( UBYTE)0x0E)
  870. #define STATUS_RESERVED_15              ( ( UBYTE)0x0F)
  871. //manufacturer specific between 16 and 31
  872. //Siemens Error Codes
  873. #define STATUS_PRM_ERROR                ( ( UBYTE)0x10)
  874. #define STATUS_VOLTAGE                  ( ( UBYTE)0x11)
  875. #define STATUS_FUSE_ERROR               ( ( UBYTE)0x12)
  876. #define STATUS_GND_ERROR                ( ( UBYTE)0x13)
  877. #define STATUS_REF_ERROR                ( ( UBYTE)0x14)
  878. #define STATUS_UNKNOWN_ERROR            ( ( UBYTE)0x1B)
  879. //defines for channel number in/out
  880. #define CH_NUMBER_INOUT                 ( ( UBYTE)0xC0)
  881. #define CH_NUMBER_OUT                   ( ( UBYTE)0x80)
  882. #define CH_NUMBER_IN                    ( ( UBYTE)0x40)
  883. // -- channel diagnosis data --------------------------------------------------
  884. typedef struct
  885. {
  886.     UBYTE   sign_ident;
  887.     UBYTE   number;
  888.     UBYTE   status_code;
  889. } STRUC_CHN_DIAG;
  890. // -- device diagnosis data ---------------------------------------------------
  891. typedef struct
  892. {
  893.     UBYTE   sign_len;
  894.     UBYTE   user_data[9];
  895. } STRUC_DEV_DIAG;
  896. // -- status message data (coded as device diagnosis (see above) --------------
  897. typedef struct
  898. {
  899.     UBYTE   sign_len;           // equal to DIAG_DEV_SIGN
  900.     UBYTE   status_type;
  901.     UBYTE   slot_number;
  902.     UBYTE   specifier;
  903.     UBYTE   user_data;
  904. } STRUC_STATUS_DIAG;
  905. // alarm data (coded as device diagnosis (see above) --------------------------
  906. typedef struct
  907. {
  908.     UBYTE   sign_len;           // equal to DIAG_DEV_SIGN */
  909.     UBYTE   alarm_type;
  910.     UBYTE   slot_number;
  911.     UBYTE   specifier;
  912.     UBYTE   user_data;
  913. } STRUC_ALARM_DIAG;
  914. typedef union
  915. {
  916.     STRUC_REV_DIAG     rev;
  917.     STRUC_KEN_DIAG     ken;
  918.     STRUC_CHN_DIAG     chn;
  919.     STRUC_DEV_DIAG     dev;
  920.     STRUC_STATUS_DIAG  status;
  921.     STRUC_ALARM_DIAG   alarm;
  922. } UNION_DIAG;
  923. #define VPC3_DIAG_PTR   UNION_DIAG PTR_ATTR *
  924. typedef union
  925. {
  926.     VPC3_DIAG_PTR       struc_ptr;
  927.     VPC3_UNSIGNED8_PTR  byte_ptr;//uint8 *
  928. } VPC3_UNION_DIAG_PTR;
  929. /*---------------------------------------------------------------------------*/
  930. /* 7.3 macros                                                                */
  931. /*---------------------------------------------------------------------------*/
  932. // get pointer to diag-buffers ----------------------------------------------
  933. #define VPC3_GET_DIAG1_PTR(dev_num) (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[0]) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  934. #define VPC3_GET_DIAG2_PTR(dev_num) (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[1]) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  935. //-- Control diagnostics buffer ------------
  936. #define VPC3_GET_DIAG_FLAG(dev_num)  (p_Vpc3[dev_num]->isreg.rd.status_L & VPC3_DIAG_FLAG)
  937. /*-----------------------------------------------------------------------------------------------------------*/
  938. /* 8.0 subscriber                                                                                            */
  939. /*-----------------------------------------------------------------------------------------------------------*/
  940. /*---------------------------------------------------------------------------*/
  941. /* 8.1 structures                                                            */
  942. /*---------------------------------------------------------------------------*/
  943. #ifdef DP_SUBSCRIBER
  944. typedef struct
  945. {
  946.     UBYTE       publisher_addr;
  947.     UBYTE       link_status;
  948. } DXB_STATUS;
  949. typedef struct
  950. {
  951.     UBYTE       header;
  952.     UBYTE       status_type;
  953.     UBYTE       slot_number;
  954.     UBYTE       status_specifier;
  955.     DXB_STATUS  link_status[MAX_LINK_SUPPORTED];
  956. } VPC3_DXB_LINK_STATUS;
  957. #define VPC3_DXB_LINK_STATUS_PTR  VPC3_DXB_LINK_STATUS PTR_ATTR *
  958. typedef struct
  959. {
  960.     UBYTE       publisher_addr;
  961.     UBYTE       publisher_length;
  962.     UBYTE       sample_offset;
  963.     UBYTE       sample_length;
  964. } DXB_LINK_TABLE;
  965. typedef struct
  966. {
  967.     DXB_LINK_TABLE  link_table_entry[MAX_LINK_SUPPORTED];
  968. } VPC3_DXB_LINK_TABLE;
  969. #define VPC3_DXB_LINK_TABLE_PTR  VPC3_DXB_LINK_TABLE PTR_ATTR *
  970. typedef struct
  971. {
  972.     UBYTE       publisher_addr;
  973.     UBYTE       publisher_length;
  974.     UBYTE       sample_offset;
  975.     UBYTE       dest_slot_number;
  976.     UBYTE       offset_data_area;
  977.     UBYTE       sample_length;
  978. } DXB_SUBSCRIBER_TABLE;
  979. typedef struct
  980. {
  981.     UBYTE                   version;
  982.     DXB_LINK_TABLE          link_table_entry[MAX_LINK_SUPPORTED];
  983. } PRM_DXB_LINK_TABLE;
  984. #define PRM_DXB_LINK_TABLE_PTR  PRM_DXB_LINK_TABLE PTR_ATTR *
  985. typedef struct
  986. {
  987.     UBYTE                   version;
  988.     DXB_SUBSCRIBER_TABLE    subscriber_table_entry[MAX_LINK_SUPPORTED];
  989. } PRM_SUBSCRIBER_TABLE;
  990. #define PRM_SUBSCRIBER_TABLE_PTR  PRM_SUBSCRIBER_TABLE PTR_ATTR *
  991. typedef struct
  992. {
  993.     UBYTE       publisher_addr;
  994.     UBYTE       sample_length;
  995.     UBYTE       sample_data;
  996. } VPC3_DXB_OUT;
  997. #define VPC3_DXB_OUT_PTR  VPC3_DXB_OUT PTR_ATTR *
  998. #endif//#ifdef DP_SUBSCRIBER
  999. /*---------------------------------------------------------------------------*/
  1000. /* 8.2 macros                                                                */
  1001. /*---------------------------------------------------------------------------*/
  1002. #define VPC3_GET_DXB_LINK_STATUS_BUF_PTR(dev_num)  (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dxb_link_status_buf_ptr) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  1003. #define VPC3_GET_DXB_LINK_STATUS_LEN(dev_num)      BFWORD2BYTE(p_Vpc3[dev_num]->len_dxb_link_status_buf)
  1004. #define VPC3_SET_DXB_LINK_STATUS_LEN(dev_num,value) p_Vpc3[dev_num]->len_dxb_link_status_buf = value
  1005. #define VPC3_GET_DXB_LINK_TABLE_BUF_PTR(dev_num)   (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dxb_link_table_buf_ptr) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))
  1006. #define VPC3_GET_DXB_LINK_TABLE_LEN(dev_num)       BFWORD2BYTE(p_Vpc3[dev_num]->len_dxb_link_table_buf)
  1007. #define VPC3_SET_DXB_LINK_TABLE_LEN(dev_num,value)  p_Vpc3[dev_num]->len_dxb_link_table_buf = value
  1008. /*-----------------------------------------------------------------------------------------------------------*/
  1009. /* 9.0 isochron mode                                                                                         */
  1010. /*-----------------------------------------------------------------------------------------------------------*/
  1011. /*---------------------------------------------------------------------------*/
  1012. /* 9.2 defines                                                               */
  1013. /*---------------------------------------------------------------------------*/
  1014. #define PLL_OFFLINE                     ((UBYTE)0x01)
  1015. #define PLL_WAIT_SYNCH                  ((UBYTE)0x02)
  1016. #define PLL_WAIT_DELAY                  ((UBYTE)0x04)
  1017. #define PLL_RUN                         ((UBYTE)0x08)
  1018. #define PLL_RUN_PLL                     ((UBYTE)0x10)
  1019. /*---------------------------------------------------------------------------*/
  1020. /* 9.2 structures                                                            */
  1021. /*---------------------------------------------------------------------------*/
  1022. typedef struct
  1023. {
  1024.     ULONG   T_BASE_DP;
  1025.     UWORD   T_DP;
  1026.     UBYTE   T_MAPC;
  1027.     ULONG   T_BASE_IO;
  1028.     UWORD   T_I;
  1029.     UWORD   T_O;
  1030.     ULONG   T_DX;
  1031.     UWORD   T_PLL_W;
  1032.     UWORD   T_PLL_D;
  1033. } T_ISOCHRON;
  1034. /*-----------------------------------------------------------------------------------------------------------*/
  1035. /* 10.0 fdl layer                                                                                            */
  1036. /*-----------------------------------------------------------------------------------------------------------*/
  1037. /*---------------------------------------------------------------------------*/
  1038. /* 10.1 SAPs (service access points) for MSAC1                               */
  1039. /*---------------------------------------------------------------------------*/
  1040. #define DP_C1_ALARM_SAP_NR              ((UBYTE)0x32)
  1041. #define DP_C1_RD_WR_SAP_NR              ((UBYTE)0x33)
  1042. /*---------------------------------------------------------------------------*/
  1043. /* 10.2 SAPs (service access points) for MSAC2                               */
  1044. /*---------------------------------------------------------------------------*/
  1045. #define MSAC_C2_MAX_INPUT_ITEMS         ((UBYTE)((2*DP_C2_NUM_SAPS)+1)) // number of elements in the input queue
  1046. #define MSAC_C2_SAP_NR_LOW              ((UBYTE)0x00)                   // lowest possible SAP for MSAC_C2
  1047. #define MSAC_C2_SAP_NR_HIGH             ((UBYTE)0x30)                   // highest possible SAP for MSAC_C2 (dp_mode =1)
  1048. /*---------------------------------------------------------------------------*/
  1049. /* 10.3 structure of a FDL-indication-response-buffer-head                   */
  1050. /*---------------------------------------------------------------------------*/
  1051. // -- defines for buffer-control-byte ----------------------------------------
  1052. #define PCNTRL_USER                     ((UBYTE)0x80)  // 1: buffer in user
  1053. #define PCNTRL_IND                      ((UBYTE)0x40)  // 1: indication occured
  1054. #define PCNTRL_RESP                     ((UBYTE)0x20)  // 1: response provided
  1055. #define PCNTRL_INUSE                    ((UBYTE)0x10)  // 1: buffer in use
  1056. // -- structure of a FDL-indication-response-buffer-head ---------------------
  1057. typedef struct
  1058. {
  1059.     BLACKFINDATATYPE cntrl;        // buffer-control
  1060.     BLACKFINDATATYPE max_len;      // max ind-buffer-length
  1061.     BLACKFINDATATYPE len;          // actual ind-response-length
  1062.     BLACKFINDATATYPE fc;           // ind-response-function-code
  1063. } FDL_BUF_HEAD;
  1064. #define FDL_BUF_HEAD_PTR FDL_BUF_HEAD PTR_ATTR *
  1065. #define sizeof_FDL_BUF_HEAD             ((UBYTE)0x04)
  1066. /*---------------------------------------------------------------------------*/
  1067. /* 10.4 structure of a FDL-sap-entry                                         */
  1068. /*---------------------------------------------------------------------------*/
  1069. typedef struct
  1070. {
  1071.     BLACKFINDATATYPE  resp_s__sap_nr;
  1072.     BLACKFINDATATYPE  req_sa;
  1073.     BLACKFINDATATYPE  access__req_ssap;
  1074.     BLACKFINDATATYPE  event__serv_sup;
  1075.     BLACKFINDATATYPE  ind_ptr[2];
  1076.     BLACKFINDATATYPE  resp_ptr;
  1077. } FDL_SAP_CNTRL;
  1078. #define FDL_SAP_CNTRL_PTR FDL_SAP_CNTRL PTR_ATTR *
  1079. #define sizeof_FDL_SAP_CNTRL   ((UBYTE)0x07)
  1080. /*---------------------------------------------------------------------------*/
  1081. /* 10.5 structure of a sap-control-block                                     */
  1082. /*---------------------------------------------------------------------------*/
  1083. // -- defines for FDL SAP TYPE -----------------------------------------------
  1084. typedef enum
  1085. {
  1086.     FDL_RM_SAP      = ((UBYTE)0x00),
  1087.     FDL_MSAC_C1_SAP = ((UBYTE)0x01),
  1088.     FDL_MSAC_C2_SAP = ((UBYTE)0x02)
  1089. } FDL_SAP_TYPE;
  1090. // -- defines for FDL STATE --------------------------------------------------
  1091. typedef enum
  1092. {
  1093.     ENABLED          =  ((UBYTE)0x00),
  1094.     DIS_RUNNING      =  ((UBYTE)0x01),
  1095.     DISABLED         =  ((UBYTE)0x02),
  1096.     DISABLED_FOR_RM  =  ((UBYTE)0x03),
  1097.     DISABLED_IN_RM   =  ((UBYTE)0x04)
  1098. } FDL_STATE;
  1099. typedef struct
  1100. {
  1101.     FDL_BUF_HEAD_PTR  ind_ptr[2];       // ind-buffer-address uP-formatted
  1102.     FDL_BUF_HEAD_PTR  resp_ptr;         // resp-buffer-address uP-formatted
  1103.     FDL_SAP_CNTRL_PTR sap_ptr;          // pointer to VPC3-SAP uP-formatted
  1104.     FDL_SAP_CNTRL     sap;              // content of VPC3-sap
  1105.     UBYTE             vpc3_ind_ptr[2];  // ind-buffer-address VPC3-formatted
  1106.     FDL_STATE         state;
  1107.     UBYTE             sap_nr;
  1108.     UBYTE             req_ssap;
  1109.     FDL_SAP_TYPE      sap_type;
  1110.     UBYTE             ind_buf_len;
  1111.     UBYTE             resp_buf_len;
  1112.     UBYTE             serv_sup;
  1113.     UBYTE             req_sa;
  1114. } FDL_SAP_HEADER;
  1115. #define FDL_SAP_HEADER_PTR  FDL_SAP_HEADER PTR_ATTR *
  1116. /*---------------------------------------------------------------------------*/
  1117. /* 10.6 structure of a indication- or response-buffer                        */
  1118. /*---------------------------------------------------------------------------*/
  1119. typedef struct
  1120. {
  1121.     BLACKFINDATATYPE data_len;       // length of netto-data
  1122.     BLACKFINDATATYPE fc;             // function-code
  1123.     BLACKFINDATATYPE user_data[246]; // netto-data
  1124. } IND_RESP_BUF;
  1125. #define IND_RESP_BUF_PTR        IND_RESP_BUF PTR_ATTR *
  1126. #define MSAC_C2_DATA_BUF        IND_RESP_BUF
  1127. #define MSAC_C2_DATA_BUF_PTR    MSAC_C2_DATA_BUF PTR_ATTR *
  1128. /*---------------------------------------------------------------------------*/
  1129. /* 10.7 structure of the immediate-response-pdu of the FDL-RM-SAP            */
  1130. /*---------------------------------------------------------------------------*/
  1131. typedef struct
  1132. {
  1133.     BLACKFINDATATYPE opcode;
  1134.     BLACKFINDATATYPE sap_nr;
  1135.     BLACKFINDATATYPE poll_to_high;
  1136.     BLACKFINDATATYPE poll_to_low;
  1137. } rm_answer;
  1138. /*---------------------------------------------------------------------------*/
  1139. /* 10.8 global structure of FDL state machine                                */
  1140. /*---------------------------------------------------------------------------*/
  1141. // -- defines for resource manager state -------------------------------------
  1142. typedef enum
  1143. {
  1144.     RM_LOCKED       = ((UBYTE)0x01),    // do not treat rm-sap (channel not opened)
  1145.     RM_LOADABLE     = ((UBYTE)0x02),    // load rm-sap (immediate response was sent or channel was opened)
  1146.     RM_LOADED       = ((UBYTE)0x03)     // do not load rm-sap (immediate-response not sent yet)
  1147. } FDL_RM_STATE;
  1148. #ifdef DP_FDL
  1149. typedef struct
  1150. {
  1151.     UBYTE                   dpv2_open;
  1152.     // saps for use of rm
  1153.     FDL_RM_STATE            rm_state;
  1154.     rm_answer PTR_ATTR      *rm_buffer;
  1155.     // saps for reset-check
  1156.     UBYTE                   reset_ctr;
  1157.     // list for fast sap-finding
  1158.     UBYTE                   search_key[0x41]; /* alle SAPs, Index 0x40 = Def.-SAP */
  1159.     // sap-list with any sap-information
  1160.     FDL_SAP_HEADER          sap_header[FDL_SAP_MAX];
  1161. } PTR_ATTR FDL_STRUC;
  1162. #endif//#ifdef DP_FDL
  1163. #define FDL_RM_BUF_LENGTH           ((UBYTE)0x04)
  1164. #define FDL_DPV2_SEC_BUF_LENGTH     ((UBYTE)0x04)
  1165. /*---------------------------------------------------------------------------*/
  1166. /* 10.9 function-codes                                                       */
  1167. /*---------------------------------------------------------------------------*/
  1168. #define SS_ALL                      ((UBYTE)0x00)
  1169. #define SS_SDN_L                    ((UBYTE)0x01)
  1170. #define SS_SDN_H                    ((UBYTE)0x02)
  1171. #define SS_SDN_LH                   ((UBYTE)0x03)
  1172. #define SS_SDN_SRD_LH               ((UBYTE)0x04)
  1173. #define SS_SDA_L                    ((UBYTE)0x05)
  1174. #define SS_SDA_H                    ((UBYTE)0x06)
  1175. #define SS_SDA_LH                   ((UBYTE)0x07)
  1176. #define SS_SRD_DDB                  ((UBYTE)0x08)
  1177. #define SS_SRD_L                    ((UBYTE)0x09)
  1178. #define SS_SRD_H                    ((UBYTE)0x0A)
  1179. #define SS_SRD_LH                   ((UBYTE)0x0B)
  1180. #define SS_DDB_REQ                  ((UBYTE)0x0C)
  1181. #define SS_DDB_RES_L                ((UBYTE)0x0D)
  1182. #define SS_DDB_RES_H                ((UBYTE)0x0E)
  1183. #define SS_DDB_RES_LH               ((UBYTE)0x0F)
  1184. #define FC_RESP_L                   ((UBYTE)0x08)
  1185. #define FC_RESP_H                   ((UBYTE)0x0A)
  1186. #define DEFAULT_SAP                 ((UBYTE)0x40)
  1187. #define SAP_ALL                     ((UBYTE)0x7F)
  1188. #define SA_ALL                      ((UBYTE)0x7F)
  1189. /*---------------------------------------------------------------------------*/
  1190. /* 10.A returncodes of FDL-services                                          */
  1191. /*---------------------------------------------------------------------------*/
  1192. #define FDL_OK                      ((UBYTE)0x00)
  1193. #define FDL_SNI                     ((UBYTE)0x01)
  1194. #define FDL_IUSE                    ((UBYTE)0x02)
  1195. #define FDL_IVP                     ((UBYTE)0x03)
  1196. #define FDL_ACT                     ((UBYTE)0x04)
  1197. #define FDL_DACT                    ((UBYTE)0x05)
  1198. #define FDL_SND                     ((UBYTE)0x06)
  1199. #define FDL_NUIB                    ((UBYTE)0x07)
  1200. #define FDL_UBLEN                   ((UBYTE)0x08)
  1201. #define FDL_FPTR                    ((UBYTE)0x09)
  1202. #define FDL_NRB                     ((UBYTE)0x0A)
  1203. #define FDL_NURB                    ((UBYTE)0x0B)
  1204. #define FDL_SBNI                    ((UBYTE)0x0C)
  1205. #define FDL_RLEN                    ((UBYTE)0x0D)
  1206. #define FDL_SBUF                    ((UBYTE)0x0E)
  1207. #define FDL_SDA                     ((UBYTE)0x0F)
  1208. #define FDL_NRD                     ((UBYTE)0x40)
  1209. #define FDL_OPEN_ERR                ((UBYTE)0xAA)
  1210. #define FDL_CLOSE_ERR               ((UBYTE)0xAB)
  1211. #define FDL_RR                      ((UBYTE)0x10)    // do not change
  1212. #define FDL_RS                      ((UBYTE)0x20)    // do not change
  1213. #define FDL_PRIMARY_BUF             ((UBYTE)0x01)
  1214. #define FDL_SECONDARY_BUF           ((UBYTE)0x02)
  1215. /*---------------------------------------------------------------------------*/
  1216. /* 10.B helpful macros                                                       */
  1217. /*---------------------------------------------------------------------------*/
  1218. #define _INIT_FDL_BUF_HEAD(FDL_PTR, LEN)                                
  1219. {                                                                       
  1220.   (FDL_PTR)->cntrl   = 0;                                               
  1221.   (FDL_PTR)->len     = 0;                                               
  1222.   (FDL_PTR)->fc      = 0;                                               
  1223.   (FDL_PTR)->max_len = (LEN);                                           
  1224. }//#define _INIT_FDL_BUF_HEAD(FDL_PTR, LEN)
  1225. #define copy_sap_parameter__(_dest, _src)                               
  1226. {                                                                       
  1227.   FDL_SAP_CNTRL PTR_ATTR * dest = (_dest);                              
  1228.   FDL_SAP_CNTRL PTR_ATTR * src =  (_src);                               
  1229.                                                                         
  1230.   dest->resp_s__sap_nr    =  src->resp_s__sap_nr;                       
  1231.   dest->req_sa            =  src->req_sa;                               
  1232.   dest->access__req_ssap  =  src->access__req_ssap;                     
  1233.   dest->event__serv_sup   =  src->event__serv_sup;                      
  1234.   dest->ind_ptr[0]        =  src->ind_ptr[0];                           
  1235.   dest->ind_ptr[1]        =  src->ind_ptr[1];                           
  1236.   dest->resp_ptr          =  src->resp_ptr;                             
  1237. }//#define copy_sap_parameter__(_dest, _src)
  1238. //vpc3_ptr 是word型指针不需要×2
  1239. #define incr_vpc3_up_ptr__(_buf_size)                                   
  1240. {                                                                       
  1241.   vpc3_seg_adr += (UBYTE)((_buf_size)>>SEG_MULDIV);                     
  1242.   vpc3_ptr = &vpc3_ptr[(_buf_size)];                                    
  1243. }//#define incr_vpc3_up_ptr__(_buf_size)
  1244. #define SWAP_WORD(w) ((((w)&0x00ff)*0x100) + (((w)>>8)&0x00ff))
  1245. #define SWAP_LONG(w) ((((w)&0x0000ffff)*0x10000) + (((w)>>16)&0x0000ffff))
  1246. /*-----------------------------------------------------------------------------------------------------------*/
  1247. /* 11.0 DPV1                                                                                                 */
  1248. /*-----------------------------------------------------------------------------------------------------------*/
  1249. /*---------------------------------------------------------------------------*/
  1250. /* 11.1 return codes for DPV1 services                                       */
  1251. /*---------------------------------------------------------------------------*/
  1252. typedef enum
  1253. {
  1254.     DPV1_OK     = ((UBYTE)0x00),      //must be the same as for return no_error
  1255.     DPV1_NOK    = ((UBYTE)0x81),      //negative response
  1256.     DPV1_DELAY  = ((UBYTE)0x82),      //user give pdu later back
  1257.     DPV1_ABORT  = ((UBYTE)0x83)       //user want abort the connection
  1258. } DPV1_RET_VAL;
  1259. /*----------------------------------------------------------------------------*/
  1260. /* 11.2 errorcodes of DPV1 for ERROR_DECODE                                   */
  1261. /*----------------------------------------------------------------------------*/
  1262. #define DPV1_ERRDC_DPV1                 ((UBYTE)0x80) // Error_decode, DPV1 fixed value
  1263. #define DPV1_ERRDC_FMS                  ((UBYTE)0xFE) // Error_decode, FMS  fixed value
  1264. #define DPV1_ERRDC_HART                 ((UBYTE)0xFF) // Error_decode, HART fixed value
  1265. /*----------------------------------------------------------------------------*/
  1266. /* 11.3 errorcodes of DPV1 for ERROR_CODE_1                                   */
  1267. /*----------------------------------------------------------------------------*/
  1268. // error_class
  1269. #define DPV1_ERRCL_APPLICATION          ((UBYTE)0xA0)
  1270. #define DPV1_ERRCL_ACCESS               ((UBYTE)0xB0)
  1271. #define DPV1_ERRCL_RESSOURCE            ((UBYTE)0xC0)
  1272. #define DPV1_ERRCL_USER                 ((UBYTE)0xD0)
  1273. // error_code for  DPV1_ERRCL_APPLICATION
  1274. #define DPV1_ERRCL_APP_READ             ((UBYTE)0x00)
  1275. #define DPV1_ERRCL_APP_WRITE            ((UBYTE)0x01)
  1276. #define DPV1_ERRCL_APP_MODULE           ((UBYTE)0x02)
  1277. #define DPV1_ERRCL_APP_VERSION          ((UBYTE)0x08)
  1278. #define DPV1_ERRCL_APP_NOTSUPP          ((UBYTE)0x09)
  1279. #define DPV1_ERRCL_APP_USER             ((UBYTE)0x0A)
  1280. // error_code for  DPV1_ERRCL_ACCESS
  1281. #define DPV1_ERRCL_ACC_INV_INDEX        ((UBYTE)0x00)
  1282. #define DPV1_ERRCL_ACC_WRITE_LEN        ((UBYTE)0x01)
  1283. #define DPV1_ERRCL_ACC_INV_SLOT         ((UBYTE)0x02)
  1284. #define DPV1_ERRCL_ACC_TYPE             ((UBYTE)0x03)
  1285. #define DPV1_ERRCL_ACC_INV_AREA         ((UBYTE)0x04)
  1286. #define DPV1_ERRCL_ACC_STATE            ((UBYTE)0x05)
  1287. #define DPV1_ERRCL_ACC_ACCESS           ((UBYTE)0x06)
  1288. #define DPV1_ERRCL_ACC_INV_RANGE        ((UBYTE)0x07)
  1289. #define DPV1_ERRCL_ACC_INV_PARAM        ((UBYTE)0x08)
  1290. #define DPV1_ERRCL_ACC_INV_TYPE         ((UBYTE)0x09)
  1291. #define DPV1_ERRCL_ACC_USER             ((UBYTE)0x0A)
  1292. // error_code for  DPV1_ERRCL_RESOURCE
  1293. #define DPV1_ERRCL_RES_READ_CONSTRAIN   ((UBYTE)0x00)
  1294. #define DPV1_ERRCL_RES_WRITE_CONSTRAIN  ((UBYTE)0x01)
  1295. #define DPV1_ERRCL_RES_BUSY             ((UBYTE)0x02)
  1296. #define DPV1_ERRCL_RES_UNAVAIL          ((UBYTE)0x03)
  1297. #define DPV1_ERRCL_RES_USER             ((UBYTE)0x08)
  1298. // error_code for  msac_c1_transmit_delay
  1299. #define DPV1_NO_VALID_SAP               ((UBYTE)0x01)
  1300. #define DPV1_ERR_INV_PARAM              ((UBYTE)0x02)
  1301. #define DPV1_ERR_NO_JOB                 ((UBYTE)0x03)
  1302. /*----------------------------------------------------------------------------*/
  1303. /* 11.4 coding of abort                                                       */
  1304. /*----------------------------------------------------------------------------*/
  1305. /* subnet */
  1306. #define MSAC_C2_SUBNET_NO               ((UBYTE)0x00)
  1307. #define MSAC_C2_SUBNET_LOCAL            ((UBYTE)0x01)
  1308. #define MSAC_C2_SUBNET_REMOTE           ((UBYTE)0x02)
  1309. /* instance */
  1310. #define MSAC_C2_INSTANCE_FDL            ((UBYTE)0x00)
  1311. #define MSAC_C2_INSTANCE_MSAC_C2        ((UBYTE)0x10)
  1312. #define MSAC_C2_INSTANCE_USER           ((UBYTE)0x20)
  1313. #define MSAC_C2_INSTANCE_RESERVED       ((UBYTE)0x30)
  1314. /* reason */
  1315. #define MSAC_C2_ABT_SE                  ((UBYTE)0x01)   // sequence error
  1316. #define MSAC_C2_ABT_FE                  ((UBYTE)0x02)   // invalid request PDU received
  1317. #define MSAC_C2_ABT_TO                  ((UBYTE)0x03)   // timeout of the connection
  1318. #define MSAC_C2_ABT_RE                  ((UBYTE)0x04)   // invalid response PDU received
  1319. #define MSAC_C2_ABT_IV                  ((UBYTE)0x05)   // invalid service from USER
  1320. #define MSAC_C2_ABT_STO                 ((UBYTE)0x06)   // Send_Timeout requested was too small
  1321. #define MSAC_C2_ABT_IA                  ((UBYTE)0x07)   // invalid additional address information
  1322. #define MSAC_C2_ABT_OC                  ((UBYTE)0x08)   // waiting for FDL_DATA_REPLY.con
  1323. #define MSAC_C2_ABT_RES                 ((UBYTE)0x0F)   // resource error
  1324. /*----------------------------------------------------------------------------*/
  1325. /* 11.5 Function Codes for DPV1                                               */
  1326. /*----------------------------------------------------------------------------*/
  1327. #define DPV1_FC_ERROR                   ((UBYTE)0x80)
  1328. #define DPV1_FC_INITIATE                ((UBYTE)0x57)
  1329. #define DPV1_FC_ABORT                   ((UBYTE)0x58)
  1330. #define DPV1_FC_READ                    ((UBYTE)0x5E)
  1331. #define DPV1_FC_WRITE                   ((UBYTE)0x5F)
  1332. #define DPV1_FC_ALARM_ACK               ((UBYTE)0x5C)
  1333. #define DPV1_FC_IDLE                    ((UBYTE)0x48)
  1334. #define DPV1_FC_TRANSPORT               ((UBYTE)0x51)
  1335. #define DPV1_FC_RM                      ((UBYTE)0x56)
  1336. // mask for function code
  1337. #define MSAC_C2_FN_MASK                 ((UBYTE)0x1F)
  1338. #define MSAC_C2_FN_CONNECT              ((UBYTE)0x17)
  1339. #define MSAC_C2_FN_DATA                 ((UBYTE)0x11)
  1340. #define MSAC_C2_FN_DISCONNECT           ((UBYTE)0x18)
  1341. #define MSAC_C2_FN_IDLE                 ((UBYTE)0x08)
  1342. #define MSAC_C2_FN_DS_READ              ((UBYTE)0x1E)
  1343. #define MSAC_C2_FN_DS_WRITE             ((UBYTE)0x1F)
  1344. /*----------------------------------------------------------------------------*/
  1345. /* 11.6 general defines for DPV1                                              */
  1346. /*----------------------------------------------------------------------------*/
  1347. #define MSAC_C2_TIMEOUT_12MBAUD         ((UWORD)0x0064)
  1348. #define MSAC_C2_TIMEOUT_6MBAUD          ((UWORD)0x0064)
  1349. #define MSAC_C2_TIMEOUT_3MBAUD          ((UWORD)0x0064)
  1350. #define MSAC_C2_TIMEOUT_1_5MBAUD        ((UWORD)0x0064)
  1351. #define MSAC_C2_TIMEOUT_500KBAUD        ((UWORD)0x00C8)
  1352. #define MSAC_C2_TIMEOUT_187_50KBAUD     ((UWORD)0x0190)
  1353. #define MSAC_C2_MIN_POLL_TIMEOUT        ((UWORD)0x0001)
  1354. #define MSAC_C2_MAX_POLL_TIMEOUT        ((UWORD)0x7FFF)
  1355. #define MSAC_C2_MIN_PDU_LEN             ((UBYTE)0x04)
  1356. #define MSAC_C2_LEN_DISCONNECT_PDU      ((UBYTE)0x04)
  1357. #define MSAC_C2_LEN_IDLE_PDU            ((UBYTE)0x02)
  1358. #define MSAC_C2_LEN_RESSOURCE_PDU       ((UBYTE)0x04)
  1359. #define MSAC_C2_MIN_CC_PDU_SIZE         ((UBYTE)0x10)
  1360. #define MSAC_C2_MAX_PDU_SIZE            ((UBYTE)0xF0)
  1361. #define MSAC_C2_MIN_CR_PDU_SIZE         ((UBYTE)0x14)
  1362. #define MSAC_C2_MAX_PDU                 ((UBYTE)0xF4)   // PDU with DPV1-Header (4Byte) + 240 User Data
  1363. #define MSAC_C2_LEN_INITIATE_RES_HEAD   ((UBYTE)0x0C)   // Initiate response, no addr_data[]
  1364. #define DPV1_LEN_NEG_RESPONSE           ((UBYTE)0x04)   // Negative Response PDU
  1365. #define DPV1_LEN_HEAD_DATA              ((UBYTE)0x04)   // Fct,Slot,Index,Len
  1366. #define MSAC_C2_FUNCTION_NUM_EXTENSION  ((UBYTE)0x40)
  1367. #define MSAC_C2_ERROR_FRAME             ((UBYTE)0xC0)
  1368. #define DPV1_ERROR_BIT_RESPONSE         ((UBYTE)0x80)
  1369. #define MSAC_C2_IND_RECV                ((UBYTE)0x01)   // indication receive
  1370. #define MSAC_C2_RESP_SENT               ((UBYTE)0x02)   // response sent
  1371. #define MSAC_C2_IND_DISABLE_DONE        ((UBYTE)0x10)   // ind_disable_done
  1372. #define MSAC_C2_FC_SRD_L                ((UBYTE)0x0C)
  1373. #define VPC3_MSAC_C1_CLOSE_FAILED       ((UBYTE)0x90)
  1374. typedef enum
  1375. {
  1376.     MSAC_C2_RESP_DIRECTION = ((UBYTE)0x01),
  1377.     MSAC_C2_REQ_DIRECTION  = ((UBYTE)0x02)
  1378. } MSAC2_DIRECTION;
  1379. /*----------------------------------------------------------------------------*/
  1380. /* 11.7 structures for DPV1                                                   */
  1381. /*----------------------------------------------------------------------------*/
  1382. typedef struct
  1383. {
  1384.     BLACKFINDATATYPE function_num;
  1385.     BLACKFINDATATYPE slot_num;
  1386.     BLACKFINDATATYPE index;
  1387.     BLACKFINDATATYPE length;
  1388.     BLACKFINDATATYPE pdu_data[1];
  1389. }DPV1_PDU;
  1390. typedef struct
  1391. {
  1392.     BLACKFINDATATYPE function_num;
  1393.     BLACKFINDATATYPE slot_num;
  1394.     BLACKFINDATATYPE index;
  1395.     BLACKFINDATATYPE length;
  1396.     BLACKFINDATATYPE pdu_data[1];
  1397. }DPV1_READ_PDU;
  1398. typedef struct
  1399. {
  1400.     BLACKFINDATATYPE function_num;
  1401.     BLACKFINDATATYPE slot_num;
  1402.     BLACKFINDATATYPE index;
  1403.     BLACKFINDATATYPE length;
  1404.     BLACKFINDATATYPE pdu_data[1];
  1405. }DPV1_WRITE_PDU;
  1406. typedef struct
  1407. {
  1408.     BLACKFINDATATYPE function_num;
  1409.     BLACKFINDATATYPE err_decode;
  1410.     BLACKFINDATATYPE err_code1;
  1411.     BLACKFINDATATYPE err_code2;
  1412. }DPV1_NEG_RES_PDU;
  1413. typedef struct _MSAC_C2_TRANSPORT_PDU
  1414. {
  1415.     BLACKFINDATATYPE  function_num;
  1416.     BLACKFINDATATYPE  slot_num;
  1417.     BLACKFINDATATYPE  index;
  1418.     BLACKFINDATATYPE  length;
  1419.     BLACKFINDATATYPE  pdu_data[1];
  1420. }MSAC_C2_TRANSPORT_PDU;
  1421. typedef struct
  1422. {
  1423.     BLACKFINDATATYPE  function_num;
  1424.     BLACKFINDATATYPE  reserved1;
  1425.     BLACKFINDATATYPE  reserved2;
  1426.     BLACKFINDATATYPE  reserved3;
  1427.     BLACKFINWORD  send_timeout;//未用到
  1428.     BLACKFINDATATYPE  features_supported1;
  1429.     BLACKFINDATATYPE  features_supported2;
  1430.     BLACKFINDATATYPE  profile_features_supported1;
  1431.     BLACKFINDATATYPE  profile_features_supported2;
  1432.     BLACKFINWORD  profile_ident_nummer;
  1433.     BLACKFINDATATYPE  s_type;
  1434.     BLACKFINDATATYPE  s_len;
  1435.     BLACKFINDATATYPE  d_type;
  1436.     BLACKFINDATATYPE  d_len;
  1437.     BLACKFINDATATYPE  addr_data[20];  /* len is defined by S_len or D_len !! */
  1438. }MSAC_C2_INITIATE_REQ_PDU;
  1439. #define MSAC_C2_INITIATE_REQ_PDU_PTR   MSAC_C2_INITIATE_REQ_PDU PTR_ATTR *
  1440. typedef struct _MSAC_C2_INITIATE_SUB_PARAM
  1441. {
  1442.     BLACKFINDATATYPE  api;
  1443.     BLACKFINDATATYPE  reserved;
  1444.     BLACKFINDATATYPE  net_addr[6];
  1445.     BLACKFINDATATYPE  mac_addr[1]; /* len is defined by S_len or D_len !! */
  1446. }MSAC_C2_INITIATE_SUB_PARAM;
  1447. typedef struct _MSAC_C2_INITIATE_RES_PDU
  1448. {
  1449.     BLACKFINDATATYPE  function_num;
  1450.     BLACKFINDATATYPE  max_len_data_unit;
  1451.     BLACKFINDATATYPE  features_supported1;
  1452.     BLACKFINDATATYPE  features_supported2;
  1453.     BLACKFINDATATYPE  profile_features_supported1;
  1454.     BLACKFINDATATYPE  profile_features_supported2;
  1455.     BLACKFINWORD  profile_ident_nummer;
  1456.     BLACKFINDATATYPE  s_type;
  1457.     BLACKFINDATATYPE  s_len;
  1458.     BLACKFINDATATYPE  d_type;
  1459.     BLACKFINDATATYPE  d_len;
  1460.     BLACKFINDATATYPE  addr_data[1]; /* len is defined by S_len and D_len !! */
  1461. }MSAC_C2_INITIATE_RES_PDU;
  1462. typedef struct _MSAC_C2_ABORT_PDU
  1463. {
  1464.     BLACKFINDATATYPE  function_num;
  1465.     BLACKFINDATATYPE  subnet;
  1466.     BLACKFINDATATYPE  instance_reason;
  1467.     BLACKFINDATATYPE  reserved; /* MSAC_C2 + 1 Byte, no additional Detail */
  1468. }MSAC_C2_ABORT_PDU;
  1469. typedef struct
  1470. {
  1471.     BLACKFINDATATYPE function_num;
  1472.     BLACKFINDATATYPE slot_num;
  1473.     BLACKFINDATATYPE alarm_type;
  1474.     BLACKFINDATATYPE specifier;
  1475. }MSAC_C1_ALARM_ACK_PDU;
  1476. #define ALARM_ACK_REQ_PTR MSAC_C1_ALARM_ACK_PDU PTR_ATTR *
  1477. typedef union
  1478. {
  1479.     BLACKFINDATATYPE                     ubyte_ptr;
  1480.     DPV1_READ_PDU             read;
  1481.     DPV1_WRITE_PDU            write;
  1482.     MSAC_C1_ALARM_ACK_PDU     alarm;
  1483.     MSAC_C2_TRANSPORT_PDU     transport;
  1484.     MSAC_C2_INITIATE_REQ_PDU  initiate_req;
  1485.     MSAC_C2_ABORT_PDU         abort;
  1486.     MSAC_C2_INITIATE_RES_PDU  initiate_res;
  1487.     DPV1_NEG_RES_PDU          neg;
  1488.     DPV1_PDU                  response;
  1489. }DPV1_UNION_PDU;
  1490. #define DPV1_PTR   DPV1_UNION_PDU PTR_ATTR *
  1491. typedef struct
  1492. {
  1493.   BLACKFINDATATYPE                   opcode;
  1494.   BLACKFINDATATYPE                   reserved1;
  1495.   BLACKFINWORD                       reserved2;
  1496.   BLACKFINWORD                       poll_time_out;
  1497.   BLACKFINWORD                       features_supported;//未用到
  1498.   BLACKFINWORD                       profile_features_supported;
  1499.   BLACKFINWORD                       profile_ident_number;
  1500. }MSAC_C2_CR_BUF;
  1501. #define MSAC_C2_CR_BUF_PTR            MSAC_C2_CR_BUF PTR_ATTR *
  1502. typedef struct
  1503. {
  1504.   BLACKFINDATATYPE                       opcode;
  1505.   BLACKFINDATATYPE                       max_pdu_size;
  1506.   BLACKFINWORD                       features_supported;
  1507.   BLACKFINWORD                       profile_features_supported;
  1508.   BLACKFINWORD                       profile_ident_number;
  1509. }MSAC_C2_CC_BUF;
  1510. #define MSAC_C2_CC_BUF_PTR            MSAC_C2_CC_BUF PTR_ATTR *
  1511. typedef struct
  1512. {
  1513.   BLACKFINDATATYPE                       opcode;
  1514.   BLACKFINDATATYPE                       location;
  1515.   BLACKFINDATATYPE                       reason_code;
  1516.   BLACKFINDATATYPE                       reserved;
  1517. }MSAC_C2_DR_BUF;
  1518. #define MSAC_C2_DR_BUF_PTR            MSAC_C2_DR_BUF PTR_ATTR *
  1519. typedef struct
  1520. {
  1521.   BLACKFINDATATYPE                       opcode;
  1522.   BLACKFINDATATYPE                       slot;
  1523.   BLACKFINDATATYPE                       index;
  1524.   BLACKFINDATATYPE                       length;
  1525. }MSAC_C2_DE_BUF;
  1526. #define MSAC_C2_DE_BUF_PTR            MSAC_C2_DE_BUF PTR_ATTR *
  1527. typedef struct
  1528. {
  1529.   BLACKFINDATATYPE                       opcode;
  1530.   BLACKFINDATATYPE                       reserved;
  1531. }MSAC_C2_WAIT_BUF;
  1532. #define MSAC_C2_WAIT_BUF_PTR      MSAC_C2_WAIT_BUF PTR_ATTR *
  1533. // input queue element
  1534. typedef struct
  1535. {
  1536.   MSAC_C2_DATA_BUF_PTR  buf_ptr;
  1537.   UBYTE                 ret_value;
  1538.   UBYTE                 sap_nr;
  1539.   UBYTE                 fdl_code;
  1540. }MSAC_C2_REC_QUEUE;
  1541. #define MSAC_C2_REC_QUEUE_PTR    MSAC_C2_REC_QUEUE PTR_ATTR *
  1542. // reserve queue for ind disable buffer
  1543. typedef struct
  1544. {
  1545.   BLACKFINDATATYPE                 data_len;                              // length of netto-data
  1546.   BLACKFINDATATYPE                 fc;                                    // function-code
  1547.   BLACKFINDATATYPE                 user_data[MSAC_C2_LEN_DISCONNECT_PDU]; // netto-data
  1548. }MSAC_C2_RES_IND_QUEUE;
  1549. //defines for MSAC_C2 connection state
  1550. typedef enum
  1551. {
  1552.     MSAC_C2_CS_CLOSE_CHANNEL    = ((UBYTE)0x01),    // initialization state
  1553.     MSAC_C2_CS_AWAIT_CONNECT    = ((UBYTE)0x04),    // first state
  1554.     MSAC_C2_CS_AWAIT_IND        = ((UBYTE)0x05),    // state after successfull connect
  1555.     MSAC_C2_CS_PROVIDE_IND      = ((UBYTE)0x06),
  1556.     MSAC_C2_CS_PROVIDE_RESP     = ((UBYTE)0x07),
  1557.     MSAC_C2_CS_DISABLE_CONNECT  = ((UBYTE)0x08)
  1558. } MSAC2_CONN_STATE;
  1559. //defines for MSAC_C2 error codes
  1560. typedef enum
  1561. {
  1562.     MSAC_C2_EC_OK               = ((UBYTE)0x00),    //  without errors
  1563.     MSAC_C2_EC_USER_ERR         = ((UBYTE)0x01),    //  invalid response data
  1564.     MSAC_C2_EC_INV_S_D_LEN_ERR  = ((UBYTE)0x03),    //  S,D-len error
  1565.     MSAC_C2_EC_REQ_TIMEOUT      = ((UBYTE)0x05),    //  req_time_out
  1566.     MSAC_C2_EC_DC_BY_USER       = ((UBYTE)0x0D),    //  user response is disconnect
  1567.     MSAC_C2_EC_DC_BY_MASTER     = ((UBYTE)0x0E),    //  master request is disconnect
  1568.     MSAC_C2_EC_REMOTE_ERROR     = ((UBYTE)0x10)     //  invalid pdu from the master
  1569. } MSAC2_ERROR_CODE;
  1570. //defines for MSAC_C2 user_break
  1571. typedef enum
  1572. {
  1573.     MSAC_C2_UB_NO_BREAK         = ((UBYTE)0x00),
  1574.     MSAC_C2_UB_BREAK            = ((UBYTE)0x01)
  1575. } MSAC2_USER_BREAK;
  1576. // MSAC_C2 connections
  1577. typedef struct
  1578. {
  1579.   MSAC_C2_DATA_BUF_PTR  buf_ptr;             /* data_ptr */
  1580.   MSAC_C2_DATA_BUF_PTR  buf_ptr_res;         /* reserve data_ptr */
  1581.   MSAC_C2_DATA_BUF_PTR  wait_buf_ptr;        /* buffer_ptr for wait_pdu */
  1582.   UWORD                 poll_time_out;       /* poll_time_out for the connection */
  1583.   UBYTE                 timer_id;            /* id for used timer */
  1584.   UBYTE                 sap_nr;              /* sap_nr FDL */
  1585.   UBYTE                 cn_id;               /* connection id */
  1586.   UBYTE                 opcode;              /* fc of actual pdu */
  1587.   MSAC2_CONN_STATE      state;               /* connection state */
  1588.   MSAC2_ERROR_CODE      error_code;
  1589.   UBYTE                 dr_reason_code;      /* save reason_code of MSAC_C2_disconnect() */
  1590.   UBYTE                 dr_location;         /* save location of MSAC_C2_disconnect() */
  1591.   MSAC2_USER_BREAK      user_break;          /* user with disconnect request */
  1592.   UBYTE                 timer_break;         /* timeout may be ignored */
  1593.   UBYTE                 timer_active;        /* timer has started */
  1594. }MSAC_C2_CONNECT_ITEM;
  1595. #define MSAC_C2_CONNECT_ITEM_PTR  MSAC_C2_CONNECT_ITEM PTR_ATTR *
  1596. // -- defines for MSAC2 - Timer -----------------------------------------------------
  1597. #define MSAC_C2_TIMER_OK                ((UBYTE)10)
  1598. #define MSAC_C2_TIMER_ALREADY_STOPPED   ((UBYTE)20)
  1599. #define MSAC_C2_TIMER_ALREADY_RUNS      ((UBYTE)30)
  1600. typedef struct
  1601. {
  1602.   UWORD  time_act;
  1603.   UBYTE  running;
  1604. } MSAC_C2_TIMER;
  1605. #define MSAC_C1_IND_DS_READ             ((UBYTE)0x01)
  1606. #define MSAC_C1_IND_DS_WRITE            ((UBYTE)0x02)
  1607. #define MSAC_C1_IND_ALARM_QUIT          ((UBYTE)0x04)
  1608. #define MSAC_C1_IND_ALARM_QUIT_SAP50    ((UBYTE)0x08)
  1609. /*----------------------------------------------------------------------------*/
  1610. /* 11.8 defines for ALARM                                                     */
  1611. /*----------------------------------------------------------------------------*/
  1612. // max length of alarm-fifo
  1613. #define ALARM_MAX_FIFO                  ((UBYTE)0x20)
  1614. // defines for Status-Types
  1615. #define STATUS_MESSAGE                  ((UBYTE)0x81)
  1616. #define MODUL_STATUS                    ((UBYTE)0x82)
  1617. #define SET_ALARM_AL_STATE_CLOSED       ((UBYTE)0x01)
  1618. #define SET_ALARM_SEQ_NR_ERROR          ((UBYTE)0x02)
  1619. #define SET_ALARM_SPECIFIER_ERROR       ((UBYTE)0x03)
  1620. #define SET_ALARM_LIMIT_EXPIRED         ((UBYTE)0x04)
  1621. #define SET_ALARM_PENDING               ((UBYTE)0x05)
  1622. #define SET_ALARM_ALARMTYPE_NOTSUPP     ((UBYTE)0x06)
  1623. #define SET_ALARM_OK                    ((UBYTE)0x00)
  1624. #define SET_STATUS_NOT_ENABLED          ((UBYTE)0x01)
  1625. #define SET_STATUS_OK                   ((UBYTE)0x00)
  1626. // defines for alarm-type
  1627. #define ALARM_TYPE_MAX                  ((UBYTE)0x07)   //wusenlin 这个宏有问题alarm_decode地址越界,待处理。
  1628. #define ALARM_TYPE_DIAGNOSTIC           ((UBYTE)0x01)
  1629. #define ALARM_TYPE_PROCESS              ((UBYTE)0x02)
  1630. #define ALARM_TYPE_PULL                 ((UBYTE)0x03)
  1631. #define ALARM_TYPE_PLUG                 ((UBYTE)0x04)
  1632. #define ALARM_TYPE_STATUS               ((UBYTE)0x05)
  1633. #define ALARM_TYPE_UPDATE               ((UBYTE)0x06)
  1634. #define ALARM_TYPE_MANU_MIN             ((UBYTE)0x20)
  1635. #define ALARM_TYPE_MANU_MAX             ((UBYTE)0x7E)
  1636. // defines for sequence_mode
  1637. #define SEQC_MODE_TOTAL_00              ((UBYTE)0x00)
  1638. #define SEQC_MODE_OFF                   ((UBYTE)0x01)
  1639. #define SEQC_MODE_TOTAL_02              ((UBYTE)0x02)
  1640. #define SEQC_MODE_TOTAL_04              ((UBYTE)0x04)
  1641. #define SEQC_MODE_TOTAL_08              ((UBYTE)0x08)
  1642. #define SEQC_MODE_TOTAL_12              ((UBYTE)0x0C)
  1643. #define SEQC_MODE_TOTAL_16              ((UBYTE)0x10)
  1644. #define SEQC_MODE_TOTAL_24              ((UBYTE)0x18)
  1645. #define SEQC_MODE_TOTAL_32              ((UBYTE)0x20)
  1646. // defines for specifier
  1647. #define SPEC_GENERAL                    ((UBYTE)0x00)
  1648. #define SPEC_APPEARS                    ((UBYTE)0x01)
  1649. #define SPEC_DISAPPEARS                 ((UBYTE)0x02)
  1650. #define SPEC_MASK                       ((UBYTE)0x03)
  1651. #define SPEC_SEQ_START                  ((UBYTE)0x03)   //use it to shift the sequence number down to bit 0 or up to bit 3
  1652. #define MAX_SEQ_NR                      ((UBYTE)0x20)
  1653. #define SEQUENCE_NUMBER_ALL             ((UBYTE)0xFF)
  1654. #define SEQ_NR_MASK                     ((UBYTE)0xF8)
  1655. #define SPEC_ADD_ACK                    ((UBYTE)0x04)
  1656. #define szAlarmHeader                   ((UBYTE)0x04)
  1657. /*----------------------------------------------------------------------------*/
  1658. /* 11.9 structure of ALARM                                                    */
  1659. /*----------------------------------------------------------------------------*/
  1660. /*
  1661. typedef struct dpl_list_cb
  1662. {
  1663.     struct dpl_list_cb DPL_PTR_ATTR *next_blk_ptr;
  1664.     struct dpl_list_cb DPL_PTR_ATTR *prev_blk_ptr;
  1665. }   DPL_STRUC_LIST_CB;*/
  1666. typedef struct
  1667. {
  1668.   DPL_STRUC_LIST_CB list_head;
  1669.   UBYTE                 header;
  1670.   UBYTE                 type;
  1671.   UBYTE                 slot;
  1672.   UBYTE                 spec;
  1673.   UBYTE                 user_data_len;
  1674.   UBYTE                 callback;
  1675.   VPC3_UNSIGNED8_PTR    user_data_ptr;
  1676. }ALARM_STATUS_PDU;
  1677. #define ALARM_STATUS_PDU_PTR   ALARM_STATUS_PDU PTR_ATTR *
  1678. typedef union
  1679. {
  1680.     DPL_STRUC_LIST_CB_PTR list_ptr;
  1681.     ALARM_STATUS_PDU_PTR  data_ptr;
  1682. }ALARM_UNION_ALARM;
  1683. /*-----------------------------------------------------------------------------------------------------------*/
  1684. /* 12.0 global system structure                                                                              */
  1685. /*-----------------------------------------------------------------------------------------------------------*/
  1686. //defines for MSAC1 Operation Mode
  1687. typedef enum
  1688. {
  1689.     DP_OPMODE_V0        = ((UBYTE)0x00),
  1690.     DP_OPMODE_V1        = ((UBYTE)0x01)
  1691. } MSAC1_OPMODE;
  1692. //defines for MSAC1 Start State
  1693. typedef enum
  1694. {
  1695.     DP_SS_IDLE          = ((UBYTE)0x00),
  1696.     DP_SS_STOP          = ((UBYTE)0x01),
  1697.     DP_SS_START_AGAIN   = ((UBYTE)0x02),
  1698.     DP_SS_RUN           = ((UBYTE)0x03)
  1699. } MSAC1_START_STATE;
  1700. // -- structures --------------------------------------------------------------
  1701. typedef struct
  1702. {
  1703.     UBYTE               DX_Entered;
  1704.     UBYTE               Fdl_Closing;
  1705.     MSAC1_OPMODE        Operation_Mode;             // DP/DPV1
  1706.     UBYTE               active_Job;
  1707.     MSAC1_START_STATE   Start_State;
  1708.     UBYTE               event;
  1709. } C1_STRUC;
  1710. #define AL_STATE_CLOSED                 ((UBYTE)0x10)
  1711. #define AL_STATE_OPEN                   ((UBYTE)0x11)
  1712. #define AL_TYPE_MAX                     ((UBYTE)0x07)   // dpv1 draft specification - do not use cast !
  1713. #define AL_SEQUENCE_MAX                 ((UBYTE)0x20)   // dpv1 draft specification - do not use cast !
  1714. //defines for sequence_status
  1715. #define AL_SEQUENCE_STATUS_SIZE         ((UBYTE)(((ALARM_TYPE_MAX * MAX_SEQ_NR)+7)/8))
  1716. #define AL_ALARM_STATUS_ACTION_SET      ((UBYTE)0x11)
  1717. #define AL_ALARM_STATUS_ACTION_CHECK    ((UBYTE)0x49)
  1718. #define AL_ALARM_STATUS_ACTION_RESET    ((UBYTE)0x57)
  1719. typedef struct
  1720. {
  1721.     DPL_STRUC_LIST_CB queue_new;
  1722.     DPL_STRUC_LIST_CB queue_ack;
  1723.     UBYTE       state;
  1724.     UBYTE       enabled;    //DPV1_STATUS 2, indicates the type of alarms
  1725.     UBYTE       mode;       //DPV1_STATUS 3
  1726.     UBYTE       type_status;
  1727.     UBYTE       sequence_status[ AL_SEQUENCE_STATUS_SIZE ];
  1728.     UBYTE       sequence;   //FALSE: only one alarm of a specific ALARM_TYPE can be active at one time
  1729.                             //TRUE : several alarms (2 to 32) of the same or different ALARM_TYPE can be
  1730.                             //       active at one time
  1731.     UBYTE       limit;      //contains the maximum number of alarms
  1732.                             //allowed by the actual master-slave connection
  1733.     UBYTE       count;      //contains the number of alarms, which have been sent
  1734. } AL_STRUC;
  1735. // -- dp system structure -----------------------------------------------------
  1736. typedef struct
  1737. {
  1738.     UBYTE               outp_data_len;              // calculated output length (data from DP-Master to VPC3)
  1739.     UBYTE               inp_data_len;               // calculated input length  (data from VPC3 to DP-Master)
  1740.     UWORD               vpc3_used_dp_buf_mem;       // consumed user_memory
  1741.     UBYTE               ind_high;                   // interrupt indication high byte
  1742.     UBYTE               ind_low;                    // interrupt indication low byte
  1743.     UBYTE               vpc3_con;                   // dummy
  1744.     UBYTE               din_bufsize;                // Length of the DIn Buffer (Data Slave to Master)                0..244
  1745.     UBYTE               dout_bufsize;               // Length of the DOut Buffer     (Data Master to Slave)           0..244
  1746.     UBYTE               prm_bufsize;                // Length of the Parameter Buffer                                 7..244
  1747.     UBYTE               diag_bufsize;               // Length of the Diagnosis Buffer                                 6..244
  1748.     UBYTE               cfg_bufsize;                // Length of the Configuration Buffer                             1..244
  1749.     UBYTE               ssa_bufsize;                // Length of the Input Data in the Set_Slave_Address-Buffer 0 and 4..244
  1750.     UBYTE               c2_num_saps;                // Number of MSAC_C2 connections
  1751.     UBYTE               c2_len;                     // Length of MSAC_C2 Data
  1752.     C1_STRUC            c1;
  1753.     AL_STRUC            al;
  1754.     T_ISOCHRON          iso_m;
  1755.     VPC3_UNION_DIAG_PTR diag_buf_ptr;               // pointer to actual diagnosis buffer
  1756. } VPC3_SYSTEM_STRUC;
  1757. #define VPC3_SYSTEM_STRUC_PTR    VPC3_SYSTEM_STRUC  PTR_ATTR *
  1758. /*---------------------------------------------------------------------------*/
  1759. /* 13.0 defines, structure for sDP_VERSION                                   */
  1760. /*---------------------------------------------------------------------------*/
  1761. // structure for I&M CALL
  1762. #define IM_FN_CALL ((UBYTE)0x08)
  1763. #define IM0_INDEX ((UWORD)0xFDE8)
  1764. typedef struct
  1765. {
  1766. BLACKFINDATATYPE bExtendedFunctionNumber;
  1767. BLACKFINDATATYPE bReserved;
  1768. BLACKFINWORD wIndex;
  1769. BLACKFINDATATYPE abData[1];  
  1770. } sIMCALL;
  1771. #define psIMCALL sIMCALL PTR_ATTR *
  1772. // structure for I&M0 (mandatory)
  1773. typedef struct
  1774. {
  1775. BLACKFINDATATYPE abHeader[10];
  1776. BLACKFINWORD wManufacturerID;
  1777. BLACKFINDATATYPE abOrderID[20];
  1778. BLACKFINDATATYPE abSerialNumber[16];
  1779. BLACKFINWORD wHardwareRevision;
  1780. BLACKFINDATATYPE abSoftwareRevision[4];
  1781. BLACKFINWORD wRevCounter;
  1782. BLACKFINWORD wProfileID;
  1783. BLACKFINWORD   wProfileSpecificType;
  1784. BLACKFINDATATYPE abIMVersion[2];
  1785. BLACKFINWORD wIMSupported;
  1786. } sIM0;
  1787. #define SizeOfIM0 ((UBYTE)0x40)
  1788. /*---------------------------------------------------------------------------*/
  1789. /* 14.0 defines, structure for sDP_VERSION                                   */
  1790. /*---------------------------------------------------------------------------*/
  1791. #define DP_COMP_INSTALLED_MSAC1_IFA ((UWORD)0x0001)
  1792. #define DP_COMP_INSTALLED_SUB_AL ((UWORD)0x0002)
  1793. #define DP_COMP_INSTALLED_SUB_AL_50 ((UWORD)0x0004)
  1794. #define DP_COMP_INSTALLED_MSAC2_IFA ((UWORD)0x0100)
  1795. #define DP_COMP_INSTALLED_IM ((UWORD)0x0200)
  1796. #define DP_COMP_INSTALLED_VPC3_B  ((UWORD)0x1000)
  1797. #define DP_COMP_INSTALLED_VPC3_C  ((UWORD)0x2000)
  1798. #define DP_COMP_INSTALLED_VPC3_D  ((UWORD)0x4000)
  1799. typedef struct
  1800. {
  1801.     UWORD wComponentsInstalled;
  1802.     UBYTE bMainInterface;
  1803.     UBYTE bFunction;
  1804.     UBYTE bBugfix;
  1805. } sDP_VERSION;
  1806. #define psDP_VERSION sDP_VERSION  VPC3_PTR
  1807. /*-----------------------------------------------------------------------------------------------------------*/
  1808. /* 15.0 ERROR defines                                                                                        */
  1809. /*-----------------------------------------------------------------------------------------------------------*/
  1810. typedef enum
  1811. {
  1812.     DP_FATAL_ERROR                  = 0x00, // fatal error
  1813.     DP_OK                           = 0x01, // OK
  1814.     DP_NOK                          = 0x02, // OK
  1815.     DP_NOT_OFFLINE_ERROR            = 0x10, // VPC3 is not in OFFLINE state
  1816.     DP_ADDRESS_ERROR                = 0x11, // Slave Address Error
  1817.     DP_CALCULATE_IO_ERROR           = 0x12,
  1818.     DP_DOUT_LEN_ERROR               = 0x13,
  1819.     DP_DIN_LEN_ERROR                = 0x14,
  1820.     DP_DIAG_LEN_ERROR               = 0x15,
  1821.     DP_PRM_LEN_ERROR                = 0x16,
  1822.     DP_SSA_LEN_ERROR                = 0x17,
  1823.     DP_CFG_LEN_ERROR                = 0x18,
  1824.     DP_LESS_MEM_ERROR               = 0x19,
  1825.     DP_LESS_MEM_FDL_ERROR           = 0x1A,
  1826.     DP_PRM_ENTRY_ERROR              = 0x20,
  1827.     DP_PRM_DXB_MAX_LINK_ERROR       = 0x21,
  1828.     DP_PRM_DXB_ERROR                = 0x22,
  1829.     DP_CFG_ENTRY_ERROR              = 0x23,
  1830.     DP_CFG_UPDATE_ERROR             = 0x24,
  1831.     DP_PRM_DPV1_STATUS              = 0x25,
  1832.     DP_PRM_BLOCK_ERROR              = 0x26,
  1833.     DP_PRM_ALARM_ERROR              = 0x27,
  1834.     DP_PRMCMD_LEN_ERROR             = 0x28,
  1835.     DP_PRM_SOLL_IST_ERROR           = 0x29,
  1836.     DP_PRM_DXB_WD_ERROR             = 0x2A,
  1837.     DP_DIAG_BUFFER_ERROR            = 0x30,
  1838.     DP_DIAG_SEQUENCE_ERROR          = 0x31,
  1839.     DP_DIAG_OLD_DIAG_NOT_SEND_ERROR = 0x32,
  1840.     DP_DIAG_NOT_POSSIBLE_ERROR      = 0x33,
  1841.     DP_DIAG_NO_BUFFER_ERROR         = 0x34,
  1842.     DP_DIAG_BUFFER_LENGTH_ERROR     = 0x35,
  1843.     DP_DIAG_CONTROL_BYTE_ERROR      = 0x36,
  1844.     C2_DATA_LEN_ERROR               = 0x80,
  1845.     C2_DATA_POLL_TIMEOUT_ERROR      = 0x81,
  1846.     C2_DATA_SAP_ERROR               = 0x82,
  1847.     C2_NO_CONN_RESOURCE             = 0x83,
  1848.     C2_INV_LOWER_LAYER              = 0x84,
  1849.     C2_ENABLED_ERROR                = 0x85,
  1850.     C2_RESOURCE_ERROR               = 0x86,
  1851.     C2_INV_CN_ID                    = 0x87,
  1852.     C2_USER_ERR                     = 0x88,
  1853.     SSC_MAX_DATA_PER_LINK           = 0x90,
  1854.     DP_EEPROM_ERROR                 = 0xF1, // Hardware errors
  1855.     DP_VPC3_ERROR                   = 0xF4,
  1856.     DP_SRAM_ERROR                   = 0xFF
  1857. }   DP_ERROR_CODE;
  1858. typedef enum
  1859. {
  1860.     _DP_USER    = 0x10,
  1861.     _DP_IF      = 0x20,
  1862.     _DP_ISR     = 0x30,
  1863.     _DP_FDL     = 0x40,
  1864.     _DP_C1      = 0x50,
  1865.     _DP_C2      = 0x60
  1866. }   DP_ERROR_FILE;
  1867. typedef struct
  1868. {
  1869.     UBYTE                   function;
  1870.     UBYTE                   error_code;
  1871.     UWORD                   detail;
  1872.     UBYTE                   cn_id;
  1873. }   VPC3_STRUC_ERRCB;
  1874. #define VPC3_ERRCB_PTR   VPC3_STRUC_ERRCB PTR_ATTR *
  1875. extern VPC3_STRUC_ERRCB   vpc3_errcb[MAX_DEV_NUM];
  1876. /*****************************************************************************/
  1877. /* reinclude-protection */
  1878. #else
  1879.     #pragma message "The header DP_IF.H is included twice or more !"
  1880. #endif
  1881. /*****************************************************************************/
  1882. /*  Copyright (C) profichip GmbH 2001. Confidential.                         */
  1883. /*****************************************************************************/