HAL SDIO Use Cases

User application starting a driver with USE_HAL_SDIO_CLK_ENABLE_MODEL

@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 SDIO" 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 SDIO card

part1->part2 ++ : HAL_SDIO_Init()

note right: 2 instances availables : \n- SDMMC1 \n- SDMMC2

part2 --> part1

end



group #lightblue Global configuration

group #lightblue Use case 1

part1->part2 ++ : HAL_SDIO_SetConfig(&hsdio, &config, NULL)

note right: When using the NULL parameter in the HAL_SDIO_SetConfig(), \n the enumeration sequence to identify the SDIO module will be performed \n using the identification card function defined in the SDIO source file.

part2 --> part1

end



group #lightblue Use case 2

part1->part2 ++ : HAL_SDIO_SetConfig(&hsdio, &config, SDIO_IdentifyCard)

note right: The function HAL_SDIO_SetConfig(&hsdio, &config, SDIO_IdentifyCard) \n includes a custom function named SDIO_IdentifyCard to perform the identification \n phase for the SDIO module which properly registered and implemented by the user \n to handle the specific identification sequence of the SDIO card.

part2 --> part1

end

end



group #9898fb Optional : Set SDIO Card configuration

part1->part2 : HAL_SDIO_SetDataBusWidth()

note right: 2 wide bus mode availables : \n- 1-bit data transfer \n- 4-bit data transfer

part2 --> part1

part1->part2 : HAL_SDIO_SetClockFreq()

part2 --> part1

part1->part2 : HAL_SDIO_SetSpeedMode()

part2 --> part1

part1->part2 : HAL_SDIO_SetBlockSize()

note right: SDIO Data block size up to 2048B

part2 --> part1

end

@enduml

Called functions:

User application starting a driver without USE_HAL_SDIO_CLK_ENABLE_MODEL

@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 SDIO" 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



part1->part3 : HAL_RCC_SDMMCxEnableClock()

note right : The user need to enable the \n SDMMC clock througth RCC API.

end



group #lightsalmon Initialize SDIO card

part1->part2 ++ : HAL_SDIO_Init()

note right: 2 instances availables : \n- SDMMC1 \n- SDMMC2

part2 --> part1

end



group #lightblue Global configuration

part1->part2 ++ : HAL_SDIO_SetConfig()

part2 --> part1

end



group #9898fb Optional : Set SDIO Card configuration

part1->part2 : HAL_SDIO_SetDataBusWidth()

note right: 2 wide bus mode availables : \n- 1-bit data transfer \n- 4-bit data transfer

part2 --> part1

part1->part2 : HAL_SDIO_SetClockFreq()

part2 --> part1

part1->part2 : HAL_SDIO_SetSpeedMode()

part2 --> part1

part1->part2 : HAL_SDIO_SetBlockSize()

note right: SDIO Data block size up to 2048B

part2 --> part1

end

@enduml

Called functions:

User application starting an Extended Polling transfer using Block mode

@startuml

hide footbox

participant "User Application" as part1 

participant "Driver SDIO" 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 SDIO card

part1->part2 ++ : HAL_SDIO_Init()

note right: 2 instances availables : \n- SDMMC1 \n- SDMMC2

part2 --> part1

end



group #lightblue Global configuration

part1->part2 ++ : HAL_SDIO_SetConfig()

part2 --> part1

end



group #9898fb Optional :Set SDIO Block size



part1->part2 : HAL_SDIO_SetBlockSize(SDIO_DATA_BLOCK_SIZE_2048B)

note right: SDIO Data block size up to 2048B

part2 --> part1

end



group #9898fb Set SDIO Card Xfer process



part1->part2 : HAL_SDIO_WriteExtended()

part2 --> part1



part1->part2 : HAL_SDIO_ReadExtended()

part2 --> part1



part1->part1: Check the read memory vs written data memory



part1->part2 : HAL_SDIO_DeInit()

part2 --> part1

end

@enduml

Called functions:

User application starting an Extended DMA transfer using block mode

@startuml

hide footbox

participant "User Application" as part1

participant "SDIO Driver" as part2

participant "ISR" as part3



activate part1

activate part2



group #lightsalmon Initialize SDIO card

part1->part2 ++ : HAL_SDIO_Init()

