From 75e593edf10291b946f9ec9da21b10e97d7bccbf Mon Sep 17 00:00:00 2001 From: klassents Date: Fri, 20 Dec 2024 14:40:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=81=D1=82=D0=BE=D0=BC=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F-=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87=D0=B8=D0=BA=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D1=80=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D0=B9,=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=83=D1=8E=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B3=D1=83=D1=82=20=D1=81=D0=B0=D0=BC=D0=B8=20=D0=BE?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D1=8F=D1=82=D1=8C=20"?= =?UTF-8?q?=D0=BD=D0=B0=D0=B2=D0=B5=D1=80=D1=85=D1=83"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/arduino/trap_handler.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/cores/arduino/trap_handler.c b/cores/arduino/trap_handler.c index b491eae..f302625 100644 --- a/cores/arduino/trap_handler.c +++ b/cores/arduino/trap_handler.c @@ -1,5 +1,5 @@ -#include "mik32_hal_irq.h" -#include "wiring_LL.h" +#include "mik32_hal_irq.h" +#include "wiring_LL.h" // isr functions extern void serial_interrupt_handler(uint8_t uartNumInt); @@ -11,12 +11,37 @@ void __attribute__((weak)) wire_interrupt_handler(void) } void __attribute__((weak)) servo_interrupt_handler(void) { - // dummy function for case when wire library is not in use + // dummy function for case when servo library is not in use +} + +void __attribute__((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(void) + { + // timer16 is taken as an example + if (TIM16_GET_ARRM_INT_STATUS(htimer16_1_)) + { + // necessary actions + } + // reset timer interrupt flags + TIM16_CLEAR_INT_MASK(htimer16_1_, 0xFFFFFFFF); + } + libraries required to use this example: + #include "mik32_hal_timer16.h" + #include "mik32_hal_irq.h" + #include "wiring_LL.h" + */ } // ---------------------------------------------- // void __attribute__((noinline, section(".ram_text"), optimize("O3"))) trap_handler (void) { + // custom interrupt + ISR(); + // gpio interrupt if (EPIC_CHECK_GPIO_IRQ()) gpio_interrupt_handler(); @@ -36,7 +61,7 @@ void __attribute__((noinline, section(".ram_text"), optimize("O3"))) trap_handle // uart1 interrupt if (EPIC_CHECK_UART_1()) serial_interrupt_handler(1); - + // i2c interrupt if (EPIC_CHECK_I2C_1()) wire_interrupt_handler();