Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread一般讨论
STM32 UART不能同时收发
发布于 2016-12-29 11:01:26 浏览:5137
订阅该版
STM32 UART不能同时收发 使用的是STM32F103,需要串口使用DMA发送和中断接收,发现只要打开接收设备就不能进DMA发送完成中断 应用层代码如下 ``` #include "WTL.h" //WTL模块收发接口 #include
#include "PackageManage.h" rt_mailbox_t WTLPackList_Tx=RT_NULL; rt_mailbox_t WTLPackList_Rx=RT_NULL; //发送部分 //事件 #define WTL_Tx_event_txdone 1 #define WTL_Tx_event_delayfinished 2 //事件位1://发送完成 //事件位2://延时完成 rt_event_t WTL_Tx_event=RT_NULL; static rt_err_t TxDoneWakeup(rt_device_t dev, void *buffer) { //rt_kprintf("TxDoneWakeup ! "); //产生发送完成事件 if(WTL_Tx_event!=RT_NULL) rt_event_send(WTL_Tx_event, (1 << WTL_Tx_event_txdone)); return RT_EOK; } static rt_err_t TxDelayWakeup(rt_device_t dev, rt_size_t size) { //rt_kprintf("TxDelayWakeup ! "); //产生延时完成事件 if(WTL_Tx_event!=RT_NULL) rt_event_send(WTL_Tx_event, (1 << WTL_Tx_event_delayfinished)); return RT_EOK; } //模块发送管理线程 //从WTLPackList_Tx中取数据 //使用DMA发送 //挂起线程直到发送结束 //创建单次定时器,油定时器回调函数唤醒线程 void WTLSend_thread(void) { rt_err_t result; rt_device_t device_uart; rt_device_t device_hwtimer; struct WTLPack *task=RT_NULL; int freq = 1000;//1KHz 1ms rt_hwtimer_mode_t mode=HWTIMER_MODE_ONESHOT; rt_hwtimerval_t val={0,WTL_TX_Delay_ms*1000}; //初始化发送队列 WTLPackList_Tx=rt_mb_create ("mb_wtl_tx", WTL_TX_FIFO_SIZE, RT_IPC_FLAG_FIFO); if(WTLPackList_Tx==RT_NULL) { //报错 } //创建事件 WTL_Tx_event=rt_event_create ("eve_wtl_tx",RT_IPC_FLAG_FIFO); if(WTL_Tx_event==RT_NULL) { //报错 } //打开硬件定时器 device_hwtimer=rt_device_find(WTL_TX_TIMER); if (device_hwtimer != RT_NULL) { rt_device_set_rx_indicate(device_hwtimer, TxDelayWakeup); rt_device_open(device_hwtimer, RT_DEVICE_FLAG_RDWR); result = rt_device_control(device_hwtimer, HWTIMER_CTRL_FREQ_SET, &freq); result = rt_device_control(device_hwtimer, HWTIMER_CTRL_MODE_SET, &mode); } //打开串口 device_uart = rt_device_find(WTL_TX_UART);//发送 if (device_uart != RT_NULL) { rt_device_set_tx_complete(device_uart, TxDoneWakeup); rt_device_open(device_uart, RT_DEVICE_FLAG_DMA_TX); } while(1) { //取数据 result=rt_mb_recv( WTLPackList_Tx, (rt_uint32_t *)&task, RT_WAITING_FOREVER); if (result == RT_EOK) { //rt_kprintf("WTLSend_thread ok ! "); //DMA发送 rt_device_write(device_uart,0,task->data,task->size); //等待DMA发送完成 rt_event_recv(WTL_Tx_event, (1 << WTL_Tx_event_txdone), RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, RT_NULL); //释放内存空间 rt_free(task->data); rt_free(task); task=RT_NULL; //开启延时 rt_device_write(device_hwtimer, 0, &val, sizeof(val)); //等待延时完成 rt_event_recv(WTL_Tx_event, (1 << WTL_Tx_event_delayfinished), RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, RT_NULL); } } } //接收部分 //事件 #define WTL_Rx_event_received 1 #define WTL_Rx_event_timeout 2 //事件位1://收到数据 //事件位2://收到数据超时 rt_event_t WTL_Rx_event=RT_NULL; static rt_err_t ReceivedWakeup(rt_device_t dev, rt_size_t size) { if(WTL_Rx_event!=RT_NULL) rt_event_send(WTL_Rx_event, (1 << WTL_Rx_event_received)); return RT_EOK; } static rt_err_t ReceiveTimeoutWakeup(rt_device_t dev, rt_size_t size) { if(WTL_Rx_event!=RT_NULL) rt_event_send(WTL_Rx_event, (1 << WTL_Rx_event_timeout)); return RT_EOK; } void WTLReceive_thread(void) { rt_err_t result; rt_device_t device_uart; rt_device_t device_hwtimer; int freq = 1000;//1KHz 1ms rt_hwtimer_mode_t mode=HWTIMER_MODE_ONESHOT; rt_hwtimerval_t val={0,WTL_RX_Timeout_ms*1000}; uint8_t isReceiving=0; rt_uint32_t event; uint16_t pos=0; uint8_t *buffer=rt_malloc(WTL_RX_MAX_Length); if(buffer==RT_NULL) { //报错 } uint16_t read_size; struct WTLPack *pack=RT_NULL; //初始化接收队列 WTLPackList_Rx=rt_mb_create ("mb_wtl_rx", WTL_RX_FIFO_SIZE, RT_IPC_FLAG_FIFO); if(WTLPackList_Rx==RT_NULL) { //报错 } //创建事件 WTL_Rx_event=rt_event_create ("eve_wtl_rx",RT_IPC_FLAG_FIFO); if(WTL_Rx_event==RT_NULL) { //报错 } //打开硬件定时器 device_hwtimer=rt_device_find(WTL_RX_TIMER); if (device_hwtimer != RT_NULL) { rt_device_set_rx_indicate(device_hwtimer, ReceiveTimeoutWakeup); rt_device_open(device_hwtimer, RT_DEVICE_FLAG_RDWR); result = rt_device_control(device_hwtimer, HWTIMER_CTRL_FREQ_SET, &freq); result = rt_device_control(device_hwtimer, HWTIMER_CTRL_MODE_SET, &mode); } //打开串口 device_uart = rt_device_find(WTL_RX_UART);//接收 if (device_uart != RT_NULL) { rt_device_set_rx_indicate(device_uart, ReceivedWakeup); rt_device_open(device_uart, RT_DEVICE_FLAG_INT_RX); } while(1) { result=rt_event_recv(WTL_Rx_event, (1 << WTL_Rx_event_received)|(1<
=WTL_RX_MAX_Length) { //缓冲区满,强制接收完成 pack=rt_malloc(sizeof(struct WTLPack)); if(pack!=RT_NULL) { rt_err_t err; pack->size=pos; pack->data=rt_malloc(pack->size); memcpy(pack->data,buffer,pack->size); err=rt_mb_send (WTLPackList_Rx, (rt_uint32_t )pack); if(err!=RT_EOK) { //报错 } pack=RT_NULL; } pos=0; isReceiving=0; goto WTL_ReadData; } if(isReceiving==1) { //开启超时事件定时器 rt_device_write(device_hwtimer, 0, &val, sizeof(val)); } } else if(event==(1 << WTL_Rx_event_timeout)) { rt_device_control(device_hwtimer, HWTIMER_CTRL_STOP, RT_NULL); //超时结束 if(pos>0) { //超时接收完成 pack=rt_malloc(sizeof(struct WTLPack)); if(pack!=RT_NULL) { rt_err_t err; pack->size=pos; pack->data=rt_malloc(pack->size); memcpy(pack->data,buffer,pack->size); err=rt_mb_send (WTLPackList_Rx, (rt_uint32_t )pack); if(err!=RT_EOK) { //报错 } pack=RT_NULL; } pos=0; isReceiving=0; } } } } } ``` 在函数WTLReceive_thread中使用了 ``` rt_device_open(device_uart, RT_DEVICE_FLAG_INT_RX); ``` 一句后就会导致函数WTLSend_thread中 ``` rt_event_recv(WTL_Tx_event, (1 << WTL_Tx_event_txdone), RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, RT_NULL); ``` 一句无法走过,并且在DMA中断中创建的断点也无法触发,反之注释```rt_device_open(device_uart, RT_DEVICE_FLAG_INT_RX);```后发送就正常 **是这种打开方式有问题???** 驱动层代码如下 ``` #include "stm32f10x.h" #include "usart.h" #include "board.h" #include
/* USART1 */ #define UART1_GPIO_TX GPIO_Pin_9 #define UART1_GPIO_RX GPIO_Pin_10 #define UART1_GPIO GPIOA #define UART1_TX_DMA DMA1_Channel4 #define UART1_RX_DMA DMA1_Channel5 /* USART2 */ #define UART2_GPIO_TX GPIO_Pin_2 #define UART2_GPIO_RX GPIO_Pin_3 #define UART2_GPIO GPIOA #define UART2_TX_DMA DMA1_Channel7 #define UART2_RX_DMA DMA1_Channel6 /* USART3_REMAP[1:0] = 00 */ #define UART3_GPIO_TX GPIO_Pin_10 #define UART3_GPIO_RX GPIO_Pin_11 #define UART3_GPIO GPIOB #define UART3_TX_DMA DMA1_Channel2 #define UART3_RX_DMA DMA1_Channel3 /* STM32 uart driver */ struct stm32_uart { USART_TypeDef* uart_device; IRQn_Type irq; struct stm32_uart_dma { /* dma channel */ DMA_Channel_TypeDef *tx_ch; /* dma translate completed flag */ uint32_t tx_tc_flag; /* dma irq channel */ uint8_t tx_irq_ch; } dma; }; static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_configure *cfg) { struct stm32_uart* uart; USART_InitTypeDef USART_InitStructure; RT_ASSERT(serial != RT_NULL); RT_ASSERT(cfg != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; USART_InitStructure.USART_BaudRate = cfg->baud_rate; if (cfg->data_bits == DATA_BITS_8){ USART_InitStructure.USART_WordLength = USART_WordLength_8b; } else if (cfg->data_bits == DATA_BITS_9) { USART_InitStructure.USART_WordLength = USART_WordLength_9b; } if (cfg->stop_bits == STOP_BITS_1){ USART_InitStructure.USART_StopBits = USART_StopBits_1; } else if (cfg->stop_bits == STOP_BITS_2){ USART_InitStructure.USART_StopBits = USART_StopBits_2; } if (cfg->parity == PARITY_NONE){ USART_InitStructure.USART_Parity = USART_Parity_No; } else if (cfg->parity == PARITY_ODD) { USART_InitStructure.USART_Parity = USART_Parity_Odd; } else if (cfg->parity == PARITY_EVEN) { USART_InitStructure.USART_Parity = USART_Parity_Even; } USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(uart->uart_device, &USART_InitStructure); /* Enable USART */ USART_Cmd(uart->uart_device, ENABLE); return RT_EOK; } static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *arg) { struct stm32_uart* uart; RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; switch (cmd) { /* disable interrupt */ case RT_DEVICE_CTRL_CLR_INT: /* disable rx irq */ UART_DISABLE_IRQ(uart->irq); /* disable interrupt */ USART_ITConfig(uart->uart_device, USART_IT_RXNE, DISABLE); break; /* enable interrupt */ case RT_DEVICE_CTRL_SET_INT: /* enable rx irq */ UART_ENABLE_IRQ(uart->irq); /* enable interrupt */ USART_ITConfig(uart->uart_device, USART_IT_RXNE, ENABLE); break; } return RT_EOK; } static int stm32_putc(struct rt_serial_device *serial, char c) { struct stm32_uart* uart; RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; uart->uart_device->DR = c; while (!(uart->uart_device->SR & USART_FLAG_TC)); return 1; } static int stm32_getc(struct rt_serial_device *serial) { int ch; struct stm32_uart* uart; RT_ASSERT(serial != RT_NULL); uart = (struct stm32_uart *)serial->parent.user_data; ch = -1; if (uart->uart_device->SR & USART_FLAG_RXNE) { ch = uart->uart_device->DR & 0xff; } return ch; } static rt_size_t stm32_dma_transmit(struct rt_serial_device *serial, const rt_uint8_t *buf, rt_size_t size, int direction) { switch(direction) { case RT_SERIAL_DMA_TX: { struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data; uart->dma.tx_ch->CMAR = (u32)(buf); DMA_SetCurrDataCounter(uart->dma.tx_ch,size); DMA_Cmd(uart->dma.tx_ch,ENABLE); } break; default: break; } return 0; } static void uart_isr(struct rt_serial_device *serial) { struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data; RT_ASSERT(uart != RT_NULL); if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET) { rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); } if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET) { /* clear interrupt */ USART_ClearITPendingBit(uart->uart_device, USART_IT_TC); } if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET) { stm32_getc(serial); } } static void uart_dma_isr(struct rt_serial_device *serial) { //struct rt_serial_tx_dma *tx_dma= (struct rt_serial_tx_dma*)(serial->serial_tx); struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data; if(DMA_GetITStatus(uart->dma.tx_tc_flag)) { /* clear DMA flag */ DMA_ClearFlag(uart->dma.tx_tc_flag); DMA_Cmd(uart->dma.tx_ch,DISABLE); rt_hw_serial_isr(serial,RT_SERIAL_EVENT_TX_DMADONE); } } static const struct rt_uart_ops stm32_uart_ops = { stm32_configure, stm32_control, stm32_putc, stm32_getc, stm32_dma_transmit }; #if defined(RT_USING_UART1) /* UART1 device driver structure */ struct stm32_uart uart1 = { USART1, USART1_IRQn, { DMA1_Channel4, DMA1_FLAG_TC4, DMA1_Channel4_IRQn } }; struct rt_serial_device serial1; void USART1_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); uart_isr(&serial1); /* leave interrupt */ rt_interrupt_leave(); } void DMA1_Channel4_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); //dma_rx_done_isr(&serial1); uart_dma_isr(&serial1); /* leave interrupt */ rt_interrupt_leave(); } #endif /* RT_USING_UART1 */ #if defined(RT_USING_UART2) /* UART1 device driver structure */ struct stm32_uart uart2 = { USART2, USART2_IRQn, { DMA1_Channel7, DMA1_FLAG_TC7, DMA1_Channel7_IRQn } }; struct rt_serial_device serial2; void USART2_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); uart_isr(&serial2); /* leave interrupt */ rt_interrupt_leave(); } void DMA1_Channel7_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); //dma_rx_done_isr(&serial2); uart_dma_isr(&serial2); /* leave interrupt */ rt_interrupt_leave(); } #endif /* RT_USING_UART2 */ #if defined(RT_USING_UART3) /* UART3 device driver structure */ struct stm32_uart uart3 = { USART3, USART3_IRQn, { DMA1_Channel2, DMA1_FLAG_TC2, DMA1_Channel2_IRQn } }; struct rt_serial_device serial3; void USART3_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); uart_isr(&serial3); /* leave interrupt */ rt_interrupt_leave(); } void DMA1_Channel2_IRQHandler(void) { /* enter interrupt */ rt_interrupt_enter(); //dma_rx_done_isr(&serial3); uart_dma_isr(&serial3); /* leave interrupt */ rt_interrupt_leave(); } #endif /* RT_USING_UART3 */ static void RCC_Configuration(void) { #if defined(RT_USING_UART1) /* Enable UART GPIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* Enable UART clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); #endif /* RT_USING_UART1 */ #if defined(RT_USING_UART2) /* Enable UART GPIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* Enable UART clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); #endif /* RT_USING_UART2 */ #if defined(RT_USING_UART3) /* Enable UART GPIO clocks */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); /* Enable UART clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); #endif /* RT_USING_UART3 */ } static void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; #if defined(RT_USING_UART1) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART1_GPIO_RX; GPIO_Init(UART1_GPIO, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = UART1_GPIO_TX; GPIO_Init(UART1_GPIO, &GPIO_InitStructure); #endif /* RT_USING_UART1 */ #if defined(RT_USING_UART2) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_RX; GPIO_Init(UART2_GPIO, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = UART2_GPIO_TX; GPIO_Init(UART2_GPIO, &GPIO_InitStructure); #endif /* RT_USING_UART2 */ #if defined(RT_USING_UART3) /* Configure USART Rx/tx PIN */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = UART3_GPIO_RX; GPIO_Init(UART3_GPIO, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = UART3_GPIO_TX; GPIO_Init(UART3_GPIO, &GPIO_InitStructure); #endif /* RT_USING_UART3 */ } static void NVIC_Configuration(struct stm32_uart* uart) { NVIC_InitTypeDef NVIC_InitStructure; /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = uart->irq; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } static void DMA_Configuration(struct rt_serial_device *serial) { struct stm32_uart *uart = (struct stm32_uart *) serial->parent.user_data; struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx; DMA_InitTypeDef DMA_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* DMA clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); /* tx dma config */ DMA_DeInit(uart->dma.tx_ch); DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) &(uart->uart_device->DR); DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) 0; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_BufferSize = 1; 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_M2M = DMA_M2M_Disable; DMA_Init(uart->dma.tx_ch, &DMA_InitStructure); DMA_ITConfig(uart->dma.tx_ch, DMA_IT_TC, ENABLE); USART_DMACmd(uart->uart_device, USART_DMAReq_Tx, ENABLE); DMA_Cmd(uart->dma.tx_ch, DISABLE); /* tx dma interrupt config */ NVIC_InitStructure.NVIC_IRQChannel = uart->dma.tx_irq_ch; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void stm32_hw_usart_init(void) { struct stm32_uart* uart; struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; RCC_Configuration(); GPIO_Configuration(); #if defined(RT_USING_UART1) uart = &uart1; config.baud_rate = BAUD_RATE_115200; serial1.ops = &stm32_uart_ops; serial1.config = config; serial1.config.bufsz=256;//用较大缓冲区来接收 NVIC_Configuration(&uart1); /* register UART1 device */ rt_hw_serial_register(&serial1, "WTL", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX |RT_DEVICE_FLAG_DMA_TX, uart); DMA_Configuration(&serial1); #endif /* RT_USING_UART1 */ #if defined(RT_USING_UART2) uart = &uart2; config.baud_rate = BAUD_RATE_57600; serial2.ops = &stm32_uart_ops; serial2.config = config; NVIC_Configuration(&uart2); /* register UART2 device */ rt_hw_serial_register(&serial2, "DData", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX|RT_DEVICE_FLAG_DMA_TX, uart); DMA_Configuration(&serial2); #endif /* RT_USING_UART2 */ #if defined(RT_USING_UART3) uart = &uart3; serial3.ops = &stm32_uart_ops; struct serial_configure sbus_config=RT_SERIAL_CONFIG_DEFAULT; sbus_config.baud_rate=100000;//100K sbus_config.data_bits=DATA_BITS_8; sbus_config.stop_bits=STOP_BITS_2; sbus_config.parity=PARITY_EVEN;//偶校验 sbus_config.bit_order=BIT_ORDER_MSB;//高位在前 sbus_config.invert=NRZ_INVERTED;//电平反向 serial3.config = sbus_config; NVIC_Configuration(&uart3); /* register UART3 device */ rt_hw_serial_register(&serial3, "SBus", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX|RT_DEVICE_FLAG_DMA_TX, uart); DMA_Configuration(&serial3); #endif /* RT_USING_UART3 */ } ```
查看更多
4
个回答
默认排序
按发布时间排序
bernard
2016-12-29
这家伙很懒,什么也没写!
这样打开: rt_device_open(device_uart, RT_DEVICE_FLAG_INT_RX); 应该就不会触及到DMA吧
huzhiyuan
2016-12-29
这家伙很懒,什么也没写!
不是,我需要用dma发送,但开了RT_DEVICE_FLAG_INT_RX就不能进代码发送完成中断
bernard
2016-12-29
这家伙很懒,什么也没写!
为什么不是, rt_device_open(device_uart, RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_DMA_TX);
撰写答案
登录
注册新账号
关注者
0
被浏览
5.1k
关于作者
huzhiyuan
这家伙很懒,什么也没写!
提问
6
回答
7
被采纳
0
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
rt-thread使用cherryusb实现虚拟串口
2
《C++20 图形界面程序:速度与渲染效率的双重优化秘籍》
3
《原子操作:程序世界里的“最小魔法单位”解析》
4
《C++设计模式:重塑游戏角色系统类结构的秘籍》
5
rt-thread官方usb驱动之虚拟串口
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
ART-Pi
FinSH
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
ota在线升级
UART
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
msh
SFUD
rt_mq_消息队列_msg_queue
keil_MDK
at_device
ulog
C++_cpp
本月问答贡献
踩姑娘的小蘑菇
6
个答案
3
次被采纳
张世争
8
个答案
2
次被采纳
rv666
5
个答案
2
次被采纳
用户名由3_15位
11
个答案
1
次被采纳
KunYi
6
个答案
1
次被采纳
本月文章贡献
出出啊
1
篇文章
3
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
1
次点赞
crystal266
2
篇文章
2
次点赞
whj467467222
2
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部