@@ -51,9 +51,12 @@ static __aligned(16) char rx_data[TRANSFER_LOOPS][RX_BUFF_SIZE] = { { 0 } };
51
51
volatile uint8_t transfer_count ;
52
52
static struct dma_config dma_cfg = {0 };
53
53
static struct dma_block_config dma_block_cfg = {0 };
54
+ static int test_case_id ;
54
55
55
56
static void test_transfer (const struct device * dev , uint32_t id )
56
57
{
58
+ int res = 0 ;
59
+
57
60
transfer_count ++ ;
58
61
if (transfer_count < TRANSFER_LOOPS ) {
59
62
dma_block_cfg .block_size = strlen (tx_data );
@@ -66,6 +69,16 @@ static void test_transfer(const struct device *dev, uint32_t id)
66
69
zassert_false (dma_start (dev , id ),
67
70
"Not able to start next transfer %d" ,
68
71
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
+ }
69
82
}
70
83
}
71
84
@@ -90,6 +103,7 @@ static int test_loop(void)
90
103
const struct device * dma ;
91
104
static int chan_id ;
92
105
106
+ test_case_id = 0 ;
93
107
TC_PRINT ("DMA memory to memory transfer started on %s\n" ,
94
108
DMA_DEVICE_NAME );
95
109
TC_PRINT ("Preparing DMA Controller\n" );
@@ -176,6 +190,7 @@ static int test_loop_suspend_resume(void)
176
190
static int chan_id ;
177
191
int res = 0 ;
178
192
193
+ test_case_id = 1 ;
179
194
TC_PRINT ("DMA memory to memory transfer started on %s\n" ,
180
195
DMA_DEVICE_NAME );
181
196
TC_PRINT ("Preparing DMA Controller\n" );
@@ -235,17 +250,6 @@ static int test_loop_suspend_resume(void)
235
250
while (transfer_count == 0 ) {
236
251
}
237
252
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
-
249
253
TC_PRINT ("Sleeping while suspended\n" );
250
254
k_sleep (K_MSEC (SLEEPTIME ));
251
255
0 commit comments