• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ USART_DMACmd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中USART_DMACmd函数的典型用法代码示例。如果您正苦于以下问题:C++ USART_DMACmd函数的具体用法?C++ USART_DMACmd怎么用?C++ USART_DMACmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了USART_DMACmd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: MicoUartSend

OSStatus MicoUartSend( mico_uart_t uart, const void* data, uint32_t size )
{
  /* Reset DMA transmission result. The result is assigned in interrupt handler */
  uart_interfaces[uart].tx_dma_result = kGeneralErr;
  
  MicoMcuPowerSaveConfig(false);  
  
  uart_mapping[uart].tx_dma_stream->CR  &= ~(uint32_t) DMA_SxCR_CIRC;
  uart_mapping[uart].tx_dma_stream->NDTR = size;
  uart_mapping[uart].tx_dma_stream->M0AR = (uint32_t)data;
  
  USART_DMACmd( uart_mapping[uart].usart, USART_DMAReq_Tx, ENABLE );
  USART_ClearFlag( uart_mapping[uart].usart, USART_FLAG_TC );
  DMA_Cmd( uart_mapping[uart].tx_dma_stream, ENABLE );
  
#ifndef NO_MICO_RTOS
  mico_rtos_get_semaphore( &uart_interfaces[ uart ].tx_complete, MICO_NEVER_TIMEOUT );
#else 
  while(uart_interfaces[ uart ].tx_complete == false);
  uart_interfaces[ uart ].tx_complete = false;
#endif
  
  while ( ( uart_mapping[ uart ].usart->SR & USART_SR_TC ) == 0 )
  {
  }
  
  DMA_Cmd( uart_mapping[uart].tx_dma_stream, DISABLE );
  USART_DMACmd( uart_mapping[uart].usart, USART_DMAReq_Tx, DISABLE );
  
  MicoMcuPowerSaveConfig(true);
  
  return uart_interfaces[uart].tx_dma_result;
  //#endif
}
开发者ID:yantrabuddhi,项目名称:bootlaoder_EMW3165,代码行数:34,代码来源:MicoDriverUart.c


示例2: DMA_Configuration

void DMA_Configuration(void)
{
    DMA_DeInit(DMA1_Channel6);

    /* Enable the USART Rx DMA request */
    USART_DMACmd(USART2, USART_DMAReq_Tx, ENABLE);

    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; // Receive //DMA_DIR_PeripheralDST
    DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)read_parameters_android;
    DMA_InitStructure.DMA_BufferSize = sizeof(read_parameters_android);
    DMA_InitStructure.DMA_PeripheralBaseAddr =(uint32_t) &(USART2->RDR);

    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_InitStructure.DMA_M2M = DMA_M2M_Disable;
    DMA_Init(DMA1_Channel6, &DMA_InitStructure);
    USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);
    DMA_ITConfig(DMA1_Channel6, DMA_IT_TC, ENABLE);
    DMA_ITConfig(DMA1_Channel6, DMA_IT_HT, ENABLE);
    DMA_Cmd(DMA1_Channel6, ENABLE);
}
开发者ID:lennytraviano,项目名称:quadrocopter,代码行数:26,代码来源:usart.c


示例3: DMA_USART_ReInit

void DMA_USART_ReInit()
{
    DMA_Cmd(DMA1_Stream6, DISABLE);
    USART_DMACmd(USART2,USART_DMAReq_Tx,DISABLE);
    DMA_Init(DMA1_Stream6, &DMA_InitStructure);
    USART_DMACmd(USART2,USART_DMAReq_Tx,ENABLE);
    DMA_Cmd(DMA1_Stream6, ENABLE);
}
开发者ID:vehar,项目名称:CAN-viewer,代码行数:8,代码来源:stuff.c


示例4: pingpong_usart1_rx_dma_int

void pingpong_usart1_rx_dma_int(void)
{
	if(!dma1_ch5_mode_is_circular())
	{
		USART_DMACmd(USART1, USART_DMAReq_Rx, DISABLE);
		DMA_Cmd(DMA1_Channel5, DISABLE);
	}
	
#if DMA_Circular
	if(PINGPONG_BUF_NO0 == PingPongBuf_Free_No)
	{
		DMA1_Channel5->CMAR = (unsigned int)&pingpongbuf[0]; // DMA_MemoryBaseAddr;
		PingPongBuf_Free_No = PINGPONG_BUF_NO1;
		//usart1_dma_write(pingpongbuf[1], PINGPONG_BUFSIZE, usart1_dma_tx_done_callback);
	}
	else
	{
		DMA1_Channel5->CMAR = (unsigned int)pingpongbuf[1]; // DMA_MemoryBaseAddr;
		PingPongBuf_Free_No = PINGPONG_BUF_NO0;
		//usart1_dma_write(pingpongbuf[1], PINGPONG_BUFSIZE, usart1_dma_tx_done_callback);
	}
	PINGPONG_BUF_OK = TRUE;
#else // DMA Mode Normal
	if(PINGPONG_BUF_NO0 == PingPongBuf_Free_No)
	{
		PingPongBuf_Free_No = PINGPONG_BUF_NO1;
		//usart1_dma_write(pingpongbuf[1], PINGPONG_BUFSIZE, usart1_dma_tx_done_callback);
		#if 1
		DMA1_Channel5->CMAR = (unsigned int)pingpongbuf[0]; // DMA_MemoryBaseAddr;
		DMA1_Channel5->CNDTR = PINGPONG_BUFSIZE; // DMA_BufferSize;
		DMA_Cmd(DMA1_Channel5, ENABLE);
		USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
		#else
		dma1_ch5_peri2mem_start((unsigned char *)(&USART1->DR), pingpongbuf[0], PINGPONG_BUFSIZE);
		USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
		#endif
		
	}
	else
	{
		PingPongBuf_Free_No = PINGPONG_BUF_NO0;
		//usart1_dma_write(pingpongbuf[0], PINGPONG_BUFSIZE, usart1_dma_tx_done_callback);
		#if 1
		DMA1_Channel5->CMAR = (unsigned int)pingpongbuf[1]; // DMA_MemoryBaseAddr;
		DMA1_Channel5->CNDTR = PINGPONG_BUFSIZE; // DMA_BufferSize;
		DMA_Cmd(DMA1_Channel5, ENABLE);
		USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
		#else
		dma1_ch5_peri2mem_start((unsigned char *)(&USART1->DR), pingpongbuf[1], PINGPONG_BUFSIZE);
		USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
		#endif		
	}
	PINGPONG_BUF_OK = TRUE;
#endif
}
开发者ID:wga1985,项目名称:stm32f103xx-prj-git,代码行数:55,代码来源:pingpongbuf.c


示例5: uart_Init

static int uart_Init(const uart_cfg_t *cfg)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	USART_InitTypeDef uartinfo;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
#ifdef CONFIG_STM32F10X_CL
	/*configure PD5<uart2.tx>, PD6<uart2.rx>*/
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE);
	GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
#else
	/*configure PA2<uart2.tx>, PA3<uart2.rx>*/
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
#endif

	/*init serial port*/
	USART_StructInit(&uartinfo);
	uartinfo.USART_BaudRate = cfg->baud;
	USART_Init(uart, &uartinfo);

#ifdef ENABLE_TX_DMA
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	uart_SetupTxDMA(uart_fifo_tx, 0);
	USART_DMACmd(uart, USART_DMAReq_Tx, ENABLE);
	uart_fifo_tn = 0;
	uart_fifo_tp = 0;
#endif

#ifdef ENABLE_RX_DMA
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	uart_SetupRxDMA(uart_fifo_rx, RX_FIFO_SZ);
	USART_DMACmd(uart, USART_DMAReq_Rx, ENABLE);
	uart_fifo_rn = 0;
#endif

	USART_Cmd(uart, ENABLE);
	return 0;
}
开发者ID:miaofng,项目名称:ulp,代码行数:54,代码来源:uart2_stm32.c


示例6: USART_DMA_Config

