forked from Elron_dev/elbear_arduino_bsp
- добавлена поддержка платы ELBEAR ACE-NANO; - добавлена поддержка плат ELSOMIK OEM и SE; - добавлена возможность работы в режиме отладки для всех плат, входящих в состав пакета. Доступно для версии ArduinoIDE 2 и выше; - добавлена поддержка библиотеки FreeRTOS; - добавлена поддержка библиотеки IRremote; - добавлена поддержка библиотеки OneWire; - добавлена поддержка аппаратного I2C0 для плат START-MIK32 и ELSOMIK. Для работы с ним доступен экземпляр класса Wire1; - добавлена поддержка аппаратного SPI0 для всех плат, входящих в пакет. Для работы с ним доступен экземпляр класса SPI1; - увеличено быстродействие функций digitalWrite, digitalRead; - исправлены известные ошибки. Co-authored-by: KlassenTS <klassen@elron.tech> Co-committed-by: KlassenTS <klassen@elron.tech>
86 lines
2.2 KiB
C
86 lines
2.2 KiB
C
#include "mik32_hal_irq.h"
|
|
#include "wiring_LL.h"
|
|
|
|
// isr functions
|
|
extern void serial_interrupt_handler(uint8_t uartNumInt);
|
|
extern void gpio_interrupt_handler(void);
|
|
extern void tone_interrupt_handler(void);
|
|
void __attribute__((weak)) wire_interrupt_handler(uint8_t num)
|
|
{
|
|
// dummy function for case when wire library is not in use
|
|
}
|
|
void __attribute__((weak)) servo_interrupt_handler(void)
|
|
{
|
|
// dummy function for case when servo library is not in use
|
|
}
|
|
void __attribute__((weak)) IRremote_interrupt_handler(void)
|
|
{
|
|
// dummy function for case when IRremote 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()
|
|
{
|
|
if (EPIC_CHECK_TIMER16_1())
|
|
{
|
|
// 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();
|
|
|
|
// IRremote timer interrupt
|
|
if (EPIC_CHECK_TIMER16_0())
|
|
IRremote_interrupt_handler();
|
|
|
|
// tone timer interrupt
|
|
if (EPIC_CHECK_TIMER16_1())
|
|
tone_interrupt_handler();
|
|
|
|
// servo timer interrupt
|
|
if (EPIC_CHECK_TIMER16_2())
|
|
servo_interrupt_handler();
|
|
|
|
// uart0 interrupt
|
|
if (EPIC_CHECK_UART_0())
|
|
serial_interrupt_handler(0);
|
|
|
|
// uart1 interrupt
|
|
if (EPIC_CHECK_UART_1())
|
|
serial_interrupt_handler(1);
|
|
|
|
// i2c0 interrupt
|
|
if (EPIC_CHECK_I2C_0())
|
|
wire_interrupt_handler(0);
|
|
|
|
if (EPIC_CHECK_I2C_1())
|
|
wire_interrupt_handler(1);
|
|
|
|
// reset all interrupts
|
|
EPIC_CLEAR_ALL();
|
|
}
|