在UART 16550和Linux内核中断 [英] Interrupts in UART 16550 and Linux Kernel
问题描述
我正在尝试使用中断来查看UART 16550D中是否有错误以及何时可以读取字符.
I'm trying to use interrupts to see if there are errors in an UART 16550D and when a character is available to be read.
在UART配置如下:
#define UART 0x03f8 // Endereço da Porta Serial - I (com1)
#define UART_IER 1
#define UART_LCR 3
#define UART_LSR 5
#define UART_DLL 0 /* Out: Divisor Latch Low */
#define UART_DLM 1 /* Out: Divisor Latch High */
#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
#define UART_LSR_DR 0x01 /* Receiver data ready */
#define UART_RX 0 /* In: Receive buffer */
#define UART_TX 0 /* Out: Transmit buffer */
void UART_init(void){
outb( 0x80 , UART + UART_LCR );
outb( 0x00 , UART + UART_DLM );
outb( 0x60 , UART + UART_DLL );
outb( 0x1f , UART + UART_LCR );
outb( 0x07 , UART + UART_IER );
return;
}
和所述中断
irqreturn_t short_interrupt(int irq, void *dev_id){
printk("INTERRUPT HAPPENED. WILL NOW RETURN\n");
return 0;
}
static int seri_init(void){
int result, i;
UART_init();
request_irq(4, short_interrupt, SA_SHIRQ, "seri", NULL);
....
所以现在我只想看看是否调用了处理程序. 4被定义为在我使用该虚框设置IRQ.
So for now I just want to see if the handler is called or not. 4 is defined as the IRQ in the virtual box settings I'm using.
我想知道的是,是有什么错此设置?测试时,我没有问题,阅读和处理我在读什么.的是,该处理程序没有被调用.
What I want to know is, is there something wrong about this setup? When testing, I have no problem reading and processing what I'm reading. Thing is, the handler is never called.
这的request_irq()的返回是-22.不存在任何问题编译期间.
The return from request_irq() is -22. There are no problems during compilation.
推荐答案
我知道这是一个古老的职位,但想到我会扔了一个答案.使用的 gpio_to_irq 的获得中断号.第三个参数确定何时中断发生.
I know this is an old post, but thought I would throw up an answer. use gpio_to_irq to get interrupt number. The third parameter determines when the interrupt occurs.
irqNumber = gpio_to_irq(gpioUART);
// This next call requests an interrupt line
result = request_irq(irqNumber, // The interrupt number requested
(irq_handler_t) short_interrupt, // The pointer to handler function below
IRQF_TRIGGER_FALLING, // Interrupt on FALL edge ()
"seri", // For /proc/interrupts identity
NULL); // The *dev_id for shared interrupt
这篇关于在UART 16550和Linux内核中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!