Hi Small Coke
I've done that - It is quite easy just wait for
i2s_evt.type == I2S_EVENT_TX_DONE using xQueueReceive(i2s_queue, &i2s_evt, portMAX_DELAY);
The queue handle you will get from you driver install setup call
i2s_driver_install(0, &i2s_config, 10, &i2s_queue);
Let me know if you need more liquor to spice up you coke
/J
Code: Select all
...
double sweepPeriod = 4; // in sec
uint32_t i = 0;
i2s_event_t i2s_evt;
sweepCnt = 0;
freq = 50.0;
angleSpeed = 2*M_PI*freq/sampleRate;
while (1) {
xQueueReceive(i2s_queue, &i2s_evt, portMAX_DELAY);
if (i2s_evt.type == I2S_EVENT_TX_DONE)
{ timer_cnt++;
switch (mode) {
case 0 : gate = 1; // Continues
break;
case 1 : // Sweep
if (sweepCnt == 0 ) {
gate = 1;
freq = sweepStartFreq;
} else
{ freq = freq * sweepSpeed;
angleSpeed = 2*M_PI*freq/sampleRate;
xQueueReceive(i2s_queue, &i2s_evt, portMAX_DELAY);
if (i2s_evt.type == I2S_EVENT_TX_DONE)
}
if ( freq > sweepStopFreq )
{ gate = 0;
//printf("sweepCnt : %d",sweepCnt);
sweepCnt = ( sweepCnt > sweepPeriod*lengthSig) ? 0 : sweepCnt + 1;
} else
{ sweepCnt++;
}
...