Nut/OS  5.0.5
API Reference
MCI Public Functions

Functions

int32_t Lpc177x_8x_MciInit (uint8_t powerActiveLevel)
 Do initialization the MCI block as set its clock, registers, setup NVIC for interrupts, configure the pins used for MCI function, do initialize the card in slot...
void Lpc177x_8x_MciSendCmd (uint32_t CmdIndex, uint32_t Argument, uint32_t ExpectResp, uint32_t AllowTimeout)
 The routine is used to send a CMD to the card.
int32_t Lpc177x_8x_MciGetCmdResp (uint32_t CmdIndex, uint32_t NeedRespFlag, uint32_t *CmdRespStatus)
 The routine is to get the reponse from card after commands. This function is always used in pair of Lpc177x_8x_MciSendCmd() func.
int32_t Lpc177x_8x_MciCmdResp (uint32_t CmdIndex, uint32_t Argument, uint32_t ExpectResp, uint32_t *CmdResp, uint32_t AllowTimeout)
 The routine is to send command to cards then get back the reponses (if required).
void Lpc177x_8x_MciSet_MCIClock (uint32_t clockrate)
 Set MCI clock rate, during initialization phase < 400K during data phase < 20Mhz.
int32_t Lpc177x_8x_MciSetBusWidth (uint32_t width)
 Set the Width to 1-bit Bus or 4-bit Bus.
int32_t Lpc177x_8x_MciAcmd_SendOpCond (uint8_t hcsVal)
 Send ACMD41 (SEND_APP_OP_COND) to Host Capacity Support (HCS) information and asks the accessed card to send its operating condition (OCR).
int32_t Lpc177x_8x_MciCardInit (void)
 Do initialization for the card in the slot.
en_Mci_CardType Lpc177x_8x_MciGetCardType (void)
 Get the type of card that is currently used in the slot.
int32_t Lpc177x_8x_MciCardReset (void)
 To reset the card, the CMD0 is sent and then the card is put in idle state. This is the very first command to be sent to initialize either MMC or SD card.
int32_t Lpc177x_8x_MciCmd_SendIfCond (void)
 Send CMD8 (SEND_IF_COND) for interface condition to card.
int32_t Lpc177x_8x_MciGetCID (st_Mci_CardId *cidValue)
 Get the all the Identifier (CID) of the card by sending the CMD2 (ALL_SEND_CID) command. Then parse 4-byte data obtained from the card by the CID meaning.
int32_t Lpc177x_8x_MciSetCardAddress (void)
 Set the address for the card in the slot by sending CMD3 (SET_RELATIVE_ADDR) command. To get the address of the card currently in used, needs to call Lpc177x_8x_MciGetCardAddress()
uint32_t Lpc177x_8x_MciGetCardAddress (void)
 Get the address for the card in the slot.
int32_t Lpc177x_8x_MciGetCSD (uint32_t *csdVal)
 Get the Card-Specific Data of in-slot card by sending CMD9 (SEND_CSD) command.
int32_t Lpc177x_8x_MciCmd_SelectCard (void)
 Select the card by the specified address. This is done by sending out the CMD7 with the address argument to needed card.
int32_t Lpc177x_8x_MciGetCardStatus (int32_t *cardStatus)
 Get the status of the card. The return is from the card. By sending CMD13 (SEND_STATUS), the status of the card will be responded from card addressed.
uint32_t Lpc177x_8x_MciGetDataXferEndState (void)
 Get the state of data transfer to see if it is ended or not.
uint32_t Lpc177x_8x_MciGetXferErrState (void)
 Get the error state of the lastest data transfer.
int32_t Lpc177x_8x_MciSetBlockLen (uint32_t blockLength)
 Set the length for the blocks in the next action on data manipulation (as read, write, erase). This function is to send CMD16 (SET_BLOCK_LEN) to cards.
int32_t Lpc177x_8x_MciAcmd_SendBusWidth (uint32_t buswidth)
 Set bus-width (1 bit or 4 bit) to work with the card by command CMD6 (SET_ACMD_BUS_WIDTH).
