本文整理汇总了C++中DMA_StructInit函数的典型用法代码示例。如果您正苦于以下问题:C++ DMA_StructInit函数的具体用法?C++ DMA_StructInit怎么用?C++ DMA_StructInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DMA_StructInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: config_DMA
static void config_DMA( void )
{
DMA_InitTypeDef DMA_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
DMA_DeInit(DMA2_Stream0);
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC_CDR_Address;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADCConvertedValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = 2;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Word;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
//DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
DMA_Cmd(DMA2_Stream0, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(DMA2_Stream0, DMA_IT_TC | DMA_IT_TE, ENABLE);
}
示例2: wsDMA_Init
void wsDMA_Init(void * pSrc,void *pDest, uint32_t DataLen)
{
/* Enable WS_DMA_CHANNEL clock */
WS_DMA_RCC_CMD(WS_DMA_RCC_PERIPH, ENABLE);
DMA_DeInit(WS_DMA_CHANNEL);
DMA_StructInit(&_wsDMA_PayLoadInit);
_wsDMA_PayLoadInit.DMA_PeripheralBaseAddr = (uint32_t)pDest;
_wsDMA_PayLoadInit.DMA_MemoryBaseAddr = (uint32_t)pSrc;
_wsDMA_PayLoadInit.DMA_DIR = DMA_DIR_PeripheralDST;
_wsDMA_PayLoadInit.DMA_BufferSize = DataLen;
_wsDMA_PayLoadInit.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
_wsDMA_PayLoadInit.DMA_MemoryInc = DMA_MemoryInc_Enable;
_wsDMA_PayLoadInit.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
_wsDMA_PayLoadInit.DMA_MemoryDataSize = WS_DMA_TRANSFER_T;
_wsDMA_PayLoadInit.DMA_Priority = DMA_Priority_High;
_wsDMA_PayLoadInit.DMA_M2M = DMA_M2M_Disable;
_wsDMA_PayLoadInit.DMA_Mode = DMA_Mode_Circular;
/* WS_DMA_CHANNEL Config */
DMA_Init(WS_DMA_CHANNEL, &_wsDMA_PayLoadInit);
/* WS_DMA_CHANNEL enable */
DMA_Cmd(WS_DMA_CHANNEL, ENABLE);
}
示例3: DMA_RxConfiguration
/**
* @brief Configures the DMA2 Channel4 for SDIO Rx request.
* @param BufferDST: pointer to the destination buffer
* @param BufferSize: buffer size
* @retval None
*/
static void DMA_RxConfiguration(uint32_t *BufferDST, uint32_t BufferSize)
{
DMA_InitTypeDef DMA_InitStructure;
DMA_ITConfig(DMA2_Stream5, DMA_IT_TC | DMA_IT_TE | DMA_IT_HT,DISABLE);
DMA_ClearFlag(DMA2_Stream5, DMA_FLAG_TCIF5 | DMA_FLAG_TEIF5 | DMA_FLAG_HTIF5 | DMA_FLAG_DMEIF5 | DMA_FLAG_HTIF5);
/* DMA2 Channel4 disable */
DMA_Cmd(DMA2_Stream5, DISABLE);
DMA_StructInit(&DMA_InitStructure);
/* DMA2 Channel4 Config */
DMA_InitStructure.DMA_Channel = DMA_Channel_4;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(USART1->DR);
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferDST;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = BufferSize;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //循环模式
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_Init(DMA2_Stream5, &DMA_InitStructure);
u1_recv.pos = 0; //当前读取位置清零
/* DMA2 Channel4 enable */
DMA_ITConfig(DMA2_Stream5, DMA_IT_TE,ENABLE); //使能出错中断
DMA_Cmd(DMA2_Stream5, ENABLE);
USART_DMACmd(USART1,USART_DMAReq_Rx,ENABLE);
NVIC_EnableIRQ(DMA2_Stream5_IRQn);
}
示例4: USART2_Enable_Rx
static void USART2_Enable_Rx(void)
{
GPIO_InitTypeDef GPIO_USART_InitStruct;
USART_InitTypeDef USART_InitStruct;
DMA_InitTypeDef DMA_InitStruct;
/* Enable Clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE);
/* Set up GPIO for alternate function */
GPIO_PinAFConfig(GPIOD,GPIO_PinSource6,GPIO_AF_USART2);
/* Configure GPIO to transmit */
GPIO_USART_InitStruct.GPIO_Mode = GPIO_Mode_AF;
GPIO_USART_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_USART_InitStruct.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_USART_InitStruct.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOD, &GPIO_USART_InitStruct);
/* Configure USART */
USART_InitStruct.USART_BaudRate = MIDI_BAUD_RATE;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
USART_InitStruct.USART_Parity = USART_Parity_No;
USART_InitStruct.USART_Mode = USART_Mode_Rx;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART2, &USART_InitStruct);
/* Enable UART */
USART_Cmd(USART2, ENABLE);
DMA_StructInit(&DMA_InitStruct);
DMA_InitStruct.DMA_Channel = DMA_Channel_4;
DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)(&(USART2->DR));
DMA_InitStruct.DMA_Memory0BaseAddr = (uint32_t)midiBuffer;
DMA_InitStruct.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStruct.DMA_BufferSize = MIDI_BUF_SIZE;
DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStruct.DMA_Mode = DMA_Mode_Circular;
DMA_InitStruct.DMA_Priority = DMA_Priority_Medium;
DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA1_Stream5, &DMA_InitStruct);
DMA_Cmd(DMA1_Stream5, ENABLE);
/* Connect UART to DMA */
USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);
/* wait for DMA to be enabled */
while (DMA_GetCmdStatus(DMA1_Stream5) != ENABLE);
}
示例5: main
/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
debug();
#endif
SCU_MCLKSourceConfig(SCU_MCLK_OSC); /*Use OSC as the default clock source*/
SCU_PCLKDivisorConfig(SCU_PCLK_Div1); /* ARM Peripheral bus clokdivisor = 1*/
/* source addresses and destination addresses for the Second LLI structure */
Link[0]=(u32)(&Buffer0[12]);
Link[1]=(u32)(&Buffer2[0]);
/* source addresses and destination addresses for the Third LLI structure */
Link[4]=(u32)(&Buffer0[24]);
Link[5]=(u32)(&Buffer3[0]);
/*Set the addresses of next linked list for the second LLI structure*/
Link[2]=(u32)(&Link[4]);
SCU_AHBPeriphClockConfig(__DMA,ENABLE); /* Enable the clock for DMA*/
DMA_DeInit(); /* DMA default configuration : Reset configuration*/
DMA_Cmd(ENABLE);/*Enable the DMA*/
DMA_StructInit(&DMA_InitStruct);
/* Write the first LLI*/
DMA_InitStruct.DMA_Channel_LLstItm=(u32)(&Link[0]); /*Set the addresses of next linked list for the first LLI structure*/
DMA_InitStruct.DMA_Channel_SrcAdd=(u32)(&Buffer0[0]); /* source address for the first LLI structure */
DMA_InitStruct.DMA_Channel_DesAdd=(u32)(&Buffer1[0]); /*Destination address for the first LLI structure */
DMA_InitStruct.DMA_Channel_SrcWidth= DMA_SrcWidth_Word;/* The source bus width is a word" 32 bits"*/
DMA_InitStruct.DMA_Channel_DesWidth= DMA_DesWidth_Word; /* The Destination bus width is a word word*/
DMA_InitStruct.DMA_Channel_FlowCntrl=DMA_FlowCntrlt0_DMA;/* DMA is The flow controller*/
DMA_InitStruct.DMA_Channel_TrsfSize =12; /*transfer size*/
/* Configure the DMA channel1 "the chosen channel to perform the transfer" */
DMA_ChannelSRCIncConfig (DMA_Channel1, ENABLE);
DMA_ChannelDESIncConfig (DMA_Channel1, ENABLE);
DMA_Init(DMA_Channel1,&DMA_InitStruct);/* update the DMA channel1 registers with the cfirst LLI structure*/
DMA_ChannelCmd (DMA_Channel1,ENABLE);/*Enable the DMA channel*/
/*wait for the fifo to be empty*/
while(DMA_GetChannelActiveStatus(DMA_Channel1));
while(1);
}
示例6: spiInit
void spiInit(SPI_TypeDef* SPIx)
{
SPI_InitTypeDef SPI_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
DMA_Channel_TypeDef* DMA_Ch;
if (SPIx == SPI1)
{
chSemObjectInit(&spi1_semI, 1);
chSemObjectInit(&spi1_semS, 1);
DMA_Ch = DMA_CHANNEL_SPI1_TX;
}
else
{
return;
}
SPI_Cmd(SPIx, DISABLE);
//configure spi
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Hard;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPIx, &SPI_InitStructure);
SPI_Cmd(SPIx, ENABLE);
/* Setup DMA */
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPIx->DR;
DMA_InitStructure.DMA_MemoryBaseAddr = 0;
DMA_InitStructure.DMA_BufferSize = 0;
/* write */
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_Init(DMA_Ch, &DMA_InitStructure);
/* Enable the SPI Tx DMA request */
SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Tx, ENABLE);
}
示例7: BT_Usart2_Config
/**
* @brief To set and config blutooth then send data to the register.
* @param rate, baudrate has setted on AT mode; addr, the memory base address; leng, the length of data you want to send.
* @retval None.
*/
void BT_Usart2_Config(uint32_t rate, uint32_t addr, uint8_t leng)
{
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_2/*TX, PA2*/ | GPIO_Pin_3/*RX, PA3*/);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_7);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_7);
USART_InitStructure.USART_BaudRate = rate;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_DeInit(USART2);
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
DMA_StructInit(&DMA_InitStructure);
DMA_DeInit(DMA1_Channel7);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)USART2 + 0x28; //////
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&addr;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = leng;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //address register is incremented or not
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord ;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord ;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel7,&DMA_InitStructure);
USART_ClearFlag(USART2,USART_FLAG_TC);
DMA_ClearFlag(DMA1_FLAG_TC7);
USART_DMACmd(USART2,USART_DMAReq_Tx,ENABLE);
DMA_Cmd(DMA1_Channel7,ENABLE);
sig_lam(2,1);
while (!DMA_GetFlagStatus(USART_FLAG_TC)){};
}
示例8: init_DMA_in
void init_DMA_in() {
DMA_InitTypeDef DMA_InitStruct;
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_DMA1, ENABLE );
DMA_DeInit(DMA1_Channel5);
DMA_StructInit( &DMA_InitStruct );
DMA_InitStruct.DMA_PeripheralBaseAddr = (unsigned int)&(I2C2 -> DR);
DMA_InitStruct.DMA_BufferSize = 4;
DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStruct.DMA_MemoryBaseAddr = (int)out_buf;
DMA_InitStruct.DMA_Priority = DMA_Priority_VeryHigh;
DMA_Init(DMA1_Channel5, &DMA_InitStruct);
DMA_Cmd( DMA1_Channel5, ENABLE );
}
示例9: enable_dma_tx
static void enable_dma_tx(const uint32_t dma_periph,
const uint8_t irq_channel,
const uint8_t irq_priority,
const uint32_t dma_it_flags,
volatile struct usart_info* ui)
{
const volatile struct dma_info* dma = &ui->dma_tx;
RCC_AHB1PeriphClockCmd(dma_periph, ENABLE);
DMA_DeInit(dma->stream);
DMA_InitTypeDef DMA_InitStructure;
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_Channel = dma->channel;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) dma->buff;
/*
* Setting BufferSize here to 0 is invalid. Its initial value
* doesn't matter anyways so set 1 here.
*/
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &ui->usart->DR;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
DMA_Init(dma->stream, &DMA_InitStructure);
if (dma_it_flags) {
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = irq_channel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority
= irq_priority;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(dma->stream, dma_it_flags, ENABLE);
}
/* Enable the USART Rx DMA request */
USART_DMACmd(ui->usart, USART_DMAReq_Tx, ENABLE);
}
示例10: dma_setup
void dma_setup(int bitRate) {
// init SPI
JshSPIInfo inf;
jshSPIInitInfo(&inf);
inf.baudRate = bitRate;
inf.baudRateSpec = SPIB_MINIMUM; // we don't want SPI to be any slower than this
inf.spiMSB = false;
inf.pinMOSI = tvPinVideo;
jshPinSetValue(tvPinVideo, 0); // set default video output state
jshSPISetup(TVSPIDEVICE, &inf);
// disable IRQs - because jsHardware enabled them
SPI_I2S_ITConfig(TVSPI, SPI_I2S_IT_RXNE, DISABLE);
// init DMA
#ifdef STM32F4
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_TVDMA, ENABLE);
#else
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_TVDMA, ENABLE);
#endif
DMA_InitTypeDef DMA_InitStructure;
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&(TVSPI->DR));
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; // DMA_PeripheralDataSize_HalfWord and 16 bit?
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
#ifdef STM32F4
DMA_InitStructure.DMA_Channel = DMA_Channel_TVSPI_TX; // needed for SPI TX
DMA_InitStructure.DMA_Memory0BaseAddr = (u32)tvPixelPtr;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_MemoryBurst =DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst =DMA_PeripheralBurst_Single;
#else
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)tvPixelPtr;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
#endif
DMA_InitStructure.DMA_BufferSize = tvWidth>>3/*bytes*/;
DMA_DeInit(DMA_TVSPI_TX);
DMA_Init(DMA_TVSPI_TX, &DMA_InitStructure);
SPI_I2S_DMACmd(TVSPI, SPI_I2S_DMAReq_Tx, ENABLE);
}
示例11: enable_dma_rx
static void enable_dma_rx(const uint32_t dma_periph,
const uint8_t irq_channel,
const uint8_t irq_priority,
const uint32_t dma_it_flags,
volatile struct usart_info* ui)
{
const volatile struct dma_info* dma = &ui->dma_rx;
RCC_AHB1PeriphClockCmd(dma_periph, ENABLE);
DMA_DeInit(dma->stream);
DMA_InitTypeDef DMA_InitStructure;
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_Channel = dma->channel;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t) dma->buff;
DMA_InitStructure.DMA_BufferSize = dma->buff_size;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &ui->usart->DR;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_Init(dma->stream, &DMA_InitStructure);
if (dma_it_flags) {
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = irq_channel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = irq_priority;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(dma->stream, dma_it_flags, ENABLE);
}
/* Enable the USART Rx DMA request */
USART_DMACmd(ui->usart, USART_DMAReq_Rx, ENABLE);
/* Enable the DMA RX Stream */
DMA_Cmd(dma->stream, ENABLE);
}
示例12: ETH_DMAPrepare
/**
* @brief Init the DMA channel.
* @param None
* @retval None.
*/
void ETH_DMAPrepare(void)
{
DMA_CtrlDataInitTypeDef DMA_PriCtrlStr;
DMA_ChannelInitTypeDef DMA_InitStr;
DMA_DeInit();
DMA_StructInit(&DMA_InitStr);
/* Set Channel Structure */
DMA_InitStr.DMA_PriCtrlData = &DMA_PriCtrlStr;
DMA_InitStr.DMA_Priority = DMA_Priority_High;
DMA_InitStr.DMA_UseBurst = DMA_BurstClear;
DMA_InitStr.DMA_SelectDataStructure = DMA_CTRL_DATA_PRIMARY;
/* Init DMA channel */
DMA_Init(DMA_Channel_SW1, &DMA_InitStr);
}
示例13: USART6_RX_DMA
/*
*********************************************************************************************************
* 函 数 名: USART6_RX_DMA
* 功能说明: 设置USART6 DMA接收方式
* 形 参:无
* 返 回 值: 无
*********************************************************************************************************
*/
void USART6_RX_DMA(void)
{
//DMA_InitTypeDef UART6_DMA_RX;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); //开DMA时钟
DMA_StructInit(&UART6_DMA_RX);
UART6_DMA_RX.DMA_Channel = DMA_Channel_5;
UART6_DMA_RX.DMA_PeripheralBaseAddr = (u32)&USART6->DR;
UART6_DMA_RX.DMA_Memory0BaseAddr = (u32)&UART6_Recv_Buf[UART6_User_Buf_No];
UART6_DMA_RX.DMA_DIR = DMA_DIR_PeripheralToMemory;
UART6_DMA_RX.DMA_BufferSize = UART6_MAX_RECV_LEN;
UART6_DMA_RX.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
UART6_DMA_RX.DMA_MemoryInc = DMA_MemoryInc_Enable;
UART6_DMA_RX.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
UART6_DMA_RX.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
UART6_DMA_RX.DMA_Mode = DMA_Mode_Normal;//DMA_Mode_Circular;
UART6_DMA_RX.DMA_Priority = DMA_Priority_Medium;
UART6_DMA_RX.DMA_FIFOMode = DMA_FIFOMode_Disable;
UART6_DMA_RX.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
UART6_DMA_RX.DMA_MemoryBurst = DMA_MemoryBurst_Single;
UART6_DMA_RX.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
//DMA_DoubleBufferModeConfig ( DMA2_Stream5, (uint32_t)&UART6_Str.Buf[1], DMA_Memory_0 );
//DMA_DoubleBufferModeCmd ( DMA2_Stream5, ENABLE );
DMA_Init(DMA2_Stream2, &UART6_DMA_RX);
USART_DMACmd(USART6, USART_DMAReq_Rx, ENABLE);
DMA_Cmd(DMA2_Stream2, ENABLE);
DMA_ITConfig(DMA2_Stream2, DMA_IT_TC, ENABLE); //DMA5传输完成中断
DMA_ITConfig(DMA2_Stream2, DMA_IT_TE, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
示例14: dma_channel_usart2_init
void dma_channel_usart2_init(void){
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
DMA_InitTypeDef myDMA;
DMA_StructInit(&myDMA);
myDMA.DMA_DIR = DMA_DIR_PeripheralDST;
myDMA.DMA_M2M = DMA_M2M_Disable;
myDMA.DMA_Mode = DMA_Mode_Normal;
myDMA.DMA_Priority = DMA_Priority_Medium;
myDMA.DMA_PeripheralBaseAddr =(uint32_t) &(USART2->TDR);
myDMA.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
myDMA.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
myDMA.DMA_MemoryBaseAddr = 0x200000 ;
myDMA.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
myDMA.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_Init(DMA1_Channel7,&myDMA);// DMA1 Channel 7 = USART2_Tx
NVIC_EnableIRQ(DMA1_Channel7_IRQn);
}
示例15: ADC_DMA_init
void ADC_DMA_init()
{
NVIC_InitTypeDef NVIC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
/* Enable DMA1 clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
/* De-initialise DMA */
DMA_DeInit(DMA1_Channel1);
//DMA_InitTypeDef DMA_InitStructure;
/* DMA1 channel1 configuration */
DMA_StructInit(&DMA_InitStructure);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(ADC1->DR); // Set DMA channel Peripheral base address to ADC Data register
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADC_ConvertedValueBuff; // Set DMA channel Memeory base addr to ADC_ConvertedValueBuff address
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; // Set DMA channel direction to peripheral to memory
DMA_InitStructure.DMA_BufferSize = ADC_CONV_BUFF_SIZE; // Set DMA channel buffersize to peripheral to ADC_CONV_BUFF_SIZE
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; // Disable DMA channel Peripheral address auto increment
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; // Enable Memeory increment (To be verified ....)
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;// set Peripheral data size to 8bit
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; // set Memeory data size to 8bit
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; // Set DMA in normal mode
DMA_InitStructure.DMA_Priority = DMA_Priority_High; // Set DMA channel priority to High
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; // Disable memory to memory option
DMA_Init(DMA1_Channel1, &DMA_InitStructure); // Use Init structure to initialise channel1 (channel linked to ADC)
/* Enable Transmit Complete Interrup for DMA channel 1 */
DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE);
/* Setup NVIC for DMA channel 1 interrupt request */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_Cmd(DMA1_Channel1, ENABLE);
}