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

📄 socrat_b.c

📁 Infineon公司有一款实现SHDSL协议(ADSL协议的变种)的芯片
💻 C
📖 第 1 页 / 共 4 页
字号:
   pMsg->id      = MSG_ID_SOCRATES_GHS_INDICATE_STATE;
   pMsg->length  = 1;
   DdsMsgSend (pMsg);
}


/*******************************************************************************
Description:
   Downloads capability list.
Arguments:
   none
Return:
   none
Remarks:
    none
Author: CM
 ******************************************************************************/
static void Soc_Cl_Download (void)
{
    WORD8 i, counter, blocknr;

                                       /* reset TX and RX FIFO for EOC data 
                                          may reside */
   BFLD (SOCRATES_CMD_E, 0x00, SOCRATES_CMD_E_XRES_E);
                                       /* take back reset */
   BFLD (SOCRATES_CMD_E, SOCRATES_CMD_E_XRES_E, 0x00);
   
   counter = G_Ghs_Capability_List [CL_NUMOCT];
   blocknr = 0;
                                        /* wait for INITIALIZATION */
   WHILE_NOT_ABORT (In (SOCRATES_TSTAT) != INITIALIZATION);
   if (G_Abort == TRUE)
   {
       V24_PRINT (("\n(SLOT %d) ERROR: INITIALIZATION not detected!", SLOT_NR));
       return;
   }
   
                                        /* write CapList to FIFO  */
   while (counter > FIFO_SIZE)
   {
         //WHILE_NOT_ABORT(In (SOCRATES_TSTAT) == INITIALIZATION);
                                        /* write RevNr and Nr of Bytes */
      Out (SOCRATES_XFIFO_E, G_Ghs_Capability_List [CL_REVNR_CL]);
      Out (SOCRATES_XFIFO_E, G_Ghs_Capability_List [CL_NUMOCT]);

                                        /* write first block */
      for (i = 2; i < FIFO_SIZE; i++)
      {
         Out (SOCRATES_XFIFO_E, G_Ghs_Capability_List [(blocknr * (FIFO_SIZE-2)) + i]);
      }
                                       /* send STORE CL command */
      G_Processing_Cl = FALSE;                                 
      Out (SOCRATES_TCMD, STCL);
                                       /* set variables for next block */      
      blocknr++;
      counter -= (FIFO_SIZE-2);

                                       /* wait for PROCESSING_CL */
      WHILE_NOT_ABORT(G_Processing_Cl != TRUE);
      if (G_Abort == TRUE)
      {
          V24_PRINT (("\n(SLOT %d) ERROR: PROCESSING_CL not detected!", SLOT_NR));
          return;
      }

                                       /* wait for INITIALIZATION */
      WHILE_NOT_ABORT(In (SOCRATES_TSTAT) != INITIALIZATION);
      if (G_Abort == TRUE)
      {
          V24_PRINT (("\n(SLOT %d) ERROR: INITIALIZATION not detected!", SLOT_NR));
          return;
      }

   }

                                     /* write RevNr and Nr of Bytes */
   Out (SOCRATES_XFIFO_E, G_Ghs_Capability_List [CL_REVNR_CL]);

   Out (SOCRATES_XFIFO_E, G_Ghs_Capability_List [CL_NUMOCT]);

   for (i = 2; i < counter; i++)
   {
      Out (SOCRATES_XFIFO_E, G_Ghs_Capability_List [(blocknr * (FIFO_SIZE-2)) + i]);
   }
                   
                                    /* send STORE CL command */
   G_Processing_Cl = FALSE;                                 
   Out (SOCRATES_TCMD, STCL);
                                    /* wait for PROCESSING_CL */
   WHILE_NOT_ABORT(G_Processing_Cl != TRUE);
   if (G_Abort == TRUE)
   {
       V24_PRINT (("\n(SLOT %d) ERROR: PROCESSING_CL not detected!", SLOT_NR));
       return;
   }

                                    /* wait for INITIALIZATION */
   WHILE_NOT_ABORT(In (SOCRATES_TSTAT) != INITIALIZATION);
   if (G_Abort == TRUE)
   {
       V24_PRINT (("\n(SLOT %d) ERROR: INITIALIZATION not detected!", SLOT_NR));
       return;
   }
                                       /* reset TX FIFO */
   BFLD (SOCRATES_CMD_E, 0x00, SOCRATES_CMD_E_XRES_E);
                                       /* take back reset */
   BFLD (SOCRATES_CMD_E, SOCRATES_CMD_E_XRES_E, 0x00);

}  


/*******************************************************************************
Description:
   Set customer interface standard rate from 160 kbps to 800 kbps.
Arguments:
   standard_rate  -  Identifier for SOCRATES bitrate
Return.
   NONE.
Remarks:
   (see description of SOCRATES RATE_CON register).
 ******************************************************************************/
