File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -49,5 +49,6 @@ void rxDataReceived()
4949 while (CurieI2S.available ())
5050 {
5151 dataBuff[count++] = CurieI2S.requestdword ();
52+ count %= 256 ; // prevent buffer overflow and just write data in front of the buffer.
5253 }
5354}
Original file line number Diff line number Diff line change @@ -222,7 +222,8 @@ static void i2sInterruptHandler(void)
222222 // TXFIFO and tx buffer empty
223223
224224 // last frame delay
225- delayTicks (960 );
225+ // delayTicks(960);
226+ CurieI2S.lastFrameDelay ();
226227 // stop transmission
227228 *I2S_CTRL = *I2S_CTRL & 0xFDFFFFFE ;
228229
@@ -357,6 +358,9 @@ void Curie_I2S::setSampleRate(uint32_t dividerValue)
357358 i2s_srr &= I2S_SAMPLERATE_MASK;
358359 i2s_srr |= dividerValue;
359360 *I2S_SRR = i2s_srr;
361+
362+ // set frameDelay value.
363+ frameDelay = (dividerValue&0x000000FF )*32 *2 ;
360364}
361365
362366void Curie_I2S::setResolution (uint32_t resolution)
@@ -632,6 +636,11 @@ uint8_t Curie_I2S::getRxFIFOLength()
632636 return fifolength;
633637}
634638
639+ void Curie_I2S::lastFrameDelay ()
640+ {
641+ delayTicks (frameDelay);
642+ }
643+
635644void Curie_I2S::attachRxInterrupt (void (*userCallBack)())
636645{
637646 i2s_rxCB = userCallBack;
Original file line number Diff line number Diff line change @@ -96,6 +96,9 @@ class Curie_I2S
9696{
9797 private:
9898 uint32_t clock;
99+
100+ int frameDelay = 0 ;
101+
99102 bool useDMA;
100103
101104 // initializes i2s interface
@@ -202,6 +205,8 @@ class Curie_I2S
202205
203206 uint8_t getRxFIFOLength ();
204207
208+ void lastFrameDelay ();
209+
205210 // Attach user callback that is triggered when there is data pushed into the rx buffer from the RX_FIFO
206211 void attachRxInterrupt (void (*userCallBack)());
207212
You can’t perform that action at this time.
0 commit comments