File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,29 @@ static void i2s_hw_rx_flush(void)
9494 (SPI_I2S_GetFlagStatus (SPI2 , SPI_I2S_FLAG_OVR ) != RESET ));
9595}
9696
97+ static bool i2s_wait_for_ws_falling_edge (void )
98+ {
99+ uint32_t timeout = I2S_WS_SYNC_TIMEOUT_POLLS ;
100+
101+ /*
102+ * For some reason waiting for WS to be low before enabling fixes the bitslip issue
103+ * Wait for falling edge to give the most time before we reach the i2s enable
104+ */
105+ while ((timeout > 0U ) &&
106+ (GPIO_ReadInputDataBit (I2S_WS_GPIO_PORT , I2S_WS_GPIO_PIN ) == Bit_RESET ))
107+ {
108+ -- timeout ;
109+ }
110+
111+ while ((timeout > 0U ) &&
112+ (GPIO_ReadInputDataBit (I2S_WS_GPIO_PORT , I2S_WS_GPIO_PIN ) != Bit_RESET ))
113+ {
114+ -- timeout ;
115+ }
116+
117+ return timeout > 0U ;
118+ }
119+
97120static void i2s_hw_dma_irq_init (void )
98121{
99122 NVIC_InitTypeDef nvic = {0 };
@@ -239,6 +262,12 @@ static void i2s_dma_rx_start(void)
239262 DMA_ITConfig (I2S_RX_DMA_CHANNEL , DMA_IT_HT | DMA_IT_TC | DMA_IT_TE , ENABLE );
240263 DMA_Cmd (I2S_RX_DMA_CHANNEL , ENABLE );
241264 SPI_I2S_DMACmd (SPI2 , SPI_I2S_DMAReq_Rx , ENABLE );
265+
266+ if (!i2s_wait_for_ws_falling_edge ())
267+ {
268+ printf ("I2S: WS falling-edge sync timeout; starting unsynchronized\r\n" );
269+ }
270+
242271 I2S_Cmd (SPI2 , ENABLE );
243272}
244273
Original file line number Diff line number Diff line change @@ -323,11 +323,10 @@ static void Application_Task(void *parameters)
323323
324324 trng_hw_init ();
325325 (void )tlv320adc6120_ch1_mute (true );
326- Draw_I2S_Syncing_Status ();
327326 while (s_i2s_bitslip_check)
328327 {
329- TLV320_I2S_CheckBitslip ();
330328 portYIELD ();
329+ TLV320_I2S_CheckBitslip ();
331330 }
332331 (void )tlv320adc6120_ch1_mute (false );
333332 trng_hw_deinit ();
You can’t perform that action at this time.
0 commit comments