Re: IRQ_CONNECT: enum based line number?


Carles Cufi
 

Hi Erwan,

Sorry I can’t quote you but my email client doesn’t allow me to for some reason.

We had the exact same issue with the nRF5x from Nordic, and we resorted to redefining them altogether:
https://github.com/zephyrproject-rtos/zephyr/blob/master/arch/arm/soc/nordic_nrf5/include/nrf5_common.h#L29

That said, we’d be glad to be able to use the original values. I filed a report with the MDK team at Nordic to see if they could switch to #define from enum too, but I am not sure if they’ve implemented it yet.

Regards,

Carles

From: Erwan Gouriou [mailto:erwan.gouriou(a)linaro.org]
Sent: Friday, October 28, 2016 16:27
To: devel(a)lists.zephyrproject.org
Subject: [devel] IRQ_CONNECT: enum based line number?

Hi all,

I've a question around IRQ_CONNECT macro for Cortex_m defined in
include/arch/arm/cortex_m/irq.h

In ST CMSIS, we define IRQ line as enum. For instance:
typedef enum
{
/****** Cortex-M3 Processor Exceptions Numbers ***************************************************/
...
USART1_IRQn = 37, /*!< USART1 global Interrupt */
USART2_IRQn = 38, /*!< USART2 global Interrupt */
USART3_IRQn = 39, /*!< USART3 global Interrupt */
...
} IRQn_Type;

Issue is that we cannot use directly these values in IRQ_CONNECT macro since it
expects constant IRQ line number.

Note: It compiles without any warning though, since compilation trap does not catch enums:
enum { IRQ = irq_p }; \ --> irq_p could be an enum

Actual issue is in following directive:
__attribute__ ((section(STRINGIFY(_CONCAT(.gnu.linkonce.isr_irq, irq_p)))))
If irq_p is not a number, compiler will not be able to understand it has to overwrite
section _isr_irq38.

I've tried numerous ways to cast my enum value into an acceptable const value for the macro,
but it remained unsuccessful.

Is there any way to cast ny enum into an acceptable const for this macro?
If not, would it be possible to get the macro accepting enum values without breaking its
benefice?

Thanks
Erwan

Join devel@lists.zephyrproject.org to automatically receive all group messages.