/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-26 RT-Thread first version
*/
#include <rtthread.h>
#include"rtdevice.h"
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
static rt_err_t uart1_input(rt_device_t dev,rt_size_t size)
{
LOG_D("触发中断");
char c;
int i;
for(i=0;i<size;i++)
{
rt_device_read(dev, 0, &c, 1);
LOG_D(":%d",size);
}
return RT_EOK;
}
int main(void)
{
rt_device_t uart=rt_device_find("uart1");
rt_device_open(uart, RT_DEVICE_FLAG_INT_RX);
rt_device_set_rx_indicate(uart, uart1_input);
return RT_EOK;
}
不是很明白,rx_indicate在中断里面调用的是什么意思,不应该是数据传进来然后触发中断接着调用中断函数吗
我把LOG_D改了rt_device_write也是一样的结果,触发两次中断,每次读取第一个字节