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

📄 csl_mmcsdaux.h

📁 ccs下对dm6446的测试程序
💻 H
📖 第 1 页 / 共 3 页
字号:
/*  ============================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005                 
 *                                                                              
 *   Use of this software is controlled by the terms and conditions found in the
 *   license agreement under which this software has been supplied.             
 *   ===========================================================================
 */ 

/** @file csl_mmcsdAux.h
 *
 *  @brief  API Auxilary header file for MMCSD CSL
 *
 *    Path: \\(CSLPATH)\\ipmodules\\mmcsd\\src
 *
 *  Description
 *    - The defines inline function definitions
 *
 */

/* =============================================================================
 *  Revision History
 *  ===============
 *  01-Sep-2004 Hs Added inline functions for query commands also.
 *  31-Aug-2004 Hs File Created from CSL_mmscdHwControl.c.
 * =============================================================================
 */

#ifndef _CSL_MMCSDAUX_H_
#define _CSL_MMCSDAUX_H_

#include<csl_mmcsd.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 *  Status Query Functions of MMCSD.
 */

/** ============================================================================
 *   @n@b CSL_mmcsdReset
 *
 *   @b Description
 *   @n This function resets the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdReset (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdReset (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    hMmcsd->regs->MMCCTL = *(CSL_BitMask16*)arg;
}

/** ============================================================================
 *   @n@b CSL_mmcsdEnable
 *
 *   @b Description
 *   @n This function enables the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdEnable (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdEnable (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    hMmcsd->regs->MMCCTL &= ~(*(CSL_BitMask16*)arg);
}

/** ============================================================================
 *   @n@b CSL_mmcsdInitSeqSend
 *
 *   @b Description
 *   @n This function sends the init sequence of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdInitSeqSend (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdInitSeqSend (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd
)
{
    hMmcsd->regs->MMCCMD =  CSL_FMKT (MMCSD_MMCCMD_DMATRIG, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_DCLR, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_STRMTP, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_WDATX, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_DTRW, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_BSYEXP, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_RSPFMT, RESETVAL)
                            |CSL_FMKT (MMCSD_MMCCMD_INITCK, INIT)
                            |CSL_FMKT (MMCSD_MMCCMD_PPLEN, RESETVAL)
                            |CSL_FMK  (MMCSD_MMCCMD_CMD, 0);
}

/** ============================================================================
 *   @n@b CSL_mmcsdSetSdBusWidth
 *
 *   @b Description
 *   @n This function sets the SD Bus width of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdSetSdBusWidth (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdSetSdBusWidth (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    /* MMC controller must be in RESET state */
    CSL_FINS (hMmcsd->regs->MMCCTL, MMCSD_MMCCTL_WIDTH,
              *(CSL_MmcsdBusWidth*)arg);
}

/** ============================================================================
 *   @n@b CSL_mmcsdSetBlkSize
 *
 *   @b Description
 *   @n This function sets the block size of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdSetBlkSize (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdSetBlkSize (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    CSL_FINS (hMmcsd->regs->MMCBLEN, MMCSD_MMCBLEN_BLEN, *(Uint16*)arg);
}

/** ============================================================================
 *   @n@b CSL_mmcsdSetNumBlks
 *
 *   @b Description
 *   @n This function sets the number of blocks of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdSetNumBlks (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdSetNumBlks (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    CSL_FINS (hMmcsd->regs->MMCNBLK, MMCSD_MMCNBLK_NBLK, *(Uint16*)arg);


}

/** ============================================================================
 *   @n@b CSL_mmcsdSendCmd
 *
 *   @b Description
 *   @n This function send the respective command of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdSendCmd (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdSendCmd (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    CSL_MmcsdCmd    mmcsdCmd;
    /* See the need to implement preconditions like clear status and
      clear response  here*/
    mmcsdCmd = *(CSL_MmcsdCmd*)arg;
    hMmcsd->regs->MMCARGHL = mmcsdCmd.arg;
    hMmcsd->regs->MMCCMD = mmcsdCmd.cmdType | mmcsdCmd.flag;

}

/** ============================================================================
 *   @n@b CSL_mmcsdReadWord
 *
 *   @b Description
 *   @n This function reads the word of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdReadWord (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdReadWord (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    *(Uint32*)arg = hMmcsd->regs->MMCDRR;
}
/** ============================================================================
 *   @n@b CSL_mmcsdWriteWord
 *
 *   @b Description
 *   @n This function writes word of the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdWriteWord (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdWriteWord (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    hMmcsd->regs->MMCDXR = *(Uint32*)arg;
}

/** ============================================================================
 *   @n@b CSL_mmcsdRead
 *
 *   @b Description
 *   @n This function implements the read operation of the the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdRead (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdRead (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    Uint32 i;
    register volatile Uint16 stat;
    CSL_MmcsdBufferDescriptor buffDescr;
    CSL_MmcsdRegsOvly mmcsdRegs;

    mmcsdRegs = hMmcsd->regs;
    buffDescr = *(CSL_MmcsdBufferDescriptor*)arg;
    buffDescr.error  = 0;
    buffDescr.transfernum = 0;
    for (i = buffDescr.num; i > 0; i--) {
      do {
        stat = mmcsdRegs->MMCST0;
        if ( stat & (CSL_MMCSD_STAT0_CRCRD|CSL_MMCSD_STAT0_TOUTRD) ) {
          if (stat & CSL_MMCSD_STAT0_CRCRD)
            buffDescr.error |= CSL_MMCSD_STAT0_CRCRD;
          if (stat & CSL_MMCSD_STAT0_TOUTRD)
            buffDescr.error |= CSL_MMCSD_STAT0_TOUTRD;

          break;
        }
      } while (!(stat & CSL_MMCSD_STAT0_DRRDY));

      if (buffDescr.error)
        break;

     *buffDescr.buff++ = mmcsdRegs->MMCDRR;
      buffDescr.transfernum++;

    }
    *(CSL_MmcsdBufferDescriptor*)arg = buffDescr;
    return;
}

/** ============================================================================
 *   @n@b CSL_mmcsdWrite
 *
 *   @b Description
 *   @n This function implements the write operation of the the MMCSD module.
 *
 *   @b Arguments
 *   @verbatim

            hMmcsd            Handle to MMCSD instance
            arg               argument, if any for the command.

     @endverbatim
 *
 *   <b> Return Value </b>  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *    @n None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim

        CSL_mmcsdWrite (hMmcsd);

     @endverbatim
 * ===========================================================================
 */
CSL_IDEF_INLINE
void CSL_mmcsdWrite (
    /** Pointer to the object that holds reference to the
     *  instance of MMCSD requested after the call
     */
    CSL_MmcsdHandle        hMmcsd,

    /* Arguments if any for the command */
    void                   *arg
)
{
    Uint32 i;
    register volatile Uint16 stat;
    CSL_MmcsdBufferDescriptor buffDescr;
    CSL_MmcsdRegsOvly mmcsdRegs;

    mmcsdRegs = hMmcsd->regs;
    buffDescr = *(CSL_MmcsdBufferDescriptor*)arg;
    buffDescr.error  = 0;
    buffDescr.transfernum = 0;
    for (i = buffDescr.num; i > 0; i--) {
      do {
        stat = mmcsdRegs->MMCST0;
        if (stat & CSL_MMCSD_STAT0_CRCWR) {
          buffDescr.error |= CSL_MMCSD_STAT0_CRCWR;
          break;
        }
      } while (!(stat & CSL_MMCSD_STAT0_DXRDY));

⌨️ 快捷键说明

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