void  USART_DMA_Config(void)
{
  
  /* USART configuration -----------------------------------------------------*/
  USART_Config(); 
    
    
   /******************************************************************
    DMA TX   
    
    *******************************************************************/
    /* Prepare the DMA to transfer the transaction command (2bytes) from the
         memory to the USART  */ 
    DMA_DeInit(USARTx_TX_DMA_STREAM);
    DMA_InitStructure.DMA_Channel = USARTx_TX_DMA_CHANNEL;
    DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;  
    DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)TxBuffer_dma;
    DMA_InitStructure.DMA_BufferSize = (uint16_t)24;
    DMA_Init(USARTx_TX_DMA_STREAM, &DMA_InitStructure); 
    
    DMA_ITConfig(USARTx_TX_DMA_STREAM, DMA_IT_TC , ENABLE);
    
    /* Enable the USART DMA requests */   
    USART_DMACmd(USARTx, USART_DMAReq_Tx, ENABLE);
      
    /* Clear the TC bit in the SR register by writing 0 to it */
    USART_ClearFlag(USARTx, USART_FLAG_TC);         
    
   
	
/******************************************************************
    DMA RX
    
*******************************************************************/       
#if 1
    DMA_DeInit(USARTx_RX_DMA_STREAM);
    DMA_InitStructure.DMA_Channel = USARTx_RX_DMA_CHANNEL;
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
	DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;  
    DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)RxBuffer_dma;
    DMA_InitStructure.DMA_BufferSize = (uint16_t)24;
    DMA_Init(USARTx_RX_DMA_STREAM, &DMA_InitStructure);
    
    /******        DMA ÖжÏÅäÖà        ************************/
    DMA_ITConfig(USARTx_RX_DMA_STREAM, DMA_IT_TC , ENABLE);
    /* Enable the USART Rx DMA request  */
    USART_DMACmd(USARTx, USART_DMAReq_Rx, ENABLE);  
    /* Enable the DMA RX Stream*/ 
    DMA_Cmd(USARTx_RX_DMA_STREAM, ENABLE);   
    

#endif
  
}
开发者ID:wangxubo1988,项目名称:Center_System,代码行数:54,代码来源:usart_dma.c


示例7: USART_DMACmd

void CmdUnit_t::IStartTx(void) {
    IDmaIsIdle = false;
    // Start DMA
    USART_DMACmd(USART1, USART_DMAReq_Tx, DISABLE);
    DMA_Cmd(UART_DMA_CHNL, DISABLE);
    UART_DMA_CHNL->CMAR = (uint32_t) PBuf;  // Set memory base address
    UART_DMA_CHNL->CNDTR = TxIndx;          // Set count to transmit
    DMA_Cmd(UART_DMA_CHNL, ENABLE);
    USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);
    // Switch to next buf
    PBuf = (PBuf == TXBuf1)? TXBuf2 : TXBuf1;
    TxIndx = 0;
}
开发者ID:Kreyl,项目名称:nute,代码行数:13,代码来源:kl_lib_f0.cpp


示例8: platform_uart_transmit_bytes

OSStatus platform_uart_transmit_bytes( platform_uart_driver_t* driver, const uint8_t* data_out, uint32_t size )
{
    OSStatus err = kNoErr;

    platform_mcu_powersave_disable();

#ifndef NO_MICO_RTOS
    mico_rtos_lock_mutex( &driver->tx_mutex );
#endif

    require_action_quiet( ( driver != NULL ) && ( data_out != NULL ) && ( size != 0 ), exit, err = kParamErr);

    /* Clear interrupt status before enabling DMA otherwise error occurs immediately */
    clear_dma_interrupts( driver->peripheral->tx_dma_config.stream, driver->peripheral->tx_dma_config.complete_flags | driver->peripheral->tx_dma_config.error_flags );

    /* Init DMA parameters and variables */
    driver->last_transmit_result                    = kGeneralErr;
    driver->tx_size                                 = size;
    driver->peripheral->tx_dma_config.stream->CR   &= ~(uint32_t) DMA_SxCR_CIRC;
    driver->peripheral->tx_dma_config.stream->NDTR  = size;
    driver->peripheral->tx_dma_config.stream->M0AR  = (uint32_t)data_out;

    USART_DMACmd( driver->peripheral->port, USART_DMAReq_Tx, ENABLE );
    USART_ClearFlag( driver->peripheral->port, USART_FLAG_TC );
    driver->peripheral->tx_dma_config.stream->CR   |= DMA_SxCR_EN;

    /* Wait for transmission complete */
#ifndef NO_MICO_RTOS
    mico_rtos_get_semaphore( &driver->tx_complete, MICO_NEVER_TIMEOUT );
#else
    while( driver->tx_complete == false );
    driver->tx_complete = false;
#endif

    while ( ( driver->peripheral->port->SR & USART_SR_TC ) == 0 )
    {
    }

    /* Disable DMA and clean up */
    USART_DMACmd( driver->peripheral->port, USART_DMAReq_Tx, DISABLE );
    driver->tx_size = 0;
    err = driver->last_transmit_result;

exit:
#ifndef NO_MICO_RTOS
    mico_rtos_unlock_mutex( &driver->tx_mutex );
#endif
    platform_mcu_powersave_enable();
    return err;
}
开发者ID:ilittlerui,项目名称:MICO,代码行数:50,代码来源:platform_uart.c


