Skip to content

Commit 7d256ba

Browse files
facchinmiabdalkader
authored andcommitted
Core/IRQManager: Add support for I2S.
1 parent aee54e9 commit 7d256ba

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

cores/arduino/IRQManager.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define ADC_PRIORITY 12
2424
#define CAN_PRIORITY 12
2525
#define CANFD_PRIORITY 12
26+
#define I2S_PRIORITY 12
2627
#define FIRST_INT_SLOT_FREE 0
2728

2829
IRQManager::IRQManager() : last_interrupt_index{0} {
@@ -930,6 +931,41 @@ bool IRQManager::addPeripheral(Peripheral_t p, void *cfg) {
930931
}
931932
}
932933
#endif
934+
935+
#if I2S_HOWMANY > 0
936+
/* **********************************************************************
937+
I2S
938+
********************************************************************** */
939+
else if(p == IRQ_I2S && cfg != NULL) {
940+
i2s_cfg_t *i2s_cfg = (i2s_cfg_t *)cfg;
941+
942+
if(i2s_cfg->txi_irq == FSP_INVALID_VECTOR) {
943+
i2s_cfg->txi_irq = (IRQn_Type)last_interrupt_index;
944+
i2s_cfg->txi_ipl = I2S_PRIORITY;
945+
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_txi_isr;
946+
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_TXI);
947+
R_FSP_IsrContextSet(i2s_cfg->txi_irq, (void*)i2s_cfg->p_context);
948+
last_interrupt_index++;
949+
}
950+
if(i2s_cfg->rxi_irq == FSP_INVALID_VECTOR) {
951+
i2s_cfg->rxi_irq = (IRQn_Type)last_interrupt_index;
952+
i2s_cfg->rxi_ipl = I2S_PRIORITY;
953+
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_rxi_isr;
954+
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_RXI);
955+
R_FSP_IsrContextSet(i2s_cfg->rxi_irq, (void*)i2s_cfg->p_context);
956+
last_interrupt_index++;
957+
}
958+
if(i2s_cfg->int_irq == FSP_INVALID_VECTOR) {
959+
i2s_cfg->int_irq = (IRQn_Type)last_interrupt_index;
960+
i2s_cfg->idle_err_ipl = I2S_PRIORITY;
961+
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_int_isr;
962+
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_INT);
963+
R_FSP_IsrContextSet(i2s_cfg->int_irq, (void*)i2s_cfg->p_context);
964+
last_interrupt_index++;
965+
}
966+
}
967+
#endif
968+
933969
else {
934970
rv = false;
935971
}

cores/arduino/IRQManager.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
#include "r_external_irq_api.h"
1919
#endif
2020

21+
#if I2S_HOWMANY > 0
22+
#include "r_ssi.h"
23+
extern "C" {
24+
void ssi_txi_isr(void);
25+
void ssi_rxi_isr(void);
26+
void ssi_int_isr(void);
27+
}
28+
#endif
29+
2130
#include "r_timer_api.h"
2231

2332
#ifdef ELC_EVENT_DMAC0_INT
@@ -43,7 +52,8 @@ typedef enum {
4352
IRQ_CAN,
4453
IRQ_ETHERNET,
4554
IRQ_CANFD,
46-
IRQ_SDCARD
55+
IRQ_SDCARD,
56+
IRQ_I2S
4757
} Peripheral_t;
4858

4959
#if SDCARD_HOWMANY > 0

variants/PORTENTA_C33/pins_arduino.h

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ static const uint8_t SS = PIN_SPI_CS;
161161
/****** SDCARD CORE DEFINES *******/
162162
#define SDCARD_HOWMANY 1
163163

164+
#define I2S_HOWMANY 1
164165

165166
#define EXT_INTERRUPTS_HOWMANY 8
166167

0 commit comments

Comments
 (0)