Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Core/IRQManager: Add support for I2S.
  • Loading branch information
facchinm authored and iabdalkader committed May 6, 2024
commit 7d256ba5e3b07dd1b0260cd68446bd08a5ede61b
36 changes: 36 additions & 0 deletions cores/arduino/IRQManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define ADC_PRIORITY 12
#define CAN_PRIORITY 12
#define CANFD_PRIORITY 12
#define I2S_PRIORITY 12
#define FIRST_INT_SLOT_FREE 0

IRQManager::IRQManager() : last_interrupt_index{0} {
Expand Down Expand Up @@ -930,6 +931,41 @@ bool IRQManager::addPeripheral(Peripheral_t p, void *cfg) {
}
}
#endif

#if I2S_HOWMANY > 0
/* **********************************************************************
I2S
********************************************************************** */
else if(p == IRQ_I2S && cfg != NULL) {
i2s_cfg_t *i2s_cfg = (i2s_cfg_t *)cfg;

if(i2s_cfg->txi_irq == FSP_INVALID_VECTOR) {
i2s_cfg->txi_irq = (IRQn_Type)last_interrupt_index;
i2s_cfg->txi_ipl = I2S_PRIORITY;
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_txi_isr;
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_TXI);
R_FSP_IsrContextSet(i2s_cfg->txi_irq, (void*)i2s_cfg->p_context);
last_interrupt_index++;
}
if(i2s_cfg->rxi_irq == FSP_INVALID_VECTOR) {
i2s_cfg->rxi_irq = (IRQn_Type)last_interrupt_index;
i2s_cfg->rxi_ipl = I2S_PRIORITY;
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_rxi_isr;
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_RXI);
R_FSP_IsrContextSet(i2s_cfg->rxi_irq, (void*)i2s_cfg->p_context);
last_interrupt_index++;
}
if(i2s_cfg->int_irq == FSP_INVALID_VECTOR) {
i2s_cfg->int_irq = (IRQn_Type)last_interrupt_index;
i2s_cfg->idle_err_ipl = I2S_PRIORITY;
*(irq_ptr + last_interrupt_index) = (uint32_t)ssi_int_isr;
R_ICU->IELSR[last_interrupt_index] = BSP_PRV_IELS_ENUM(EVENT_SSI0_INT);
R_FSP_IsrContextSet(i2s_cfg->int_irq, (void*)i2s_cfg->p_context);
last_interrupt_index++;
}
}
#endif

else {
rv = false;
}
Expand Down
12 changes: 11 additions & 1 deletion cores/arduino/IRQManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
#include "r_external_irq_api.h"
#endif

#if I2S_HOWMANY > 0
#include "r_ssi.h"
extern "C" {
void ssi_txi_isr(void);
void ssi_rxi_isr(void);
void ssi_int_isr(void);
}
#endif

#include "r_timer_api.h"

#ifdef ELC_EVENT_DMAC0_INT
Expand All @@ -43,7 +52,8 @@ typedef enum {
IRQ_CAN,
IRQ_ETHERNET,
IRQ_CANFD,
IRQ_SDCARD
IRQ_SDCARD,
IRQ_I2S
} Peripheral_t;

#if SDCARD_HOWMANY > 0
Expand Down
1 change: 1 addition & 0 deletions variants/PORTENTA_C33/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ static const uint8_t SS = PIN_SPI_CS;
/****** SDCARD CORE DEFINES *******/
#define SDCARD_HOWMANY 1

#define I2S_HOWMANY 1

#define EXT_INTERRUPTS_HOWMANY 8

Expand Down