示例9: DMA_Configuration

//DMA配置:
void DMA_Configuration(void)
{
  DMA_InitTypeDef DMA_InitStructure;
  /* DMA clock enable */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);//DMA1
  /* DMA1 Channel7 (triggered by USART2 Tx event) Config */
  DMA_DeInit(DMA1_Channel7);
  DMA_InitStructure.DMA_PeripheralBaseAddr = 0x40004404;
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART2_SEND_DATA;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
  DMA_InitStructure.DMA_BufferSize = 512;
  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_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel7, &DMA_InitStructure);
  DMA_ITConfig(DMA1_Channel7, DMA_IT_TC, ENABLE);
  DMA_ITConfig(DMA1_Channel7, DMA_IT_TE, ENABLE);
  /* Enable USART2 DMA TX request */
  USART_DMACmd(USART2, USART_DMAReq_Tx, ENABLE);
  DMA_Cmd(DMA1_Channel7, DISABLE);



/* DMA1 Channel6 (triggered by USART1 Rx event) Config */
  DMA_DeInit(DMA1_Channel6);
  DMA_InitStructure.DMA_PeripheralBaseAddr = 0x40004404;
  DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART2_RECEIVE_DATA;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = 512;
  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_Medium;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel6, &DMA_InitStructure);
  DMA_ITConfig(DMA1_Channel6, DMA_IT_TC, ENABLE);
  DMA_ITConfig(DMA1_Channel6, DMA_IT_TE, ENABLE);
  /* Enable USART2 DMA RX request */
  USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);
  DMA_Cmd(DMA1_Channel6, ENABLE);

}
开发者ID:huang87975716,项目名称:temp,代码行数:49,代码来源:bsp.c


示例10: UART_DMA_Rx_Enable

void UART_DMA_Rx_Enable(void)
{
    USART_DMACmd(USART1, USART_DMAReq_Rx, ENABLE);
	DMA_Cmd(DMA1_Channel5, DISABLE );
	DMA_SetCurrDataCounter(DMA1_Channel5,UART_RX_BUFFER_SIZE);
	DMA_Cmd(DMA1_Channel5, ENABLE); 
}
开发者ID:chenzhengxin,项目名称:SmartScale,代码行数:7,代码来源:usart.c


示例11: RCC_AHBPeriphClockCmd

void Usart::enableDmaRead()
{
    DMA_InitTypeDef DMA_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

    DMA_DeInit(theConfig.DMA_Channel);

    DMA_InitStructure.DMA_PeripheralBaseAddr =  (uint32_t) & (USARTx->DR);
    DMA_InitStructure.DMA_MemoryBaseAddr =(u32)USART_defaultBuf;
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    DMA_InitStructure.DMA_BufferSize = DMA_BUFSIZE;
    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_Medium;
    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
    DMA_Init(theConfig.DMA_Channel, &DMA_InitStructure);

    DMA_ITConfig(theConfig.DMA_Channel,DMA_IT_TC,ENABLE );
    USART_DMACmd(USARTx,USART_DMAReq_Rx,ENABLE);

    NVIC_InitStructure.NVIC_IRQChannel = theConfig.DMA_IRQChannel;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    DMA_Cmd(theConfig.DMA_Channel,ENABLE);

}
开发者ID:2cats,项目名称:STM32,代码行数:35,代码来源:usart.cpp


