HAL MMC Functions

Initialization and de-initialization functions

group MMC_Exported_Functions_Group1

This section provides functions allowing to initialize/de-initialize the MMC card device :

  • Call the function HAL_MMC_Init() to initialize the selected HAL MMC handle and associate an MMC peripheral instance.

  • Call the function HAL_MMC_DeInit() to de-initialize the MMC card device.

Functions

hal_status_t HAL_MMC_Init ( hal_mmc_handle_t * hmmc , hal_mmc_t instance )

Initialize the selected HAL MMC handle and associate an MMC peripheral instance.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – MMC handle has been correctly Initialized.

void HAL_MMC_DeInit ( hal_mmc_handle_t * hmmc )

De-Initialize the MMC card.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Set and Get configurations functions

group MMC_Exported_Functions_Group2

This subsection provides a set of functions allowing to configure the MMC peripheral:

There are 2 categories of HAL configuration APIs:

Functions

hal_status_t HAL_MMC_SetConfig ( hal_mmc_handle_t * hmmc , const hal_mmc_config_t * p_config )

Configure the MMC according to the user parameters.

Parameters :
Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – MMC instance is already configured and cannot be modified.

  • HAL_OK – MMC instance has been correctly configured.

void HAL_MMC_GetConfig ( hal_mmc_handle_t * hmmc , hal_mmc_config_t * p_config )

Get the MMC configuration.

Parameters :
hal_status_t HAL_MMC_NotifyCardInsertion ( hal_mmc_handle_t * hmmc , const hal_mmc_config_t * p_config )

Notify MMC card after insertion.

Parameters :
Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_OK – MMC instance has been correctly configured after detection.

hal_status_t HAL_MMC_NotifyCardRemoval ( hal_mmc_handle_t * hmmc )

Notify MMC card after removal.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

HAL_OK – MMC card has been correctly re-configured with its default configuration.

hal_status_t HAL_MMC_SwitchSpeedMode ( hal_mmc_handle_t * hmmc , hal_mmc_speed_mode_t speed_mode )

Configure the speed bus mode.

Parameters :
Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_SetDataTimeout ( hal_mmc_handle_t * hmmc , uint32_t data_timeout_cycle )

Set MMC data timeout.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • data_timeout_cycle – MMC data timeout cycle.

Return values :

HAL_OK – MMC card has been correctly set the data timeout cycle value in millisecond.

uint32_t HAL_MMC_GetDataTimeout ( const hal_mmc_handle_t * hmmc )

Get MMC data timeout.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

uint32_t – data_timeout_cycle value in millisecond.

hal_status_t HAL_MMC_SetStopXferTimeout ( hal_mmc_handle_t * hmmc , uint32_t stopxfer_timeout_ms )

Set MMC stop transfer timeout.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • stopxfer_timeout_ms – MMC stop xfer timeout in millisecond.

Return values :

HAL_OK – When the MMC card correctly sets the stop xfer timeout in millisecond.

uint32_t HAL_MMC_GetStopXferTimeout ( const hal_mmc_handle_t * hmmc )

Get MMC stop transfer timeout.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

uint32_t – stop_xfer_timeout_ms Stop xfer timeout value in millisecond.

hal_status_t HAL_MMC_SetEraseTimeout ( hal_mmc_handle_t * hmmc , uint32_t erase_timeout_ms )

Set MMC erase timeout.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • erase_timeout_ms – MMC erase timeout in millisecond.

Return values :

HAL_OK – When the MMC card correctly sets the erase timeout value in millisecond.

uint32_t HAL_MMC_GetEraseTimeout ( const hal_mmc_handle_t * hmmc )

Get MMC erase timeout.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

uint32_t – erase_timeout_ms Erase timeout value in millisecond.

uint32_t HAL_MMC_GetClockFreq ( const hal_mmc_handle_t * hmmc )

Return the peripheral clock frequency for MMC card.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

uint32_t – Frequency in Hz. 0 if the source clock of the MMC is not configured or not ready.

Input and Output operation functions

group MMC_Exported_Functions_Group3

This subsection provides a set of functions allowing to manage the data transfer from/to MMC card.

There are 4 categories of HAL functions APIs to manage the data transfer:

There are 2 categories of HAL functions APIs to abort transfer data:

Functions

hal_status_t HAL_MMC_Erase ( hal_mmc_handle_t * hmmc , uint32_t start_block_addr , uint32_t end_block_addr )

Erase the specified memory area of the given MMC card.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • start_block_addr – Start Block address.

  • end_block_addr – End Block address.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_ReadBlocks ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr , uint32_t timeout_ms )

Read block(s) from a specified address in a card. The Data transfer is managed by polling mode.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that must contain the received data.

  • block_addr – Block Address from where data is to be read.

  • blocks_nbr – Number of MMC blocks to read.

  • timeout_ms – Timeout value in millisecond.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_WriteBlocks ( hal_mmc_handle_t * hmmc , const uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr , uint32_t timeout_ms )

Write block(s) to a specified address in a card. The Data transfer is managed by polling mode.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that must contain the data to transmit.

  • block_addr – Block Address where data must be written.

  • blocks_nbr – Number of MMC blocks to write.

  • timeout_ms – Timeout value in millisecond.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_ReadBlocks_IT ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr )

Read block(s) from a specified address in a card. The Data transfer is managed in interrupt mode.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Warning

It could also check the IT transfer process through the MMC Rx interrupt event.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that must contain the received data.

  • block_addr – Block Address from where data is to be read.

  • blocks_nbr – Number of blocks to read.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_WriteBlocks_IT ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr )

Write block(s) to a specified address in a card. The Data transfer is managed in interrupt mode.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Warning

It could also check the IT transfer process through the MMC Tx interrupt event.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that must contain the data to transmit.

  • block_addr – Block Address where data must be written.

  • blocks_nbr – Number of blocks to write.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_ReadBlocks_DMA ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr )

Read block(s) from a specified address in a card. The Data transfer is managed by DMA mode.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Warning

It could also check the DMA transfer process through the MMC Rx interrupt event.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that must contain the received data.

  • block_addr – Block Address from where data is to be read.

  • blocks_nbr – Number of blocks to read.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_WriteBlocks_DMA ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr )

Write block(s) to a specified address in a card. The Data transfer is managed by DMA mode.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Warning

It could also check the DMA transfer process through the MMC Tx interrupt event.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that must contain the data to transmit.

  • block_addr – Block Address where data must be written.

  • blocks_nbr – Number of blocks to write.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_ReadBlocks_LinkedList ( hal_mmc_handle_t * hmmc , uint32_t block_addr , uint32_t blocks_nbr , const hal_q_t * p_q )

Read block(s) from a specified address in a card. The received Data must be stored in linked list buffers.

Note

linked list must be prepared before calling this function.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • block_addr – Block Address from where data is to be read.

  • blocks_nbr – Total number of blocks to read.

  • p_q – Pointer to a hal_q_t structure that contains the configuration information for the Q.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_WriteBlocks_LinkedList ( hal_mmc_handle_t * hmmc , uint32_t block_addr , uint32_t blocks_nbr , const hal_q_t * p_q )

Write block(s) to a specified address in a card. The transferred Data are stored linked list nodes buffers.

Note

Linked list must be prepared before calling this function.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • block_addr – Block Address from where data is to be read.

  • blocks_nbr – Total number of blocks to read.

  • p_q – Pointer to a hal_q_t structure that contains the configuration information for the Q.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_Abort ( hal_mmc_handle_t * hmmc )

Abort the current transfer and disable the MMC.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_Abort_IT ( hal_mmc_handle_t * hmmc )

Abort the current transfer and disable the MMC (IT mode).

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

IRQHandler and Callbacks Functions

group MMC_Exported_Functions_Group4

This subsection provides a set of callback functions allowing to manage the data transfer from/to MMC card.

Functions

void HAL_MMC_IRQHandler ( hal_mmc_handle_t * hmmc )

This function handles MMC card interrupt request.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

void HAL_MMC_XferCpltCallback ( hal_mmc_handle_t * hmmc , hal_mmc_event_cb_t cb_event )

Xfer Transfer completed callbacks.

Parameters :
void HAL_MMC_ErrorCallback ( hal_mmc_handle_t * hmmc )

