Skip to content

Commit d6ddd89

Browse files
facchinmdelta-G
authored andcommitted
Core/IRQManager: Add support for I2S.
1 parent 1e5e0e6 commit d6ddd89

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} {
@@ -1006,6 +1007,41 @@ bool IRQManager::addPeripheral(Peripheral_t p, void *cfg) {
10061007
}
10071008
}
10081009
#endif
1010+
1011+
#if I2S_HOWMANY > 0
1012+
/* **********************************************************************
1013+
I2S
1014+
********************************************************************** */
1015+
else if(p == IRQ_I2S && cfg != NULL) {
1016+
i2s_cfg_t *i2s_cfg = (i2s_cfg_t *)cfg;
1017+
1018+
if(i2s_cfg->txi_irq == FSP_INVALID_VECTOR) {
1019+
i2s_cfg->txi_irq = (IRQn_Type)last_interrupt_index;
1020+
i2s_cfg->txi_ipl = I2S_PRIORITY;
1021+
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_txi_isr;
1022+
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_TXI);
1023+
R_FSP_IsrContextSet(i2s_cfg->txi_irq, (void*)i2s_cfg->p_context);
1024+
last_interrupt_index++;
1025+
}
1026+
if(i2s_cfg->rxi_irq == FSP_INVALID_VECTOR) {
1027+
i2s_cfg->rxi_irq = (IRQn_Type)last_interrupt_index;
1028+
i2s_cfg->rxi_ipl = I2S_PRIORITY;
1029+
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_rxi_isr;
1030+
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_RXI);
1031+
R_FSP_IsrContextSet(i2s_cfg->rxi_irq, (void*)i2s_cfg->p_context);
1032+
last_interrupt_index++;
1033+
}
1034+
if(i2s_cfg->int_irq == FSP_INVALID_VECTOR) {
1035+
i2s_cfg->int_irq = (IRQn_Type)last_interrupt_index;
1036+
i2s_cfg->idle_err_ipl = I2S_PRIORITY;
1037+
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_int_isr;
1038+
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_INT);
1039+
R_FSP_IsrContextSet(i2s_cfg->int_irq, (void*)i2s_cfg->p_context);
1040+
last_interrupt_index++;
1041+
}
1042+
}
1043+
#endif
1044+
10091045
else {
10101046
rv = false;
10111047
}

cores/arduino/IRQManager.h

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

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

2433
#ifdef ELC_EVENT_DMAC0_INT
@@ -44,7 +53,8 @@ typedef enum {
4453
IRQ_CAN,
4554
IRQ_ETHERNET,
4655
IRQ_CANFD,
47-
IRQ_SDCARD
56+
IRQ_SDCARD,
57+
IRQ_I2S
4858
} Peripheral_t;
4959

5060
#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)