#include "common.h"
#include "rtc.h"
#include "uart.h"
#include "dma.h"
#include "uart_dma_app.h"
#include "sysinit.h"
#define RECEIVE_BUF_LEN 8
uint8_t receive_buf[RECEIVE_BUF_LEN] = {0};
void DMA_Group0_Task(void);
void DMA_Group1_Task(void);
/******************************************************************************/
int main (void)
{
uint32_t i;
UART_ConfigType sConfig;
DMA_ConfigType DMA_Config={0};
/*执行系统初始化*/
sysinit();
LED0_Init();//初始化 LED
printf("\nRunning the UART_Loopback_DMA_demo project.\r\n");
DMA_int(DMA,&DMA_Config); /*初始化DMA模块*/
UART_DMASendInit(UART1,receive_buf,RECEIVE_BUF_LEN,DMA_CHANNEL0);
DMA_DisableRequest(DMA,DMA_CHANNEL0);//禁用通道硬件请求信号
UART_DMARevInit(UART1,receive_buf,RECEIVE_BUF_LEN,DMA_CHANNEL4);
DMA_INTConfig(DMA,DMA_INT_Major,DMA_EnInt,DMA_CHANNEL4);
DMA_SetCallback(DMA,DMA_IntGroup2,&DMA_Group1_Task);
sConfig.u32SysClkHz = BUS_CLK_HZ;//选择系统时钟
sConfig.u32Baudrate = 115200;//配置波特率为115200
UART_Init(UART1,&sConfig);//初始化串口 0
UART_EnableDMA(UART1, TxDMA);
UART_EnableDMA(UART1, RxDMA); /*接收器满,选择DMA读取接收器的数据*/
while (1)
{
}
}
/*****************************************************************************//*!
*
* [url=home.php?mod=space&uid=247401]@brief[/url] DMA传输回调函数.
*
* @param none.
*
* [url=home.php?mod=space&uid=266161]@return[/url] none.
*
*****************************************************************************/
void DMA_Group1_Task(void)
{
LED0_Toggle();//初始化 LED
DMA_SetMajorLoopCounter(DMA,RECEIVE_BUF_LEN,DMA_CHANNEL0);//设置主循环迭代次数
DMA_sLastAddressAdjust(DMA,-RECEIVE_BUF_LEN,DMA_CHANNEL0); //主循环结束后将源地址调整到初始值
DMA_EnableRequest(DMA,DMA_CHANNEL0); /*使能通道硬件请求信号*/
}
|