Libopencm3 interrupt table on STM32F4

∥☆過路亽.° 提交于 2019-12-11 05:36:59

问题


I'm using libopenCM3 for my project on STM32F4. I've used previously Standard Peripheral Library and newer Hardware Abstraction Layer developed by ST.

In these libraries you have assembly file (startup file) with the definition of vector table.

This is what I'm missing for libopenCM3. Can you please show me where to find this table? Or is it done some another way?

I really need to use interrupts in my project.

Thanks.


回答1:


Can you please show me where to find this table?

Interrupt vector table is located in lib/cm3/vector.c:

__attribute__ ((section(".vectors")))
vector_table_t vector_table = {
    ...
    .irq = {
        IRQ_HANDLERS
    }
};

And IRQ_HANDLERS for STM32F4 are defined in lib/stm32/f4/vector_nvic.c file. This file will be available after building the library (it's generated with irq2nvic_h script). In this file you can see something like this:

#define IRQ_HANDLERS \
    [NVIC_DMA1_STREAM0_IRQ] = dma1_stream0_isr, \
    [NVIC_ADC_IRQ] = adc_isr, \
    ...

Functions like dma1_stream0_isr() and adc_isr() are defined like this:

#pragma weak adc_isr = blocking_handler

So these functions are just blocking handlers by default. But they are defined as weak, so you can easily redefine them in your code.

Or is it done some another way?

As discussed above, it boils down to next: you just need to define interrupt handler function (ISR) with correct name in your code, and your function will be placed to interrupt vector table automatically.

For instance, if you want to handle UART2 interrupt, just implement usart2_isr() function somewhere in your code. For the whole list of ISR function names refer to include/libopencm3/stm32/f4/nvic.h. But those names are usually pretty straight-forward.

Also, check out the libopencm3-examples project. The chances are you will find just what you need there.



来源:https://stackoverflow.com/questions/37710085/libopencm3-interrupt-table-on-stm32f4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!