note right: 2 instances availables : \n- SDMMC1 \n- SDMMC2

part2 --> part1

end



group #lightblue Global configuration

part1->part2 ++ : HAL_SDIO_SetConfig()

part2 --> part1

end



group #lightblue I/O Operation process



part1->part2 : HAL_SDIO_WriteExtended_DMA()

part2 --> part1

part3 -> part2 : HAL_SDIO_IRQHandler()

part2 -> part1 : Tx complete callback



part1->part2 : HAL_SDIO_ReadExtended_DMA()

part2--> part1

part3 -> part2 : HAL_SDIO_IRQHandler()

part2 -> part1 : Rx complete callback



end 

@enduml

Called functions:

Starting an Extended DMA transfer with enabling IO Function Interrupt

@startuml

hide footbox

participant "User Application" as part1

participant "SDIO Driver" as part2

participant "ISR" as part3



activate part1

activate part2



group #lightsalmon Initialize SDIO card

part1->part2 ++ : HAL_SDIO_Init()

note right: 2 instances availables : \n- SDMMC1 \n- SDMMC2

part2 --> part1

end



group #lightblue Global configuration

part1->part2 ++ : HAL_SDIO_SetConfig()

part2 --> part1

end





group #lightblue I/O Operation process

part1->part2 : HAL_SDIO_RegisterIOFunctionCallback(&hsdio, HAL_SDIO_FUNCTION_0, IO_Function_cb1)

note right: The SDIO driver register an IO callback function for function 0. \n And store in the parameter io_function_mask the Function number that has been registered.



part1->part2 : HAL_SDIO_RegisterIOFunctionCallback(&hsdio, HAL_SDIO_FUNCTION_2, IO_Function_cb2)

note right: The SDIO driver register an IO callback function for function 2. \n And store in the parameter io_function_mask the Function number that has been registered.



part1->part2 : HAL_SDIO_EnableIOFunctionInterrupt(&hsdio, HAL_SDIO_FUNCTION_0)

note right: Enbale IO function interrupt which are available and supported \n on the device (Function 0 to function 7). \n In this case, The user will enable the SDIO function 0. \n io_interrupt_nbr shall be incrementated by 1 and stored on the SDIO handle;

part2 --> part1



part1->part2 : HAL_SDIO_EnableIOFunctionInterrupt(&hsdio, HAL_SDIO_FUNCTION_2)

note right:  The user will enable the SDIO function 1. \n io_interrupt_nbr shall be incrementated by 1 and stored on the SDIO handle. \n now the io_interrupt_nbr is set to 2.

part2 --> part1



part1->part2 : HAL_SDIO_WriteExtended_DMA()

part2 --> part1

part3 -> part2 : HAL_SDIO_IRQHandler()

note right: Within the HAL_SDIO_IRQHandler, the SDMMC_FLAG_SDIOIT is generated, \n that means that an SDIO function interrupt will be generated \n and call the static function SDIO_IOFunction_IRQHandler within the SDIO IRQ. \n Then we call the IO callaback function with the io_function_mask to allow the user \n on the application to identify the IO function number that has been generated

part2 --> part1 : IO Function Callback with the specified IO function number.

part2 -> part1 : Tx complete callback



end 

@enduml

Called functions:

User application starting an Extended DMA transfer using block mode

@startuml

hide footbox

participant "User Application" as part1

participant "SDIO Driver" as part2

participant "ISR" as part3



activate part1

activate part2



group #lightsalmon Initialize SDIO card

part1->part2 ++ : HAL_SDIO_Init()

note right: 2 instances availables : \n- SDMMC1 \n- SDMMC2

part2 --> part1

end



group #lightblue Global configuration

part1->part2 ++ : HAL_SDIO_SetConfig()

part2 --> part1

end



group #lightblue I/O Operation process



part1->part2 : HAL_SDIO_WriteDirect()

note right: Example : Set the interrupt enable master(IENM) bit.\n when this bit is set, any function's \n interrupt shall be sent to the host. 

part2 --> part1



part1->part2 : HAL_SDIO_ReadDirect()

note right: Example : Check if the interrupt enable master bit has been set.

part2--> part1



part1 -> part1 : Check the read bit vs written bit



end 

@enduml

Called functions: