如何禁用avr-gcc的“似乎是拼写错误的中断处理程序”警告?

时间:2016-05-30 20:46:29

标签: c gcc avr

我目前正在为AVR微控制器上的USB设备创建固件。由于USB时序非常严格,我不能允许非USB中断阻塞超过几个指令周期。因此,我的USART RXC(字符接收)中断如下所示:

void usart_rxc_wrapped() __attribute__ ((interrupt));
void usart_rxc_wrapped(){
    uint8_t c=UDR;
    if(!ringBufferFull(&rx)){
        ringBufferWrite(&rx, c);
    }
    // Reenable nterrupt
    UCSRB|=1<<RXCIE;
}

// This cannot be ISR_NOBLOCK, since the interrupt would go
// into infinite loop, since we wouldn't get up to reading
// UDR register. Instead, we use assembly to do the job
// manually and then jump to the real handler.
ISR(USART_RXC_vect, ISR_NAKED){
    // Disable this interrupt by clearing its Interrupt Enable flag.
    __asm__ volatile("cbi %0, %1"::
            "I"(_SFR_IO_ADDR(UCSRB)),"I"(RXCIE));
    __asm__ volatile("sei"::);
    __asm__ volatile("rjmp usart_rxc_wrapped"::);
}

请注意,我不能把主中断代码放在ISR例程中,因为avr-gcc为这个函数生成了一个很长的序幕(毕竟,我从那里调用其他函数,所以需要推送很多寄存器) 。即使C代码中的第一条指令正在清除中断标志,它仍会被许多周期令人不安地延迟。

此解决方案运行正常,但我担心avr-gcc的警告:

uart.c:128:6: warning: ‘usart_rxc_wrapped’ appears to be a misspelled interrupt handler

这是因为我在其定义中使用__attribute__((interrupt))以通知编译器将寄存器保存为ISR。我在编译器中找不到任何禁用此警告的选项。是否有解决方法使编译减少噪音?或者也许有更好的方法来处理这种情况?

1 个答案:

答案 0 :(得分:4)

我在8年前找到了这个补丁:http://savannah.nongnu.org/bugs/download.php?file_id=15656。显然,警告是无条件生成的(编译时没有-WnoXXX标志)。但是,仅当函数名称不以__vector开头时,avr-gcc才会生成此警告。为了解决我的问题,我只是将包装函数重命名为__vector_usart_rxc_wrapped