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

📄 debug.c

📁 Infineon公司有一款实现SHDSL协议(ADSL协议的变种)的芯片
💻 C
📖 第 1 页 / 共 3 页
字号:
      for (i = 0;i < (nr-1); i++)
      {
         V24_PRINT (("0x%02X,", data_array[i]));
      }
      V24_PRINT (("0x%02X", data_array[i]));

                                       /* Write data via the synchron.  
                                          serial interface.                   */
      Ssc_Write (cs, nr, data_array);

   }  
                                       /* V24 control message:          
                                          When error.                         */
   if (error_text != NULL)
   {
      V24_PRINT (("\nDebug_Write_Sync: %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 data via synchronous serial interface (Ssc_Read).
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
static void Debug_Read_Sync (P_DDS_MSG pMsg)
{
   WORD8   cs;
   WORD8   nr_tr;
   WORD8   nr_rc;
   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_rc  = MsgReadWord8 (pMsg, 2);
   nr_tr  = MsgReadWord8 (pMsg, 3);
                                       /* Set error text dependent on   
                                          the received parameters.            */
   if ((cs == 0) || (cs > 6))
      error_text = "CS";
   if ((nr_rc == 0) || (nr_rc > 0x10))
      error_text = "NR";
   if ((nr_tr == 0) || (nr_tr > 0x10))
      error_text = "NR";

                                       /* Start processing if all       
                                          parameters are correct.             */
   if (error_text == NULL)
   {
                                       /* V24 control message:          
                                          When processing (part1)             */
      for (i = 0;i < nr_tr; i++)                
      {
         data_array[i] = MsgReadWord8 (pMsg, (i+4));
      }
      V24_PRINT (("\nDebug_Read_Sync: CS=0x%02X; data_tr=", cs));
      for (i = 0;i < (nr_tr-1); i++)
      {
         V24_PRINT (("0x%02X,", data_array[i]));
      }
      V24_PRINT (("0x%02X ", data_array[i]));
     
                                       /* Read data via the synchronous 
                                          serial interface.                   */
      Ssc_Read (cs, nr_rc, nr_tr, data_array);

                                       /* V24 control message:          
                                          When processing (part2).            */
      V24_PRINT ((";data_rc="));
      for (i = 0;i < (nr_rc-1); i++)
      {
         V24_PRINT (("0x%02X,", data_array[i]));
      }
      V24_PRINT (("0x%02X ", data_array[i]));
      
                                       /* Send answer to user.                */
      MsgWriteWord8 (pMsg, 0, cs)
      for (i = 0; i < nr_rc; i++)
         MsgWriteWord8 (pMsg, i+1, data_array[i]);
      pMsg->dst     = 0;
      pMsg->src     = MOD_ID_DEBUG_MODULE;
      pMsg->id      = MSG_ID_DEBUG_READ_SYNC;
      pMsg->length  = (nr_rc+1);
      DdsMsgSend (pMsg);
   }

                                       /* V24 control message:          
                                          When error.                         */
   if (error_text != NULL)
   {
      V24_PRINT (("\nDebug_Read_Sync: %s ", Error_Text_Start));
      V24_PRINT (("%s ", error_text));     
      V24_PRINT (("%s", Error_Text_End));     
      DdsMsgFree (pMsg);
   }
}

/*******************************************************************************
Description:
   Receive message to read a 8 bit value from specified register
   calling function In().
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks: 
   This adds the based address of the respective AOM. Because of this only
   register offset must be specified in this message.
 ******************************************************************************/
static void Debug_Read_Register (P_DDS_MSG pMsg)
{
   WORD16 regadr;
   WORD8  val;

                                       /* Read parameters of received   
                                          message.                            */
   G_V24  = MsgReadWord8 (pMsg, 0);
   regadr = MsgReadWord16 (pMsg, 1);
   
                                       /* Read value of register in mux or    
                                          demux mode                          */
   val = In(regadr);
                                       /* V24 control message:          
                                          When processing.                    */
   V24_PRINT (("\nDebug_Read_Register RegAdr: 0x%04X", regadr));
   V24_PRINT ((" val: 0x%02X",val));

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


/*******************************************************************************
Description:
   Receive message to write a 8 bit value to specified  register
   Calling function Out().
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   This adds the based address of the respective AOM. Because of this only
   register offset must be specified in this message.
 ******************************************************************************/
static void Debug_Write_Register (P_DDS_MSG pMsg)
{
                                       /* Read parameters of received   
                                          message.                            */
   WORD16 regadr;
   WORD8  val;
                                       /* Read parameters of received   
                                          message.                            */
   G_V24  = MsgReadWord8 (pMsg, 0);
   regadr = MsgReadWord16 (pMsg, 1);
   val    = MsgReadWord16 (pMsg, 3);
                                       /* Start processing:             
                                          Write value to address.             */
   Out (regadr,  val);
                                       /* V24 control message:          
                                          When processing.                    */
   V24_PRINT (("\nDebug_Write_Register RegAdr: 0x%04X", regadr));
   V24_PRINT ((" val: 0x%02X",val));
                                       /* Free received message         
                                          because no message is         
                                          returned to the user.               */
   DdsMsgFree (pMsg);
}

/*******************************************************************************
Description:
   Receive message to write a 8 bit value to specified  register
   Calling function Out().
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   This adds the based address of the respective AOM. Because of this only
   register offset must be specified in this message.
 ******************************************************************************/
static void Debug_Write_Register_Time (P_DDS_MSG pMsg)
{
                                       /* Read parameters of received   
                                          message.                            */
   WORD16 regadr, time;
   WORD8  val;
                                       /* Read parameters of received   
                                          message.                            */
   G_V24  = MsgReadWord8 (pMsg, 0);
   regadr = MsgReadWord16 (pMsg, 1);
   val    = MsgReadWord8 (pMsg, 3);
   time   = MsgReadWord16 (pMsg, 4);
   
                                       /* V24 control message:          
                                          When entering.                    */
   V24_PRINT (("\nDebug_Write_Register_Time RegAdr: 0x%04X", regadr));
   V24_PRINT ((" val: 0x%02X for 0x%04X x 6ms", val, time));
   
                                       /* Start processing:  */           
   G_Register_Timer.Old_Value = In (regadr);
   G_Register_Timer.Counter   = time;
   
                                       /* Write value to address.             */
   Out (regadr,  val);
                                       
   Start_Timer (TIMER_REG_WAIT);
                                       
                                       
                                       /* Free received message         
                                          because no message is         
                                          returned to the user.               */
   DdsMsgFree (pMsg);
}

/*******************************************************************************
Description:
   Write SSC buffer of synchronous serial interface.
Arguments:
   val   -  Value to be written.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
static void Ssc_Write_Buffer (WORD8 val)
{
  while (!SSCTIR);
  SSCTIR = 0;
  SSCTB = val;
}

/*******************************************************************************
Description:
   Read SSC buffer of synchronous serial interface.
Arguments:
   NONE.
Return:
   WORD8 -  Returns read value.
Remarks:
   NONE.
*******************************************************************************/
static WORD8 Ssc_Read_Buffer (void)
{
  while (!SSCRIR);
  SSCRIR = 0;
  return (SSCRB);
}

/*******************************************************************************
Description: 
   Message entry function of this module. Assigns all module functions to 
   the according function identifier.
Arguments: 
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   NONE.
******************************************************************************/
static void Debug_Msg_Entry (P_DDS_MSG pMsg)
{
   switch (pMsg->id)
   {
   case MSG_ID_DEBUG_V24:
      Debug_V24 (pMsg);
      break;

   case MSG_ID_DEBUG_READ_BYTE:
      Debug_Read_Byte (pMsg);
      break;

   case MSG_ID_DEBUG_WRITE_BYTE:
      Debug_Write_Byte (pMsg);
      break; 
      
   case MSG_ID_DEBUG_READ_WORD:
      Debug_Read_Word (pMsg);
      break;

   case MSG_ID_DEBUG_WRITE_WORD:
      Debug_Write_Word (pMsg);
      break; 
      
   case MSG_ID_DEBUG_WRITE_SYNC:
      Debug_Write_Sync (pMsg);
      break;

   case MSG_ID_DEBUG_READ_SYNC:
      Debug_Read_Sync (pMsg);
      break;

   case MSG_ID_DEBUG_READ_REGISTER:
      Debug_Read_Register (pMsg);
      break;

   case MSG_ID_DEBUG_WRITE_REGISTER:
      Debug_Write_Register (pMsg);
      break; 
      
   case MSG_ID_DEBUG_WRITE_REGISTER_TIME:
      Debug_Write_Register_Time (pMsg);
      break;
      
   default:
      printf ("\n(SLOT %d) Module DEBUG.C\t: unknown msg id (0x%02X).", SLOT_NR, pMsg->id);
      DdsMsgFree (pMsg);
      break;
   }
}

⌨️ 快捷键说明

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