@@ -350,7 +350,8 @@ static int dma_stm32_configure(const struct device *dev,
350
350
struct dma_stm32_stream * stream =
351
351
& dev_config -> streams [id - STM32_DMA_STREAM_OFFSET ];
352
352
DMA_TypeDef * dma = (DMA_TypeDef * )dev_config -> base ;
353
- LL_DMA_InitTypeDef DMA_InitStruct ;
353
+ uint32_t ll_priority ;
354
+ uint32_t ll_direction ;
354
355
int ret ;
355
356
356
357
/* Linked list Node and structure initialization */
@@ -360,7 +361,6 @@ static int dma_stm32_configure(const struct device *dev,
360
361
361
362
LL_DMA_ListStructInit (& DMA_InitLinkedListStruct );
362
363
LL_DMA_NodeStructInit (& NodeConfig );
363
- LL_DMA_StructInit (& DMA_InitStruct );
364
364
365
365
/* Give channel from index 0 */
366
366
id = id - STM32_DMA_STREAM_OFFSET ;
@@ -431,31 +431,32 @@ static int dma_stm32_configure(const struct device *dev,
431
431
LOG_WRN ("dest_buffer address is null." );
432
432
}
433
433
434
- DMA_InitStruct .SrcAddress = config -> head_block -> source_address ;
435
- DMA_InitStruct .DestAddress = config -> head_block -> dest_address ;
434
+ LL_DMA_ConfigAddresses (dma , dma_stm32_id_to_stream (id ), config -> head_block -> source_address ,
435
+ config -> head_block -> dest_address );
436
+
436
437
NodeConfig .SrcAddress = config -> head_block -> source_address ;
437
438
NodeConfig .DestAddress = config -> head_block -> dest_address ;
438
439
NodeConfig .BlkDataLength = config -> head_block -> block_size ;
439
440
440
- ret = dma_stm32_get_priority (config -> channel_priority ,
441
- & DMA_InitStruct .Priority );
441
+ ret = dma_stm32_get_priority (config -> channel_priority , & ll_priority );
442
442
if (ret < 0 ) {
443
443
return ret ;
444
444
}
445
+ LL_DMA_SetChannelPriorityLevel (dma , dma_stm32_id_to_stream (id ), ll_priority );
445
446
446
- ret = dma_stm32_get_direction (config -> channel_direction ,
447
- & DMA_InitStruct .Direction );
447
+ ret = dma_stm32_get_direction (config -> channel_direction , & ll_direction );
448
448
if (ret < 0 ) {
449
449
return ret ;
450
450
}
451
+ LL_DMA_SetDataTransferDirection (dma , dma_stm32_id_to_stream (id ), ll_direction );
451
452
452
453
/* This part is for source */
453
454
switch (config -> head_block -> source_addr_adj ) {
454
455
case DMA_ADDR_ADJ_INCREMENT :
455
- DMA_InitStruct . SrcIncMode = LL_DMA_SRC_INCREMENT ;
456
+ LL_DMA_SetSrcIncMode ( dma , dma_stm32_id_to_stream ( id ), LL_DMA_SRC_INCREMENT ) ;
456
457
break ;
457
458
case DMA_ADDR_ADJ_NO_CHANGE :
458
- DMA_InitStruct . SrcIncMode = LL_DMA_SRC_FIXED ;
459
+ LL_DMA_SetSrcIncMode ( dma , dma_stm32_id_to_stream ( id ), LL_DMA_SRC_FIXED ) ;
459
460
break ;
460
461
case DMA_ADDR_ADJ_DECREMENT :
461
462
return - ENOTSUP ;
@@ -464,16 +465,16 @@ static int dma_stm32_configure(const struct device *dev,
464
465
config -> head_block -> source_addr_adj );
465
466
return - EINVAL ;
466
467
}
467
- LOG_DBG ("Channel (%d) src inc (%x)." ,
468
- id , DMA_InitStruct . SrcIncMode );
468
+ LOG_DBG ("Channel (%d) src inc (%x)." , id ,
469
+ LL_DMA_GetSrcIncMode ( dma , dma_stm32_id_to_stream ( id )) );
469
470
470
471
/* This part is for dest */
471
472
switch (config -> head_block -> dest_addr_adj ) {
472
473
case DMA_ADDR_ADJ_INCREMENT :
473
- DMA_InitStruct . DestIncMode = LL_DMA_DEST_INCREMENT ;
474
+ LL_DMA_SetDestIncMode ( dma , dma_stm32_id_to_stream ( id ), LL_DMA_DEST_INCREMENT ) ;
474
475
break ;
475
476
case DMA_ADDR_ADJ_NO_CHANGE :
476
- DMA_InitStruct . DestIncMode = LL_DMA_DEST_FIXED ;
477
+ LL_DMA_SetDestIncMode ( dma , dma_stm32_id_to_stream ( id ), LL_DMA_DEST_FIXED ) ;
477
478
break ;
478
479
case DMA_ADDR_ADJ_DECREMENT :
479
480
return - ENOTSUP ;
@@ -482,35 +483,35 @@ static int dma_stm32_configure(const struct device *dev,
482
483
config -> head_block -> dest_addr_adj );
483
484
return - EINVAL ;
484
485
}
485
- LOG_DBG ("Channel (%d) dest inc (%x)." ,
486
- id , DMA_InitStruct . DestIncMode );
486
+ LOG_DBG ("Channel (%d) dest inc (%x)." , id ,
487
+ LL_DMA_GetDestIncMode ( dma , dma_stm32_id_to_stream ( id )) );
487
488
488
489
stream -> source_periph = (stream -> direction == PERIPHERAL_TO_MEMORY );
489
490
490
491
/* Set the data width, when source_data_size equals dest_data_size */
491
492
int index = find_lsb_set (config -> source_data_size ) - 1 ;
492
493
493
- DMA_InitStruct . SrcDataWidth = table_src_size [index ];
494
+ LL_DMA_SetSrcDataWidth ( dma , dma_stm32_id_to_stream ( id ), table_src_size [index ]) ;
494
495
495
496
index = find_lsb_set (config -> dest_data_size ) - 1 ;
496
- DMA_InitStruct . DestDataWidth = table_dst_size [index ];
497
+ LL_DMA_SetDestDataWidth ( dma , dma_stm32_id_to_stream ( id ), table_dst_size [index ]) ;
497
498
498
- DMA_InitStruct . BlkDataLength = config -> head_block -> block_size ;
499
+ LL_DMA_SetBlkDataLength ( dma , dma_stm32_id_to_stream ( id ), config -> head_block -> block_size ) ;
499
500
500
501
/* The request ID is stored in the dma_slot */
501
- DMA_InitStruct . Request = config -> dma_slot ;
502
+ LL_DMA_SetPeriphRequest ( dma , dma_stm32_id_to_stream ( id ), config -> dma_slot ) ;
502
503
503
504
if (config -> head_block -> source_reload_en == 0 ) {
504
505
/* Initialize the DMA structure in non-cyclic mode only */
505
- LL_DMA_Init (dma , dma_stm32_id_to_stream (id ), & DMA_InitStruct );
506
+ LL_DMA_SetLinkedListAddrOffset (dma , dma_stm32_id_to_stream (id ), 0 );
506
507
} else {/* cyclic mode */
507
508
/* Setting GPDMA request */
508
- NodeConfig .DestDataWidth = DMA_InitStruct . DestDataWidth ;
509
- NodeConfig .SrcDataWidth = DMA_InitStruct . SrcDataWidth ;
510
- NodeConfig .DestIncMode = DMA_InitStruct . DestIncMode ;
511
- NodeConfig .SrcIncMode = DMA_InitStruct . SrcIncMode ;
512
- NodeConfig .Direction = DMA_InitStruct . Direction ;
513
- NodeConfig .Request = DMA_InitStruct . Request ;
509
+ NodeConfig .DestDataWidth = table_dst_size [ index ] ;
510
+ NodeConfig .SrcDataWidth = table_src_size [ index ] ;
511
+ NodeConfig .DestIncMode = LL_DMA_GetDestIncMode ( dma , dma_stm32_id_to_stream ( id )) ;
512
+ NodeConfig .SrcIncMode = LL_DMA_GetSrcIncMode ( dma , dma_stm32_id_to_stream ( id )) ;
513
+ NodeConfig .Direction = ll_direction ;
514
+ NodeConfig .Request = config -> dma_slot ;
514
515
515
516
/* Continuous transfers with Linked List */
516
517
stream -> cyclic = true;
0 commit comments