HAL MMC Use Cases

User application starting a driver

@startuml
hide footbox
' To add a number by line
'autonumber

' Fix order of each column
skinparam ParticipantPadding 40

participant "User Application" as part1 
participant "Driver MMC" as part2
participant "System" as part3

activate part1

group #9898fb Initializes the Flash interface and the Systick
part1->part3 : HAL_Init()
activate part3
part3 --> part1
deactivate part3
end

group #lightblue Configure the system clock
part1->part3 : SystemClock_Config()
activate part3
part3 --> part1
deactivate part3
end

group #lightsalmon Initialize MMC card
part1->part2 ++ : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2 \n SDMMC clock is enabled when USE_MMC_CLK_ENABLE_MODEL \n is set to HAL_CLK_ENABLE_PERIPH_ONLY
part2 --> part1
part1->part2 : MMC HW Initialisation and MMC NVIC configuration for SDMMC interrupts
part2 --> part1
end

group #9898fb Set MMC Card configuration
part1->part2 : HAL_MMC_SetConfig
part2 --> part1
end

group #lightblue <size:15>Optional</size> : Enable and configure the MMC delayblock with the maximum output clock phase
part1->part2 : HAL_MMC_CalculateDlybMaxClockPhase
part2 --> part1
note right: The max output clock phase will be used as parameter \n in HAL_MMC_SetConfigDlybDelay function.
part1->part2 : HAL_MMC_SetConfigDlybDelay
part2 --> part1

part1->part2 : HAL_MMC_EnableDlyb
note right: Enable the MMC delay block.
part2 --> part1
end

group #lightsalmon <size:15>Optional</size> : Enable and configure the MMC delayblock \n                  with an output clock phase chosen by the user
part1->part2 : HAL_MMC_SetConfigDlybDelay
part2 --> part1
note right: The user sets a desired output clock phase.
part1->part2 : HAL_MMC_EnableDlyb
part2 --> part1
end

group #lightblue <size:15>Optional</size> : Get MMC delayblock configuration
part1->part2 : HAL_MMC_GetDlybOutputClockPhase
note right: Get the MMC delay block output clock phase.
part2 --> part1
end

group #lightsalmon <size:15>Optional</size> : Disable the MMC delayblock peripheral
part1->part2 : HAL_MMC_DisableDlyb
note right:  Disable MMC the delay block peripheral.
part2 --> part1
end
@enduml

Called functions:

User application starting a Polling transfer mode

@startuml
hide footbox
participant "User Application" as part1
participant "MMC Driver" as part2

activate part1
activate part2

group #lightsalmon Initialize MMC card
part1->part2 : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2
part2 --> "part1"
end

group #9898fb Set MMC Card configuration
"part1"->part2 : HAL_MMC_SetConfig()
part2 --> "part1"
end


group #lightblue I/O Operation process
part1->part2 : HAL_MMC_Erase()
part2 --> "part1" : Erase Completed

part1->part2 : HAL_MMC_WriteBlocks()
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in \n HAL_MMC_CARD_TRANSFER

part1->part2 : HAL_MMC_ReadBlocks()
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in \n HAL_MMC_CARD_TRANSFER
end
@enduml

Called functions:

User application starting a DMA transfer mode

@startuml
hide footbox
participant "User Application" as part1
participant "MMC Driver" as part2
participant "ISR" as part3

activate part1
activate part2

group #lightsalmon MMC Card initialization
part1->part2 : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2
part2 --> part1
end

group #9898fb MMC Card configuration
part1->part2 : HAL_MMC_SetConfig()
part2 --> part1
end


group #lightblue I/O Operation process
part1->part2 : HAL_MMC_Erase()
part2 --> part1: Erase completed

part1->part2 : HAL_MMC_WriteBlocks_DMA()
part2 --> part1
part3 -> part2 : HAL_MMC_IRQ_HANDLER()
part2 -> part1 : Notify the User application with Transfer complete
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in \n HAL_MMC_CARD_TRANSFER


part1->part2 : HAL_MMC_ReadBlocks_DMA()
part2--> part1
part3 -> part2 : HAL_MMC_IRQ_HANDLER()
part2 -> part1 : Notify the User application with Transfer complete
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in \n HAL_MMC_CARD_TRANSFER
end
@enduml

Called functions:

User application starting a IT transfer mode

@startuml
hide footbox
participant "User Application" as part1
participant "MMC Driver" as part2
participant "ISR" as part3

activate part1
activate part2

group #lightsalmon MMC Card initialization
part1->part2 : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2
part2 --> part1
end

group #9898fb MMC Card configuration
part1->part2 : HAL_MMC_SetConfig
part2 --> part1
end


group #lightblue I/O Operation process
part1->part2 : HAL_MMC_Erase()
part2 --> part1: Erase completed

part1->part2 : HAL_MMC_WriteBlocks_IT()
part2-->part1

