mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-03-27 01:10:20 +08:00
Merge pull request #3478 from SummerLife/optimize_uart
[stm32/driver] optimize uart driver
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018.10.30 SummerGift first version
|
||||
* 2019.03.05 whj4674672 add stm32h7
|
||||
* 2019.03.05 whj4674672 add stm32h7
|
||||
*/
|
||||
|
||||
#ifndef __DRV_USART_H__
|
||||
@@ -50,7 +50,7 @@ struct stm32_uart
|
||||
{
|
||||
UART_HandleTypeDef handle;
|
||||
struct stm32_uart_config *config;
|
||||
|
||||
|
||||
#ifdef RT_SERIAL_USING_DMA
|
||||
struct
|
||||
{
|
||||
|
||||
@@ -733,6 +733,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
rt_free(rx_fifo);
|
||||
serial->serial_rx = RT_NULL;
|
||||
dev->open_flag &= ~RT_DEVICE_FLAG_INT_RX;
|
||||
|
||||
/* configure low level device */
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_RX);
|
||||
}
|
||||
@@ -754,10 +755,11 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
|
||||
rt_free(rx_fifo);
|
||||
}
|
||||
/* configure low level device */
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_RX);
|
||||
serial->serial_rx = RT_NULL;
|
||||
dev->open_flag &= ~RT_DEVICE_FLAG_DMA_RX;
|
||||
|
||||
/* configure low level device */
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_RX);
|
||||
}
|
||||
#endif /* RT_SERIAL_USING_DMA */
|
||||
|
||||
@@ -771,6 +773,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
rt_free(tx_fifo);
|
||||
serial->serial_tx = RT_NULL;
|
||||
dev->open_flag &= ~RT_DEVICE_FLAG_INT_TX;
|
||||
|
||||
/* configure low level device */
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void*)RT_DEVICE_FLAG_INT_TX);
|
||||
}
|
||||
@@ -785,7 +788,14 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
rt_free(tx_dma);
|
||||
serial->serial_tx = RT_NULL;
|
||||
dev->open_flag &= ~RT_DEVICE_FLAG_DMA_TX;
|
||||
|
||||
/* configure low level device */
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_TX);
|
||||
}
|
||||
|
||||
serial->ops->control(serial, RT_DEVICE_CTRL_CLOSE, RT_NULL);
|
||||
dev->flag &= ~RT_DEVICE_FLAG_ACTIVATED;
|
||||
|
||||
#endif /* RT_SERIAL_USING_DMA */
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
@@ -898,6 +898,7 @@ enum rt_device_class_type
|
||||
#define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
|
||||
#define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
|
||||
#define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
|
||||
#define RT_DEVICE_CTRL_CLOSE 0x04 /**< close device */
|
||||
|
||||
#define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */
|
||||
#define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */
|
||||
|
||||
Reference in New Issue
Block a user