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

📄 main.c

📁 Infineon公司有一款实现SHDSL协议(ADSL协议的变种)的芯片
💻 C
📖 第 1 页 / 共 3 页
字号:
   init_mempool (Mmu_Buffer, MMU_SIZE);

                                       /* Initialization of all devices and 
                                          start previous configuration if
                                          auto start was configured           */
   //if (G_Eeprom[CONFIG_AUTO]) Initialize_Devices();
   return 0;
}


/*******************************************************************************
Description:
   Cancel the message communication to the firmware.
Arguments:
   pInfo    -  Pointer to info data structure.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
void AmdExit (P_DDS_INFO pInfo)   
{                                       /* called before download from EDL
                                         for disabling interrupts */
   printf ("\nExit Slot %i",pInfo->slotId+1);

                                       /* Disable timer interrupts.           */
   Disable_Interrupt (INT_TIMER);       
}


/*******************************************************************************
Description:
    Enable one interrupt source if allowed.
Arguments:
    int_nr   -  Number of the interrupt source to be enabled.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
void Enable_Interrupt (WORD8 int_nr)
{
   WORD16 state;
                                       /* Disable global interrupts.          */
   state = IrqDisable ();
                                       /* Adapt value of interrupt      
                                          disable counter.                    */
   if (G_Int_Disable_Count[int_nr] != 0x00)
      G_Int_Disable_Count[int_nr]--;
   if (G_Int_Disable_Count[int_nr] == 0x00)
      IrqControl (G_Int_Vector[int_nr], TRUE);
                                       /* Restore global interrupts.          */
   IrqRestore (state); 
}


/*******************************************************************************
Description:
    Disable one interrupt source if allowed.
Arguments:
    int_nr   -  Number of the interrupt source to be disabled.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
void Disable_Interrupt (WORD8 int_nr)
{
   WORD16 state;

                                       /* Disable global interrupts.          */
   state = IrqDisable ();
                                       /* Adapt value of interrupt      
                                          disable counter.                    */
   if (G_Int_Disable_Count[int_nr] == 0x00)
      IrqControl (G_Int_Vector[int_nr], FALSE);
   if (G_Int_Disable_Count[int_nr] != 0xFF)
      G_Int_Disable_Count[int_nr]++;
                                       /* Restore global interrupts.          */
   IrqRestore (state); 
}


/*******************************************************************************
Description:
   Start one of the software timers.
Arguments:
   timer_nr    -  Number of the software timer to be started.
Return:
   NONE.
Remarks:
   Unpaired appearances of Start/Stop_Timer(TIMER_MEASUREMENT)
   don't matter.
 ******************************************************************************/
void Start_Timer (WORD8 timer_nr)
{
                                       /* Disable timer interrupts.           */
   Disable_Interrupt (INT_TIMER);
                                       /* Set corresponding value in    
                                          timer control word.                 */
   Timer_Current_Value [timer_nr] = Timer_Start_Value [timer_nr];
   
                                       /* reset time measurement counter 
                                          if wanted */
   if (timer_nr == TIMER_MEASURE)   G_Timer.Time_Counter=0;

                                       /* Enable timer interrupts.            */
   Enable_Interrupt (INT_TIMER);       
}


/*******************************************************************************
Description:
   Stop one of the software timers.
Arguments:
   timer_nr    -  Number of the software timer to be stopped.
Return:
   NONE.
Remarks:
   Unpaired appearances of Start/Stop_Timer(TIMER_MEASUREMENT)
   don't matter.
 ******************************************************************************/
void Stop_Timer (WORD8 timer_nr) 
{
                                       /* Disable timer interrupts.           */
   Disable_Interrupt (INT_TIMER);        
                                       /* Reset corresponding value in  
                                          timer control word.                 */
   Timer_Current_Value [timer_nr] = 0;
   
                                       /* Enable timer interrupts.            */ 
   Enable_Interrupt (INT_TIMER);       
}

/*******************************************************************************
Description:
   Write a couple of values to EEPROM.
Arguments:
   start_index  -  index were to start writing.
   stop_index   -  index were to stop writing.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
void Write_Eeprom (WORD16 start_index, WORD16 stop_index) 
{
   WORD16 i;

   for (i = start_index;i < stop_index; i++) 
   {
      EprWrite (i, G_Eeprom[i]);
   }                   
}

/*******************************************************************************
Description:
   Read a couple of values from EEPROM.
Arguments:
   start_index  -  index were to start reading.
   stop_index   -  index were to stop reading.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
void Read_Eeprom (WORD16 start_index, WORD16 stop_index) 
{
   WORD16 i;

   for (i = start_index;i < stop_index; i++) 
   {
       EprRead (i, &G_Eeprom[i]);
   }                   
}


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

/*******************************************************************************
Description:
   Interrupt routine for timers.
Arguments:
   NONE.
Return:
   NONE.
Remarks:
   TIMER_MEASURE gives a possibility for time measurement in units of 
   6 milli seconds up to an amount of more than six minutes with sufficient precision.
 ******************************************************************************/
static void Timer_Interrupt_Routine (void)
{
   WORD8 i;
   
                                       /* Decrement the active timer    
                                          values and take reaction for  
                                          the expired one.                    */
   for ( i = 0; i < TOTAL_NR_OF_TIMERS; i++  )
   {
      if ( Timer_Current_Value[i] )
      {
         if ( --Timer_Current_Value[i] == 0 )
         {
            switch (i)
            {
            case TIMER_ABORT:
               G_Abort = TRUE;
               printf("\n(SLOT %d) TIMER_ABORT expired", SLOT_NR);
               break;

            case TIMER_WAIT:
               G_Wait = FALSE;
               break;

            case TIMER_MEASURE:
               Timer_Current_Value [TIMER_MEASURE] = Timer_Start_Value [TIMER_MEASURE];
               G_Timer.Time_Counter++;
               break;

            case TIMER_LED:
               G_Led_Crc_Error = FALSE;
               Soc_Set_Cot_Rt_Led ();
               break;

            case TIMER_REG_WAIT:
               G_Register_Timer.Counter--;
               if (G_Register_Timer.Counter == 0x00)
               {
                  G_Register_Timer.Last_Value = In (G_Register_Timer.Address);
                  Soc_Int_Fifo_Put (INT_REG_TIMER, 0x00);
               }
               else
                  Timer_Current_Value [TIMER_REG_WAIT] = Timer_Start_Value [TIMER_REG_WAIT];
               break;

            default:
               break;
            }
         }
      }
   }
   RELOAD_TIMER;
}


#ifdef SLOT1
/*******************************************************************************
Description:
   Initialization of Timer 5 for slot 1.
Arguments:
   NONE.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
static void Timer_Interrupt_Init (void)
{
                                       /* Establishment of timer 5.           */
   if (!IrqEstablish (G_Int_Vector[INT_TIMER]))     
   {
      printf ("\nT5 for Slot1: IrqEstablish failed");
      return;
   }
                                       /* Set timer interrupt routine.        */
   IrqSetEntry (G_Int_Vector[INT_TIMER], Timer_Interrupt_Routine);

                                       /* Int. priority GLVL 2/ILVL 11        */
   T5IC  = 0xAE;    
                                       /* Timer mode, prescale 32.            */
   T5CON = 0x03;    
                                       /* Timer is stopped.                   */
   T5R   = 0;       
                                       /* Count downwards.                    */
   T5UD  = 1;       
                                       /* Disable port P3.4 direction   
                                          control.                            */
   T5UDE = 0;       
                                       /* Enable CPU Timer-Interrupt          */
   T5IE  = 1;
                                       /* Load T5                             */
   T5    = T_1MS;
                                       /* Start T5                            */
   T5R   = 1;      
    
                                       /* Enable timer interrupts.            */
   Enable_Interrupt (INT_TIMER);       
}   
#endif


#ifdef SLOT2
/*******************************************************************************
Description:
   Initialization of Timer 6 for slot 2.
Arguments:
   NONE.
Return:
   NONE.
Remarks:
   NONE.
 ******************************************************************************/
static void Timer_Interrupt_Init (void)
{
                                       /* Establishment of timer 6.           */
   if (!IrqEstablish (G_Int_Vector[INT_TIMER]))     
   {
      printf ("\nT6 for Slot2: IrqEstablish failed");
      return;
   }
                                       /* Set timer interrupt routine.        */
   IrqSetEntry (G_Int_Vector[INT_TIMER], Timer_Interrupt_Routine); 

                                       /* Int. priority GLVL 1/ILVL 11        */
   T6IC = 0xAD; 
                                       /* Timer mode, prescale 32.            */
   T6CON = 0x03;    
                                       /* Timer is stopped.                   */
   T6R = 0;     
                                       /* Count downwards.                    */
   T6UD = 1;        
                                       /* Disable port P3.4 direction   
                                          control.                            */
   T6UDE = 0;       
                                       /* Disable timer control of      
                                          port P3.3                           */
   T6OE = 0;        
                                       /* Enable CPU Timer-Interrupt          */
   T6IE = 1;
                                       /* Load T6                             */
   T6 = T_1MS;    
                                       /* Start T6                            */
   T6R = 1;      
                                       /* Enable timer interrupts.            */
   Enable_Interrupt (INT_TIMER);       
} 
#endif

/*******************************************************************************
Description:
   Shows waiting sign on screen.
Arguments:
   NONE.
Return:
   NONE.
Remarks:
   NONE.
*******************************************************************************/
void Show_Wait_Sign (void)
{    
   static WORD16 i;
   
   switch (i)
   {
   case 6000:
      V24_PRINT (("\b|"));
      break;
     
   case 12000:
      V24_PRINT (("\b/"));
      break; 
        
   case 18000:
      V24_PRINT (("\b-"));
      break;
     
   case 24000:
      V24_PRINT (("\b\\"));
      i=0;
      break;
   }
   i++;
}


/*******************************************************************************
Description:
   Initializes the capability list.
Arguments:
   pMsg  -  Pointer to received message.
Return:
   NONE.
Remarks:
   None.
Author:
    CM 14.11.00
 ******************************************************************************/
static void Soc_Cl_Init (void)
{
    G_Ghs_Capability_List[CL_REVNR_CL]      = 0x01;
    G_Ghs_Capability_List[CL_NUMOCT]        = CAPLIST_LENGTH;
    G_Ghs_Capability_List[CL_CMD_TYPE]      = 0x00;

    G_Ghs_Capability_List[CL_REVNR]         = 0x02;
    G_Ghs_Capability_List[CL_COUNTRY1]      = 0x00;
    G_Ghs_Capability_List[CL_COUNTRY2]      = 0x00;
    G_Ghs_Capability_List[CL_PROVIDER1]     = 0x00;
    G_Ghs_Capability_List[CL_PROVIDER2]     = 0x00;
    G_Ghs_Capability_List[CL_PROVIDER3]     = 0x00; 
    G_Ghs_Capability_List[CL_PROVIDER4]     = 0x00;
    G_Ghs_Capability_List[CL_VENDOR1]       = 0x00;
    G_Ghs_Capability_List[CL_VENDOR2]       = 0x00;

    G_Ghs_Capability_List[CL_ID_NPAR1]      = 0x00;
    G_Ghs_Capability_List[CL_ID_SPAR1]      = 0x00;

    G_Ghs_Capability_List[CL_UP_MAX_NDR]    = 0x00;
    G_Ghs_Capability_List[CL_UP_MIN_NDR]    = 0x00;
    G_Ghs_Capability_List[CL_UP_AVG_NDR]    = 0x00;

    G_Ghs_Capability_List[CL_DN_MAX_NDR]    = 0x00;
    G_Ghs_Capability_List[CL_DN_MIN_NDR]    = 0x00;
    G_Ghs_Capability_List[CL_DN_AVG_NDR]    = 0x00;

    G_Ghs_Capability_List[CL_UP_MAX_LAT]    = 0x00;
    G_Ghs_Capability_List[CL_UP_AVG_LAT]    = 0x00;

    G_Ghs_Capability_List[CL_DN_MAX_LAT]    = 0x00;
    G_Ghs_Capability_List[CL_DN_AVG_LAT]    = 0x00;

⌨️ 快捷键说明

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