示例12: ZPH01_USART_Configuration

//串口配置
void ZPH01_USART_Configuration(void)
{
    USART_InitTypeDef  USART_InitStructure;

	USART_InitStructure.USART_BaudRate=9600;				//波特率设置
	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_Init(USART1,&USART_InitStructure);					//初始化配置
	USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);				//使能串口中断
	USART_Cmd(USART1,ENABLE);									//使能串口
	USART_ClearFlag(USART1,USART_FLAG_TC);						//清除发送完成标志
	
	USART_InitStructure.USART_BaudRate=9600;				//波特率设置
	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_Init(USART2,&USART_InitStructure);					//初始化配置
	USART_ITConfig(USART2,USART_IT_RXNE,ENABLE);				//使能串口接收中断
	//USART_ITConfig(USART2, USART_IT_IDLE,DISABLE);				//先失能串口空闲中断
	USART_Cmd(USART2,ENABLE);									//使能串口
	USART_ClearFlag(USART2,USART_FLAG_TC);						//清除发送完成标志
	
	/* Enable or Disable USART DMA RX request */
	USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);

}
开发者ID:xz1996,项目名称:Stm32_uCOSIII,代码行数:34,代码来源:ZPH01.C


示例13: DMA_usart3_Configuration

void DMA_usart3_Configuration(void)
{
  DMA_InitTypeDef DMA_TX_InitStructure;

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE);

  DMA_DeInit(DMA1_Stream3);
  DMA_TX_InitStructure.DMA_Channel = DMA_Channel_4;
  DMA_TX_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; // Transmit
  DMA_TX_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&(USART3->DR));
  DMA_TX_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_TX_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_TX_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_TX_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_TX_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_TX_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_TX_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
  DMA_TX_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
  DMA_TX_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_TX_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;

  DMA_Init(DMA1_Stream3, &DMA_TX_InitStructure);
  USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE);
  DMA_ITConfig(DMA1_Stream3, DMA_IT_TC, ENABLE);
  DMA_Cmd(DMA1_Stream3, ENABLE);
}
开发者ID:jongwonk,项目名称:fun_thing1,代码行数:26,代码来源:nfcTask.c


示例14: send_data_to_WBTDS01

/**
* @brief  发数据给蓝牙模块
* @param[in] unsigned char *pData 要发送的数据
* @param[in] int length 要发送数据的长度
*/
static void send_data_to_WBTDS01(const unsigned char *pData, unsigned short length)
{
	//while(length--)
	//{
	//	USART_SendData(USART2, *pData++);
	//	while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET)
	//	{
	//	}
	//}
	//while(USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET){};

	/* disable DMA */
	DMA_Cmd(DMA1_Channel7, DISABLE);

	/* set buffer address */
	memcpy(wbtd_send_buff,pData,length);

	DMA1_Channel7->CMAR = (u32)&wbtd_send_buff[0];
	/* set size */
	DMA1_Channel7->CNDTR = length;

	USART_DMACmd(USART2, USART_DMAReq_Tx , ENABLE);
	/* enable DMA */
	DMA_Cmd(DMA1_Channel7, ENABLE);

	while(DMA1_Channel7->CNDTR);
	while(USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET){};
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:33,代码来源:WBTDS01.c


示例15: USART1_Config

 /**
  * @brief  USART1 GPIO 配置,工作模式配置。115200 8-N-1
  * @param  无
  * @retval 无
  */
void USART1_Config(uint32_t BaudRate)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	USART_InitTypeDef USART_InitStructure;
	
	/* config USART1 clock */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
	
	/* USART1 GPIO config */
	/* Configure USART1 Tx (PA.09) as alternate function push-pull */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_Init(GPIOA, &GPIO_InitStructure);    
	
	/* Configure USART1 Rx (PA.10) as input floating */
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	/* USART1 mode config */
	USART_InitStructure.USART_BaudRate = BaudRate;
	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_Init(USART1, &USART_InitStructure);
    /* 使能串口2接收中断 */
	USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);	
    USART_ClearFlag(USART1,USART_FLAG_TC);//先清除一下发送中断标志位,会解决第一个字节丢失的问题。
    USART_Cmd(USART1, ENABLE);
    USART1_NVIC_Configuration(ENABLE);
    USART_DMACmd(USART1,USART_DMAReq_Tx,ENABLE);
}
开发者ID:longline,项目名称:STM32-W5500_TCP_Client,代码行数:40,代码来源:bsp_usart1.c


