|
请问有同学用过吗?下面这段代码有点儿不明白,
void rt_hw_serial_dma_tx_isr(rt_device_t device)
{
#ifdef RT_USING_HEAP
rt_uint32_t level;
struct stm32_serial_data_node* data_node;
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private;
/* DMA mode receive */
RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_TX);
/* get the first data node */
data_node = uart->dma_tx->list_head;
RT_ASSERT(data_node != RT_NULL);
/* invoke call to notify tx complete */
if (device->tx_complete != RT_NULL)
device->tx_complete(device, data_node->data_ptr);
/* disable interrupt */
level = rt_hw_interrupt_disable();
/* remove list tail */
uart->dma_tx->list_tail = data_node->prev;
if (uart->dma_tx->list_tail == RT_NULL)
uart->dma_tx->list_head = RT_NULL;
/* enable interrupt */
rt_hw_interrupt_enable(level);
/* free data node memory(!!) */
rt_free(data_node);
if (uart->dma_tx->list_tail != RT_NULL)
{
/* transmit next data node */
rt_serial_enable_dma(uart->dma_tx->dma_channel,
(rt_uint32_t)uart->dma_tx->list_tail->data_ptr,
uart->dma_tx->list_tail->data_size);
}
else
{
/* no data to be transmitted, disable DMA */
DMA_Cmd(uart->dma_tx->dma_channel, DISABLE);
}
#endif
}
当前节点data_node = uart->dma_tx->list_head(头节点)的数据发送完成,不是应该移除头节点吗?为什么是
/*remove list tail*/
uart->dma_tx->list_tail = data_node->prev呢?
另外,感觉这段代码中所有的list_tail似乎应该是list_head才对呀。
请高手赐教,谢谢。 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|