int32_t Lpc177x_8x_MciCmd_StopTransmission (void)
 Stop the current transmission on the bus by sending command CMD12 (STOP_TRANSMISSION). In this case, the card may be in a unknown state. So that it need a warm reset for normal operation.
int32_t Lpc177x_8x_MciCmd_WriteBlock (uint32_t blockNum, uint32_t numOfBlock)
 Write blocks to card by sending command CMD24 (WRITE_BLOCK) or command CMD25 (WRITE_MULTIPLE_BLOCK) followed by the blocks of data to be written.
int32_t Lpc177x_8x_MciCmd_ReadBlock (uint32_t blockNum, uint32_t numOfBlock)
 Read blocks to card by sending CMD17 (READ_SINGLE_BLOCK) or CMD18 (READ_MULTIPLE_BLOCK) commands followed by the blocks of data to be read.
int32_t Lpc177x_8x_MciWriteBlock (uint8_t *memblock, uint32_t blockNum, uint32_t numOfBlock)
 Write data at a specific address to starting block with number of blocks will be written from first block.
int32_t Lpc177x_8x_MciReadBlock (uint8_t *destBlock, uint32_t blockNum, uint32_t numOfBlock)
 Read data at a specific address to starting block with number of blocks will be read from first block.

Variables

uint8_t mci_cid::MID
uint16_t mci_cid::OID
uint8_t mci_cid::PNM_H
uint32_t mci_cid::PNM_L
uint8_t mci_cid::PRV
uint32_t mci_cid::PSN
uint8_t mci_cid::reserved
uint16_t mci_cid::MDT
uint8_t mci_cid::CRC
uint8_t mci_cid::unused

Function Documentation

int32_t Lpc177x_8x_MciInit ( uint8_t  powerActiveLevel)

Do initialization the MCI block as set its clock, registers, setup NVIC for interrupts, configure the pins used for MCI function, do initialize the card in slot...

Parameters:
[in]powerActiveLevelthe power level to activate the card in slot
Returns:
MCI_FUNC_OK in case of success

References CLKPWR_PCONP_PCSDC, GPIO_CFG_OUTPUT, GPIO_CFG_PERIPHERAL2, GpioPinConfigSet(), GpioPinSetHigh, GpioPinSetLow, LOW_LVL, Lpc177x_8x_MciCardInit(), Lpc177x_8x_MciSet_MCIClock(), LPC_MCI, LPC_SC, MCI_CARD_UNKNOWN, MCI_CardType, MCI_SLOW_RATE, NutDelay(), NUTGPIO_PORT1, NutIrqEnable(), NutRegisterIrqHandler(), sig_MCI, and SysCtlPeripheralClkEnable.

Here is the call graph for this function:

void Lpc177x_8x_MciSendCmd ( uint32_t  CmdIndex,
uint32_t  Argument,
uint32_t  ExpectResp,
uint32_t  AllowTimeout 
)

The routine is used to send a CMD to the card.

Parameters:
[in]CmdIndexthe command to be sent to cards
[in]Argumentthe argument follows the command
[in]ExpectRespthe response type for the command. They may be:
  • EXPECT_NO_RESP: means no response required
  • EXPECT_SHORT_RESP: means a response in a word needed
  • EXPECT_LONG_RESP: means a response in 4 words needed
[in]AllowTimeoutallow timeout the command or not
Returns:
None

References ALLOW_CMD_TIMER, EXPECT_LONG_RESP, EXPECT_NO_RESP, EXPECT_SHORT_RESP, LPC_MCI, MCI_CMD_ACTIVE, and MCI_DISABLE_CMD_TIMER.

Referenced by Lpc177x_8x_MciCardReset(), and Lpc177x_8x_MciCmdResp().

int32_t Lpc177x_8x_MciGetCmdResp ( uint32_t  ExpectCmdData,
uint32_t  ExpectResp,
uint32_t CmdResp 
)

The routine is to get the reponse from card after commands. This function is always used in pair of Lpc177x_8x_MciSendCmd() func.

