SAMV71 Xplained Ultra Software Package 1.3

mcid.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2013, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 
00031 /** \file */
00032 
00033 /**
00034  * \ingroup sdmmc_hal
00035  * \addtogroup mcid_module MCI Driver (HAL for SD/MMC Lib)
00036  *
00037  * \section Purpose
00038  *
00039  * This driver implements SD(IO)/MMC command operations and MCI configuration
00040  * routines to perform SD(IO)/MMC access. It's used for upper layer
00041  * (\ref libsdmmc_module "SD/MMC driver") to perform SD/MMC operations.
00042  *
00043  * \section Usage
00044  *
00045  * -# MCID_Init(): Initializes a MCI driver instance and the underlying
00046  *                 peripheral.
00047  * -# MCID_SendCmd(): Starts a MCI transfer which described by
00048  *                    \ref sSdmmcCommand.
00049  * -# MCID_CancelCmd(): Cancel a pending command.
00050  * -# MCID_IsCmdCompleted(): Check if MCI transfer is finished.
00051  * -# MCID_Handler(): Interrupt handler which is called by ISR handler.
00052  * -# MCID_IOCtrl(): IO control function to report HW attributes to upper
00053  *                   layer driver and modify HW settings (such as clock
00054  *                   frequency, High-speed support, etc. See
00055  *                   \ref sdmmc_ioctrls).
00056  *
00057  * \sa \ref dmad_module "DMA Driver", \ref hsmci_module "HSMCI",
00058  *     \ref libsdmmc_module "SD/MMC Library"
00059  *
00060  * Related files:\n
00061  * \ref mcid.h\n
00062  * \ref mcid_dma.c.\n
00063  */
00064 
00065 #ifndef MCID_H
00066 #define MCID_H
00067 /** \addtogroup mcid_module
00068  *@{
00069  */
00070 
00071 /*----------------------------------------------------------------------------
00072  *         Headers
00073  *----------------------------------------------------------------------------*/
00074 
00075 #include "chip.h"
00076 
00077 #include <stdint.h>
00078 #include <stdio.h>
00079 
00080 /** \addtogroup mcid_defines MCI Driver Defines
00081  *      @{*/
00082 
00083 /*----------------------------------------------------------------------------
00084  *         Constants
00085  *----------------------------------------------------------------------------*/
00086 
00087 /** MCI States */
00088 #define MCID_IDLE   0       /**< Idle */
00089 #define MCID_LOCKED 1       /**< Locked for specific slot */
00090 #define MCID_CMD    2       /**< Processing the command */
00091 #define MCID_ERROR  3       /**< Command error */
00092 
00093 /** MCI Initialize clock 400K Hz */
00094 #define MCI_INITIAL_SPEED   400000
00095 
00096 /**     @}*/
00097 
00098 /*----------------------------------------------------------------------------
00099  *         Types
00100  *----------------------------------------------------------------------------*/
00101 /** \addtogroup mcid_structs MCI Driver Data Structs
00102  *      @{
00103  */
00104 #ifdef __cplusplus
00105  extern "C" {
00106 #endif
00107 
00108 /**
00109  *  \brief MCI Driver
00110  */
00111 typedef struct _Mcid
00112 {
00113     /** Pointer to a MCI peripheral. */
00114     Hsmci         *pMciHw;
00115     /** Pointer to a DMA driver */
00116     sXdmad         *pXdmad;
00117     /** Pointer to currently executing command. */
00118     void          *pCmd;
00119     /** MCK source, Hz */
00120     uint32_t       dwMck;
00121     /** DMA transfer channel */
00122     uint32_t       dwDmaCh;
00123     /** DMA transferred data index (bytes) */
00124     uint32_t       dwXfrNdx;
00125     /** DMA transfer size (bytes) */
00126     uint32_t       dwXSize;
00127     /** MCI peripheral identifier. */
00128     uint8_t        bID;
00129     /** Polling mode */
00130     uint8_t        bPolling;
00131     /** Reserved */
00132     uint8_t        reserved;
00133     /** state. */
00134     volatile uint8_t bState;
00135 } sMcid;
00136 
00137 /**     @}*/
00138 /*----------------------------------------------------------------------------
00139  *         Exported functions
00140  *----------------------------------------------------------------------------*/
00141 /** \addtogroup mcid_functions MCI Driver Functions
00142         @{*/
00143 extern void MCID_Init(sMcid * pMcid,
00144                       Hsmci * pMci, uint8_t bID, uint32_t dwMck,
00145                       sXdmad * pXdmad,
00146                       uint8_t bPolling);
00147 
00148 extern void MCID_Reset(sMcid * pMcid);
00149 
00150 extern void MCID_SetSlot(Hsmci *pMci, uint8_t slot);
00151 
00152 extern uint32_t MCID_Lock(sMcid * pMcid, uint8_t bSlot);
00153 
00154 extern uint32_t MCID_Release(sMcid * pMcid);
00155 
00156 extern void MCID_Handler(sMcid * pMcid);
00157 
00158 extern uint32_t MCID_SendCmd(sMcid * pMcid, void * pCmd);
00159 
00160 extern uint32_t MCID_CancelCmd(sMcid * pMcid);
00161 
00162 extern uint32_t MCID_IsCmdCompleted(sMcid * pMcid);
00163 
00164 extern uint32_t MCID_IOCtrl(sMcid * pMcid,uint32_t bCtl,uint32_t param);
00165 
00166 #ifdef __cplusplus
00167 }
00168 #endif
00169 /**     @}*/
00170 /**@}*/
00171 #endif //#ifndef HSMCID_H
00172 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines