/**********************************************************************************************
*
* @file edma.c
*
* @version 0.0.2
*
* @date June. 11, 2016
*
* @brief provide commond EDMA utilities
*
**********************************************************************************************/
/**********************************************************************************************
* Includes
**********************************************************************************************/
#include "MPC5748G.h"
#include <stdio.h>
#include "edma.h"
/**********************************************************************************************
* Macros
**********************************************************************************************/
/* configuration structures for simple loop transfers */
edma_loop_transfer_config_t loopConfig = {
.majorLoopIterationCount = MAJOR_LOOP_COUNT,
.srcOffsetEnable = false,
.dstOffsetEnable = false,
.minorLoopOffset = 0,
.minorLoopChnLinkEnable = false,
.minorLoopChnLinkNumber = 0,
.majorLoopChnLinkEnable = false,
.majorLoopChnLinkNumber = 0
};
edma_transfer_config_t transferConfig = {
.srcAddr = 0,
.destAddr = 0,
.srcTransferSize = EDMA_TRANSFER_SIZE_1B,
.destTransferSize = EDMA_TRANSFER_SIZE_1B,
.srcOffset = 1,
.destOffset = 1,
.srcLastAddrAdjust = 0,
.destLastAddrAdjust = 0,
.srcModulo = EDMA_MODULO_OFF,
.destModulo = EDMA_MODULO_OFF,
.minorByteTransferCount = 0,
.scatterGatherEnable = false,
.scatterGatherNextDescAddr = 0,
.interruptEnable = true,
.loopTransferConfig = &loopConfig
};
/**********************************************************************************************
* Local variables
***********************************************************************************************/
DMA_CallbackType DMA_Callback[1] = {}; /* eDMA interrupt callback */
/*! @brief EDMA global structure to maintain eDMA state */
static volatile edma_state_t *g_edma = NULL;
/**********************************************************************************************
* Local function
**********************************************************************************************/
/* @ edma_api_list */
/**********************************************************************************************
*
* @brief Halts/Un-halts the DMA Operations.
*
* This function stalls/un-stalls the start of any new channels. Executing channels are allowed
* to be completed.
*
* @param base Register base address for eDMA module.
* @param halt Halts (true) or un-halts (false) eDMA transfer.
*
* @return none
*
**********************************************************************************************/
void EDMA_HAL_SetHaltCmd(struct DMA_tag *pDMA, bool halt)
{
pDMA->CR.B.HALT=halt;
}
/**********************************************************************************************
*
* @brief Halts or does not halt the eDMA module when an error occurs.
*
* An error causes the HALT bit to be set. Subsequently, all service requests are ignored until the
* HALT bit is cleared.
*
* @param base Register base address for eDMA module.
* @param haltOnError Halts (true) or not halt (false) eDMA module when an error occurs.
*
* @return none
*
**********************************************************************************************/
void EDMA_HAL_SetHaltOnErrorCmd(struct DMA_tag *pDMA, bool haltOnError)
{
pDMA->CR.B.HOE= (uint32_t)haltOnError;
}
/**********************************************************************************************
*
* @brief Enables/Disables the eDMA DEBUG mode.
*
* This function enables/disables the eDMA Debug mode.
* When in debug mode, the DMA stalls the start of a new
* channel. Executing channels are allowed to complete. Channel execution resumes
* either when the system exits debug mode or when the EDBG bit is cleared.
*
* @param base Register base address for eDMA module.
* @param enable Enables (true) or Disable (false) eDMA module debug mode.
*
* @return none
*
**********************************************************************************************/
void EDMA_HAL_SetDebugCmd(struct DMA_tag *pDMA, bool enable)
{
pDMA->CR.B.EDBG=enable;
}
/**********************************************************************************************
*
* @brief Checks for valid errors.
*
* Returns whether a valid error exists, that has not been cleared.
*
* @param base Register base address for eDMA module.
*
* @return true, if a valid uncleared error exists, false otherwise.
*
**********************************************************************************************/
bool EDMA_HAL_GetValidErrorNotCleared(struct DMA_tag *pDMA)
{
return (bool)pDMA->ES.B.VLD;
}
/**********************************************************************************************
*
* @brief Checks for cancelled transfers.
*
* Returns whether the last entry was a cancelled transfer,
* by the error cancel transfer input
*
* @param base Register base address for eDMA module.
*
* @return true, if the last transfer was cancelled, false otherwise.
*
**********************************************************************************************/
bool EDMA_HAL_GetTransferCancelledError(struct DMA_tag *pDMA)
{
return (bool)pDMA->ES.B.ECX;
}
/**********************************************************************************************
*
* @brief Checks for channel priority errors.
*
* Returns whether the channel priorities configuration was erroneous
* (priorities not unique).
*
* @param base Register base address for eDMA module.
*
* @return true, if the channels priorities were misconfigured, false otherwise.
*
**********************************************************************************************/
bool EDMA_HAL_GetChannelPriorityError(struct DMA_tag *pDMA)
{
return (bool)pDMA->ES.B.CPE;
}
/**********************************************************************************************
*
* @brief Checks for source address errors.
*
* Returns whether the source address configuration was erroneous.
*
* @param base Register base address for eDMA module.
*
* @return true, if the source address was misconfigured, false otherwise.
*
**********************************************************************************************/
bool EDMA_HAL_GetSourceAddressError(struct DMA_tag *pDMA)
{
return (bool)pDMA->ES.B.SAE;
}
/**********************************************************************************************
*
* @brief Checks for source offset errors.
*
* Returns whether the source offset configuration was erroneous.
*
* @param base Register base address for eDMA module.
*
* @return true, if the source offset was misconfigured, false otherwise.
*
**********************************************************************************************/
bool EDMA_HAL_GetSourceOffsetError(struct DMA_tag *pDMA)
{
return (bool)pDMA->ES.B.SOE;
}
/**********************************************************************************************
*
* @brief Checks for destination address errors.
*
* Returns whether the destination address configuration was erroneous.
*
* @param base Register base address for eDMA module.
*
* @return true, if the destination address was misconfigured, false otherwise.
*
**********************************************************************************************/
bool EDMA_HAL_GetDestinationAddressError(struct DMA_tag *pDMA)
{
return (bool)pDMA->ES.B.DAE;
}
/**********************************************************************************************
*
* @brief Checks for destination offset errors.
*
* Returns whether the destination offset configuration was erroneous.
*
* @param base Re
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
MPC5748G LIN通信 (159个子文件)
Ethernet_Demo_Z4_0.args 1KB
LIN_5748g.args 1KB
ENET_demo.args 1KB
eth.args 1KB
dp83848.args 1KB
usdhc.args 1KB
cc936.args 1KB
ff.args 1KB
diskio.args 1KB
netbuf.args 1KB
tcpip.args 1KB
netdb.args 1KB
api_msg.args 1KB
sockets.args 1KB
err.args 1KB
netifapi.args 1KB
api_lib.args 1KB
ethernetif.args 1KB
etharp.args 1KB
dhcp.args 1KB
stats.args 1KB
tcp_in.args 1KB
init.args 1KB
sys.args 1KB
memp.args 1KB
timers.args 1KB
tcp.args 1KB
dns.args 1KB
raw.args 1KB
pbuf.args 1KB
udp.args 1KB
autoip.args 1KB
ip.args 1KB
ip_frag.args 1KB
igmp.args 1KB
inet_chksum.args 1KB
ip_addr.args 1KB
icmp.args 1KB
inet.args 1KB
netif.args 1KB
tcp_out.args 1KB
mem.args 1KB
def.args 1KB
MPC57xx__Interrupt_Init.args 940B
intc_SW_mode_isr_vectors_MPC5748G.args 940B
flashrchw.args 940B
Vector.args 940B
main.args 940B
common.args 940B
cmp.args 940B
io.args 940B
adc.args 940B
edma.args 940B
rtc.args 940B
spi.args 940B
flash.args 940B
i2c.args 940B
printf.args 940B
lin.args 940B
swt.args 940B
emios.args 940B
gpio.args 940B
flexcan.args 940B
wkpu.args 940B
clock.args 940B
smpu.args 940B
bctu.args 940B
uart.args 940B
mc_me.args 940B
sema4.args 940B
pit.args 940B
intc_sw_handlers.args 740B
startup.args 740B
edma.c 91KB
adc.c 77KB
mc_me.c 53KB
flexcan.c 51KB
intc_SW_mode_isr_vectors_MPC5748G.c 45KB
spi.c 30KB
cmp.c 29KB
emios.c 28KB
wkpu.c 19KB
flash.c 19KB
printf.c 18KB
lin.c 17KB
uart.c 16KB
i2c.c 16KB
bctu.c 14KB
MPC57xx__Interrupt_Init.c 11KB
swt.c 10KB
pit.c 9KB
rtc.c 8KB
smpu.c 7KB
main.c 4KB
gpio.c 4KB
sema4.c 4KB
Vector.c 3KB
clock.c 2KB
io.c 2KB
common.c 2KB
共 159 条
- 1
- 2
资源评论
liu25xiang
- 粉丝: 4
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功