Parameters:
[in]ExpectCmdDataspecify the command of which the data will be retrieved. This field should be the same with CmdIndex of Lpc177x_8x_MciSendCmd() function.
[in]ExpectRespthe response type for the command. They may be:
  • EXPECT_NO_RESP: means no response required
  • EXPECT_SHORT_RESP: means a response in a word needed
  • EXPECT_LONG_RESP: means a response in 4 words needed
[out]CmdRespthe buffer stored the data replied from cards
Returns:
MCI_FUNC_OK in case of success

References ACMD41_SEND_APP_OP_COND, CMD12_STOP_TRANSMISSION, CMD1_SEND_OP_COND, CMD2_ALL_SEND_CID, CMD9_SEND_CSD, EXPECT_LONG_RESP, EXPECT_NO_RESP, EXPECT_SHORT_RESP, INVALID_RESPONSE, LPC_MCI, MCI_CMD_CRC_FAIL, MCI_CMD_RESP_END, MCI_CMD_TIMEOUT, MCI_FUNC_OK, and NULL.

Referenced by Lpc177x_8x_MciCmdResp().

int32_t Lpc177x_8x_MciCmdResp ( uint32_t  CmdIndex,
uint32_t  Argument,
uint32_t  ExpectResp,
uint32_t CmdResp,
uint32_t  AllowTimeout 
)

The routine is to send command to cards then get back the reponses (if required).

Parameters:
[in]CmdIndexthe command to be sent to cards
[in]Argumentthe argument follows the command
[in]ExpectRespthe response type for the command. They may be:
  • EXPECT_NO_RESP: means no response required
  • EXPECT_SHORT_RESP: means a response in a word needed
  • EXPECT_LONG_RESP: means a response in 4 words needed
[out]CmdRespthe buffer stored the data replied from cards
[in]AllowTimeoutallow timeout the command or not
Returns:
MCI_FUNC_OK in case of success

References EXPECT_NO_RESP, Lpc177x_8x_MciGetCmdResp(), Lpc177x_8x_MciSendCmd(), MCI_FUNC_BAD_PARAMETERS, and NULL.

Referenced by Lpc177x_8x_MciAcmd_SendBusWidth(), Lpc177x_8x_MciAcmd_SendOpCond(), Lpc177x_8x_MciCmd_ReadBlock(), Lpc177x_8x_MciCmd_SelectCard(), Lpc177x_8x_MciCmd_SendACMD(), Lpc177x_8x_MciCmd_SendIfCond(), Lpc177x_8x_MciCmd_SendOpCond(), Lpc177x_8x_MciCmd_StopTransmission(), Lpc177x_8x_MciCmd_WriteBlock(), Lpc177x_8x_MciGetCardStatus(), Lpc177x_8x_MciGetCID(), Lpc177x_8x_MciGetCSD(), Lpc177x_8x_MciSetBlockLen(), and Lpc177x_8x_MciSetCardAddress().

Here is the call graph for this function:

void Lpc177x_8x_MciSet_MCIClock ( uint32_t  ClockRate)

Set MCI clock rate, during initialization phase < 400K during data phase < 20Mhz.

Parameters:
[in]ClockRateClock rate to be set
Returns:
None

References Lpc17xx_ClockGet(), LPC_MCI, MCI_NORMAL_RATE, MCI_SLOW_RATE, MCLKDIV_NORMAL, MCLKDIV_SLOW, and NUT_HWCLK_PERIPHERAL.

Referenced by Lpc177x_8x_MciInit().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciSetBusWidth ( uint32_t  width)

Set the Width to 1-bit Bus or 4-bit Bus.

Parameters:
[in]widthbuswidth expected to set
Returns:
MCI_FUNC_OK in case of success

References BUS_WIDTH_4BITS, Lpc177x_8x_MciAcmd_SendBusWidth(), LPC_MCI, MCI_FUNC_FAILED, MCI_FUNC_OK, SD_1_BIT, and SD_4_BIT.

Here is the call graph for this function:

int32_t Lpc177x_8x_MciAcmd_SendOpCond ( uint8_t  hcsVal)

Send ACMD41 (SEND_APP_OP_COND) to Host Capacity Support (HCS) information and asks the accessed card to send its operating condition (OCR).

Parameters:
[in]hcsValinput the Host Capacity Support
Returns:
MCI_FUNC_OK if all success
Note:
If SEND_APP_OP_COND is timeout, the card in the slot is not MMC type, try this combination to see if we can communicate with a SD type.

References ACMD41_SEND_APP_OP_COND, ALLOW_CMD_TIMER, CCS, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmd_SendACMD(), Lpc177x_8x_MciCmdResp(), Lpc177x_8x_MciSetOutputMode(), MCI_ACMD41_HCS_POS, MCI_CMD_TIMEOUT, MCI_FUNC_BUS_NOT_IDLE, MCI_FUNC_FAILED, MCI_FUNC_OK, MCI_FUNC_TIMEOUT, MCI_OUTPUT_MODE_PUSHPULL, and OCR_INDEX.

Referenced by Lpc177x_8x_MciCardInit().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciCardInit ( void  )

Do initialization for the card in the slot.

Try CMD1 first for MMC, if it's timeout, try CMD55 and CMD41 for SD, if both failed, initialization faliure, bailout with unknown card type. Otherwise, return the card type, either MMC or SD. <<<KHOA_110708: checking>>>

This is followed Figure 4-2: Card Initialization and Identification Flow (SD mode) in Physical Layer Simplified Specification Version 2.00 document

Parameters:
None
Returns:
MCI_FUNC_OK if success

References CCS, Lpc177x_8x_MciAcmd_SendOpCond(), Lpc177x_8x_MciCardReset(), Lpc177x_8x_MciCmd_SendIfCond(), Lpc177x_8x_MciCmd_SendOpCond(), Lpc177x_8x_MciSetOutputMode(), MCI_AddressingMode, MCI_CARD_UNKNOWN, MCI_CardType, MCI_FUNC_BAD_PARAMETERS, MCI_FUNC_FAILED, MCI_FUNC_OK, MCI_MMC_CARD, MCI_OUTPUT_MODE_OPENDRAIN, MCI_OUTPUT_MODE_PUSHPULL, MCI_SDHC_SDXC_CARD, MCI_SDSC_V1_CARD, MCI_SDSC_V2_CARD, MMC_BLOCK_MODE, and MMC_BYTE_MODE.

Referenced by Lpc177x_8x_MciInit().

Here is the call graph for this function:

en_Mci_CardType Lpc177x_8x_MciGetCardType ( void  )

Get the type of card that is currently used in the slot.

Parameters:
None
Returns:
Card Type: MMC Card or SD card

References MCI_CardType.

int32_t Lpc177x_8x_MciCardReset ( void  )

To reset the card, the CMD0 is sent and then the card is put in idle state. This is the very first command to be sent to initialize either MMC or SD card.

Parameters:
None
Returns:
Always MCI_FUNC_OK

References CMD0_GO_IDLE_STATE, EXPECT_NO_RESP, Lpc177x_8x_MciSendCmd(), and MCI_FUNC_OK.

Referenced by Lpc177x_8x_MciCardInit().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciCmd_SendIfCond ( void  )

Send CMD8 (SEND_IF_COND) for interface condition to card.

Parameters:
None
Returns:
MCI_FUNC_OK if all success

References ALLOW_CMD_TIMER, CMD8_SEND_IF_COND, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), MCI_CMD8_CHECKPATTERN_BMASK, MCI_CMD8_VOLTAGESUPPLIED_BMASK, MCI_CMD8_VOLTAGESUPPLIED_POS, MCI_CMD_TIMEOUT, MCI_FUNC_BAD_PARAMETERS, MCI_FUNC_FAILED, MCI_FUNC_OK, and MCI_FUNC_TIMEOUT.

Referenced by Lpc177x_8x_MciCardInit().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciSetCardAddress ( void  )

