Skip to content

Commit

Permalink
Moving i2SStop to IRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
Yves BAZIN authored and Yves BAZIN committed Jun 28, 2024
1 parent cbb75d5 commit 2d70a64
Showing 1 changed file with 56 additions and 11 deletions.
67 changes: 56 additions & 11 deletions src/I2SClocklessVirtualLedDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ typedef union
uint32_t shorts[16 * 2];
} Lines;



class I2SClocklessVirtualLedDriver;
struct OffsetDisplay
{
Expand Down Expand Up @@ -288,6 +290,16 @@ enum displayMode
};

__OffsetDisplay _internalOffsetDisplay;

static void IRAM_ATTR i2sReset()
{
const unsigned long lc_conf_reset_flags = I2S_IN_RST_M | I2S_OUT_RST_M | I2S_AHBM_RST_M | I2S_AHBM_FIFO_RST_M;
(&I2S0)->lc_conf.val |= lc_conf_reset_flags;
(&I2S0)->lc_conf.val &= ~lc_conf_reset_flags;
const uint32_t conf_reset_flags = I2S_RX_RESET_M | I2S_RX_FIFO_RESET_M | I2S_TX_RESET_M | I2S_TX_FIFO_RESET_M;
(&I2S0)->conf.val |= conf_reset_flags;
(&I2S0)->conf.val &= ~conf_reset_flags;
}
class I2SClocklessVirtualLedDriver
{

Expand Down Expand Up @@ -1727,8 +1739,8 @@ Driver data (overall frames):\n - nb of frames displayed:%d\n - nb of fr
(&I2S0)->conf.tx_fifo_reset = 1;
(&I2S0)->conf.tx_fifo_reset = 0;
}

static void i2sStop(I2SClocklessVirtualLedDriver *cont)
/*
static void IRAM_ATTR i2sStop(I2SClocklessVirtualLedDriver *cont)
{
// delay(1);
Expand All @@ -1743,9 +1755,8 @@ Driver data (overall frames):\n - nb of frames displayed:%d\n - nb of fr
cont->isDisplaying = false;
// cont->leds=cont->saveleds;
/*
We have finished to display the strips
*/
// We have finished to display the strips
// ets_delay_us(1000);
if (cont->wasWaitingtofinish == true) // and cont->__displayMode==NO_WAIT
{
Expand All @@ -1759,7 +1770,7 @@ Driver data (overall frames):\n - nb of frames displayed:%d\n - nb of fr
}
// printf("hehe\n");
}

*/
void putdefaultlatch(uint16_t *buff)
{
// printf("dd%d\n",NBIS2SERIALPINS);
Expand Down Expand Up @@ -1827,7 +1838,7 @@ Driver data (overall frames):\n - nb of frames displayed:%d\n - nb of fr
// Set the mode to indicate that we've started
isDisplaying = true;
}

/*
void i2sReset()
{
const unsigned long lc_conf_reset_flags = I2S_IN_RST_M | I2S_OUT_RST_M | I2S_AHBM_RST_M | I2S_AHBM_FIFO_RST_M;
Expand All @@ -1837,10 +1848,43 @@ Driver data (overall frames):\n - nb of frames displayed:%d\n - nb of fr
(&I2S0)->conf.val |= conf_reset_flags;
(&I2S0)->conf.val &= ~conf_reset_flags;
}

*/
// static void IRAM_ATTR interruptHandler(void *arg);
};


static void IRAM_ATTR i2sStop(I2SClocklessVirtualLedDriver *cont)
{

// delay(1);
esp_intr_disable(cont->_gI2SClocklessDriver_intr_handle);
ets_delay_us(16);
(&I2S0)->conf.tx_start = 0;
while ((&I2S0)->conf.tx_start == 1)
{
}

// cont->i2sReset();
i2sReset();
cont->isDisplaying = false;
// cont->leds=cont->saveleds;
/*
We have finished to display the strips
*/
// ets_delay_us(1000);
if (cont->wasWaitingtofinish == true) // and cont->__displayMode==NO_WAIT
{
cont->wasWaitingtofinish = false;
xSemaphoreGive(cont->I2SClocklessVirtualLedDriver_waitDisp);
}
if (cont->isWaiting)
{
// printf("on debloqu\n");
xSemaphoreGive(cont->I2SClocklessVirtualLedDriver_sem);
}
// printf("hehe\n");
}

static void IRAM_ATTR _I2SClocklessVirtualLedDriverinterruptHandler(void *arg)
{

Expand All @@ -1851,8 +1895,8 @@ static void IRAM_ATTR _I2SClocklessVirtualLedDriverinterruptHandler(void *arg)
if(!cont->__enableDriver)
{
REG_WRITE(I2S_INT_CLR_REG(0), (REG_READ(I2S_INT_RAW_REG(0)) & 0xffffffc0) | 0x3f);
cont->i2sStop(cont);

//cont->i2sStop(cont);
i2sStop(cont);
return;
}
if (GET_PERI_REG_BITS(I2S_INT_ST_REG(I2S_DEVICE), I2S_OUT_EOF_INT_ST_S, I2S_OUT_EOF_INT_ST_S))
Expand Down Expand Up @@ -1896,7 +1940,8 @@ if(!cont->__enableDriver)
{

// cont->ledToDisplay_inbufferfor[cont->ledToDisplay_out]=9999;
cont->i2sStop(cont);
// cont->i2sStop(cont);
i2sStop(cont);
}

REG_WRITE(I2S_INT_CLR_REG(0), (REG_READ(I2S_INT_RAW_REG(0)) & 0xffffffc0) | 0x3f);
Expand Down

0 comments on commit 2d70a64

Please sign in to comment.