static void Soc_Set_Bitrate (WORD8 standard_rate)
{
   switch (standard_rate)
   {
                                       /* Channels = 4B                       */
      case 0:  
         Out ( SOCRATES_RATE_CON_1, 0x04 ); 
         Out ( SOCRATES_RATE_CON_2, 0x00 ); 
         break;   
                                       /* Channels = 6B                       */
      case 1:  
         Out ( SOCRATES_RATE_CON_1, 0x06 ); 
         Out ( SOCRATES_RATE_CON_2, 0x00 ); 
         break;
                                       /* Channels = 8B                       */
      case 2:  
         Out ( SOCRATES_RATE_CON_1, 0x08 ); 
         Out ( SOCRATES_RATE_CON_2, 0x00 ); 
         break;
                                       /* Channels = 9B + 3Z                  */
      case 3:  
         Out ( SOCRATES_RATE_CON_1, 0x09 ); 
         Out ( SOCRATES_RATE_CON_2, 0x03 ); 
         break;
                                       /* Channels = 12B + 2Z                 */
      case 4:  
         Out ( SOCRATES_RATE_CON_1, 0x0C ); 
         Out ( SOCRATES_RATE_CON_2, 0x02 ); 
         break;
                                       /* Channels = 16B + 2Z                 */
      case 5:  
         Out ( SOCRATES_RATE_CON_1, 0x10 ); 
         Out ( SOCRATES_RATE_CON_2, 0x02 ); 
         break;
                                       /* Channels = 18B + 2Z                 */
      case 6:  
         Out ( SOCRATES_RATE_CON_1, 0x12 ); 
         Out ( SOCRATES_RATE_CON_2, 0x02 ); 
         break;
                                       /* Channels = 24B + 1Z                 */
      case 7:  
         Out ( SOCRATES_RATE_CON_1, 0x18 ); 
         Out ( SOCRATES_RATE_CON_2, 0x01 ); 
         break;
                                       /* Channels = 32B                      */
      case 8:  
         Out ( SOCRATES_RATE_CON_1, 0x20 ); 
         Out ( SOCRATES_RATE_CON_2, 0x00 ); 
         break;
                                       /* Channels = 36B + 1Z                 */
      case 9:  
         Out ( SOCRATES_RATE_CON_1, 0x24 ); 
         Out ( SOCRATES_RATE_CON_2, 0x01 ); 
         break;
   }
}


/*******************************************************************************
Description:
   Makes the basic entries 1 to 12 of the capability list.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 14.11.00
 ******************************************************************************/
static void Msg_Soc_Cl_Basic_Settings (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_REVNR_CL]  = MsgReadWord8 (pMsg, 0);   
    G_Ghs_Capability_List[CL_NUMOCT]    = MsgReadWord8 (pMsg, 1);  
    G_Ghs_Capability_List[CL_CMD_TYPE]  = MsgReadWord8 (pMsg, 2);   /*Message Type or Command */

    G_Ghs_Capability_List[CL_REVNR]     = MsgReadWord8 (pMsg, 3);
    G_Ghs_Capability_List[CL_COUNTRY1]  = MsgReadWord8 (pMsg, 4);
    G_Ghs_Capability_List[CL_COUNTRY2]  = MsgReadWord8 (pMsg, 5);
    G_Ghs_Capability_List[CL_PROVIDER1] = MsgReadWord8 (pMsg, 6);
    G_Ghs_Capability_List[CL_PROVIDER2] = MsgReadWord8 (pMsg, 7);
    G_Ghs_Capability_List[CL_PROVIDER3] = MsgReadWord8 (pMsg, 8); 
    G_Ghs_Capability_List[CL_PROVIDER4] = MsgReadWord8 (pMsg, 9);
    G_Ghs_Capability_List[CL_VENDOR1]   = MsgReadWord8 (pMsg, 10);
    G_Ghs_Capability_List[CL_VENDOR2]   = MsgReadWord8 (pMsg, 11);

    DdsMsgFree (pMsg);
}

/*******************************************************************************
Description:
   Makes the parameter entries 13 to 24 of the capability list.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 14.11.00
 ******************************************************************************/
static void Msg_Soc_Cl_Parameter (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_ID_NPAR1]      = MsgReadWord8 (pMsg, 0);
    G_Ghs_Capability_List[CL_ID_SPAR1]      = MsgReadWord8 (pMsg, 1);

    G_Ghs_Capability_List[CL_UP_MAX_NDR]    = MsgReadWord8 (pMsg, 2);
    G_Ghs_Capability_List[CL_UP_MIN_NDR]    = MsgReadWord8 (pMsg, 3);
    G_Ghs_Capability_List[CL_UP_AVG_NDR]    = MsgReadWord8 (pMsg, 4);

    G_Ghs_Capability_List[CL_DN_MAX_NDR]    = MsgReadWord8 (pMsg, 5);
    G_Ghs_Capability_List[CL_DN_MIN_NDR]    = MsgReadWord8 (pMsg, 6);
    G_Ghs_Capability_List[CL_DN_AVG_NDR]    = MsgReadWord8 (pMsg, 7);

    G_Ghs_Capability_List[CL_UP_MAX_LAT]    = MsgReadWord8 (pMsg, 8);
    G_Ghs_Capability_List[CL_UP_AVG_LAT]    = MsgReadWord8 (pMsg, 9);

    G_Ghs_Capability_List[CL_DN_MAX_LAT]    = MsgReadWord8 (pMsg, 10);
    G_Ghs_Capability_List[CL_DN_AVG_LAT]    = MsgReadWord8 (pMsg, 11);

    DdsMsgFree (pMsg);
}

/*******************************************************************************
Description:
   Makes the first standard information field entries 25 to 30 of the capability list.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 14.11.00
 ******************************************************************************/
static void Msg_Soc_Cl_Std_Info (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_SI_NPAR1]      = MsgReadWord8 (pMsg, 0);   
    G_Ghs_Capability_List[CL_SI_SPAR1_1]    = MsgReadWord8 (pMsg, 1);   /*Annex X */
    G_Ghs_Capability_List[CL_ST_SPAR1_2]    = MsgReadWord8 (pMsg, 2);   /*Annex a,b */

    G_Ghs_Capability_List[CL_SI_NPAR2]      = MsgReadWord8 (pMsg, 3);           /*Train, Lineprobe or Reg_Silent */
    G_Ghs_Capability_List[CL_SI_SPAR2_1]    = MsgReadWord8 (pMsg, 4);   
    G_Ghs_Capability_List[CL_SI_SPAR2_2]    = MsgReadWord8 (pMsg, 5);      

    DdsMsgFree (pMsg);
}

#ifdef DEBUG
/*******************************************************************************
Description:
   Sets the entries 31 to 40 of the capability list for
   the training parameters and rates.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 09.03.01
 ******************************************************************************/
static void Msg_Soc_Cl_Train_Rates_Dn (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_T_PBODN]       = MsgReadWord8 (pMsg, 0);   /*PowBackoff down */
    G_Ghs_Capability_List[CL_T_BRATEDN1]    = MsgReadWord8 (pMsg, 1);   /*B-Channels */
    G_Ghs_Capability_List[CL_T_BRATEDN2]    = MsgReadWord8 (pMsg, 2);   
    G_Ghs_Capability_List[CL_T_BRATEDN3]    = MsgReadWord8 (pMsg, 3);   
    G_Ghs_Capability_List[CL_T_BRATEDN4]    = MsgReadWord8 (pMsg, 4);   
    G_Ghs_Capability_List[CL_T_BRATEDN5]    = MsgReadWord8 (pMsg, 5); 
    G_Ghs_Capability_List[CL_T_BRATEDN6]    = MsgReadWord8 (pMsg, 6);   
    G_Ghs_Capability_List[CL_T_BRATEDN7]    = MsgReadWord8 (pMsg, 7);   
    G_Ghs_Capability_List[CL_T_SRATEDN1]    = MsgReadWord8 (pMsg, 8);   /*Z-bits */
    G_Ghs_Capability_List[CL_T_SRATEDN2]    = MsgReadWord8 (pMsg, 9);   

    DdsMsgFree (pMsg);
}

/*******************************************************************************
Description:
   Sets the entries 41 to 50 of the capability list for
   the training parameters and rates.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 09.03.01
 ******************************************************************************/
static void Msg_Soc_Cl_Train_Rates_Up (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_T_PBOUP]       = MsgReadWord8 (pMsg, 0);  /*PowerBackoff up */
    G_Ghs_Capability_List[CL_T_BRATEUP1]    = MsgReadWord8 (pMsg, 1);   /*B-Channels */
    G_Ghs_Capability_List[CL_T_BRATEUP2]    = MsgReadWord8 (pMsg, 2); 
    G_Ghs_Capability_List[CL_T_BRATEUP3]    = MsgReadWord8 (pMsg, 3);
    G_Ghs_Capability_List[CL_T_BRATEUP4]    = MsgReadWord8 (pMsg, 4);
    G_Ghs_Capability_List[CL_T_BRATEUP5]    = MsgReadWord8 (pMsg, 5);
    G_Ghs_Capability_List[CL_T_BRATEUP6]    = MsgReadWord8 (pMsg, 6); 
    G_Ghs_Capability_List[CL_T_BRATEUP7]    = MsgReadWord8 (pMsg, 7);   
    G_Ghs_Capability_List[CL_T_SRATEUP1]    = MsgReadWord8 (pMsg, 8);   /*Z-Bits */
    G_Ghs_Capability_List[CL_T_SRATEUP2]    = MsgReadWord8 (pMsg, 9);

    DdsMsgFree (pMsg);
}
#else

/*******************************************************************************
Description:
   Sets the entries 31 to 50 (42 to 50 implicit) of the capability list for
   the training parameters and rates.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 14.11.00
 ******************************************************************************/
static void Msg_Soc_Cl_Train_Rates (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_T_PBODN]       = MsgReadWord8 (pMsg, 0);   /*PowBackoff down */
    G_Ghs_Capability_List[CL_T_BRATEDN1]    = MsgReadWord8 (pMsg, 1);   /*B-Channels */
    G_Ghs_Capability_List[CL_T_BRATEDN2]    = MsgReadWord8 (pMsg, 2);   
    G_Ghs_Capability_List[CL_T_BRATEDN3]    = MsgReadWord8 (pMsg, 3);   
    G_Ghs_Capability_List[CL_T_BRATEDN4]    = MsgReadWord8 (pMsg, 4);   
    G_Ghs_Capability_List[CL_T_BRATEDN5]    = MsgReadWord8 (pMsg, 5); 
    G_Ghs_Capability_List[CL_T_BRATEDN6]    = MsgReadWord8 (pMsg, 6);   
    G_Ghs_Capability_List[CL_T_BRATEDN7]    = MsgReadWord8 (pMsg, 7);   
    G_Ghs_Capability_List[CL_T_SRATEDN1]    = MsgReadWord8 (pMsg, 8);   /*Z-bits */
    G_Ghs_Capability_List[CL_T_SRATEDN2]    = MsgReadWord8 (pMsg, 9);   

    G_Ghs_Capability_List[CL_T_PBOUP]       = MsgReadWord8 (pMsg, 10);  /*PowerBackoff up */
    G_Ghs_Capability_List[CL_T_BRATEUP1]    = MsgReadWord8 (pMsg, 1);   /*B-Channels */
    G_Ghs_Capability_List[CL_T_BRATEUP2]    = MsgReadWord8 (pMsg, 2); 
    G_Ghs_Capability_List[CL_T_BRATEUP3]    = MsgReadWord8 (pMsg, 3);
    G_Ghs_Capability_List[CL_T_BRATEUP4]    = MsgReadWord8 (pMsg, 4);
    G_Ghs_Capability_List[CL_T_BRATEUP5]    = MsgReadWord8 (pMsg, 5);
    G_Ghs_Capability_List[CL_T_BRATEUP6]    = MsgReadWord8 (pMsg, 6); 
    G_Ghs_Capability_List[CL_T_BRATEUP7]    = MsgReadWord8 (pMsg, 7);   
    G_Ghs_Capability_List[CL_T_SRATEUP1]    = MsgReadWord8 (pMsg, 8);   /*Z-Bits */
    G_Ghs_Capability_List[CL_T_SRATEUP2]    = MsgReadWord8 (pMsg, 9);


    DdsMsgFree (pMsg);
}
#endif

/*******************************************************************************
Description:
   Sets the entries 51 to 62 of the capability list for the
   lineprobing parameter and rates.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 09.03.01
 ******************************************************************************/
static void Msg_Soc_Cl_Probe_Rates_Dn (P_DDS_MSG pMsg)
{
    G_Ghs_Capability_List[CL_PBODN]     = MsgReadWord8 (pMsg, 0);   /*PowBackoff down */
    G_Ghs_Capability_List[CL_BRATEDN1]  = MsgReadWord8 (pMsg, 1);   /*B-Channels */
    G_Ghs_Capability_List[CL_BRATEDN2]  = MsgReadWord8 (pMsg, 2); 
    G_Ghs_Capability_List[CL_BRATEDN3]  = MsgReadWord8 (pMsg, 3); 
    G_Ghs_Capability_List[CL_BRATEDN4]  = MsgReadWord8 (pMsg, 4);   
    G_Ghs_Capability_List[CL_BRATEDN5]  = MsgReadWord8 (pMsg, 5);   
    G_Ghs_Capability_List[CL_BRATEDN6]  = MsgReadWord8 (pMsg, 6);   
    G_Ghs_Capability_List[CL_BRATEDN7]  = MsgReadWord8 (pMsg, 7);   
    G_Ghs_Capability_List[CL_FIX1_DN]   = MsgReadWord8 (pMsg, 8);   
    G_Ghs_Capability_List[CL_FIX2_DN]   = MsgReadWord8 (pMsg, 9);   
    G_Ghs_Capability_List[CL_DURATDN]   = MsgReadWord8 (pMsg, 10);  /*Line burst duration */
    G_Ghs_Capability_List[CL_SCRAMBDN]  = MsgReadWord8 (pMsg, 11);  /*Scrambler */

⌨️ 快捷键说明

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