@@ -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 = 44000 ;
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,126 @@ ZTEST(drivers_i2s_speed, test_i2s_transfer_short)
258249 TC_PRINT ("%d<-OK\n" , 3 );
259250}
260251
252+ /** @brief Short I2S transfer at 16000 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_16000 )
261+ {
262+ int ret ;
263+
264+ frame_clk_freq = 16000 ;
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 32000 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_32000 )
281+ {
282+ int ret ;
283+
284+ frame_clk_freq = 32000 ;
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 44000 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_44000 )
301+ {
302+ int ret ;
303+
304+ frame_clk_freq = 44000 ;
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 96000 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_96000 )
361+ {
362+ int ret ;
363+
364+ frame_clk_freq = 96000 ;
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+
261372/** @brief Long I2S transfer.
262373 *
263374 * - TX stream START trigger starts transmission.
@@ -349,14 +460,7 @@ ZTEST(drivers_i2s_speed, test_i2s_transfer_long)
349460 zassert_equal (num_verified , NUM_BLOCKS , "Invalid RX blocks received" );
350461}
351462
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 )
463+ static void i2s_dir_both_transfer_short (void )
360464{
361465 if (!dir_both_supported ) {
362466 TC_PRINT ("I2S_DIR_BOTH value is not supported.\n" );
@@ -417,6 +521,102 @@ ZTEST(drivers_i2s_speed_both_rxtx, test_i2s_dir_both_transfer_short)
417521 TC_PRINT ("%d<-OK\n" , 3 );
418522}
419523
524+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 16000.
525+ *
526+ * - START trigger starts both the transmission and reception.
527+ * - Sending / receiving a short sequence of data returns success.
528+ * - DRAIN trigger empties the transmit queue and stops both streams.
529+ */
530+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_16000 )
531+ {
532+ int ret ;
533+
534+ frame_clk_freq = 16000 ;
535+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
536+ zassert_equal (ret , TC_PASS );
537+ i2s_dir_both_transfer_short ();
538+ }
539+
540+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 32000.
541+ *
542+ * - START trigger starts both the transmission and reception.
543+ * - Sending / receiving a short sequence of data returns success.
544+ * - DRAIN trigger empties the transmit queue and stops both streams.
545+ */
546+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_32000 )
547+ {
548+ int ret ;
549+
550+ frame_clk_freq = 32000 ;
551+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
552+ zassert_equal (ret , TC_PASS );
553+ i2s_dir_both_transfer_short ();
554+ }
555+
556+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 44000.
557+ *
558+ * - START trigger starts both the transmission and reception.
559+ * - Sending / receiving a short sequence of data returns success.
560+ * - DRAIN trigger empties the transmit queue and stops both streams.
561+ */
562+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_44000 )
563+ {
564+ int ret ;
565+
566+ frame_clk_freq = 44000 ;
567+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
568+ zassert_equal (ret , TC_PASS );
569+ i2s_dir_both_transfer_short ();
570+ }
571+
572+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 44100.
573+ *
574+ * - START trigger starts both the transmission and reception.
575+ * - Sending / receiving a short sequence of data returns success.
576+ * - DRAIN trigger empties the transmit queue and stops both streams.
577+ */
578+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_44100 )
579+ {
580+ int ret ;
581+
582+ frame_clk_freq = 44100 ;
583+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
584+ zassert_equal (ret , TC_PASS );
585+ i2s_dir_both_transfer_short ();
586+ }
587+
588+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 48000.
589+ *
590+ * - START trigger starts both the transmission and reception.
591+ * - Sending / receiving a short sequence of data returns success.
592+ * - DRAIN trigger empties the transmit queue and stops both streams.
593+ */
594+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_48000 )
595+ {
596+ int ret ;
597+
598+ frame_clk_freq = 48000 ;
599+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
600+ zassert_equal (ret , TC_PASS );
601+ i2s_dir_both_transfer_short ();
602+ }
603+
604+ /** @brief Short I2S transfer using I2S_DIR_BOTH and sample rate of 96000.
605+ *
606+ * - START trigger starts both the transmission and reception.
607+ * - Sending / receiving a short sequence of data returns success.
608+ * - DRAIN trigger empties the transmit queue and stops both streams.
609+ */
610+ ZTEST (drivers_i2s_speed_both_rxtx , test_i2s_dir_both_transfer_short_96000 )
611+ {
612+ int ret ;
613+
614+ frame_clk_freq = 96000 ;
615+ ret = configure_stream (dev_i2s_rxtx , I2S_DIR_BOTH );
616+ zassert_equal (ret , TC_PASS );
617+ i2s_dir_both_transfer_short ();
618+ }
619+
420620/** @brief Long I2S transfer using I2S_DIR_BOTH.
421621 *
422622 * - START trigger starts both the transmission and reception.
0 commit comments