SAMV71 Xplained Ultra Software Package 1.5

mcid.h

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