Update version of EALib.

Dependencies:   FATFileSystem

Fork of EALib by IONX

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gpdma.h Source File

gpdma.h

00001 /*
00002  *  Copyright 2013 Embedded Artists AB
00003  *
00004  *  Licensed under the Apache License, Version 2.0 (the "License");
00005  *  you may not use this file except in compliance with the License.
00006  *  You may obtain a copy of the License at
00007  *
00008  *    http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  *  Unless required by applicable law or agreed to in writing, software
00011  *  distributed under the License is distributed on an "AS IS" BASIS,
00012  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *  See the License for the specific language governing permissions and
00014  *  limitations under the License.
00015  */
00016 
00017 #ifndef GPDMA_H
00018 #define GPDMA_H
00019 
00020 #include "platform.h"
00021 
00022 #define GPDMA_CONN_SDC              ((1UL))      /*!< SD card */
00023 
00024 typedef enum
00025 {
00026   GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA,             /* Memory to memory - DMA control */
00027   GPDMA_TRANSFERTYPE_M2P_CONTROLLER_DMA,             /* Memory to peripheral - DMA control */
00028   GPDMA_TRANSFERTYPE_P2M_CONTROLLER_DMA,             /* Peripheral to memory - DMA control */
00029   GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DMA,             /* Source peripheral to destination peripheral - DMA control */
00030   GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DestPERIPHERAL,  /* Source peripheral to destination peripheral - destination peripheral control */
00031   GPDMA_TRANSFERTYPE_M2P_CONTROLLER_PERIPHERAL,      /* Memory to peripheral - peripheral control */
00032   GPDMA_TRANSFERTYPE_P2M_CONTROLLER_PERIPHERAL,      /* Peripheral to memory - peripheral control */
00033   GPDMA_TRANSFERTYPE_P2P_CONTROLLER_SrcPERIPHERAL,  /* Source peripheral to destination peripheral - source peripheral control */
00034 } gpdma_flowControl_t;
00035 
00036 /**
00037  * @brief  Initialize the GPDMA
00038  * @param  pGPDMA  : The base of GPDMA on the chip
00039  * @return  Nothing
00040  */
00041 void gpdma_init();
00042 
00043 /**
00044  * @brief  Shutdown the GPDMA
00045  * @param  pGPDMA  : The base of GPDMA on the chip
00046  * @return  Nothing
00047  */
00048 void gpdma_deinit();
00049 
00050 /**
00051  * @brief  Stop a stream DMA transfer
00052  * @param  ChannelNum  : Channel Number to be closed
00053  * @return  Nothing
00054  */
00055 void gpdma_stop(uint8_t ChannelNum);
00056 
00057 /**
00058  * @brief  The GPDMA stream interrupt status checking
00059  * @param  ChannelNum  : Channel Number to be checked on interruption
00060  * @return  Status:
00061  *              - true  : DMA transfer success
00062  *              - false  : DMA transfer failed
00063  */
00064 bool gpdma_interrupt(uint8_t ChannelNum);
00065 
00066 /**
00067  * @brief  Get a free GPDMA channel for one DMA connection
00068  * @param  pCh  : Assigned channel number (only valid if success)
00069  * @return  Status:
00070  *              - true  : Found a free DMA channel
00071  *              - false  : No free DMA channels, pCh value is undefined
00072  */
00073 bool gpdma_getFreeChannel(uint8_t* pCh);
00074 
00075 /**
00076  * @brief  Do a DMA transfer M2M, M2P,P2M or P2P
00077  * @param  ChannelNum  : Channel used for transfer
00078  * @param  src      : Address of Memory or PeripheralConnection_ID which is the source
00079  * @param  dst      : Address of Memory or PeripheralConnection_ID which is the destination
00080  * @param  TransferType: Select the transfer controller and the type of transfer. Should be:
00081  *                               - GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA
00082  *                               - GPDMA_TRANSFERTYPE_M2P_CONTROLLER_DMA
00083  *                               - GPDMA_TRANSFERTYPE_P2M_CONTROLLER_DMA
00084  *                               - GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DMA
00085  *                               - GPDMA_TRANSFERTYPE_P2P_CONTROLLER_DestPERIPHERAL
00086  *                               - GPDMA_TRANSFERTYPE_M2P_CONTROLLER_PERIPHERAL
00087  *                               - GPDMA_TRANSFERTYPE_P2M_CONTROLLER_PERIPHERAL
00088  *                               - GPDMA_TRANSFERTYPE_P2P_CONTROLLER_SrcPERIPHERAL
00089  * @param  Size    : The number of DMA transfers
00090  * @return  False on error, true on success
00091  */
00092 //bool gpdma_transfer(uint8_t ChannelNum,
00093 //                    uint32_t src,
00094 //                    uint32_t dst,
00095 //                    gpdma_flowControl_t TransferType,
00096 //                    uint32_t Size);
00097 
00098 bool gpdma_transfer_to_mci(uint8_t ChannelNum,
00099                            uint32_t src,
00100                            uint32_t Size);
00101 bool gpdma_transfer_from_mci(uint8_t ChannelNum,
00102                              uint32_t dst,
00103                              uint32_t Size);
00104 #endif
00105 
00106