MMC error callbacks.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

void HAL_MMC_AbortCallback ( hal_mmc_handle_t * hmmc )

MMC Abort callbacks.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

hal_status_t HAL_MMC_RegisterXferCpltCallback ( hal_mmc_handle_t * hmmc , hal_mmc_xfer_cb_t callback )

Register the MMC Xfer Callback to be used instead of the weak HAL_MMC_XferCpltCallback predefined callback.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • callback – Pointer to the Callback function.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – Operation completed successfully.

hal_status_t HAL_MMC_RegisterErrorCpltCallback ( hal_mmc_handle_t * hmmc , hal_mmc_cb_t callback )

Register the MMC Error Callback to be used instead of the weak HAL_MMC_ErrorCallback predefined callback.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • callback – Pointer to the Callback function.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – Operation completed successfully.

hal_status_t HAL_MMC_RegisterAbortCpltCallback ( hal_mmc_handle_t * hmmc , hal_mmc_cb_t callback )

Register the MMC Abort Callback to be used instead of the weak HAL_MMC_AbortCallback predefined callback.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • callback – Pointer to the Callback function.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – Operation completed successfully.

Peripheral Erase management

group MMC_Exported_Functions_Group8

This subsection provides a set of functions allowing the peripheral erase management.

Functions

hal_status_t HAL_MMC_EraseSequence ( hal_mmc_handle_t * hmmc , hal_mmc_erase_type_t erase_type , uint32_t start_block_addr , uint32_t end_block_addr )

Perform specific commands sequence for the different type of erase.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • erase_type – Specifies the type of erase to be performed. This parameter can be one of hal_mmc_erase_type_t group.

  • start_block_addr – Start Block address.

  • end_block_addr – End Block address.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_Sanitize ( hal_mmc_handle_t * hmmc )

Perform sanitize operation on the device.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_SetSecureRemovalType ( hal_mmc_handle_t * hmmc , hal_mmc_secure_removal_type_t sec_removal_type )

Configure the Secure Removal Type (SRT) in the Extended CSD register.

Warning

This API must be followed by a check on the card state through HAL_MMC_GetCardState() .

Parameters :
Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_mmc_secure_removal_type_t HAL_MMC_GetSecureRemovalType ( const hal_mmc_handle_t * hmmc )

Get the supported values of the Secure Removal Type (SRT).

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

HAL – mmc secure removal type.

Peripheral low power management

group MMC_Exported_Functions_Group9

This subsection provides a set of functions allowing the control the sleep management.

Functions

hal_status_t HAL_MMC_EnterCardSleepMode ( hal_mmc_handle_t * hmmc )

Switch the device from Standby State to Sleep State.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

hal_status_t HAL_MMC_ExitCardSleepMode ( hal_mmc_handle_t * hmmc )

Exit the device from Sleep State to Standby State.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – Operation completed.

Linked-List Queue functions

group MMC_Exported_Functions_Group10

This subsection provides a set of functions allowing to manage the MMC linked-list node and queue:

Functions

hal_status_t HAL_MMC_FillNodeConfig ( hal_mmc_node_t * p_node , void * p_buffer , uint32_t size_byte )

Build Linked List node.

Parameters :
  • p_node – Pointer to new node to build.

  • p_buffer – Pointer to buffer node.

  • size_byte – size of the node in byte.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – Operation completed.

void HAL_MMC_GetNodeConfig ( const hal_mmc_node_t * p_node , uint32_t * p_buffer , uint32_t * p_size_byte )

Get the MMC node configuration.

Parameters :
  • p_node – Pointer to hal_mmc_node_t node structure.

  • p_buffer – Pointer to buffer node.

  • p_size_byte – Pointer to the size of the node in byte.

Return values :

None.

hal_status_t HAL_MMC_SetNodeDataBufferState ( const hal_mmc_node_t * p_node , hal_mmc_node_state_t state )

Set MMC linked list node data buffer state.

Parameters :
  • p_node – Pointer to node.

  • state – Node state.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – Operation completed.

hal_mmc_node_state_t HAL_MMC_GetNodeDataBufferState ( const hal_mmc_node_t * p_node )

Get MMC linked list node data buffer state.

Parameters :

p_node – Pointer to node.

Return values :
  • HAL_MMC_DATA_BUFFER_NOT_READY – MMC Data buffer node is not ready.

  • HAL_MMC_DATA_BUFFER_READY – MMC Data buffer node is ready.

void HAL_MMC_GetNodeInfo ( uint32_t * next_offset_addr , hal_q_addressing_mode_t * p_addressing_mode )

Get MMC Card Node information.

Parameters :
  • next_offset_addr – next node address offset.

  • p_addressing_mode – node addressing mode.

void HAL_MMC_SetNodeAddress ( uint32_t head_node_addr , uint32_t prev_node_addr , uint32_t next_node_addr , uint32_t node_addr_offset )

Set MMC Card node address.

Parameters :
  • head_node_addr – Head node address.

  • prev_node_addr – Previous node address.

  • next_node_addr – Next node address.

  • node_addr_offset – Node address offset.

uint32_t HAL_MMC_GetNodeAddress ( uint32_t head_node_addr , uint32_t current_node_addr , uint32_t node_addr_offset )

Get MMC Card node address.

Parameters :
  • head_node_addr – Head node address.

  • current_node_addr – Current node address.

  • node_addr_offset – Node address offset.

Return values :

SDMMC – node address.

MMC Delay Block functions

group MMC_Exported_Functions_Group11

This subsection provides a set of functions allowing to configure the delay block:

Functions

hal_status_t HAL_MMC_SetConfigDlybDelay ( const hal_mmc_handle_t * hmmc , uint32_t clock_phase_value )

Set the MMC delay block configuration.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • clock_phase_value – The selected output clock phase value to be stored.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_OK – The delay is correctly set.

hal_status_t HAL_MMC_GetDlybOutputClockPhase ( const hal_mmc_handle_t * hmmc , uint32_t * p_clock_phase )

Get the MMC delay block output clock phase.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_clock_phase – Pointer to the variable where the selected output clock phase value to be stored.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – The delay is correctly fitted.

hal_status_t HAL_MMC_CalculateDlybMaxClockPhase ( hal_mmc_handle_t * hmmc , uint32_t * p_max_clock_phase )

Calculate the MMC delay block maximum output clock phase.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_max_clock_phase – Pointer to the variable where the maximum clock phase value to be stored.

Return values :
  • HAL_INVALID_PARAM – Invalid p_max_clock_phase parameter.

  • HAL_ERROR – The max clock phase is not correctly calculated.

  • HAL_BUSY – Concurrent process ongoing.

  • HAL_OK – The max clock phase is correctly calculated.

hal_status_t HAL_MMC_EnableDlyb ( hal_mmc_handle_t * hmmc )

Enable the MMC delay block.

Parameters :

hmmc – Pointer to a hal_mm_handle_t structure.

Return values :

HAL_OK – The delay block is enabled.

hal_status_t HAL_MMC_DisableDlyb ( hal_mmc_handle_t * hmmc )

Disable the MMC delay block.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_OK – The delay block is disabled.

hal_mmc_dlyb_state_t HAL_MMC_IsEnabledDlyb ( hal_mmc_handle_t * hmmc )

Check if the delay block peripheral is enabled or not.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :
  • HAL_MMC_DLYB_DISABLED – Delay block is disabled.

  • HAL_MMC_DLYB_ENABLED – Delay block is enabled.

MMC Replay Protected Memory Block management (RPMB)

group MMC_Exported_Functions_Group13

This subsection provides a set of functions for managing the Replay Protected Memory Block (RPMB).

Functions

hal_status_t HAL_MMC_SelectPartitionArea ( hal_mmc_handle_t * hmmc , hal_mmc_area_partition_t area_partition )

Switch to the selected MMC partition.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • area_partition – The MMC partition area to be selected.

Return values :
  • HAL_ERROR – An error has occurred.

  • HAL_OK – The partition area was selected successfully.

hal_status_t HAL_MMC_ProgramRPMBAuthenticationKey ( hal_mmc_handle_t * hmmc , const uint8_t * p_key , uint32_t timeout_ms )

Program the authentication key within the RPMB partition.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure

  • p_key – Pointer to the authentication key (32 bytes)

  • timeout_ms – Timeout value in millisecond

Return values :
  • HAL_INVALID_PARAM – Invalid p_key parameter.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_ERROR – An error has occurred.

  • HAL_OK – Operation completed successfully.

hal_status_t HAL_MMC_GetRPMBWriteCounter ( hal_mmc_handle_t * hmmc , uint8_t * p_nonce , uint32_t * p_write_counter , uint32_t timeout_ms )

Get the value of write counter within the RPMB partition.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_nonce – Pointer to the value of nonce (16 bytes)

  • p_write_counter – Pointer to the write counter to read (4 bytes)

  • timeout_ms – Timeout value in millisecond.

Return values :
  • HAL_INVALID_PARAM – Invalid p_write_counter parameter.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_ERROR – An error has occurred.

  • HAL_OK – Operation completed successfully.

hal_status_t HAL_MMC_WriteRPMBBlocks ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr , uint8_t * p_mac , uint32_t timeout_ms )

Write block(s) to a specified address in the RPMB partition in polling mode.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer containing the data to transmit.

  • block_addr – Block Address where data will be written.

  • blocks_nbr – Number of blocks to write.

  • p_mac – Pointer to the authentication MAC buffer.

  • timeout_ms – Timeout value in millisecond.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_ERROR – An error has occurred.

  • HAL_OK – Operation completed successfully.

hal_status_t HAL_MMC_ReadRPMBBlocks ( hal_mmc_handle_t * hmmc , uint8_t * p_data , uint32_t block_addr , uint32_t blocks_nbr , uint8_t * p_nonce , uint8_t * p_mac , uint32_t timeout_ms )

Read block(s) from a specified address in the RPMB partition in polling mode.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_data – Pointer to the buffer that will contain the data to receive.

  • block_addr – Block address where data will be read.

  • blocks_nbr – Number of blocks to read.

  • p_nonce – Pointer to the nonce buffer.

  • p_mac – Pointer to the authentication MAC buffer.

  • timeout_ms – Timeout value in millisecond.

Return values :
  • HAL_INVALID_PARAM – Invalid parameter.

  • HAL_TIMEOUT – A timeout has occurred.

  • HAL_ERROR – An error has occurred.

  • HAL_OK – Operation completed successfully.

uint32_t HAL_MMC_GetRPMBErrorCodes ( const hal_mmc_handle_t * hmmc )

Return the MMC RPMB error code.

Parameters :

hmmc – Pointer to a hal_mmc_handle_t structure.

Return values :

uint32_t – MMC RPMB error code.

void HAL_MMC_GetRPMBSize ( const hal_mmc_handle_t * hmmc , uint32_t * p_rpmb_size_byte )

Return the MMC RPMB size in bytes.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • p_rpmb_size_byte – Pointer to the RPMB size in byte.

Return values :

None.

Interrupt And Flag Configuration

group MMC_Exported_Functions_Group12

This section provides functions allowing to initialize and de-initialize the MMC card device :

Functions

void HAL_MMC_EnableIT ( hal_mmc_handle_t * hmmc , uint32_t interrupt )

Enable the MMC device interrupt.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • interrupt – Specifies the SDMMC interrupt sources to be enabled. This parameter can be a combination of Interrupt Sources group.

void HAL_MMC_DisableIT ( hal_mmc_handle_t * hmmc , uint32_t interrupt )

Disable the MMC device interrupt.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • interrupt – Specifies the SDMMC interrupt sources to be disable. This parameter can be a combination of Interrupt Sources group.

uint32_t HAL_MMC_IsActiveFlag ( const hal_mmc_handle_t * hmmc , uint32_t flag )

Check whether the specified MMC flag is set or not.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • flag – Specifies the flag source to check. This parameter can be a combination of Flags Sources group.

Return values :

The – new state of SDMMC_FLAG (SET or RESET).

void HAL_MMC_ClearFlag ( hal_mmc_handle_t * hmmc , uint32_t flag )

Clear the MMC pending flags.

Parameters :
  • hmmc – Pointer to a hal_mmc_handle_t structure.

  • flag – Specifies the SDMMC flag sources to clear. This parameter can be a combination of Flags Sources group.