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

📄 debug.c

📁 Infineon公司有一款实现SHDSL协议(ADSL协议的变种)的芯片
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************
       Copyright (c) 2000, Infineon Technologies.  All rights reserved.
  
                               No Warranty                                                 
   Because the program is licensed free of charge, there is no warranty for 
   the program, to the extent permitted by applicable law.  Except when     
   otherwise stated in writing the copyright holders and/or other parties   
   provide the program "as is" without warranty of any kind, either         
   expressed or implied, including, but not limited to, the implied         
   warranties of merchantability and fitness for a particular purpose. The  
   entire risk as to the quality and performance of the program is with     
   you.  should the program prove defective, you assume the cost of all     
   necessary servicing, repair or correction.                               
                                                                            
   In no event unless required by applicable law or agreed to in writing    
   will any copyright holder, or any other party who may modify and/or      
   redistribute the program as permitted above, be liable to you for        
   damages, including any general, special, incidental or consequential     
   damages arising out of the use or inability to use the program           
   (including but not limited to loss of data or data being rendered        
   inaccurate or losses sustained by you or third parties or a failure of   
   the program to operate with any other programs), even if such holder or  
   other party has been advised of the possibility of such damages. 
 *******************************************************************************       
   
   Module:        DEBUG
   Product ID:    22622.1.0.1
   Description:   Contains general debug proceedings. 

 ******************************************************************************/

//   Group=DEBUG 


/* ============================= */
/* Includes                      */
/* ============================= */

#include <stdio.h>
#include <intrins.h>
#include <absacc.h>
#include <stdarg.h>

#include "sysdef.h"
#include "dds.h"
#include "sysvar.h"
#include "sysfunc.h"

#include "modid.h"
#include "reg165.h"

/* ============================= */
/* Local Macros & Definitions    */
/* ============================= */

                                       /* Message IDs                        */
#define MSG_ID_DEBUG_V24            0
#define MSG_ID_DEBUG_READ_BYTE      1
#define MSG_ID_DEBUG_READ_WORD      2
#define MSG_ID_DEBUG_WRITE_BYTE     3
#define MSG_ID_DEBUG_WRITE_WORD     4
#define MSG_ID_DEBUG_WRITE_SYNC     5
#define MSG_ID_DEBUG_READ_SYNC      6
#define MSG_ID_DEBUG_READ_REGISTER  7
#define MSG_ID_DEBUG_WRITE_REGISTER 8
#define MSG_ID_DEBUG_WRITE_REGISTER_TIME 9

                                       /* Chip select register          
                                          and values.                         */
#define CHIP_SELECT_REG  XVAR (WORD8, 0x310000)

#ifdef  SLOT1
    #define CS_1             0xFD
    #define CS_2             0xFB
    #define CS_12            0xF9
#endif
#ifdef  SLOT2
    #define CS_1             0xDF
    #define CS_2             0xBF
    #define CS_12            0x9F
#endif

                                       /*  first part of error message        */
static const WORD8 Error_Text_Start[]  = "Invalid";

                                       /*  end of error message               */
static const WORD8 Error_Text_End[]    = "parameter specified";

                                       /*  Address modification mode.         */
static WORD8 Address_Mod;

/* ============================= */
/* Global variables definition   */
/* ============================= */

WORD8  G_V24;
WORD8  G_Ssc_Adr;
T_REGISTER_TIMER  G_Register_Timer;

/* ============================= */
/* Local function declaration    */
/* ============================= */

#ifdef DEMUX
    static WORD16 Demux(WORD16 address);
#endif
static void Debug_V24 (P_DDS_MSG pMsg);
static void Debug_Read_Byte (P_DDS_MSG pMsg);
static void Debug_Write_Byte (P_DDS_MSG pMsg);
static void Debug_Read_Register (P_DDS_MSG pMsg);
static void Debug_Write_Register (P_DDS_MSG pMsg);
static void Debug_Msg_Entry (P_DDS_MSG pMsg);
static void Ssc_Write_Buffer (WORD8 val);
static WORD8 Ssc_Read_Buffer (void);
     
/* ============================= */
/* Global function definition    */
/* ============================= */

/*******************************************************************************
Description:
   Inititialization function of the debug module.
Arguments:
   NONE.
Return:
   NONE.   
Remarks:
   This function calls the message entry function of this module.
 ******************************************************************************/
void Debug_Module_Init (void)
{
   printf ("\nModule DEBUG.C\t: Initialization done");

   DdsSetMsgEntry (Debug_Msg_Entry, MOD_ID_DEBUG_MODULE);
}

