@@ -51,9 +51,12 @@ static __aligned(16) char rx_data[TRANSFER_LOOPS][RX_BUFF_SIZE] = { { 0 } };
5151volatile uint8_t transfer_count ;
5252static struct dma_config dma_cfg = {0 };
5353static struct dma_block_config dma_block_cfg = {0 };
54+ static int test_case_id ;
5455
5556static void test_transfer (const struct device * dev , uint32_t id )
5657{
58+ int res = 0 ;
59+
5760 transfer_count ++ ;
5861 if (transfer_count < TRANSFER_LOOPS ) {
5962 dma_block_cfg .block_size = strlen (tx_data );
@@ -66,6 +69,16 @@ static void test_transfer(const struct device *dev, uint32_t id)
6669 zassert_false (dma_start (dev , id ),
6770 "Not able to start next transfer %d" ,
6871 transfer_count + 1 );
72+ if (test_case_id == 1 ) {
73+ res = dma_suspend (dev , id );
74+ if (res == - ENOSYS ) {
75+ TC_PRINT ("dma suspend not supported\n" );
76+ dma_stop (dev , id );
77+ } else if (res != 0 ) {
78+ TC_PRINT ("ERROR: suspend failed, channel %d, result %d\n" , id , res );
79+ }
80+ test_case_id = 2 ;
81+ }
6982 }
7083}
7184
@@ -90,6 +103,7 @@ static int test_loop(void)
90103 const struct device * dma ;
91104 static int chan_id ;
92105
106+ test_case_id = 0 ;
93107 TC_PRINT ("DMA memory to memory transfer started on %s\n" ,
94108 DMA_DEVICE_NAME );
95109 TC_PRINT ("Preparing DMA Controller\n" );
@@ -176,6 +190,7 @@ static int test_loop_suspend_resume(void)
176190 static int chan_id ;
177191 int res = 0 ;
178192
193+ test_case_id = 1 ;
179194 TC_PRINT ("DMA memory to memory transfer started on %s\n" ,
180195 DMA_DEVICE_NAME );
181196 TC_PRINT ("Preparing DMA Controller\n" );
@@ -235,17 +250,6 @@ static int test_loop_suspend_resume(void)
235250 while (transfer_count == 0 ) {
236251 }
237252
238- res = dma_suspend (dma , chan_id );
239- TC_PRINT ("Suspended transfers\n" );
240- if (res == - ENOSYS ) {
241- TC_PRINT ("dma suspend not supported\n" );
242- dma_stop (dma , chan_id );
243- return TC_PASS ;
244- } else if (res != 0 ) {
245- TC_PRINT ("ERROR: suspend failed, channel %d, result %d\n" , chan_id , res );
246- return TC_FAIL ;
247- }
248-
249253 TC_PRINT ("Sleeping while suspended\n" );
250254 k_sleep (K_MSEC (SLEEPTIME ));
251255
0 commit comments