示例16: DMA_Configuration

void DMA_Configuration(void)
{
 
 
  DMA_InitStructure.DMA_Channel = DMA_Channel_4;
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; // Transmit
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)Buffer;
  DMA_InitStructure.DMA_BufferSize = (uint16_t)sizeof(Buffer);
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&UART4->DR;
  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_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
 
  DMA_Init(DMA1_Stream4, &DMA_InitStructure);
 
  /* Enable the USART Tx DMA request */
  USART_DMACmd(UART4, USART_DMAReq_Tx, ENABLE);
 
  /* Enable DMA Stream Transfer Complete interrupt */
  //DMA_ITConfig(DMA1_Stream4, DMA_IT_TC, ENABLE);
 
  /* Enable the DMA Tx Stream */
  DMA_Cmd(DMA1_Stream4, ENABLE);
}
开发者ID:bmaxfie,项目名称:Cerulean-Hardware,代码行数:31,代码来源:main.cpp


示例17: stopRXDMA

void stopRXDMA(){
  DMA_Cmd(USARTx_RX_DMA_STREAM, DISABLE);
  /* Clear USART Transfer Complete Flags */
  USART_ClearFlag(USARTx,USART_FLAG_TC);
  /* Enable USART DMA RX Requsts */
  USART_DMACmd(USARTx, USART_DMAReq_Rx, DISABLE);
}
开发者ID:MbedTinkerer,项目名称:uart_dma,代码行数:7,代码来源:main.c


示例18: receive_bytes

static OSStatus receive_bytes( platform_uart_driver_t* driver, void* data, uint32_t size, uint32_t timeout )
{
  OSStatus err = kNoErr;

  if ( driver->rx_buffer != NULL )
  {
    driver->peripheral->rx_dma_config.stream->CR |= DMA_SxCR_CIRC;
    
    // Enabled individual byte interrupts so progress can be updated
    USART_ClearITPendingBit( driver->peripheral->port, USART_IT_RXNE );
    USART_ITConfig( driver->peripheral->port, USART_IT_RXNE, ENABLE );
  }
  else
  {
    driver->rx_size = size;
    driver->peripheral->rx_dma_config.stream->CR &= ~(uint32_t) DMA_SxCR_CIRC;
  }
  
  clear_dma_interrupts( driver->peripheral->rx_dma_config.stream, driver->peripheral->rx_dma_config.complete_flags | driver->peripheral->rx_dma_config.error_flags );

  driver->peripheral->rx_dma_config.stream->NDTR  = size;
  driver->peripheral->rx_dma_config.stream->M0AR  = (uint32_t)data;
  driver->peripheral->rx_dma_config.stream->CR   |= DMA_SxCR_EN;
  USART_DMACmd( driver->peripheral->port, USART_DMAReq_Rx, ENABLE );
  
  if ( timeout > 0 )
  {
    err = mico_rtos_get_semaphore( &driver->rx_complete, timeout );
  }
  return err;
}
开发者ID:yangk,项目名称:Mico,代码行数:31,代码来源:platform_uart.c


示例19: hal_uart_dma_receive_block