/*******************************************************************************
Description:
   Write data via synchronous serial interface.
Arguments:
   cs          -  Chip select value.
   nr          -  Number of bytes to be transmitted.
   data_array  -  Pointer to data array for rec. values.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
void Ssc_Write (WORD8 cs, WORD8 nr, WORD8 *data_array)
{
   WORD8   i;
   volatile WORD8 dummy;

                                      /* Set chip select.                  */
   switch (cs)
   {
   case 0x01:
      CHIP_SELECT_REG = CS_1;
      break;
   case 0x02:
      CHIP_SELECT_REG = CS_2;
      break;
   case 0x03:
   case 0x04:
   case 0x05:
   case 0x06:
   default:
      CHIP_SELECT_REG = CS_12;
      break;
   }

   TRACE (("\nTRACE:SSC_Write CS%d:", cs));
   for (i = 0;i < nr; i++)
   {
      TRACE (("0x%02X,", data_array[i]));
   }
                                      /* Write data to transmit        
                                         buffer.                           */
   for (i = 0;i < nr; i++)
   {
      Ssc_Write_Buffer (data_array[i]);
      dummy = Ssc_Read_Buffer();
   }
                                      /* Chip Select disable               */
   CHIP_SELECT_REG = 0xFF;
}

/*******************************************************************************
Description:
   Read data via synchronous serial interface.
Arguments:
   cs          - Chip select value.
   nr_rc       - Number of bytes to be received.
   nr_tr       - Number of bytes to be transmitted.
   *data_array - Pointer to data array for rec. values.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
void Ssc_Read (WORD8 cs, WORD8 nr_rc, WORD8 nr_tr, WORD8 *data_array)
{
   WORD8   i;
   volatile WORD8 dummy;

                                      /* Set chip select.                  */
   switch (cs)
   {
   case 0x01:
      CHIP_SELECT_REG = CS_1;
      break;
   case 0x02:
      CHIP_SELECT_REG = CS_2;
      break;
   case 0x03:
   case 0x04:
   case 0x05:
   case 0x06:
   default:
      CHIP_SELECT_REG = CS_12;
      break;
   }
   TRACE (("\nTRACE:SSC_Read CS%d, TX:", cs));
   for (i = 0;i < nr_tr; i++)
   {
      TRACE (("0x%02X,", data_array[i]));
   }

                                     /* Write data to transmit        
                                        buffer.                            */
   for (i = 0;i < nr_tr; i++)
   {
      Ssc_Write_Buffer (data_array[i]);
      dummy = Ssc_Read_Buffer();
   }
   for (i = 0;i < nr_rc; i++)
   {
                                      /* Write 0xFF in transmit        
                                         buffer.                           */
      Ssc_Write_Buffer (0xFF);
      data_array[i] = Ssc_Read_Buffer();
   }

   TRACE ((" RX:"));
   for (i = 0;i < nr_rc; i++)
   {
      TRACE (("0x%02X,", data_array[i]));
   }

                                      /* Chip Select disable               */
   CHIP_SELECT_REG = 0xFF;
}

/*******************************************************************************
Description:
   Read a register content from a specified address.
Arguments:
   adr   -  Address of the register. This address has to be specified without 
            the AOM base offset. It is added within this function. 
Return:
   WORD8 -  The register content.
Remarks:
   Mux/Demux mode is considered by the function automatically.
 ******************************************************************************/
WORD8 In(WORD16 adr)
{
   WORD8  data;

#ifdef DEMUX
   adr = Demux ( adr );
#endif

   data = HVAR(WORD8, AOM_BASE + adr);
   if (adr != SOCRATES_TSTAT)
   {
       TRACE (("\nTRACE:Read Adr 0x%04X", (AOM_BASE>>16)));
       TRACE (("%04X, data: 0x%02X", adr, data));
   }
   return data;
}

/*******************************************************************************
Description:
   Write to a register specified by address.
Arguments:
   adr   - Address of the register. This address has to be specified without the 
           AOM base offset. It is added within this function. 
   data  - The new value for the register, that will be written.
Return:
   NONE.
Remarks:
   Mux/Demux mode is considered by the function automatically.
 ******************************************************************************/
void Out(WORD16 adr, WORD8 data)
{
#ifdef DEMUX
   adr = Demux ( adr );
#endif

   HVAR (WORD8, AOM_BASE + adr) = data;
    TRACE (("\nTRACE:Write Adr 0x%04X", (AOM_BASE>>16)));
    TRACE (("%04X, data: 0x%02X", adr, data));
}

/* ============================= */
/* Local function definition     */
/* ============================= */

#ifdef DEMUX
/*******************************************************************************
Description:
   Serves register access in demux mode.
Arguments:
   adr   - Address of the register. This address has to be specified without the 
           AOM base offset. It is added within this function. 
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
static WORD16 Demux ( WORD16 address )
{
                                       /* DEMUX mode FALC                     */
   if (( address >= FALC_BASE ) && ( address < EPIC_BASE ))
   {
      
   }
                                       /* DEMUX mode EPIC                     */
   if (( address >= EPIC_BASE ) && ( address < REGBLOCK_BASE ))
   {
      #ifdef EPIC_ADDR_BUGFIX

⌨️ 快捷键说明

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