本帖最后由 mcu8031 于 2014-2-8 18:24 编辑
一个采用DMA模式通过串口发送字符串的测试,抛砖引玉了...
#include "system.hpp"
#include "gpio.hpp"
#include "uart.hpp"
#include "dma.hpp"
using namespace System;
const char hello[] = "hello,world!\nThis string send by DMA.";
int main()
{
uint8_t i = 0;
CSystem::DefaultInit(System::ClockSource::EX50MHZ,System::CoreClock::CC100MHZ);
CSystem::WatchDogDisable();
//执行GPIO初始化 点亮LED
//PTD(PORTD) 端口,D7引脚,输出低电平,推挽输出模,禁止此引脚的中断请求
CGpio Led2(Gpio::PORT_D,Gpio::PIN_7,Gpio::BIT_SET,Gpio::OUT_PUSH_PULL,Gpio::IRQ_DISABLE);
CGpio Led3(Gpio::PORT_D,Gpio::PIN_0,Gpio::BIT_RESET,Gpio::OUT_PUSH_PULL,Gpio::IRQ_DISABLE);
CUart uart;
uart.SetSourceAddress((uint32_t)&hello[0]);
uart.SetCITER(sizeof(hello));
uart.SetBITER(sizeof(hello));
uart.Puts("hello,world!");
uart.SetDmaRequest(System::ENABLE);
while(1)
{
Led2.ToggleBit();
Led3.ToggleBit();
CSystem::Sleep(100);
uart.Put(i++);
}
}
|
|