добавлена возможность пропускать код стандартного обработчика прерываний при использовании пользовательского обработчика
This commit is contained in:
1 parent
cd3e2268c6
commit
840fc7484d
2 files changed
+44
-7
No files matched your search
@@ -18,12 +18,12 @@ void __attribute__((weak)) IRremote_interrupt_handler(void)
|
||||
// dummy function for case when IRremote library is not in use
|
||||
}
|
||||
|
||||
void __attribute__((weak)) ISR(void)
|
||||
{
|
||||
bool __attribute__((section(".ram_text"), weak)) ISR(void)
|
||||
{
|
||||
/*
|
||||
A dummy function for the case when additional interrupts are not used in the project.
|
||||
In the project, you need to create a function of the form:
|
||||
extern "C" void ISR()
|
||||
extern "C" __attribute__((section(".ram_text"))) bool ISR(void)
|
||||
{
|
||||
if (EPIC_CHECK_TIMER16_1())
|
||||
{
|
||||
@@ -35,20 +35,31 @@ void __attribute__((weak)) ISR(void)
|
||||
// reset timer interrupt flags
|
||||
TIM16_CLEAR_INT_MASK(htimer16_1_, 0xFFFFFFFF);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
If you don't need to call standard trap_handler() code, you can return true from this function
|
||||
and trap_handler() code will be missed. But you must carefully clear interrupt flags by yourself
|
||||
in your custom ISR() function.
|
||||
|
||||
libraries required to use this example:
|
||||
#include "mik32_hal_timer16.h"
|
||||
#include "mik32_hal_irq.h"
|
||||
#include "wiring_LL.h"
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------- //
|
||||
void __attribute__((noinline, section(".ram_text"), optimize("O3"))) trap_handler (void)
|
||||
{
|
||||
// custom interrupt
|
||||
ISR();
|
||||
|
||||
if(ISR())
|
||||
{
|
||||
// reset all interrupts and miss trap_handler() code
|
||||
EPIC_CLEAR_ALL();
|
||||
return;
|
||||
}
|
||||
|
||||
// gpio interrupt
|
||||
if (EPIC_CHECK_GPIO_IRQ())
|
||||
gpio_interrupt_handler();
|
||||
@@ -77,6 +88,7 @@ void __attribute__((noinline, section(".ram_text"), optimize("O3"))) trap_handle
|
||||
if (EPIC_CHECK_I2C_0())
|
||||
wire_interrupt_handler(0);
|
||||
|
||||
// i2c1 interrupt
|
||||
if (EPIC_CHECK_I2C_1())
|
||||
wire_interrupt_handler(1);
|
||||
|
||||
|
||||
Reference in new issue
Block a user