#include "stm32f10x.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_dma.h"
#include "LED.h"
const int Soc=2;
int Pac;
void DMAConfig(void)
{
DMA_InitTypeDef DMAset;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
DMAset.DMA_PeripheralBaseAddr=(uint32_t)Pac;
DMAset.DMA_MemoryBaseAddr=(uint32_t)Soc;
DMAset.DMA_DIR=DMA_DIR_PeripheralSRC;
DMAset.DMA_BufferSize=1;
DMAset.DMA_MemoryInc=DMA_MemoryInc_Disable;
DMAset.DMA_PeripheralInc=DMA_PeripheralInc_Disable;
DMAset.DMA_PeripheralDataSize=DMA_PeripheralDataSize_Word;
DMAset.DMA_MemoryDataSize=DMA_MemoryDataSize_Word;
DMAset.DMA_Mode=DMA_Mode_Normal;
DMAset.DMA_Priority=DMA_Priority_High;
DMAset.DMA_M2M=DMA_M2M_Enable;
DMA_Init(DMA1_Channel6,&DMAset);
DMA_ClearFlag(DMA1_FLAG_TC6);
DMA_Cmd(DMA1_Channel6,ENABLE);
}
void delay_us(u32 nTimer)
{
u32 i=0;
for(i=0;i<nTimer;i++){
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
}
}
void delay_ms(u32 nTimer)
{
u32 i=1000*nTimer;
delay_us(i);
}
int main(void)
{
LED_GPIO_Config();
LED_RED;
int order=0;
DMAConfig();
while(DMA_GetFlagStatus(DMA1_FLAG_TC6)==0)
{
}
delay_ms(1000);
while(1)
{
if(Pac==Soc)
{
order=1;
}
if(order==1)
{
LED_GREEN;
}
}
} |