当前位置: 技术问答>linux和unix
atmel_interrupt中断函数
来源: 互联网 发布时间:2016-04-25
本文导语: EBD9260的板子我们想要在中断函数中做些修改,先遇到了问题,想请教. /* * Interrupt handler */ static irqreturn_t atmel_interrupt(int irq, void *dev_id) { struct uart_port *port = dev_id; struct atmel_uart_port...
EBD9260的板子我们想要在中断函数中做些修改,先遇到了问题,想请教.
/*
* Interrupt handler
*/
static irqreturn_t atmel_interrupt(int irq, void *dev_id)
{
struct uart_port *port = dev_id;
struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
unsigned int status, pending, imr,pass_counter = 0;
status = UART_GET_CSR(port);
imr = UART_GET_IMR(port);
pending = status & imr;
//pending = status & UART_GET_IMR(port);
while (pending) {
printk(KERN_INFO "atmel_interrupt:534,irq=[%d],imr=[0x%08x],csr=[0x%08x]n",irq,imr,status);
/* PDC receive */
if (pending & ATMEL_US_ENDRX)
at91_pdc_endrx(port);
if (pending & ATMEL_US_TIMEOUT)
at91_pdc_timeout(port);
if (atmel_port->use_dma_rx && pending & (ATMEL_US_RXBRK | ATMEL_US_OVRE | ATMEL_US_FRAME | ATMEL_US_PARE))
at91_pdc_rxerr(port, pending);
/* Interrupt receive */
if (pending & ATMEL_US_RXRDY)
atmel_rx_chars(port);
// TODO: All reads to CSR will clear these interrupts!
if (pending & ATMEL_US_RIIC) port->icount.rng++;
if (pending & ATMEL_US_DSRIC) port->icount.dsr++;
if (pending & ATMEL_US_DCDIC)
uart_handle_dcd_change(port, !(status & ATMEL_US_DCD));
if (pending & ATMEL_US_CTSIC)
uart_handle_cts_change(port, !(status & ATMEL_US_CTS));
if (pending & (ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC | ATMEL_US_CTSIC))
wake_up_interruptible(&port->info->delta_msr_wait);
/* PDC transmit */
if (pending & ATMEL_US_ENDTX)
at91_pdc_endtx(port);
if (pending & ATMEL_US_TXBUFE)
at91_pdc_txbufe(port);
/* Interrupt transmit */
if (pending & ATMEL_US_TXRDY)
atmel_tx_chars(port);
if (pass_counter++ > ATMEL_ISR_PASS_LIMIT)
break;
status = UART_GET_CSR(port);
pending = status & UART_GET_IMR(port);
}
return IRQ_HANDLED;
}
测试:板子上运行./uart_test,从DNW发送一个字符,
printk(KERN_INFO "atmel_interrupt:534,irq=[%d],imr=[0x%08x],csr=[0x%08x]n",irq,imr,status);
上面的打印信息出现了3次.如下:
atmel_interrupt:534,irq=[8],imr=[0x000001e8],csr=[0x00800b12]
atmel_interrupt:534,irq=[8],imr=[0x000009f8],csr=[0x00800a12]
atmel_interrupt:534,irq=[8],imr=[0x000009f8],csr=[0x00800810]
1.我理解应该2次就可以,实在不知道多的一次是从哪里来的?
2.还有中断屏蔽寄存器是只读的,上面的信息是2次值是一样的,不知道中断屏蔽寄存器的值是怎么变化的?
Tks!
/*
* Interrupt handler
*/
static irqreturn_t atmel_interrupt(int irq, void *dev_id)
{
struct uart_port *port = dev_id;
struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
unsigned int status, pending, imr,pass_counter = 0;
status = UART_GET_CSR(port);
imr = UART_GET_IMR(port);
pending = status & imr;
//pending = status & UART_GET_IMR(port);
while (pending) {
printk(KERN_INFO "atmel_interrupt:534,irq=[%d],imr=[0x%08x],csr=[0x%08x]n",irq,imr,status);
/* PDC receive */
if (pending & ATMEL_US_ENDRX)
at91_pdc_endrx(port);
if (pending & ATMEL_US_TIMEOUT)
at91_pdc_timeout(port);
if (atmel_port->use_dma_rx && pending & (ATMEL_US_RXBRK | ATMEL_US_OVRE | ATMEL_US_FRAME | ATMEL_US_PARE))
at91_pdc_rxerr(port, pending);
/* Interrupt receive */
if (pending & ATMEL_US_RXRDY)
atmel_rx_chars(port);
// TODO: All reads to CSR will clear these interrupts!
if (pending & ATMEL_US_RIIC) port->icount.rng++;
if (pending & ATMEL_US_DSRIC) port->icount.dsr++;
if (pending & ATMEL_US_DCDIC)
uart_handle_dcd_change(port, !(status & ATMEL_US_DCD));
if (pending & ATMEL_US_CTSIC)
uart_handle_cts_change(port, !(status & ATMEL_US_CTS));
if (pending & (ATMEL_US_RIIC | ATMEL_US_DSRIC | ATMEL_US_DCDIC | ATMEL_US_CTSIC))
wake_up_interruptible(&port->info->delta_msr_wait);
/* PDC transmit */
if (pending & ATMEL_US_ENDTX)
at91_pdc_endtx(port);
if (pending & ATMEL_US_TXBUFE)
at91_pdc_txbufe(port);
/* Interrupt transmit */
if (pending & ATMEL_US_TXRDY)
atmel_tx_chars(port);
if (pass_counter++ > ATMEL_ISR_PASS_LIMIT)
break;
status = UART_GET_CSR(port);
pending = status & UART_GET_IMR(port);
}
return IRQ_HANDLED;
}
测试:板子上运行./uart_test,从DNW发送一个字符,
printk(KERN_INFO "atmel_interrupt:534,irq=[%d],imr=[0x%08x],csr=[0x%08x]n",irq,imr,status);
上面的打印信息出现了3次.如下:
atmel_interrupt:534,irq=[8],imr=[0x000001e8],csr=[0x00800b12]
atmel_interrupt:534,irq=[8],imr=[0x000009f8],csr=[0x00800a12]
atmel_interrupt:534,irq=[8],imr=[0x000009f8],csr=[0x00800810]
1.我理解应该2次就可以,实在不知道多的一次是从哪里来的?
2.还有中断屏蔽寄存器是只读的,上面的信息是2次值是一样的,不知道中断屏蔽寄存器的值是怎么变化的?
Tks!
|
1) 查查 中断状态寄存器 对应的位是什么意思,即代表发生什么中断了。
有可能有transmit中断的
2)IMR肯定不是只读的,不然的话怎么设它?(不能设了还有什么用呢)
我觉得如果不在其他地方修改的话,这个IMR寄存器的值不会变的。
有可能有transmit中断的
2)IMR肯定不是只读的,不然的话怎么设它?(不能设了还有什么用呢)
我觉得如果不在其他地方修改的话,这个IMR寄存器的值不会变的。
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。