/************************************************************************* $Archive: /PACS/OnBoard/m_smcsge.c $ $Revision: 1.10 $ $Date: 2009/04/23 13:51:12 $ $Author: amazy $ $Log: m_smcsge.c,v $ Revision 1.10 2009/04/23 13:51:12 amazy 6.029 * * 4 28/08/02 11:49 Amazy * Added the header with the history log *************************************************************************/ /***************************************************************************** * * Project name: Herschel PACS DEC-MEC * Product name: DM_LLDRV * Object name: m_smcsge * Filename: %M% * Language: C (ADSP-21020) * Compiler: G21K - r3.3 * Company: CRISA * Author: F. Torrero * Version: %I% * Creation date: 25/Mar/2002 * Last Modification date: %G% * * Description =============================================================== * * This module implements the lowest level functions and general definitions * related to management of two SMCS chips * * Change log =============================================================== * * | DATE | NEW VERSION | AUTHOR | REASON FOR CHANGE | * =========================================================================== * * 25/Mar/02 1 F.Torrero Creation * * ****************************************************************************/ /***************************************************************************** INCLUDES *****************************************************************************/ #include "l_gendef.h" #include "l_errcod.h" #include "l_hwmap.h" #include "l_memory.h" #include "m_smcsge.h" /***************************************************************************** PRIVATE CONSTANTS *****************************************************************************/ /***************************************************************************** PRIVATE TYPES *****************************************************************************/ /***************************************************************************** PRIVATE VARIABLES *****************************************************************************/ /***************************************************************************** DECLARATION OF PRIVATE FUNCTIONS *****************************************************************************/ /***************************************************************************** IMPLEMENTATION OF FUNCTIONS *****************************************************************************/ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_ReadSMCSReg * * DESCRIPTION * Read from SMCS chips register. All register info is contained in the Register * parameter, which has to be passed as a Physical DM address. Thus, it * is not necessary to specify the SMCS chip. * * INPUT ARGUMENTS: * SMCS register to be read * * OUTPUT ARGUMENTS: * Register value * * RETURNED VALUE: * Status return * * PSEUDOCODE * Read from SMCS register and store value in output argument * return OK *---------------------------------------------------------------------- $#$ */ T_SR DSMCS_ReadSMCSReg(T_UNSIGNED_32 Register, T_UNSIGNED_32 *RegisterValue) { (*RegisterValue)=MEM_ReadDMWord(Register); return(K_SR_OK); } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_WriteSMCSReg * * DESCRIPTION * Write to SMCS chips register. All register info is contained in the Register * parameter, which has to be passed as a Physical DM address. Thus, it * is not necessary to specify the SMCS chip. * * INPUT ARGUMENTS: * SMCS register to be written * Register value * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Status return * * PSEUDOCODE * Write input argument into SMCS register * Return OK *---------------------------------------------------------------------- $#$ */ T_SR DSMCS_WriteSMCSReg(T_UNSIGNED_32 Register, T_UNSIGNED_32 RegisterValue) { MEM_WriteDMWord(Register,RegisterValue); return(K_SR_OK); } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_GetRegAddressFromChannel * * DESCRIPTION * Get register address for the specified channel, given the register addres * for channel 1 * * INPUT ARGUMENTS: * Channel * Register address for channel 1 * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Register address * * PSEUDOCODE * if channel= Channel_1 OR channel_2 OR channel_3 * If channel= channel_1 then * Register Address= Register address for channel 1 * else if channel= channel_2 then * Register Address= Register address for channel 1 + offset between channels * Else * Register Address= Register address for channel 1 + offset between channels + * + offset between channels * else (channel is 4, 5 or 6) * Calculate address of corresponding register for channel 4, by doing: * Address_for_channel4 = Base address of SMCS2 + (Address_for_channel1 & 0xFF) * If channel= channel_4 then * Register Address= Register address for channel 4 * else if channel= channel_5 then * Register Address= Register address for channel 4 + offset between channels * Else * Register Address= Register address for channel 4 + offset between channels + * + offset between channels * Return Register address *---------------------------------------------------------------------- $#$ */ T_UNSIGNED_32 DSMCS_GetRegAddressForChannel(T_UNSIGNED_32 Channel, T_UNSIGNED_32 AddressChannel1) { T_UNSIGNED_32 AddressChannel4=0; T_UNSIGNED_32 RegisterAddress=0; if ((Channel==K_SMCSCHANNEL_1)||(Channel==K_SMCSCHANNEL_2) ||(Channel==K_SMCSCHANNEL_3)) { /* Determine register address depending on selected channel */ if (Channel==K_SMCSCHANNEL_1) { RegisterAddress=AddressChannel1; } else if (Channel==K_SMCSCHANNEL_2) { RegisterAddress=AddressChannel1+K_OFFSET_BETWEEN_SMCSCHANNELS; } else { /* SMCS Channel 3 */ RegisterAddress=AddressChannel1+K_OFFSET_BETWEEN_SMCSCHANNELS +K_OFFSET_BETWEEN_SMCSCHANNELS; } } else { /* Channel is 4, 5 or 6 */ AddressChannel4 = K_DMADDR_BASE_SMCS2 + (AddressChannel1 & 0xFF); /* Determine register address depending on selected channel */ if (Channel==K_SMCSCHANNEL_4) { RegisterAddress=AddressChannel4; } else if (Channel==K_SMCSCHANNEL_5) { RegisterAddress=AddressChannel4+K_OFFSET_BETWEEN_SMCSCHANNELS; } else { /* SMCS Channel 6 */ RegisterAddress=AddressChannel4+K_OFFSET_BETWEEN_SMCSCHANNELS +K_OFFSET_BETWEEN_SMCSCHANNELS; } } return(RegisterAddress); } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_WriteBitInSMCSReg * * DESCRIPTION * Set specified bit of specified SMCS register to specified * value (0=low, 1=high), keeping the value of the other bits. All register * info is contained in the Register parameter, which has to be passed as a * Physical DM address. Thus, it is not necessary to specify the SMCS chip. * * INPUT ARGUMENTS: * SMCS Register * Bit position * Bit value (high/low) * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * None * * PSEUDOCODE * Write bit in SMCS reg. using l_memory functions *---------------------------------------------------------------------- $#$ */ T_VOID DSMCS_WriteBitInSMCSReg(T_UNSIGNED_32 Register, T_UNSIGNED_32 BitPosition, T_UNSIGNED_32 BitValue) { MEM_WriteBitInDMWord(Register,BitPosition,BitValue); return; } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_CheckBitInSMCSReg * * DESCRIPTION * Check if specified bit in provided SMCS reg. is 1 (returning K_TRUE) * or 0 (returning K_FALSE). All register info is contained in the Register * parameter, which has to be passed as a Physical DM address. Thus, it * is not necessary to specify the SMCS chip. * * INPUT ARGUMENTS: * SMCS register * Bit position * * OUTPUT ARGUMENTS: * Result (True/False) * * RETURNED VALUE: * None * * PSEUDOCODE * Check bit (use functions from memory module) * Return result, K_TRUE if bit=1, K_FALSE if bit=0 *---------------------------------------------------------------------- $#$ */ T_BOOLEAN DSMCS_CheckBitInSMCSReg(T_UNSIGNED_32 Register, T_UNSIGNED_32 BitPosition) { return(MEM_CheckBitInDMWord(Register,BitPosition)); }