📄 sim.h
字号:
//--------------------------------------------------------------------------------
// TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
//
// Property of Texas Instruments -- For Unrestricted Internal Use Only
/// Unauthorized reproduction and/or distribution is strictly prohibited. This
// product is protected under copyright law and trade secret law as an
// unpublished work. Created 1987, (C) Copyright 1997 Texas Instruments. All
// rights reserved.
//
// Filename : sim.h
// Description : Subscriber Identity Module
// Project : Samson
// Author : pmonteil@tif.ti.com Patrice Monteil
// Adapted for Samsom by Francois Reygagne freygagne@tif.ti.com
//
// Provided Functions:
// SIM_TestRegisters = Test the reset default values and access to registers.
// SIM_WriteCmd = Setup the control command register
// SIM_ResetInterface= Activate the interface software reset
// SIM_ResetCard = Enable the SIM card reset sequence
// SIM_Start = Start the SIM card procedure and its clock
// SIM_Stop = Stop the SIM card procedure and its clock
// SIM_EnableClock = Enable the SIM clock
// SIM_GetStatus = Read the SIM status register
// SIM_ReadConf1 = Read the configuration register
// SIM_WriteConf1 = Setup the configuration register
// SIM_SetFifoSize = Set FIFO trigger level
// SIM_ReadConf2 = Read Time-Delay parameters
// SIM_WriteConf2 = Write Time-Delay parameters
// SIM_GetIt = Read the Interrupt status register
// SIM_Read = read the data and the parity bit (receive byte register)
// SIM_ReadChar = idem ...!
// SIM_IsParityOk = Check parity-check for received byte
// SIM_Write = Write into Transmit byte register
// SIM_WrCnf1Write = Write into Transmit and configuration registers
// SIM_ReadMaskIt = Read the Interrupt mask register
// SIM_WriteMaskIt = Write into the Interrupt mask register
//--------------------------------------------------------------------------------
#ifndef __SIM_H
#define __SIM_H
#include "global_types.h"
/* Useful constants */
#define MAP_SIM_REG 0xFFFB2800
#define SIM_STAT_NOCARD_MASK 0x0001
#define SIM_STAT_TXPAR_MASK 0x0002
#define SIM_STAT_FIFOFULL_MASK 0x0004
#define SIM_STAT_FIFOEMPTY_MASK 0x0008
#define SIM_CONF1_CHKPAR_MASK 0x0001
#define SIM_CONF1_CODCONV_MASK 0x0002
#define SIM_CONF1_TXRX_MASK 0x0004
#define SIM_CONF1_SCLKEN_MASK 0x0008
#define SIM_CONF1_HIGHSPEED_MASK 0x0010
#define SIM_CONF1_SCLKDIV_MASK 0x0020
#define SIM_CONF1_SCLKLEV_MASK 0x0040
#define SIM_CONF1_ETUPERIOD_MASK 0x0080
#define SIM_CONF1_BYPASS_MASK 0x0100
#define SIM_CONF1_SVCCLEV_MASK 0x0200
#define SIM_CONF1_SRSTLEV_MASK 0x0400
#define SIM_CONF1_TRIG_MASK 0x7800
#define SIM_CONF1_SIOLOW_MASK 0x8000
#define SIM_IT_ALL_MASK 0x003f // mask for all interrupts defined */
#define SIM_IT_NATR_MASK 0x0001
#define SIM_IT_WT_MASK 0x0002
#define SIM_IT_OV_MASK 0x0004
#define SIM_IT_TX_MASK 0x0008
#define SIM_IT_RX_MASK 0x0010
#define SIM_IT_CD_MASK 0x0020
#define SIM_DRX_DATA_MASK 0x00ff
#define SIM_DRX_PAR_MASK 0x0100
#define SIM_DTX_DATA_MASK 0x00ff
//------------------------------------------------------------------
// ABSOLUTE ADDRESS OF REGISTERS
//------------------------------------------------------------------
#define SIM_CMD_REG *(REGISTER_UWORD16*) MAP_SIM_REG /* SIM command register */
#define SIM_STAT_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x02) /* SIM status register */
#define SIM_CONF1_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x04) /* SIM configuration 1 register */
#define SIM_CONF2_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x06) /* SIM configuration 2 register */
#define SIM_IT_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x08) /* SIM IT register */
#define SIM_DRX_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x0A) /* SIM DRX register */
#define SIM_DTX_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x0C) /* SIM DTX register */
#define SIM_MASKIT_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x0E) /* SIM mask IT register */
#define SIM_IT_CD_REG *(REGISTER_UWORD16*)(MAP_SIM_REG + 0x10) /* SIM IT CD register */
//------------------------------------------------------------------
// MASK FIELD REGISTERS
//------------------------------------------------------------------
#define SIM_CMD_CARDRST_MASK 0x0001
#define SIM_CMD_IFRST_MASK 0x0002
#define SIM_CMD_STOP_MASK 0x0004
#define SIM_CMD_START_MASK 0x0008
#define SIM_CMD_CLKEN_MASK 0x0010
#define SIM_CONF2_TFSIM_MASK 0x000f
#define SIM_CONF2_TDSIM_MASK 0x00f0
#define SIM_CONF2_WAITI_MASK 0xff00
//---------------------------------------------------------
// POSITION BIT
//---------------------------------------------------------
#define SIM_CONF1_TRIG_POSBIT 11
//------------------------------------------------------------------
// ARBITRARY FIXED VALUE OF REGISTERS
//------------------------------------------------------------------
#define SIM_CMD_VALUE 0x0012
#define SIM_CONF1_VALUE 0xa55a
#define SIM_CONF2_VALUE 0x5aa5
#define SIM_DTX_VALUE 0x005a
#define SIM_MASKIT_VALUE 0x001a
//------------------------------------------------------------------
// REGISTERS MASK
//------------------------------------------------------------------
#define SIM_CMD_REG_MASK 0x001F
#define SIM_STAT_REG_MASK 0x000F
#define SIM_CONF1_REG_MASK 0xFFFF
#define SIM_CONF2_REG_MASK 0xFFFF
#define SIM_IT_REG_MASK 0x001F
#define SIM_IT_CD_REG_MASK 0x0001
#define SIM_DRX_REG_MASK 0x01FF
#define SIM_DTX_REG_MASK 0x00FF
#define SIM_MASKIT_REG_MASK 0x003F
//------------------------------------------------------------------
// RESET VALUE OF REGISTERS
//------------------------------------------------------------------
#define SIM_CMD_RESET_VALUE 0x0000
#define SIM_STAT_RESET_VALUE 0x000A
#define SIM_CONF1_RESET_VALUE 0x000C
#define SIM_CONF2_RESET_VALUE 0x0940
#define SIM_IT_RESET_VALUE 0x0000
#define SIM_IT_CD_RESET_VALUE 0x0000
#define SIM_DRX_RESET_VALUE 0x0000
#define SIM_DTX_RESET_VALUE 0x0000
#define SIM_MASKIT_RESET_VALUE 0x003F
/* Prototype of the functions */
//----------------------------------------------------------------
// NAME : SIM_TestRegisters
// DESCRIPTION : Test the reset defualt values and also
// the access of the register to the SIM module.
// PARAMETERS : None
// RETURN VALUE : Return the result of the test OK or BAD
// LIMITATIONS : To invoke only after Reset
//----------------------------------------------------------------
UWORD16 SIM_TestRegisters(void);
//---------------------------------------------------------
// NAME : SIM_WriteCmd
// DESCRIPTION : Setup the Control Register SIM_CMD
// PARAMETERS : None
// RETURN VALUE : None
//---------------------------------------------------------
void SIM_WriteCmd (UWORD8 cmd);
//---------------------------------------------------------
// NAME : SIM_ResetInterface
// DESCRIPTION : Reset the SIM interface
// PARAMETERS : None
// RETURN VALUE : None
//---------------------------------------------------------
void SIM_ResetInterface (void);
//---------------------------------------------------------
// NAME : SIM_ResetCard
// DESCRIPTION : Reset the SIM Card
// PARAMETERS : None
// RETURN VALUE : None
//---------------------------------------------------------
void SIM_ResetCard (void);
//---------------------------------------------------------
// NAME : SIM_UnResetCard
// DESCRIPTION : Suppress the Reset of the SIM Card
// PARAMETERS : None
// RETURN VALUE : None
//---------------------------------------------------------
void SIM_UnResetCard (void);
//---------------------------------------------------------
// NAME : SIM_Start
// DESCRIPTION : Activate the SIM card start procedure
// PARAMETERS : None
// RETURN VALUE : None
//---------------------------------------------------------
void SIM_Start (void);
//---------------------------------------------------------
// NAME : SIM_Stop
// DESCRIPTION : Activate the SIM card stop procedure
// PARAMETERS : None
// RETURN VALUE : None
//---------------------------------------------------------
void SIM_Stop (void);
//--------------------------------------------------
// NAME : SIM_EnableClock
// DESCRIPTION : Enable the clock of SIM module
// PARAMETERS : None
// RETURN VALUE : None
//--------------------------------------------------
void SIM_EnableClock (void);
//--------------------------------------------------
// NAME : SIM_GetStatus
// DESCRIPTION : Read the status register
// PARAMETERS : None
// RETURN VALUE : None
//--------------------------------------------------
UWORD8 SIM_GetStatus (void);
//--------------------------------------------------
// NAME : SIM_ReadConf1
// DESCRIPTION : Read the configuration register
// PARAMETERS : None
// RETURN VALUE : Configuration register
//--------------------------------------------------
UWORD16 SIM_ReadConf1 (void);
//--------------------------------------------------
// NAME : SIM_WriteConf1
// DESCRIPTION : Setup the configuration register
// PARAMETERS : Configuration register value
// RETURN VALUE : None
//--------------------------------------------------
void SIM_WriteConf1 (UWORD16 conf);
//--------------------------------------------------
// NAME : SIM_SetFifoSize
// DESCRIPTION : Setup the FIFO trigger level [0..15]
// PARAMETERS : Size of the fifo
// RETURN VALUE : None
//--------------------------------------------------
void SIM_SetFifoSize (UWORD8 size);
//--------------------------------------------------
// NAME : SIM_ReadConf2
// DESCRIPTION : Read the Time-Delay parameters
// PARAMETERS : None
// RETURN VALUE : Register value
//--------------------------------------------------
UWORD16 SIM_ReadConf2 (void);
//--------------------------------------------------
// NAME : SIM_WriteConf2
// DESCRIPTION : Setup the Time-Delay parameters
// PARAMETERS : conf => Register value
// RETURN VALUE : None
//--------------------------------------------------
void SIM_WriteConf2 (UWORD16 conf);
//--------------------------------------------------
// NAME : SIM_GetIt
// DESCRIPTION : Read the Interrupt Status Register
// PARAMETERS : None
// RETURN VALUE : Interrupt Status Register value
//--------------------------------------------------
UWORD8 SIM_GetIt (void);
//-----------------------------------------------------
// NAME : SIM_GetItCD
// DESCRIPTION : Read the Interrupt CD Status Register
// PARAMETERS : None
// RETURN VALUE : Interrupt Status Register value
//-----------------------------------------------------
UWORD8 SIM_GetItCD (void);
//--------------------------------------------------
// NAME : SIM_Read
// DESCRIPTION : Read the data and the parity bit
// PARAMETERS : None
// RETURN VALUE : Received byte and parity bit
//--------------------------------------------------
UWORD16 SIM_Read (void);
//--------------------------------------------------
// NAME : SIM_ReadChar
// DESCRIPTION : Read the received data only
// PARAMETERS : None
// RETURN VALUE : Received byte
//--------------------------------------------------
UWORD16 SIM_ReadChar (void);
//------------------------------------------------------
// NAME : SIM_IsParityOk
// DESCRIPTION : Check parity-check for received byte
// PARAMETERS : None
// RETURN VALUE : False on parity error otherwise True
//------------------------------------------------------
boolean_t SIM_IsParityOk (void);
//------------------------------------------------------
// NAME : SIM_Write
// DESCRIPTION : Write into Transmit Byte Register
// PARAMETERS : Data byte to write
// RETURN VALUE : None
//------------------------------------------------------
void SIM_Write (UWORD16 data);
//------------------------------------------------------
// NAME : SIM_WrCnf1Write
// DESCRIPTION : Setup Configuration register and
// Write data into Transmit byte register
// PARAMETERS : Data byte to write
// configuration register value to setup
// RETURN VALUE : None
//------------------------------------------------------
void SIM_WrCnf1Write (UWORD16 data, UWORD16 conf);
//------------------------------------------------------
// NAME : SIM_ReadMaskIt
// DESCRIPTION : Read the Interrupt mask IT register
// PARAMETERS : None
// RETURN VALUE : Register value
//------------------------------------------------------
UWORD8 SIM_ReadMaskIt (void);
//------------------------------------------------------
// NAME : SIM_WriteMaskIt
// DESCRIPTION : Setup the Interrupt mask IT register
// PARAMETERS : Register value to write
// RETURN VALUE : None
//------------------------------------------------------
void SIM_WriteMaskIt (UWORD8 mask);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -