@@ -74,6 +74,7 @@ static const struct device *dev_i2s_rx;
7474static const struct device * dev_i2s_tx ;
7575static const struct device * dev_i2s_rxtx ;
7676static bool dir_both_supported ;
77+ static uint32_t frame_clk_freq = 44100 ;
7778
7879static void fill_buf (int16_t * tx_block , int att )
7980{
@@ -125,7 +126,6 @@ static int verify_buf(int16_t *rx_block, int att)
125126}
126127
127128#define TIMEOUT 2000
128- #define FRAME_CLK_FREQ 44000
129129
130130static int configure_stream (const struct device * dev_i2s , enum i2s_dir dir )
131131{
@@ -135,7 +135,7 @@ static int configure_stream(const struct device *dev_i2s, enum i2s_dir dir)
135135 i2s_cfg .word_size = 16U ;
136136 i2s_cfg .channels = 2U ;
137137 i2s_cfg .format = I2S_FMT_DATA_FORMAT_I2S ;
138- i2s_cfg .frame_clk_freq = FRAME_CLK_FREQ ;
138+ i2s_cfg .frame_clk_freq = frame_clk_freq ;
139139 i2s_cfg .block_size = BLOCK_SIZE ;
140140 i2s_cfg .timeout = TIMEOUT ;
141141
@@ -179,16 +179,7 @@ static int configure_stream(const struct device *dev_i2s, enum i2s_dir dir)
179179 return TC_PASS ;
180180}
181181
182-
183- /** @brief Short I2S transfer.
184- *
185- * - TX stream START trigger starts transmission.
186- * - RX stream START trigger starts reception.
187- * - sending / receiving a short sequence of data returns success.
188- * - TX stream DRAIN trigger empties the transmit queue.
189- * - RX stream STOP trigger stops reception.
190- */
191- ZTEST (drivers_i2s_speed , test_i2s_transfer_short )
182+ static void i2s_transfer_short (void )
192183{
193184 if (IS_ENABLED (CONFIG_I2S_TEST_USE_I2S_DIR_BOTH )) {
194185 TC_PRINT ("RX/TX transfer requires use of I2S_DIR_BOTH.\n" );
@@ -258,6 +249,146 @@ ZTEST(drivers_i2s_speed, test_i2s_transfer_short)
258249 TC_PRINT ("%d<-OK\n" , 3 );
259250}
260251
252+ /** @brief Short I2S transfer at 8000 samples per second.
253+ *
254+ * - TX stream START trigger starts transmission.
255+ * - RX stream START trigger starts reception.
256+ * - sending / receiving a short sequence of data returns success.
257+ * - TX stream DRAIN trigger empties the transmit queue.
258+ * - RX stream STOP trigger stops reception.
259+ */
260+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_08000 )
261+ {
262+ int ret ;
263+
264+ frame_clk_freq = 8000 ;
265+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
266+ zassert_equal (ret , TC_PASS );
267+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
268+ zassert_equal (ret , TC_PASS );
269+ i2s_transfer_short ();
270+ }
271+
272+ /** @brief Short I2S transfer at 16000 samples per second.
273+ *
274+ * - TX stream START trigger starts transmission.
275+ * - RX stream START trigger starts reception.
276+ * - sending / receiving a short sequence of data returns success.
277+ * - TX stream DRAIN trigger empties the transmit queue.
278+ * - RX stream STOP trigger stops reception.
279+ */
280+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_16000 )
281+ {
282+ int ret ;
283+
284+ frame_clk_freq = 16000 ;
285+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
286+ zassert_equal (ret , TC_PASS );
287+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
288+ zassert_equal (ret , TC_PASS );
289+ i2s_transfer_short ();
290+ }
291+
292+ /** @brief Short I2S transfer at 32000 samples per second.
293+ *
294+ * - TX stream START trigger starts transmission.
295+ * - RX stream START trigger starts reception.
296+ * - sending / receiving a short sequence of data returns success.
297+ * - TX stream DRAIN trigger empties the transmit queue.
298+ * - RX stream STOP trigger stops reception.
299+ */
300+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_32000 )
301+ {
302+ int ret ;
303+
304+ frame_clk_freq = 32000 ;
305+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
306+ zassert_equal (ret , TC_PASS );
307+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
308+ zassert_equal (ret , TC_PASS );
309+ i2s_transfer_short ();
310+ }
311+
312+ /** @brief Short I2S transfer at 44100 samples per second.
313+ *
314+ * - TX stream START trigger starts transmission.
315+ * - RX stream START trigger starts reception.
316+ * - sending / receiving a short sequence of data returns success.
317+ * - TX stream DRAIN trigger empties the transmit queue.
318+ * - RX stream STOP trigger stops reception.
319+ */
320+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_44100 )
321+ {
322+ int ret ;
323+
324+ frame_clk_freq = 44100 ;
325+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
326+ zassert_equal (ret , TC_PASS );
327+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
328+ zassert_equal (ret , TC_PASS );
329+ i2s_transfer_short ();
330+ }
331+
332+ /** @brief Short I2S transfer at 48000 samples per second.
333+ *
334+ * - TX stream START trigger starts transmission.
335+ * - RX stream START trigger starts reception.
336+ * - sending / receiving a short sequence of data returns success.
337+ * - TX stream DRAIN trigger empties the transmit queue.
338+ * - RX stream STOP trigger stops reception.
339+ */
340+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_48000 )
341+ {
342+ int ret ;
343+
344+ frame_clk_freq = 48000 ;
345+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
346+ zassert_equal (ret , TC_PASS );
347+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
348+ zassert_equal (ret , TC_PASS );
349+ i2s_transfer_short ();
350+ }
351+
352+ /** @brief Short I2S transfer at 88200 samples per second.
353+ *
354+ * - TX stream START trigger starts transmission.
355+ * - RX stream START trigger starts reception.
356+ * - sending / receiving a short sequence of data returns success.
357+ * - TX stream DRAIN trigger empties the transmit queue.
358+ * - RX stream STOP trigger stops reception.
359+ */
360+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_88200 )
361+ {
362+ int ret ;
363+
364+ frame_clk_freq = 88200 ;
365+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
366+ zassert_equal (ret , TC_PASS );
367+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
368+ zassert_equal (ret , TC_PASS );
369+ i2s_transfer_short ();
370+ }
371+
372+ /** @brief Short I2S transfer at 96000 samples per second.
373+ *
374+ * - TX stream START trigger starts transmission.
375+ * - RX stream START trigger starts reception.
376+ * - sending / receiving a short sequence of data returns success.
377+ * - TX stream DRAIN trigger empties the transmit queue.
378+ * - RX stream STOP trigger stops reception.
379+ */
380+ ZTEST (drivers_i2s_speed , test_i2s_transfer_short_96000 )
381+ {
382+ int ret ;
383+
384+ frame_clk_freq = 96000 ;
385+ ret = configure_stream (dev_i2s_tx , I2S_DIR_TX );
386+ zassert_equal (ret , TC_PASS );
387+ ret = configure_stream (dev_i2s_rx , I2S_DIR_RX );
388+ zassert_equal (ret , TC_PASS );
389+ i2s_transfer_short ();
390+ }
391+
261392/** @brief Long I2S transfer.
262393 *
263394 * - TX stream START trigger starts transmission.
@@ -349,14 +480,7 @@ ZTEST(drivers_i2s_speed, test_i2s_transfer_long)
349480 zassert_equal (num_verified , NUM_BLOCKS , "Invalid RX blocks received" );
350481}
351482
352-
353- /** @brief Short I2S transfer using I2S_DIR_BOTH.
354- *
355- * - START trigger starts both the transmission and reception.
356- * - Sending / receiving a short sequence of data returns success.
357- * - DRAIN trigger empties the transmit queue and stops both streams.
358- */
359- ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short )
483+ static void i2s_dir_both_transfer_short (void )
360484{
361485 if (!dir_both_supported ) {
362486 TC_PRINT ("I2S_DIR_BOTH value is not supported.\n" );
@@ -417,6 +541,118 @@ ZTEST(drivers_i2s_speed_both_rxtx, test_i2s_dir_both_transfer_short)
417541 TC_PRINT ("%d<-OK\n" , 3 );
418542}
419543
544+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 8000.
545+ *
546+ * - START trigger starts both the transmission and reception.
547+ * - Sending / receiving a short sequence of data returns success.
548+ * - DRAIN trigger empties the transmit queue and stops both streams.
549+ */
550+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_08000 )
551+ {
552+ int ret ;
553+
554+ frame_clk_freq = 8000 ;
555+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
556+ zassert_equal (ret , TC_PASS );
557+ i2s_dir_both_transfer_short ();
558+ }
559+
560+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 16000.
561+ *
562+ * - START trigger starts both the transmission and reception.
563+ * - Sending / receiving a short sequence of data returns success.
564+ * - DRAIN trigger empties the transmit queue and stops both streams.
565+ */
566+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_16000 )
567+ {
568+ int ret ;
569+
570+ frame_clk_freq = 16000 ;
571+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
572+ zassert_equal (ret , TC_PASS );
573+ i2s_dir_both_transfer_short ();
574+ }
575+
576+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 32000.
577+ *
578+ * - START trigger starts both the transmission and reception.
579+ * - Sending / receiving a short sequence of data returns success.
580+ * - DRAIN trigger empties the transmit queue and stops both streams.
581+ */
582+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_32000 )
583+ {
584+ int ret ;
585+
586+ frame_clk_freq = 32000 ;
587+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
588+ zassert_equal (ret , TC_PASS );
589+ i2s_dir_both_transfer_short ();
590+ }
591+
592+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 44100.
593+ *
594+ * - START trigger starts both the transmission and reception.
595+ * - Sending / receiving a short sequence of data returns success.
596+ * - DRAIN trigger empties the transmit queue and stops both streams.
597+ */
598+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_44100 )
599+ {
600+ int ret ;
601+
602+ frame_clk_freq = 44100 ;
603+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
604+ zassert_equal (ret , TC_PASS );
605+ i2s_dir_both_transfer_short ();
606+ }
607+
608+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 48000.
609+ *
610+ * - START trigger starts both the transmission and reception.
611+ * - Sending / receiving a short sequence of data returns success.
612+ * - DRAIN trigger empties the transmit queue and stops both streams.
613+ */
614+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_48000 )
615+ {
616+ int ret ;
617+
618+ frame_clk_freq = 48000 ;
619+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
620+ zassert_equal (ret , TC_PASS );
621+ i2s_dir_both_transfer_short ();
622+ }
623+
624+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 88200.
625+ *
626+ * - START trigger starts both the transmission and reception.
627+ * - Sending / receiving a short sequence of data returns success.
628+ * - DRAIN trigger empties the transmit queue and stops both streams.
629+ */
630+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_88200 )
631+ {
632+ int ret ;
633+
634+ frame_clk_freq = 88200 ;
635+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
636+ zassert_equal (ret , TC_PASS );
637+ i2s_dir_both_transfer_short ();
638+ }
639+
640+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 96000.
641+ *
642+ * - START trigger starts both the transmission and reception.
643+ * - Sending / receiving a short sequence of data returns success.
644+ * - DRAIN trigger empties the transmit queue and stops both streams.
645+ */
646+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_96000 )
647+ {
648+ int ret ;
649+
650+ frame_clk_freq = 96000 ;
651+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
652+ zassert_equal (ret , TC_PASS );
653+ i2s_dir_both_transfer_short ();
654+ }
655+
420656/** @brief Long I2S transfer using I2S_DIR_BOTH.
421657 *
422658 * - START trigger starts both the transmission and reception.
0 commit comments