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

📄 psintrpt.c

📁 SIM卡的驱动程序,有利于开发一些与SIM相通的一些工具,或者手机软件SIM驱动的开发
💻 C
字号:
///////////////////////////////////////////////////////////////////////////////
//
//   ROCKWELL SEMICONDUCTOR SYSTEMS - WIRELESS COMMUNICATIONS DIVISION
//
///////////////////////////////////////////////////////////////////////////////
//
//
//   DESCRIPTION
//
//
//   REVISION HISTORY 
//
//   $Log:   W:\UC\PH2SW\Rockwell\BASE\Ps\rock\ARCHIVES\PSINTRPT.C_v  $
//   
//      Rev 3.19   18 Jan 2001 16:51:58   wanggc1
//   Project: UC SCRs ( GSM )
//   SCR 1612 - CX805 Development Platform Support
//   
//      Rev 3.18   Dec 12 2000 19:54:02   omahond
//   Project: UC SCRs ( GSM )
//   SCR 1470 - Failing SIM test case 27.11.1.5 (SIM parity Error)
//   
//      Rev 3.17   Oct 13 2000 11:36:42   maungmt
//   Project: UC SCRs ( GSM )
//   SCR 1499 - Preparation for CX805 Migration
//   Change the SIM register names consistent with CX805
//   register naming convention.
//   
//      Rev 3.16   27 Sep 2000 15:35:20   hisamok
//   Project: UC SCRs ( GSM )
//   SCR 1487 - SIM clock does not always stop in the correct state
//   
//      Rev 3.15   25 Apr 2000 18:17:56   hisamok
//   Project: UC SCRs ( GSM )
//   SCR 1366 - Defect SIM Condition NVM Logging Enhancements
//   
//      Rev 3.14   16 Mar 2000 18:02:32   hisamok
//   Project: UC SCRs ( GSM )
//   SCR 1278 - Phase 1 5v SIM Takes About 3 Minutes to Be Initialized at Startup
//   
//   
//      Rev 3.13   08 Mar 2000 17:54:34   ordd
//   Project: UC SCRs ( GSM )
//   SCR 1255 - "Broken SIM' monitor and data logger
//   
//   
//      Rev 3.12   01 Feb 2000 15:56:52   omahond
//   Project: UC SCRs ( GSM )
//   SCR 1163 - Lockup Instead of BROKEN SIM Msg.
//   
//   
//      Rev 3.11   27 Oct 1999 15:26:02   omahond
//   Project: UC SCRs ( GSM )
//   SCR 1016 - Removal of GSMcprintf from SIM interrupt handler PSWaitProcByte()
//   
//   
//      Rev 3.10   19 Aug 1999 12:44:24   ogormabj
//   Project: UC SCRs ( GSM )
//   SCR 840 - Warning Eradication
//   
//   
//      Rev 3.9   19 Jul 1999 17:31:42   hisamok
//   Project: UC SCRs ( GSM )
//   SCR 736 - Fix for SIM test case 27.11.1.5
//   
//   
//      Rev 3.8   15 Jul 1999 14:41:26   omahond
//   Project: UC SCRs ( GSM )
//   SCR 736 - Fix for SIM test case 27.11.1.5
//   
//   
//      Rev 3.3   15 Jun 1999 16:52:10   omahond
//   Project: UC SCRs ( GSM )
//   SCR 736 - Fix for SIM test case 27.11.1.5
//   
//   
//      Rev 3.2   27 Apr 1999 01:47:52   aiouaza
//   Project: UC SCRs ( GSM )
//   SCR 592 - Build Warning cleanup
//   
//   
//      Rev 3.1   29 Jul 1998 17:05:08   LIG
//   Project: UC SCRs ( GSM )
//   SCR 122 - Merge phase1 SIM driver enhancements to phase 2
//   
//   
//      Rev 3.0   19 Jun 1998 11:02:48   dangmk
//   Initial CheckIn
//   
//      Rev 2.12   28 Mar 1998 17:46:46   ramos
//   Removed #ifdef (M46, ARM)
//   
//      Rev 2.11   11 Mar 1998 17:15:46   vahdatm
//   Updated to handle "Inverse Mode" SIM (Gary)
//   
//      Rev 2.10   23 Dec 1997 15:47:50   lig
//   Moved PSIntAction() after DMA disable
//   
//      Rev 2.9   07 Nov 1997 17:22:34   quanp
//   1) Add include of HDMA.h
//   2) Add SIMDMAIH DMA interrupt handler.
//   3) Delete unused variables x & data.
//   
//      Rev 2.8   10 Oct 1997 16:28:22   Nicholson
//   Modified to support M46.
//   
//      Rev 2.7   07 Aug 1997 09:48:48   quanp
//   Add workaround to fix SIM spurious interrupt for new FPGA. 
//   
//      Rev 2.6   24 Jul 1997 09:21:52   quanp
//   Changed ifdef for code to support new SIM FPGA to _ARM_
//   
//      Rev 2.5   23 Jul 1997 15:41:22   quanp
//   Modify to support inverted mode for new SIM for ARM
//   
//      Rev 2.4   22 Jul 1997 18:50:50   quanp
//   Cleanup
//   
//      Rev 2.3   21 Jul 1997 17:53:14   quanp
//   Added HW_SIM code for ARM 
//   
//      Rev 2.0   11 Jul 1997 10:31:06   dangmk
//   Initial CheckIn for this ps\rock dir.
//   
//   
//      Rev 1.4   02 Jun 1997 17:09:48   quanp
//   Added include of Htimers.h.
//   Modified Timer A interrupt handler.
//   
//      Rev 1.3   15 May 1997 18:43:22   hsuj
//   added include of regaddr.h
//   
//      Rev 1.2   15 May 1997 18:41:14   hsuj
//   added include of system.h
//   
//      Rev 1.1   15 May 1997 08:46:34   hsuj
//   (1)  Type-casted all SIM register references with (UINT16 *) since regaddr.h define the registers to be (VOID *)
//   
//      Rev 1.0   12 Feb 1997 09:10:36   HSUJ
//   interrupt handler for hardware SIM
//   
//      Rev 1.2   12 Feb 1997 08:51:46   HSUJ
//   interrupt handler for hardware SIM
//
///////////////////////////////////////////////////////////////////////////////
//
//   ROCKWELL CONFIDENTIAL AND PROPRIETARY
//
//   This source is the sole property of Rockwell International.  Reproduction
//   or utilization of this source in whole or in part is forbidden without
//   the written consent of Rockwell International.
//
//   (c) Copyright Rockwell International, 1998.  All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////


/*---------------------------- Includes: ---------------------------------*/

#include "wcdtypes.h"
#include "..\system\syslib.h"

#include "..\global\types.h"
#include "..\global\gsmerror.h"

#include "..\ps\psgdrv.h"
#include "..\tr\tracelow.h"
#include "..\system\system.h"
#include "..\system\regaddr.h"
#include "..\system\interrup.h"
#include "iTimers.h"   // Timer register structure   
#include "HDMA.h"
#include "dsfunctions.h"

/*---------------------------- Local Defines: ----------------------------*/



/*---------------------------- Local Typedefs: ---------------------------*/



/*---------------------------- Local Statics: ----------------------------*/



/*----------------------- Local Function Prototypes: ---------------------*/



/*---------------------------- Local Functions: --------------------------*/
                                          
/*---------------------------- Global Functions: -------------------------*/

UINT8 PSTxChar;
BOOLEAN PSInverseMode = FALSE;

void (*TimerAIH)(void) = SimResetTimerAIH;


// static void Func( UINT8 Dummy )
// Changed UINT8 to char to get around ARM incompatible type 
// problem

void Func( char Dummy )
   {
   /* Dummy */
   }



/*------------------------------------------------------------------------*/
/*
Name:    SimResetTimerAIH
Desc:    Interrupt handler for Timer A interrupt during SIM Reset
Params:  None
Returns: Nothing
Caveats: 
*/

void  SimResetTimerAIH( void )
   {
   extern BOOLEAN PSClockStopped;
   //GSMcprintf( MEMPutChar, "SimResetTimerAIH\n" );

   
   *(UINT16 *)SIM_CTRL_LO_REG |= (SIM_CLK_ACT);
   // Clock turned on
   PSClockStopped = FALSE;
   SuspendTimer (TIMERA_BASE);
   DEVICE_SPEC_EnableInterrupts(eIRQ1_NONE,   eIRQ2_NONE,  // Enable nothing
                                eIRQ1_TIMERA, eIRQ2_NONE); // Disable Timer A
   TimerAIH = SimDataTimerAIH;  /* Change TimerA handler for receiving or transmitting data.*/
#if SIM_DEBUG == SIM_DEBUG_MAX
   IntHandler_Dbg = _SimDataTimerAIH;
#endif
   }

/*------------------------------------------------------------------------*/



/*------------------------------------------------------------------------*/
/*
Name:    SimDataTimerAIH
Desc:    Interrupt handler for Timer A interrupt when transmitting SIM data.
Params:  None
Returns: Nothing
Caveats: 
*/

void  SimDataTimerAIH( void )
   {
   //GSMcprintf( MEMPutChar, "SimDataTimerAIH\n" );
   DEVICE_SPEC_EnableInterrupts(eIRQ1_NONE,   eIRQ2_NONE,  // Enable nothing
                                eIRQ1_TIMERA, eIRQ2_NONE); // Disable Timer A

   SuspendTimer (TIMERA_BASE);
   *(UINT16 *)SIM_TXBUF_REG = PSTxChar;	     /* start transmitting after waiting 2 etu from PSSend()*/
   *(UINT16 *)SIM_IER_REG |= (SIM_OUTB_EMP_IE);

   }

/*------------------------------------------------------------------------*/



/*------------------------------------------------------------------------*/
/*
Name:    SimIH
Desc:    Interrupt handler for SIM interrupts
Params:  None
Returns: Nothing
Caveats: 
*/