void hal_uart_dma_receive_block(uint8_t *data, uint16_t size){
	/*
	 * USART1_RX is on DMA_CHANNEL5
	 */
	/* Reset DMA channel*/
	//DMA_Cmd(RX_DMA_CHANNEL,DISABLE);
	RST_CMD(0);
	DMA_DeInit(RX_DMA_CHANNEL);
	dma_init.DMA_Channel = USARTx_RX_DMA_CHANNEL;
	dma_init.DMA_PeripheralBaseAddr = (uint32_t)& BT_USART->DR;
	dma_init.DMA_Memory0BaseAddr = (uint32_t)data;
	dma_init.DMA_BufferSize = size;
	dma_init.DMA_DIR = DMA_DIR_PeripheralToMemory;
	dma_init.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
	dma_init.DMA_MemoryInc = DMA_MemoryInc_Enable;
	dma_init.DMA_PeripheralDataSize =
			DMA_PeripheralDataSize_Byte;
	dma_init.DMA_MemoryDataSize =
			DMA_MemoryDataSize_Byte;
	dma_init.DMA_Mode = DMA_Mode_Normal;
	dma_init.DMA_Priority = DMA_Priority_High;
	dma_init.DMA_FIFOMode = DMA_FIFOMode_Disable;
	dma_init.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
	dma_init.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
	dma_init.DMA_MemoryBurst = DMA_MemoryBurst_Single;
	//dma_init.DMA_M2M = DMA_M2M_Disable;
	DMA_Init(RX_DMA_CHANNEL, &dma_init);
	DMA_ITConfig(RX_DMA_CHANNEL,DMA_IT_TC,ENABLE);
	DMA_ClearITPendingBit(RX_DMA_CHANNEL,DMA_IT_TCIF1);
	USART_DMACmd(BT_USART,USART_DMAReq_Rx,ENABLE);
	DMA_Cmd(RX_DMA_CHANNEL,ENABLE);
	RST_CMD(1);
	//rt_kprintf("need %d\n",size);
}
开发者ID:XHelaoshi,项目名称:USER,代码行数:34,代码来源:hal_uart_dma.c


示例20: hal_uart_dma_send_block

void hal_uart_dma_send_block(const uint8_t *data, uint16_t size){

	// printf("hal_uart_dma_send_block size %u\n", size);
	/*
	 * USART1_TX Using DMA_CHANNEL4 
	 */
	//DMA_Cmd(TX_DMA_CHANNEL,DISABLE);
	/* Reset DMA channel*/
	DMA_DeInit(TX_DMA_CHANNEL);
	dma_init.DMA_Channel = USARTx_TX_DMA_CHANNEL;
	dma_init.DMA_PeripheralBaseAddr = (uint32_t)& BT_USART->DR;
	dma_init.DMA_Memory0BaseAddr = (uint32_t)data;
	dma_init.DMA_BufferSize = size;
	dma_init.DMA_DIR = DMA_DIR_MemoryToPeripheral;
	dma_init.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
	dma_init.DMA_MemoryInc = DMA_MemoryInc_Enable;
	dma_init.DMA_PeripheralDataSize =
			DMA_PeripheralDataSize_Byte;
	dma_init.DMA_MemoryDataSize =
			DMA_MemoryDataSize_Byte;
	dma_init.DMA_Mode = DMA_Mode_Normal;
	dma_init.DMA_Priority = DMA_Priority_VeryHigh;
	dma_init.DMA_FIFOMode = DMA_FIFOMode_Disable;
	//dma_init.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
	dma_init.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
	dma_init.DMA_MemoryBurst = DMA_MemoryBurst_Single;
//	dma_init.DMA_M2M = DMA_M2M_Disable;
	DMA_Init(TX_DMA_CHANNEL, &dma_init);
	DMA_ITConfig(TX_DMA_CHANNEL,DMA_IT_TC,ENABLE);
	DMA_ClearITPendingBit(TX_DMA_CHANNEL,DMA_IT_TCIF3);
	USART_DMACmd(BT_USART,USART_DMAReq_Tx,ENABLE);
	DMA_Cmd(TX_DMA_CHANNEL,ENABLE);
	//rt_kprintf("send %d\n",size);	
}
开发者ID:XHelaoshi,项目名称:USER,代码行数:34,代码来源:hal_uart_dma.c



注:本文中的USART_DMACmd函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ USLOSS_Console函数代码示例发布时间:2022-05-30
下一篇:
C++ TransactionIdIsCurrentTransactionId函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap