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

📄 debug.c

📁 Infineon公司有一款实现SHDSL协议(ADSL协议的变种)的芯片
💻 C
📖 第 1 页 / 共 3 页
字号:
      if ( address >= EPIC_BASE+EPIC_DEMUX_SWITCH )
      {
         HVAR(WORD8,AOM_BASE+EPIC_OMDR_SHIFT) |= 0x01;    
         address -= EPIC_DEMUX_SWITCH;  
      }
      else
      {
         if ( address != EPIC_OMDR_SHIFT )
         {
            HVAR(WORD8,AOM_BASE+EPIC_OMDR_SHIFT) &= ~0x01;
         }
      }      
      address -= EPIC_BASE;  
      address *= 0x10;  
      address += EPIC_BASE; 
      #else
      if ( address < EPIC_BASE+EPIC_DEMUX_SWITCH )
      {
         HVAR(WORD8,AOM_BASE+EPIC_OMDR) |= 0x01;    
      }
      else
      {
         if ( address != EPIC_OMDR )
         {
            HVAR(WORD8,AOM_BASE+EPIC_OMDR) &= ~0x01;
         }
         address -= EPIC_DEMUX_SWITCH;  
      }      
      #endif 
   }
   return (address);
}   
#endif

/*******************************************************************************
Description:
   Receive message to enable/disable v24 debug monitor.
Arguments:
   pMsg - pointer to received message
Return Value:
   This function enables/disables printfs at interrupt level and TRACE output.
Remarks:
   None.
*******************************************************************************/
static void Debug_V24 (P_DDS_MSG pMsg)
{
   WORD8 v24_on_off;
   WORD8 v24_trace_on_off;
   const WORD8 *outp_text1 = NULL;
   const WORD8 *outp_text2 = NULL;
   const WORD8 *outp_text3 = NULL;
   const WORD8 *error_text = NULL;

                                       /* Read parameters of received   
                                          message.                            */
   G_V24            = MsgReadWord8 (pMsg, 0); 
   v24_on_off       = MsgReadWord8 (pMsg, 1);
   Address_Mod      = MsgReadWord8 (pMsg, 2);
   v24_trace_on_off = MsgReadWord8 (pMsg, 3);


                                       /* Set error text dependent on   
                                          the received parameters.            */
   if (v24_on_off > 0x01) 
      error_text = "V24INT";

   if (Address_Mod > 0x01)
      error_text = "MOD";

   if (v24_trace_on_off > 0x01) 
      error_text = "V24TRACE";

                                       /* Start processing if all       
                                          parameters are correct.             */
   if (error_text == NULL)
   {
                                       /* Global enable or disable of   
                                          V24 control for interrupt     
                                          functions.                          */
      if (v24_on_off == 0x01)
      { 
         outp_text1 = "on";
         G_Eeprom[DEBUG_V24_INT] = TRUE;        
      }
      else
      { 
         outp_text1 = "off";
         G_Eeprom[DEBUG_V24_INT] = FALSE;
      }         
                                       /* Enable or disable of address  
                                          modification of debug         
                                          commands.                           */
      if (Address_Mod == 0x01)
      { 
         outp_text2 = "on";
      }
      else
      { 
         outp_text2 = "off";
      }     

                                       /* Global enable or disable of   
                                          TRACE output.                      */
      if (v24_trace_on_off == 0x01)
      { 
         outp_text3  = "on";
         G_Eeprom[DEBUG_V24_TRACE] = TRUE;      
      }
      else
      { 
         outp_text3  = "off";
         G_Eeprom[DEBUG_V24_TRACE] = FALSE;
      }         
    
                                       /* Update configuration array &  
                                          store current configuration   
                                          in description eeprom.              */
      Write_Eeprom (FIRST_DEBUG_INDEX, LAST_DEBUG_INDEX);

                                       /* V24 control message:          
                                          When processing.                    */
      V24_PRINT (("\nDebug_V24: interrupt info %s, ", outp_text1));
      V24_PRINT (("address modification %s, ", outp_text2));
      V24_PRINT (("trace info %s", outp_text3));
   }

                                       /* V24 control message:          
                                          When error.                         */
   if (error_text != NULL)
   {
      V24_PRINT (("\nDebug_V24: %s ", Error_Text_Start));
      V24_PRINT (("%s ", error_text));     
      V24_PRINT (("%s", Error_Text_End));     
   }
                                       /* Free received message         
                                          because no message is         
                                          returned to the user.               */
   DdsMsgFree(pMsg);
}

/*******************************************************************************
Description:
   Receive message to read 8 bit value from specified memory location.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
static void Debug_Read_Byte (P_DDS_MSG pMsg)
{
   WORD32 address;
   WORD8  val;

                                       /* Read parameters of received   
                                          message.                            */
   G_V24   = MsgReadWord8 (pMsg, 0);
   address = MsgReadWord32 (pMsg, 1);

                                       /* V24 control message:          
                                          When processing.                    */
   if (Address_Mod == 0x01)
      address += AOM_BASE;
   val = HVAR (WORD8, address);
   V24_PRINT (("\nDebug_Read_Byte Addr 0x%08lX: 0x%02X", address, val));

                                       /* Send answer to user.                */
   MsgWriteWord8 (pMsg, 0, val);
   pMsg->dst     = 0;
   pMsg->src     = MOD_ID_DEBUG_MODULE;
   pMsg->id      = MSG_ID_DEBUG_READ_BYTE;
   pMsg->length  = 1;
   DdsMsgSend (pMsg);
}


/*******************************************************************************
Description:
   Receive message to read 16 bit value from specified memory location.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
static void Debug_Read_Word (P_DDS_MSG pMsg)
{
   WORD32 address;
   WORD16 val;

                                       /* Read parameters of received   
                                          message.                            */
   G_V24   = MsgReadWord8 (pMsg, 0);
   address = MsgReadWord32 (pMsg, 1);

                                       /* V24 control message:          
                                          When processing.                    */
   if (Address_Mod == 0x01)
      address += AOM_BASE;
   val = HVAR (WORD16, address);
   V24_PRINT (("\nDebug_Read_Word Addr 0x%08lX: 0x%04X", address, val));

                                       /* Send answer to user.                */
   MsgWriteWord16 (pMsg, 0, val);
   pMsg->dst     = 0;
   pMsg->src     = MOD_ID_DEBUG_MODULE;
   pMsg->id      = MSG_ID_DEBUG_READ_WORD;
   pMsg->length  = 2;
   DdsMsgSend (pMsg);
}


/*******************************************************************************
Description:
   Receive message to write 16 bit value to specified memory location.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
static void Debug_Write_Byte (P_DDS_MSG pMsg)
{
   WORD32  address;
   WORD8   val;

                                       /* Read parameters of received   
                                          message.                            */
   G_V24 =   MsgReadWord8 (pMsg, 0);
   address = MsgReadWord32 (pMsg, 1);
   val =     MsgReadWord8 (pMsg, 5);

                                       /* V24 control message:          
                                          When entering.                      */
   if (Address_Mod == 0x01)
      address += AOM_BASE;
   V24_PRINT (("\nDebug_Write_Byte Addr 0x%08lX: 0x%02X", address, val));

                                       /* Start processing:             
                                          Write value to address.             */
   HVAR (WORD8, address) = val;
                                       /* Free received message         
                                          because no message is         
                                          returned to the user.               */
   DdsMsgFree (pMsg);
}


/*******************************************************************************
Description:
   Receive message to write 16 bit value to specified memory location.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks: 
   NONE.   
 ******************************************************************************/
static void Debug_Write_Word (P_DDS_MSG pMsg)
{
   WORD32 address;
   WORD16 val;

                                       /* Read parameters of received   
                                          message.                            */
   G_V24   = MsgReadWord8 (pMsg, 0);
   address = MsgReadWord32 (pMsg, 1);
   val     = MsgReadWord16 (pMsg, 5);

                                       /* V24 control message:          
                                          When entering.                      */
   if (Address_Mod == 0x01)
      address += AOM_BASE;
   V24_PRINT (("\nDebug_Write_Word Addr 0x%08lX: 0x%04X", address, val));
 
                                       /* Start processing:             
                                          Write value to address.             */
   HVAR (WORD16, address) = val;

                                       /* Free received message         
                                          because no message is         
                                          returned to the user.               */
   DdsMsgFree (pMsg);
}


/*******************************************************************************
Description:
   Receive message to write data via synchronous serial interface (Ssc_Write).
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
static void Debug_Write_Sync (P_DDS_MSG pMsg)
{
   WORD8   cs;
   WORD8   nr;
   WORD8   data_array[16];
   WORD8   i;
   const   WORD8 *error_text = NULL;

                                       /* Read parameters of received   
                                          message                             */
   G_V24 = MsgReadWord8 (pMsg,0);
   cs    = MsgReadWord8 (pMsg,1);
   nr    = MsgReadWord8 (pMsg,2);
   
                                       /* Set error text dependent on   
                                          the received parameters.            */
   if ((cs == 0) || (cs > 6))
      error_text = "CS";
   if ((nr == 0) || (nr > 0x10))
      error_text = "NR";

                                       /* Start processing if all       
                                          parameters are correct.             */
   if (error_text == NULL)
   {
                                       /* V24 control message:          
                                          When processing.                    */
      for (i = 0;i < nr; i++)                
      {
         data_array[i] = MsgReadWord8 (pMsg, i+3);
      }
      V24_PRINT (("\nDebug_Write_Sync: CS=0x%02X; data=", cs));

⌨️ 快捷键说明

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