Set the address for the card in the slot by sending CMD3 (SET_RELATIVE_ADDR) command. To get the address of the card currently in used, needs to call Lpc177x_8x_MciGetCardAddress()

Parameters:
None
Returns:
MCI_FUNC_OK if all success

References ALLOW_CMD_TIMER, CardRCA, CARDSTATEOF, CMD3_SET_RELATIVE_ADDR, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), MCI_CARDSTATE_IDENDTIFIED, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_CardType, MCI_CMD_TIMEOUT, MCI_FUNC_ERR_STATE, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, MCI_FUNC_OK, MCI_FUNC_TIMEOUT, MCI_SDHC_SDXC_CARD, MCI_SDSC_V1_CARD, MCI_SDSC_V2_CARD, and XSHIFT_.

Here is the call graph for this function:

uint32_t Lpc177x_8x_MciGetCardAddress ( void  )

Get the address for the card in the slot.

Parameters:
None
Returns:
MCI_FUNC_OK if all success
Note:
This function must be called after Lpc177x_8x_MciSetCardAddress() executing

References CardRCA.

int32_t Lpc177x_8x_MciGetCSD ( uint32_t csdVal)

Get the Card-Specific Data of in-slot card by sending CMD9 (SEND_CSD) command.

Parameters:
[out]csdVala buffer stored the value of CSD obtained from the card
Returns:
MCI_FUNC_OK if all success
Note:
CMD9 (SEND_CSD) command should be sent only at standby state (STBY) after CMD3

References ALLOW_CMD_TIMER, CardRCA, CMD9_SEND_CSD, EXPECT_LONG_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_CardType, MCI_CMD_CRC_FAIL, MCI_CMD_RESP_END, MCI_CMD_TIMEOUT, MCI_FUNC_FAILED, MCI_FUNC_OK, MCI_SDHC_SDXC_CARD, MCI_SDSC_V1_CARD, MCI_SDSC_V2_CARD, and NULL.

Here is the call graph for this function:

int32_t Lpc177x_8x_MciCmd_SelectCard ( void  )

Select the card by the specified address. This is done by sending out the CMD7 with the address argument to needed card.

