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

📄 intspc30816.lst

📁 pROFIBUS 从站源程序 SPC3 pROFIBUS 从站源程序 SPC3
💻 LST
📖 第 1 页 / 共 2 页
字号:
 189   2              do
 190   2                      {   /* check configuration data until no conflict behavior m;检查组态数据直到无冲突 */
 191   3                      cfg_ptr = DPS2_GET_CFG_BUF_PTR();             /* pointer to the config_data_block */
 192   3                      config_data_len = DPS2_GET_CFG_LEN();/* DPS2_GET_CFG_LEN()即spc3.r_len_cfg_buf */
 193   3      
 194   3                      /* $$In this example the only possible configurations are 0x15 and 0x25
 195   3                         (4 Byte I/O) or 0x11 and 0x21 (2 Byte I/O) are possible */
 196   3      
 197   3                      if ( config_data_len != 2)
 198   3                              cfg_result = DPS2_SET_CFG_DATA_NOT_OK();/**/
 199   3                      else
 200   3                              {   /* Length of the configuration data  o.k. */
 201   4                                      /* check the configuratin bytes           */
 202   4      
 203   4                              if ((cfg_akt[0] == cfg_ptr[0]) && (cfg_akt[1] == cfg_ptr[1]))
 204   4                                      result = DPS_CFG_OK;
 205   4                      /* the desired conf. is equal the actuall configuration;期望组态和实际组态数据相等;0x15*/
 206   4                              else
 207   4                                      {
 208   5                                      if (((cfg_ptr[0] == 0x51) && (cfg_ptr[1]) ==0x61)
 209   5                                        || ((cfg_ptr[0] == 0x53) && (cfg_ptr[1]) ==0x63))
 210   5                                              {
 211   6                                              cfg_akt[0] = cfg_ptr[0];
 212   6                                              cfg_akt[1] = cfg_ptr[1];
 213   6                                              result = DPS_CFG_UPDATE;
 214   6                                              }
 215   5                                      else
 216   5                                              result = DPS_CFG_FAULT;              /* as example !!!!! */
 217   5      
 218   5      
 219   5                                      if (result == DPS_CFG_UPDATE)
 220   5                                              {
 221   6                                              user_io_data_len_ptr = dps2_calculate_inp_outp_len (cfg_ptr,(UWORD)config_data_len);
 222   6                                                  /*根据新的组态数据计算I/O数据长度;见.Cp5 */
 223   6                                              if (user_io_data_len_ptr != (DPS2_IO_DATA_LEN *)0)
 224   6                                                      {
 225   7                                                      DPS2_SET_IO_DATA_LEN(user_io_data_len_ptr);
 226   7                                             /*相对与初始化设定,检查lens,如果正确,SPC3的指针和lens将装入;.Cp11 
             -*/
 227   7                                                      }
 228   6                                              else
 229   6                                                      result = DPS_CFG_FAULT;
 230   6                                              }
 231   5                                      }
 232   4                              switch (result)
 233   4                                      {
 234   5                                      case DPS_CFG_OK: cfg_result = DPS2_SET_CFG_DATA_OK();/* 见.Cp12;Hp8 */
 235   5                                              break;
 236   5      
 237   5                                      case DPS_CFG_FAULT: cfg_result = DPS2_SET_CFG_DATA_NOT_OK();/* 见.Cp12 */
 238   5                                              break;
C51 COMPILER V7.02b   INTSPC30816                                                          11/01/2004 20:51:04 PAGE 5   

 239   5      
 240   5                                      case DPS_CFG_UPDATE: cfg_result = DPS2_SET_CFG_DATA_UPDATE();/*见.Cp12 */
 241   5                                              break;
 242   5                                      }
 243   4                              }
 244   3      
 245   3                      } while(cfg_result == DPS2_CFG_CONFLICT);/**/
 246   2              }
 247   1      
 248   1      if(DPS2_GET_IND_NEW_SSA_DATA())
 249   1              {   /*=== New Slave address received;收到新的从站地址===*/
 250   2              address_data_function(DPS2_GET_SSA_BUF_PTR(), DPS2_GET_SSA_LEN());/* 函数.I;两参数见.Hp9*/
 251   2              DPS2_CON_IND_NEW_SSA_DATA();    /* confirm this indication */
 252   2              }
 253   1      
 254   1      if(DPS2_GET_IND_WD_DP_MODE_TIMEOUT())
 255   1              {   /*=== Watchdog is run out;看门狗跑飞===*/
 256   2              wd_dp_mode_timeout_function();
 257   2              DPS2_CON_IND_WD_DP_MODE_TIMEOUT();  /* confirm this indication;.Hp8 */
 258   2              }
 259   1      if(SPC3_GET_IND_USER_TIMER_CLOCK())
 260   1              {   /*==== Timer tick received;定时器;.Hp8 ====*/
 261   2              SPC3_CON_IND_USER_TIMER_CLOCK();
 262   2              }
 263   1      
 264   1      if(SPC3_GET_IND_BAUDRATE_DETECT())
 265   1              {   /*==== Baudrate found  ====*/
 266   2      
 267   2              /* If the baudrate has lost and again found in the state WAIT_CFG,  */
 268   2              /*  DATA_EX the SPC3 would answer to the next telegramms            */
 269   2              /*  with his default mintsdr.                                       */
 270   2              /* But he should answer in the meantime parametrized mindstr        */
 271   2      
 272   2              if ((DPS2_GET_DP_STATE() ==  DPS2_DP_STATE_WAIT_CFG )
 273   2                      ||  (DPS2_GET_DP_STATE()  ==  DPS2_DP_STATE_DATA_EX)) /*.Hp10;PDF22*/
 274   2                       SPC3_SET_MINTSDR(store_mintsdr);/* .Hp8 */
 275   2      
 276   2              SPC3_CON_IND_BAUDRATE_DETECT();/* .Hp8 */
 277   2              }
 278   1      SPC3_SET_EOI(); /* .Hp8  */
 279   1      }   /* End dps2_ind() */
 280          
 281          
 282          
 283          /************************************************************************/
 284          /*  D e s c r i p t i o n :                                             */
 285          /*                                                                      */
 286          /*  address data function                                               */
 287          /************************************************************************/
 288          #pragma global
 289          
 290          void address_data_function (void SPC3_PTR_ATTR*(address_data_ptr), UBYTE address_data_len)
 291          {
 292   1      char    ch;
 293   1      
 294   1      /* change the slave-address;改变从站地址*/
 295   1      struct dps_address_data SPC3_PTR_ATTR * addr_ptr;/*定义结构体指针;结构体见.Hp5 */
 296   1      
 297   1      ch=address_data_len;
 298   1      
 299   1      addr_ptr = address_data_ptr;
 300   1      
C51 COMPILER V7.02b   INTSPC30816                                                          11/01/2004 20:51:04 PAGE 6   

 301   1      this_station = addr_ptr->new_address;
 302   1      real_no_add_chg = addr_ptr->no_add_chg;
 303   1      
 304   1      /* store the new address and the bit real_no_add_chg for the next startup */
 305   1      
 306   1      DPS2_FREE_SSA_BUF(); /* release the Set Slave Address buffer;DPS2_FREE_SSA_BUF()即_dps2_x = spc3.ssa_buffe
             -r_free_cmd;14H*/
 307   1      }
 308          #pragma public
 309          
 310          
 311          /************************************************************************/
 312          /*  D e s c r i p t i o n :                                             */
 313          /*                                                                      */
 314          /*  restart_function                                               */
 315          /************************************************************************/
 316          
 317          #pragma global
 318          
 319          void wd_dp_mode_timeout_function (void)
 320          {
 321   1      UBYTE rueck;
 322   1       /* Watchdog is run out. The SPC3 reset the PROFIBUS DP Statemachine;看门狗跑飞,复位DP状态机*/
 323   1      
 324   1      user_wd_state = SPC3_GET_WD_STATE();/* .Hp10 */
 325   1      
 326   1              /*SX    small weakness of the SPC3
 327   1                              Update of the diagnosis with 00
 328   1                              otherwise the bit "static diagnosis" would appear in the
 329   1                              next startup */
 330   1      
 331   1      
 332   1      rueck = DPS2_SET_DIAG_LEN(6);/* .Hp9 */
 333   1      rueck = DPS2_SET_DIAG_STATE(0x00);/* .Hp9;诊断值为00H */
 334   1      DPS2_DIAG_UPDATE();/* 见.Cp14 dps2_diag_update() */
 335   1      
 336   1      
 337   1      }
 338          #pragma public
 339          
 340          /************************************************************************/
 341          /*  D e s c r i p t i o n :                                             */
 342          /*                                                                      */
 343          /*  global_ctrl_command_function                                        */
 344          /************************************************************************/
 345          #pragma global
 346          
 347          void global_ctrl_command_function (void)
 348          {
 349   1      
 350   1      user_global_ctrl_command = DPS2_GET_GC_COMMAND();
 351   1      
 352   1      }
 353          #pragma public
 354          
 355          /************************************************************************/
 356          /*  D e s c r i p t i o n :                                             */
 357          /*                                                                      */
 358          /*  go_leave_data_ex_function                                           */
 359          /************************************************************************/
 360          #pragma global
 361          
C51 COMPILER V7.02b   INTSPC30816                                                          11/01/2004 20:51:04 PAGE 7   

 362          void go_leave_data_ex_function (void)
 363          {
 364   1      
 365   1      user_dps_state = DPS2_GET_DP_STATE();
 366   1      }
 367          
 368          #pragma public
 369          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    863    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      4       6
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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