The wait in mci_WaitForEvent will delay all card transactions.

Dependencies:   FATFileSystem

Fork of EALib by EmbeddedArtists AB

gpdma.h

Committer:
dreschpe
Date:
2013-12-15
Revision:
9:da373a015d07
Parent:
0:0fdadbc3d852

File content as of revision 9:da373a015d07:


#ifndef GPDMA_H
#define GPDMA_H

#include "platform.h"

#define GPDMA_CONN_SDC              ((1UL))      /*!< SD card */

typedef enum
{
  GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA,             /* Memory to memory - DMA control */
  GPDMA_TRANSFERTYPE_M2P_CONTROLLER_DMA,             /* Memory to peripheral - DMA control */
  GPDMA_TRANSFERTYPE_P2M_CONTROLLER_DMA,             /* Peripheral to memory - DMA control */
  GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DMA,             /* Source peripheral to destination peripheral - DMA control */
  GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DestPERIPHERAL,  /* Source peripheral to destination peripheral - destination peripheral control */
  GPDMA_TRANSFERTYPE_M2P_CONTROLLER_PERIPHERAL,      /* Memory to peripheral - peripheral control */
  GPDMA_TRANSFERTYPE_P2M_CONTROLLER_PERIPHERAL,      /* Peripheral to memory - peripheral control */
  GPDMA_TRANSFERTYPE_P2P_CONTROLLER_SrcPERIPHERAL,  /* Source peripheral to destination peripheral - source peripheral control */
} gpdma_flowControl_t;

/**
 * @brief  Initialize the GPDMA
 * @param  pGPDMA  : The base of GPDMA on the chip
 * @return  Nothing
 */
void gpdma_init();

/**
 * @brief  Shutdown the GPDMA
 * @param  pGPDMA  : The base of GPDMA on the chip
 * @return  Nothing
 */
void gpdma_deinit();

/**
 * @brief  Stop a stream DMA transfer
 * @param  ChannelNum  : Channel Number to be closed
 * @return  Nothing
 */
void gpdma_stop(uint8_t ChannelNum);

/**
 * @brief  The GPDMA stream interrupt status checking
 * @param  ChannelNum  : Channel Number to be checked on interruption
 * @return  Status:
 *              - true  : DMA transfer success
 *              - false  : DMA transfer failed
 */
bool gpdma_interrupt(uint8_t ChannelNum);

/**
 * @brief  Get a free GPDMA channel for one DMA connection
 * @param  pCh  : Assigned channel number (only valid if success)
 * @return  Status:
 *              - true  : Found a free DMA channel
 *              - false  : No free DMA channels, pCh value is undefined
 */
bool gpdma_getFreeChannel(uint8_t* pCh);

/**
 * @brief  Do a DMA transfer M2M, M2P,P2M or P2P
 * @param  ChannelNum  : Channel used for transfer
 * @param  src      : Address of Memory or PeripheralConnection_ID which is the source
 * @param  dst      : Address of Memory or PeripheralConnection_ID which is the destination
 * @param  TransferType: Select the transfer controller and the type of transfer. Should be:
 *                               - GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA
 *                               - GPDMA_TRANSFERTYPE_M2P_CONTROLLER_DMA
 *                               - GPDMA_TRANSFERTYPE_P2M_CONTROLLER_DMA
 *                               - GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DMA
 *                               - GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DestPERIPHERAL
 *                               - GPDMA_TRANSFERTYPE_M2P_CONTROLLER_PERIPHERAL
 *                               - GPDMA_TRANSFERTYPE_P2M_CONTROLLER_PERIPHERAL
 *                               - GPDMA_TRANSFERTYPE_P2P_CONTROLLER_SrcPERIPHERAL
 * @param  Size    : The number of DMA transfers
 * @return  False on error, true on success
 */
//bool gpdma_transfer(uint8_t ChannelNum,
//                    uint32_t src,
//                    uint32_t dst,
//                    gpdma_flowControl_t TransferType,
//                    uint32_t Size);

bool gpdma_transfer_to_mci(uint8_t ChannelNum,
                           uint32_t src,
                           uint32_t Size);
bool gpdma_transfer_from_mci(uint8_t ChannelNum,
                             uint32_t dst,
                             uint32_t Size);
#endif