Parameters:
None
Returns:
MCI_FUNC_OK if all success
Note:
CMD7 (SELECT_CARD) command should be sent after CMD9 ((SEND_CSD). The state will be inter-changed between STBY to TRANS by this CMD7 command

References _SHIFT, ALLOW_CMD_TIMER, CardRCA, CARDSTATEOF, CMD7_SELECT_CARD, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_CARDSTATE_STBY, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_CardType, MCI_CMD_CRC_FAIL, MCI_CMD_RESP_END, MCI_CMD_TIMEOUT, MCI_FUNC_ERR_STATE, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, MCI_FUNC_OK, MCI_SDHC_SDXC_CARD, MCI_SDSC_V1_CARD, and MCI_SDSC_V2_CARD.

Here is the call graph for this function:

int32_t Lpc177x_8x_MciGetCardStatus ( int32_t cardStatus)

Get the status of the card. The return is from the card. By sending CMD13 (SEND_STATUS), the status of the card will be responded from card addressed.

Parameters:
[out]cardStatusthe status returned from the card
Returns:
MCI_FUNC_OK if all success

References _SHIFT, ALLOW_CMD_TIMER, CardRCA, CMD13_SEND_STATUS, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_CardType, MCI_CMD_CRC_FAIL, MCI_CMD_RESP_END, MCI_CMD_TIMEOUT, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, MCI_FUNC_OK, MCI_SDHC_SDXC_CARD, MCI_SDSC_V1_CARD, MCI_SDSC_V2_CARD, and NULL.

Referenced by Lpc177x_8x_MciCheckStatus().

Here is the call graph for this function:

uint32_t Lpc177x_8x_MciGetDataXferEndState ( void  )

Get the state of data transfer to see if it is ended or not.

Parameters:
None
Returns:
Transfer state (stored by Mci_Data_Xfer_End variable)

References Mci_Data_Xfer_End.

uint32_t Lpc177x_8x_MciGetXferErrState ( void  )

Get the error state of the lastest data transfer.

Parameters:
None
Returns:
Error state (stored by Mci_Data_Xfer_ERR variable)

References Mci_Data_Xfer_ERR.

int32_t Lpc177x_8x_MciSetBlockLen ( uint32_t  blockLength)

Set the length for the blocks in the next action on data manipulation (as read, write, erase). This function is to send CMD16 (SET_BLOCK_LEN) to cards.

Parameters:
[in]blockLengththe value for the length of block will be handled
Returns:
MCI_FUNC_OK if all success
Note:
CMD16 command should be sent after the card is selected by CMD7 (SELECT_CARD).

References _SHIFT, ALLOW_CMD_TIMER, CARDSTATEOF, CMD16_SET_BLOCK_LEN, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_CARDSTATE_TRAN, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_CMD_CRC_FAIL, MCI_CMD_RESP_END, MCI_CMD_TIMEOUT, MCI_FUNC_ERR_STATE, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, and MCI_FUNC_OK.

Here is the call graph for this function:

int32_t Lpc177x_8x_MciAcmd_SendBusWidth ( uint32_t  buswidth)

Set bus-width (1 bit or 4 bit) to work with the card by command CMD6 (SET_ACMD_BUS_WIDTH).

Parameters:
[in]buswidthThe value represented for bus-width
  • 0b00: 1-bit bus-width
  • 0b10: 4-bit bus-width
Returns:
MCI_FUNC_OK if all success
Note:
  • If SD card is currently in used, it's possible to enable 4-bit bus-width instead of 1-bit to speed up.
  • This command can only be transferred during TRANS state.
  • Since, it's a ACMD, CMD55 (APP_CMD) needs to be sent out first

References _SHIFT, ACMD6_SET_BUS_WIDTH, ALLOW_CMD_TIMER, CARDSTATEOF, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmd_SendACMD(), Lpc177x_8x_MciCmdResp(), MCI_CARDSTATE_TRAN, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_FUNC_ERR_STATE, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, and MCI_FUNC_OK.

Referenced by Lpc177x_8x_MciSetBusWidth().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciCmd_StopTransmission ( void  )

Stop the current transmission on the bus by sending command CMD12 (STOP_TRANSMISSION). In this case, the card may be in a unknown state. So that it need a warm reset for normal operation.

Parameters:
[in]None
Returns:
MCI_FUNC_OK if all success

References _SHIFT, ALLOW_CMD_TIMER, CMD12_STOP_TRANSMISSION, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, and MCI_FUNC_OK.

Referenced by Lpc177x_8x_MciReadBlock(), and Lpc177x_8x_MciWriteBlock().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciCmd_WriteBlock ( uint32_t  blockNum,
uint32_t  numOfBlock 
)

Write blocks to card by sending command CMD24 (WRITE_BLOCK) or command CMD25 (WRITE_MULTIPLE_BLOCK) followed by the blocks of data to be written.

Parameters:
[in]blockNumThe block number to start writting
[in]numOfBlockDetermine how many blocks will be written (from the starting block)
Returns:
MCI_FUNC_OK if all success
Note:
These commands should be sent in TRANS state.

References ALLOW_CMD_TIMER, BLOCK_LENGTH, CARDSTATEOF, CMD24_WRITE_BLOCK, CMD25_WRITE_MULTIPLE_BLOCK, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_AddressingMode, MCI_CARDSTATE_TRAN, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_FUNC_ERR_STATE, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, MCI_FUNC_OK, MMC_BLOCK_MODE, and XSHIFT_.

Referenced by Lpc177x_8x_MciWriteBlock().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciCmd_ReadBlock ( uint32_t  blockNum,
uint32_t  numOfBlock 
)

Read blocks to card by sending CMD17 (READ_SINGLE_BLOCK) or CMD18 (READ_MULTIPLE_BLOCK) commands followed by the blocks of data to be read.

Parameters:
[in]blockNumThe block number to start reading
[in]numOfBlockDetermine how many blocks will be read (from the starting block)
Returns:
MCI_FUNC_OK if all success
Note:
These commands should be sent in TRANS state.

References _SHIFT, ALLOW_CMD_TIMER, BLOCK_LENGTH, CARDSTATEOF, CMD17_READ_SINGLE_BLOCK, CMD18_READ_MULTIPLE_BLOCK, EXPECT_SHORT_RESP, Lpc177x_8x_MciCmdResp(), LPC_MCI, MCI_AddressingMode, MCI_CARDSTATE_TRAN, MCI_CARDSTATUS_READYFORDATA_P0S, MCI_FUNC_ERR_STATE, MCI_FUNC_FAILED, MCI_FUNC_NOT_READY, MCI_FUNC_OK, and MMC_BLOCK_MODE.

Referenced by Lpc177x_8x_MciReadBlock().

Here is the call graph for this function:

int32_t Lpc177x_8x_MciWriteBlock ( uint8_t memblock,
uint32_t  blockNum,
uint32_t  numOfBlock 
)

Write data at a specific address to starting block with number of blocks will be written from first block.

  • At preparation
    • Set MCI data control register, data length and data timeout
    • Send CMD24 (WRITE_BLOCK) or CMD25 (WRITE_MULTIPLE_BLOCK) commands to card
    • Enable interupt for MCI component
  • At completion
    • TX_ACTIVE interrupt is occured
    • Write data to FIFO register continuously until the data block length is reached
Parameters:
[in]*memblockThe pointer to location stored required data to be written to card
[in]blockNumThe block number to start writting
[in]numOfBlockDetermine how many blocks will be written (from the starting block)
Returns:
MCI_FUNC_OK if all success

References BLOCK_LENGTH, DATA_BLOCK_LEN, DATA_TIMER_VALUE, dataSrcBlock, fifo_plane, Lpc177x_8x_MciCheckStatus(), Lpc177x_8x_MciCmd_StopTransmission(), Lpc177x_8x_MciCmd_WriteBlock(), Lpc177x_8x_MciTXEnable(), LPC_MCI, Mci_Data_Xfer_End, Mci_Data_Xfer_ERR, MCI_DATACTRL_DIR_TO_CARD, MCI_DATACTRL_ENABLE, MCI_DTATCTRL_BLOCKSIZE, MCI_FUNC_FAILED, MCI_FUNC_OK, and txBlockCnt.

Here is the call graph for this function:

int32_t Lpc177x_8x_MciReadBlock ( uint8_t destBlock,
uint32_t  blockNum,
uint32_t  numOfBlock 
)

Read data at a specific address to starting block with number of blocks will be read from first block.

  • At preparation
    • Set MCI data control register, data length and data timeout
    • Send CMD17 (READ_SINGLE_BLOCK) or CMD18 (READ_MULTIPLE_BLOCK) commands to card
    • Enable interupt for MCI component
  • At completion
    • RX_ACTIVE interrupt is occured
    • Read data from FIFO register continuously until the data block length is reached to retrieve needed data
Parameters:
[in]*destBlockThe pointer to location will captured data read from card
[in]blockNumThe block number to start reading
[in]numOfBlockDetermine how many blocks will be read (from the starting block)
Returns:
MCI_FUNC_OK if all success

References BLOCK_LENGTH, DATA_BLOCK_LEN, DATA_TIMER_VALUE, dataDestBlock, fifo_plane, Lpc177x_8x_MciCheckStatus(), Lpc177x_8x_MciCmd_ReadBlock(), Lpc177x_8x_MciCmd_StopTransmission(), Lpc177x_8x_MciRXEnable(), LPC_MCI, Mci_Data_Xfer_End, Mci_Data_Xfer_ERR, MCI_DATACTRL_DIR_FROM_CARD, MCI_DATACTRL_ENABLE, MCI_DTATCTRL_BLOCKSIZE, MCI_FUNC_FAILED, MCI_FUNC_OK, and rxBlockCnt.

Here is the call graph for this function:


Variable Documentation