void SimIH( void )
   {
      //GSMcprintf( MEMPutChar, "SimIH SAT%X, IER%X, RWT%d\n", *(UINT8 *)SIM_STAT_REG, *(UINT8 *)SIM_IER_REG,PSRemainingWorkTime);

      PSRemainingWorkTime = PSWorkWaitingTime; //FIXME DOM
      //PSResetWorkWaitTimer(PSETUWorkWaitingTime);
      if (PSRxDMAEnabled == TRUE)
      	{      	
      	//Nothing more to do when RxDMA is active ??
        //GSMcprintf( MEMPutChar, "ExitIH\n");
         if ( *(UINT16 *)SIM_STAT_REG & SIM_ME_RX_FAIL )
            {
            UINT16 psdummyread;

            psdummyread = *(UINT16 *)SIM_RXBUF_REG; /* clear input buffer */
            //GSMcprintf( MEMPutChar, "ParityError\n");
            }

      	return;
      	}	
      //GSMcprintf( MEMPutChar, "PSAct=%X\n",PSIntAction);

      if ( ( (  *(UINT16 *)SIM_STAT_REG & SIM_STS_INBFUL ) && (  *(UINT16 *)SIM_IER_REG & SIM_INB_FULL_IE ) )
            ||  ( ( *(UINT16 *)SIM_IER_REG & SIM_OUTB_EMP_IE ) && ( *(UINT16 *)SIM_STAT_REG & SIM_STS_OUTEMP ) ) )

         /* A byte has been received or transmitted */
         {	 
           	//GSMcprintf( MEMPutChar, "SIR:%X,%X\n",*(UINT8 *)SIM_IER_REG, *(UINT8 *)SIM_STAT_REG);

         if( *(UINT16 *)SIM_STAT_REG&SIM_ERR_OVERUN )
            {
            GSMcprintf( MEMPutChar, "SIM_ERR_OVERRUN\n" );
            *(UINT16 *)SIM_STAT_REG &=~SIM_ERR_OVERUN;
#if SIM_DEBUG == SIM_DEBUG_MAX
            //PS Debug...
            PSCompletionCode_Dbg = PSUnexpectedSIMData;
           //End PS Debug
#endif 
			//PSReturnToIdle(PSUnexpectedSIMData);  /* game over !! */
			//return;
            }
         PSTransferRemainingRetries = PS_TRANSFER_ALLOWED_RETRIES;
         if ( *(UINT16 *)SIM_IER_REG & SIM_INB_FULL_IE )  

            {
            /*GSMcprintf( MEMPutChar, "SIM_INB_FULL_IE\n" );*/

            /*GSMcprintf( Func, "SIM %x\n", *(UINT16 *)SIM_STAT_REG ); */
            }
         if ( *(UINT16 *)SIM_STAT_REG & SIM_ME_RX_FAIL )
            {
			UINT16 psdummyread;

			psdummyread = *(UINT16 *)SIM_RXBUF_REG; /* clear input buffer */
            return; /* do not process a Rx byte with parity error */
            }

         PSIntAction();
         }
      else if ( *(UINT16 *)SIM_STAT_REG & SIM_ME_RX_FAIL )
         {
            PSIntAction(); /* dealing with inverse mode SIM */
         }
      else
         {
         GSMcprintf( MEMPutChar, "SIM SPURIOUS INT\n" );
         }
   }
                                                   

/*
Name:    SimDMAIH
Desc:    Interrupt handler for SIM DMA interrupt
Params:  None
Returns: Nothing
Caveats: 
*/
void SimDMAIH(void)
   {
   DMA_THRESHOLD_PARAMS ThresholdParams;
   //GSMcprintf( MEMPutChar, "SimDMAIH\n" );
   // Reset the Work Waiting Time to the default
   PSRemainingWorkTime = PSWorkWaitingTime; //FIXME

   ThresholdParams.Threshold = (VOID *) SIMConfigDataPtr->EndAddress;
   ThresholdParams.Mode = NON_CIRCULAR; // as non circular usage of DMA, no need to specify base and end address
										// for threshold setup

   DisableDMA (SIMConfigDataPtr->pDMARegs);   
   SetDMAThreshold (SIMConfigDataPtr->pDMARegs, &ThresholdParams);
   DEVICE_SPEC_EnableInterrupts(eIRQ1_NONE,  eIRQ2_NONE,  // Enable nothing
                                SIM_DMA_IRQ, eIRQ2_NONE); // Disable SIM DMA
   PSRxDMAEnabled=FALSE;
   PSIntAction();
   
   DEVICE_SPEC_ClearPendingInterrupts(eIRQ1_SIM, eIRQ2_NONE);
   DEVICE_SPEC_EnableInterrupts(eIRQ1_SIM, eIRQ2_NONE,  // Enable nothing
                                eIRQ1_NONE,  eIRQ2_NONE); // Disable SIM DMA
   }

/*------------------------------------------------------------------------*/

                                   
/* static */ const UINT8 nibble[16] =
   { 15, 7, 11, 3, 13, 5, 9, 1, 14, 6, 10, 2, 12, 4, 8, 0 };

UINT8 PSInverseData( UINT8 in )
   {
   return in;    
   }

/*------------------------------------------------------------------------*/

⌨️ 快捷键说明

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