part3 -> part2 : HAL_MMC_IRQ_HANDLER()
part2 -> part1 : Notify the User application with Transfer complete
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be \n in  HAL_MMC_CARD_TRANSFER

part1->part2 : HAL_MMC_ReadBlocks_IT()
part3 -> part2 : HAL_MMC_IRQ_HANDLER()
part2 -> part1 : Notify the User application with Transfer complete
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in \n HAL_MMC_CARD_TRANSFER
end
@enduml

Called functions:

User application starting a LINKED-LIST transfer mode

@startuml
hide footbox
participant "User Application" as part1
participant "MMC Driver" as part2
participant "ISR" as part3
participant "Q Driver" as part4

activate part1
activate part2

group #FFB133 Q Building
  group #lightblue Mandatory
    part1->part2 : HAL_MMC_FillNodeConfig(&MMC_Node_Conf, &MMC_N1);
    note right : Build an SDMMC Node according to \n configured parameters within hal_mmc_node_config_t structure
  end

  group #lightblue Mandatory
    part1->part4 : HAL_Q_Init(..., <b>&HAL_MMC_DescOps)
    note right : Q initialization according to \n MMC descriptor operation constant
  end
  group #lightblue Mandatory
    part1->part4 : HAL_Q_InsertNode() / HAL_Q_InsertNode_Head() / HAL_Q_InsertNode_Tail()
    note right : this operation can be repeated according \n to the Q node number to be inserted
    end
end

group #lightsalmon MMC Card initialization
part1->part2 : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2
part2 --> part1
end

group #9898fb MMC Card configuration
part1->part2 : HAL_MMC_SetConfig
part2 --> part1
end


group #lightblue I/O Operation process
part1->part2 : HAL_MMC_Erase()
part2 --> part1: Erase completed

part1->part2 : HAL_MMC_WriteBlocks_LinkedList()
part2-->part1

part3 -> part2 : HAL_MMC_IRQ_HANDLER()
part2 -> part1 : Notify the User application with Transfer complete
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in  HAL_MMC_CARD_TRANSFER

part1->part2 : HAL_MMC_ReadBlocks_LinkedList()
part3 -> part2 : HAL_MMC_IRQ_HANDLER()
part2 -> part1 : Notify the User application with Transfer complete
part1->part1 : Wait for the Card Transfer status using API HAL_MMC_GetCardState()
note right: The MMC Card status shall be in  HAL_MMC_CARD_TRANSFER
end
@enduml

Called functions:

MMC Card Insertion/Removal Use case

@startuml
hide footbox
participant "User Application" as part1
participant "MMC Driver" as part2
participant "ISR" as part3

activate part1
activate part2

group #lightsalmon MMC Card initialization
part1->part2 : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2
part2 --> part1
end


group #9898fb MMC Card configuration
part1->part2 : HAL_MMC_SetConfig
part2 --> part1
end


group #9898fb Use Case when Detect the removal of an MMC Card
part3 -> part1 : Notify the User application That the MMC card has been removed
part1->part2 : HAL_MMC_NotifyCardRemoval()
note right: According to the MMC specification, set the default SDMMC configuration \n to be ready for a new card insertion
part2 --> part1
end

group #9898fb Use Case when Detect the insertion of an MMC Card
part3 -> part1 : Notify the User application That the MMC card has been inserted

part1->part2 : HAL_MMC_NotifyCardInsertion()
note right: Apply user configuration once MMC card inserted
part2 --> part1
end
@enduml

Called functions:

MMC Card Replay Protected Memory Block management

@startuml
hide footbox
participant "User Application" as part1
participant "MMC Driver" as part2
participant "ISR" as part3

activate part1
activate part2

group #lightsalmon MMC Card initialization
part1->part2 : HAL_MMC_Init()
note right: 2 instances availables : \n- HAL_MMC_CARD_1 \n- HAL_MMC_CARD_2
part2 --> part1
end


group #9898fb MMC Card configuration
part1->part2 : HAL_MMC_SetConfig
part2 --> part1
end

group #9898fb Replay Protected Memory Block management

part1 --> part2 : HAL_MMC_SelectPartitionArea(HAL_MMC_RPMB_AREA_PARTITION)
part2 --> part1

group #1790fb Program Authentication key
part1->part2 : HAL_MMC_ProgramRPMBAuthenticationKey()
note right: This step shall be one time programmable
part2 --> part1
end

part1->part2 : HAL_MMC_GetRPMBWriteCounter()
part2 --> part1

part1 --> part1: Generate the MAC for the data to be written. \n The MAC ensure the integrity and authenticity of the data. \n The user can use the HAL HASH driver.

part1 --> part2 : HAL_MMC_WriteRPMBBlocks()
part2 --> part1

part1 --> part2 : HAL_MMC_ReadRPMBBlocks()
part2 --> part1
end
@enduml

Called functions: