Driver API for HSMCI (plib_hsmci.h) More...
Data Structures | |
| struct | HSMCI_COMMAND |
| Parameters for a command issued on the HSMCI bus via HSMCI_SendCommand(). More... | |
Typedefs | |
| typedef uint32_t | HSMCI_BUS_WIDTH |
| Type definition for the HSMCI SD/SDIO bus width selection (SDCBUS in HSMCI_SDCR). Use one of the HSMCI_SDCR_SDCBUS_*_Val constants from the component header. | |
| typedef uint32_t | HSMCI_RESPONSE_TYPE |
| Type definition for the HSMCI command response type selection (RSPTYP in HSMCI_CMDR). Use one of the HSMCI_CMDR_RSPTYP_*_Val constants from the component header. | |
| typedef uint32_t | HSMCI_TRANSFER_CMD |
| Type definition for the HSMCI data transfer command selection (TRCMD in HSMCI_CMDR). Use one of the HSMCI_CMDR_TRCMD_*_Val constants from the component header. | |
| typedef uint32_t | HSMCI_TRANSFER_DIR |
| Type definition for the HSMCI data transfer direction selection (TRDIR in HSMCI_CMDR). Use one of the HSMCI_CMDR_TRDIR_*_Val constants from the component header. | |
| typedef uint32_t | HSMCI_TRANSFER_TYPE |
| Type definition for the HSMCI data transfer type selection (TRTYP in HSMCI_CMDR). Use one of the HSMCI_CMDR_TRTYP_*_Val constants from the component header. | |
| typedef uint32_t | HSMCI_SPECIAL_CMD |
| Type definition for the HSMCI special command selection (SPCMD in HSMCI_CMDR). Use one of the HSMCI_CMDR_SPCMD_*_Val constants from the component header. | |
| typedef uint32_t | HSMCI_SDIO_SPECIAL_CMD |
| Type definition for the HSMCI SDIO special command selection (IOSPCMD in HSMCI_CMDR). Use one of the HSMCI_CMDR_IOSPCMD_*_Val constants from the component header. | |
| typedef void(* | HSMCI_CALLBACK) (uint32_t status) |
| Function pointer type for HSMCI event callback. | |
Functions | |
| void | HSMCI_ResetSoftware (void) |
| Performs a software reset of the HSMCI peripheral. | |
| void | HSMCI_Enable (void) |
| Enables the HSMCI peripheral. | |
| void | HSMCI_Disable (void) |
| Disables the HSMCI peripheral. | |
| void | HSMCI_SetPowerSave (bool enable) |
| Enables or disables power save mode. | |
| void | HSMCI_SetClockDivider (uint8_t clk_div, bool clk_odd) |
| Sets the MCI clock divider and odd-division setting. | |
| void | HSMCI_SetPowerSavingDivider (uint8_t pws_div) |
| Sets the power saving clock divider. | |
| void | HSMCI_SetReadProof (bool enable) |
| Enables or disables Read Proof (deactivates the MCI clock during read data if the internal FIFO is full). | |
| void | HSMCI_SetWriteProof (bool enable) |
| Enables or disables Write Proof (deactivates the MCI clock during write data if the internal FIFO is full). | |
| void | HSMCI_SetForceByteTransfer (bool enable) |
| Enables or disables forcing byte transfers for the last transfer of a data block when the block length is not a multiple of four bytes. | |
| void | HSMCI_SetPaddingValue (bool high_level) |
| Sets the padding value driven on the data bus when there is no more data to transfer. | |
| void | HSMCI_SetBusWidth (HSMCI_BUS_WIDTH width) |
| Selects the SD/SDIO bus width. | |
| void | HSMCI_SetDataTimeout (uint8_t cycles, uint8_t multiplier) |
| Sets the data timeout period. | |
| void | HSMCI_SetCompletionSignalTimeout (uint8_t cycles, uint8_t multiplier) |
| Sets the CE-ATA completion signal timeout period. | |
| void | HSMCI_SetBlockLength (uint16_t block_count, uint16_t block_length) |
| Sets the block count and block length used by the next data transfer. | |
| void | HSMCI_SendCommand (const HSMCI_COMMAND *command) |
| Writes the command argument and command register, issuing a command on the HSMCI bus. | |
| uint32_t | HSMCI_GetResponse (uint8_t index) |
| Retrieves a word of the response of the last issued command. | |
| uint32_t | HSMCI_ReadData (void) |
| Reads a 32-bit word from the HSMCI receive data register. | |
| void | HSMCI_WriteData (uint32_t data) |
| Writes a 32-bit word to the HSMCI transmit data register. | |
| uint32_t | HSMCI_ReadFIFOData (uint16_t index) |
| Reads a 32-bit word from the HSMCI internal FIFO memory aperture. | |
| void | HSMCI_WriteFIFOData (uint16_t index, uint32_t data) |
| Writes a 32-bit word to the HSMCI internal FIFO memory aperture. | |
| uint32_t | HSMCI_GetStatus (void) |
| Retrieves the current HSMCI status register (HSMCI_SR) value. | |
| bool | HSMCI_CommandIsReady (void) |
| Checks whether the HSMCI command register is ready to accept a new command. | |
| bool | HSMCI_ReceiverIsReady (void) |
| Checks whether the HSMCI receive data register holds data ready to be read. | |
| bool | HSMCI_TransmitterIsReady (void) |
| Checks whether the HSMCI transmit data register is ready to accept new data. | |
| bool | HSMCI_DataTransferIsInProgress (void) |
| Checks whether a data transfer is currently in progress. | |
| bool | HSMCI_IsNotBusy (void) |
| Checks whether the HSMCI interface (card data line) is busy. | |
| bool | HSMCI_TransferIsDone (void) |
| Checks whether the current data transfer has completed. | |
| void | HSMCI_EnableInterrupt (uint32_t flag) |
| Enables one or more HSMCI interrupt sources. | |
| void | HSMCI_DisableInterrupt (uint32_t flag) |
| Disables one or more HSMCI interrupt sources. | |
| uint32_t | HSMCI_GetInterruptMask (void) |
| Retrieves the current HSMCI interrupt mask register value. | |
| void | HSMCI_EnableDMA (uint8_t chunk_size) |
| Enables DMA hardware handshaking and sets the DMA channel read/write chunk size. | |
| void | HSMCI_DisableDMA (void) |
| Disables DMA hardware handshaking. | |
| void | HSMCI_SetFIFOMode (bool enable) |
| Selects the HSMCI internal FIFO control mode. | |
| void | HSMCI_SetFlowErrorResetControl (bool enable) |
| Selects the flow error flag (OVRE/UNRE) reset control mode. | |
| void | HSMCI_SetHighSpeedMode (bool enable) |
| Enables or disables High Speed mode. | |
| void | HSMCI_SetLastBlockSync (bool enable) |
| Enables or disables synchronization of a pending command on the last block of the current data transfer. | |
| void | HSMCI_SetWriteProtection (bool enable) |
| Enables or disables write protection for the HSMCI configuration registers. | |
| bool | HSMCI_GetWriteProtectionViolation (uint16_t *violation_src) |
| Retrieves the write protection violation status. | |
| void | HSMCI_SetCallbackHandler (HSMCI_CALLBACK callback) |
| Registers the callback function to be invoked from the HSMCI ISR. | |
Driver API for HSMCI (plib_hsmci.h)
The following example demonstrates typical usage of the HSMCI peripheral:
| typedef uint32_t HSMCI_BUS_WIDTH |
Type definition for the HSMCI SD/SDIO bus width selection (SDCBUS in HSMCI_SDCR). Use one of the HSMCI_SDCR_SDCBUS_*_Val constants from the component header.
| typedef void(* HSMCI_CALLBACK) (uint32_t status) |
Function pointer type for HSMCI event callback.
| status | HSMCI status register value (masked by the interrupt mask register) at the time of the interrupt. |
| typedef uint32_t HSMCI_RESPONSE_TYPE |
Type definition for the HSMCI command response type selection (RSPTYP in HSMCI_CMDR). Use one of the HSMCI_CMDR_RSPTYP_*_Val constants from the component header.
| typedef uint32_t HSMCI_SDIO_SPECIAL_CMD |
Type definition for the HSMCI SDIO special command selection (IOSPCMD in HSMCI_CMDR). Use one of the HSMCI_CMDR_IOSPCMD_*_Val constants from the component header.
| typedef uint32_t HSMCI_SPECIAL_CMD |
Type definition for the HSMCI special command selection (SPCMD in HSMCI_CMDR). Use one of the HSMCI_CMDR_SPCMD_*_Val constants from the component header.
| typedef uint32_t HSMCI_TRANSFER_CMD |
Type definition for the HSMCI data transfer command selection (TRCMD in HSMCI_CMDR). Use one of the HSMCI_CMDR_TRCMD_*_Val constants from the component header.
| typedef uint32_t HSMCI_TRANSFER_DIR |
Type definition for the HSMCI data transfer direction selection (TRDIR in HSMCI_CMDR). Use one of the HSMCI_CMDR_TRDIR_*_Val constants from the component header.
| typedef uint32_t HSMCI_TRANSFER_TYPE |
Type definition for the HSMCI data transfer type selection (TRTYP in HSMCI_CMDR). Use one of the HSMCI_CMDR_TRTYP_*_Val constants from the component header.
| bool HSMCI_CommandIsReady | ( | void | ) |
Checks whether the HSMCI command register is ready to accept a new command.
| bool HSMCI_DataTransferIsInProgress | ( | void | ) |
Checks whether a data transfer is currently in progress.
| void HSMCI_Disable | ( | void | ) |
Disables the HSMCI peripheral.
| void HSMCI_DisableDMA | ( | void | ) |
Disables DMA hardware handshaking.
| void HSMCI_DisableInterrupt | ( | uint32_t | flag | ) |
Disables one or more HSMCI interrupt sources.
| flag | Bitwise OR of HSMCI_IDR_*_Msk values representing the interrupt sources to disable. |
| void HSMCI_Enable | ( | void | ) |
Enables the HSMCI peripheral.
| void HSMCI_EnableDMA | ( | uint8_t | chunk_size | ) |
Enables DMA hardware handshaking and sets the DMA channel read/write chunk size.
| chunk_size | 3-bit chunk size value (refer to HSMCI_DMA_CHKSIZE field definitions). |
| void HSMCI_EnableInterrupt | ( | uint32_t | flag | ) |
Enables one or more HSMCI interrupt sources.
| flag | Bitwise OR of HSMCI_IER_*_Msk values representing the interrupt sources to enable. |
| uint32_t HSMCI_GetInterruptMask | ( | void | ) |
Retrieves the current HSMCI interrupt mask register value.
| uint32_t HSMCI_GetResponse | ( | uint8_t | index | ) |
Retrieves a word of the response of the last issued command.
| index | Response register index (0-3, only relevant for a 136-bit response). |
| uint32_t HSMCI_GetStatus | ( | void | ) |
Retrieves the current HSMCI status register (HSMCI_SR) value.
| bool HSMCI_GetWriteProtectionViolation | ( | uint16_t * | violation_src | ) |
Retrieves the write protection violation status.
| violation_src | Pointer to a variable that will receive the violation source identifier. |
| bool HSMCI_IsNotBusy | ( | void | ) |
Checks whether the HSMCI interface (card data line) is busy.
| uint32_t HSMCI_ReadData | ( | void | ) |
Reads a 32-bit word from the HSMCI receive data register.
| uint32_t HSMCI_ReadFIFOData | ( | uint16_t | index | ) |
Reads a 32-bit word from the HSMCI internal FIFO memory aperture.
| index | FIFO word index (0-255). |
| bool HSMCI_ReceiverIsReady | ( | void | ) |
Checks whether the HSMCI receive data register holds data ready to be read.
| void HSMCI_ResetSoftware | ( | void | ) |
Performs a software reset of the HSMCI peripheral.
| void HSMCI_SendCommand | ( | const HSMCI_COMMAND * | command | ) |
Writes the command argument and command register, issuing a command on the HSMCI bus.
| command | Pointer to the command parameters to issue. |
| void HSMCI_SetBlockLength | ( | uint16_t | block_count, |
| uint16_t | block_length ) |
Sets the block count and block length used by the next data transfer.
| block_count | MMC/SDIO block count, or SDIO byte count. |
| block_length | Data block length in bytes. |
| void HSMCI_SetBusWidth | ( | HSMCI_BUS_WIDTH | width | ) |
Selects the SD/SDIO bus width.
| width | Requested bus width; one of the HSMCI_SDCR_SDCBUS_*_Val constants from the component header. |
| void HSMCI_SetCallbackHandler | ( | HSMCI_CALLBACK | callback | ) |
Registers the callback function to be invoked from the HSMCI ISR.
| callback | Pointer to the callback function (NULL to clear). |
| void HSMCI_SetClockDivider | ( | uint8_t | clk_div, |
| bool | clk_odd ) |
Sets the MCI clock divider and odd-division setting.
| clk_div | 8-bit clock divider value. |
| clk_odd | true if the divider is odd, false otherwise. |
| void HSMCI_SetCompletionSignalTimeout | ( | uint8_t | cycles, |
| uint8_t | multiplier ) |
Sets the CE-ATA completion signal timeout period.
| cycles | 4-bit completion signal timeout cycle number (CSTOCYC). |
| multiplier | 3-bit completion signal timeout multiplier (CSTOMUL). |
| void HSMCI_SetDataTimeout | ( | uint8_t | cycles, |
| uint8_t | multiplier ) |
Sets the data timeout period.
| cycles | 4-bit data timeout cycle number (DTOCYC). |
| multiplier | 3-bit data timeout multiplier (DTOMUL). |
| void HSMCI_SetFIFOMode | ( | bool | enable | ) |
Selects the HSMCI internal FIFO control mode.
| enable | true to select the new FIFO control mode, false to select the legacy mode. |
| void HSMCI_SetFlowErrorResetControl | ( | bool | enable | ) |
Selects the flow error flag (OVRE/UNRE) reset control mode.
| enable | true so flags are only cleared by writing HSMCI_CMDR, false to clear on read. |
| void HSMCI_SetForceByteTransfer | ( | bool | enable | ) |
Enables or disables forcing byte transfers for the last transfer of a data block when the block length is not a multiple of four bytes.
| enable | true to enable forced byte transfers, false to disable. |
| void HSMCI_SetHighSpeedMode | ( | bool | enable | ) |
Enables or disables High Speed mode.
| enable | true to enable, false to disable. |
| void HSMCI_SetLastBlockSync | ( | bool | enable | ) |
Enables or disables synchronization of a pending command on the last block of the current data transfer.
| enable | true to enable, false to disable. |
| void HSMCI_SetPaddingValue | ( | bool | high_level | ) |
Sets the padding value driven on the data bus when there is no more data to transfer.
| high_level | true to pad with 0xFF, false to pad with 0x00. |
| void HSMCI_SetPowerSave | ( | bool | enable | ) |
Enables or disables power save mode.
| enable | true to enable power save mode (MCI clock only asserted on card bus cycles), false to disable (MCI clock always asserted). |
| void HSMCI_SetPowerSavingDivider | ( | uint8_t | pws_div | ) |
Sets the power saving clock divider.
| pws_div | 3-bit power saving divider value. |
| void HSMCI_SetReadProof | ( | bool | enable | ) |
Enables or disables Read Proof (deactivates the MCI clock during read data if the internal FIFO is full).
| enable | true to enable, false to disable. |
| void HSMCI_SetWriteProof | ( | bool | enable | ) |
Enables or disables Write Proof (deactivates the MCI clock during write data if the internal FIFO is full).
| enable | true to enable, false to disable. |
| void HSMCI_SetWriteProtection | ( | bool | enable | ) |
Enables or disables write protection for the HSMCI configuration registers.
| enable | true to enable, false to disable. |
| bool HSMCI_TransferIsDone | ( | void | ) |
Checks whether the current data transfer has completed.
| bool HSMCI_TransmitterIsReady | ( | void | ) |
Checks whether the HSMCI transmit data register is ready to accept new data.
| void HSMCI_WriteData | ( | uint32_t | data | ) |
Writes a 32-bit word to the HSMCI transmit data register.
| data | 32-bit data value. |
| void HSMCI_WriteFIFOData | ( | uint16_t | index, |
| uint32_t | data ) |
Writes a 32-bit word to the HSMCI internal FIFO memory aperture.
| index | FIFO word index (0-255). |
| data | 32-bit data value. |
| uint32_t HSMCI_COMMAND::argument |
Command argument.
| bool HSMCI_COMMAND::ata_completion_signal |
true = CE-ATA completion signal expected.
| bool HSMCI_COMMAND::boot_ack |
true = boot acknowledge expected.
| uint8_t HSMCI_COMMAND::cmd_number |
Command index (0-63).
| bool HSMCI_COMMAND::max_latency_64cyc |
true = 64-cycle latency, false = 5-cycle.
| bool HSMCI_COMMAND::open_drain |
true = open drain, false = push-pull.
| HSMCI_RESPONSE_TYPE HSMCI_COMMAND::response_type |
Expected response type.
| HSMCI_SDIO_SPECIAL_CMD HSMCI_COMMAND::sdio_special_cmd |
SDIO special command selection.
| HSMCI_SPECIAL_CMD HSMCI_COMMAND::special_cmd |
Special command selection.
| HSMCI_TRANSFER_CMD HSMCI_COMMAND::transfer_cmd |
Data transfer command.
| HSMCI_TRANSFER_DIR HSMCI_COMMAND::transfer_dir |
Data transfer direction.
| HSMCI_TRANSFER_TYPE HSMCI_COMMAND::transfer_type |
Data transfer type.