Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

void  FSDev_SD_Card_BSP_CmdDataWr (FS_QTY               unit_nbr,

...

                                   FS_DEV_SD_CARD_CMD  *p_cmd,

...

                                   void                *p_src,

...

                                   FS_DEV_SD_CARD_ERR  *p_err);

...

...

File

...

...

Called from

...

Code enabled by

...

...

fs_dev_sd_card_bsp.c

...

...

FSDev_SD_Card_WrData()

...

N/A

...

1142698Write data following a command. Anchor11426991142699

Arguments

Anchor11427001142700unit_nbr Anchor11427011142701

Unit number of SD/MMC card.

...

p_cmd Anchor11427031142703

Pointer to command that was started.

...

p_src Anchor11427051142705

Pointer to source buffer.

...

p_erranchor11427071142707

Pointer to variable that will receive the return error code from this function:

...

...

FS_DEV_SD_CARD_ERR_NONE

...

...

No error.

...

...

classWebWorks_Indent_1

...

FS_DEV_SD_CARD_ERR_NO_CARD

...

classWebWorks_Indent_2

...

...

No card present.

...

...

FS_DEV_SD_CARD_ERR_UNKNOWN

...

classWebWorks_Indent_2

...

Unknown or other error.

...

classWebWorks_Indent_1

...

FS_DEV_SD_CARD_ERR_WAIT_TIMEOUT

...

classWebWorks_Indent_2

...

...

Timeout in waiting for data.

...

...

FS_DEV_SD_CARD_ERR_DATA_UNDERRUN

...

classWebWorks_Indent_2

...

Data underrun.

...

classWebWorks_Indent_1

...

FS_DEV_SD_CARD_ERR_DATA_CHKSUM

...

classWebWorks_Indent_2

...

...

Error in data checksum.

...

...

FS_DEV_SD_CARD_ERR_DATA_START_BIT

...

...

Data start bit error.

...

classWebWorks_Indent_1

...

FS_DEV_SD_CARD_ERR_DATA

...

classWebWorks_Indent_2

...

...

Other data error.

...

Returned Value

Anchor11427251142725None. Anchor11427261142726

Notes/Warnings

...

None. Anchor11427281142728

Example

...

The implementation of FSDev_SD_Card_BSP_CmdDataWr() in Listing C-10 is  is targeted for the same host controller as the other listings in this chapter; for more information, see FSDev_SD_Card_BSP_CmdStart().anchor

Code Block

...

language

...

void
HTML Table
summary
classCode_Listing
Table Row (tr)
Table Cell (td)
Anchor
11427351142735
cpp

...


                                   FS_DEV_SD_CARD_CMD  *p_cmd,
void *p_src,

                                   void                *p_src,
                                   FS_DEV_SD_CARD_ERR  *p_err)
{

{
    CPU_INT16U  interrupt_status;

    CPU_INT16U  error_status;

    CPU_INT16U  timeout;
timeout = 0u; /* Wait until data xfer compl. */ (1) interrupt_status =

    timeout          = 0u;                        /* Wait until data xfer compl. */  (1)
    interrupt_status = REG_INTERRUPT_STATUS;
while

    while (DEF_BIT_IS_CLR(interrupt_status,BIT_INTERRUPT_STATUS_ERROR
|
 | 
                                           BIT_INTERRUPT_STATUS_TRANSFER_COMPLETE) == DEF_YES))
{
 {
        timeout++;

        interrupt_status = REG_INTERRUPT_STATUS;
if (timeout ==

        if (timeout == TIMEOUT_TRANSFER_MAX)
{
 {
           *p_err = FS_DEV_SD_CARD_ERR_WAIT_TIMEOUT;
return; } } /* Handle error. */ (2) if

            return;
        }
    }
                                                  /* Handle error.              */  (2)
    if (DEF_BIT_IS_SET(interrupt_status, BIT_INTERRUPT_STATUS_ERROR) == DEF_YES)
{
 {
        error_status = REG_ERROR_STATUS;
if

        if (DEF_BIT_IS_SET(error_status, REG_ERROR_STATUS_DATA_END_BIT) == DEF_YES)
{
 {
           *p_err = FS_DEV_SD_CARD_ERR_DATA;
} else if

        } else if (DEF_BIT_IS_SET(error_status, REG_ERROR_STATUS_DATA_CRC) == DEF_YES)
{
 {
           *p_err = FS_DEV_SD_CARD_ERR_DATA_CRC;
} else if

        } else if (DEF_BIT_IS_SET(error_status, REG_ERROR_STATUS_DATA_TIMEOUT) == DEF_YES)
{
 {
           *p_err = FS_DEV_SD_CARD_ERR_DATA_TIMEOUT;
} else {

        } else {
           *p_err = FS_DEV_SD_CARD_ERR_UNKONWN;
}

        }
        REG_ERROR_STATUS     = error_status;

        REG_INTERRUPT_STATUS = interrupt_status;
return; }

        return;
    }
   
   *p_err = FS_DEV_SD_CARD_ERR_NONE;
(3) }
titleFSDev_SD_Card_BSP_CmdDataWr()
void  FSDev_SD_Card_BSP_CmdDataWr (FS_QTY               unit_nbr,
Anchor
11427361142736
Anchor
11427371142737
Anchor
11427381142738
Anchor
11427391142739
Anchor
11427401142740
Anchor
11427411142741
Anchor
11427421142742
Anchor
11427431142743
Anchor
11427441142744
Anchor
11427451142745
Anchor
11427461142746
Anchor
11427471142747
Anchor
11427481142748
Anchor
11427491142749
Anchor
11427501142750
Anchor
11427511142751
Anchor
11427521142752
Anchor
11427531142753
Anchor
11427541142754
Anchor
11427551142755
Anchor
11427561142756
Anchor
11427571142757
Anchor
11427581142758
Anchor
11427591142759
Anchor
11427601142760
Anchor
11427611142761
Anchor
11427621142762
Anchor
11427631142763
Anchor
11427641142764
Anchor
11427651142765
Anchor
11427661142766
Anchor
11427671142767
Anchor
11427681142768
Anchor
11427691142769
Anchor
11427701142770
Anchor
11427711142771
Anchor
11427721142772

...

                                                  (3)
}


Panel
bgColor#f0f0f0

(1) Wait until data transfer completes or an error occurs. The wait loop (or wait on semaphore) SHOULD always have a timeout to avoid blocking the task in the case of an unforeseen hardware malfunction or a software flaw.

...

(2) Check if an error occurred. The error status register is decoded to produce the actual error condition. That is not necessary, strictly, but error counters that accumulate within the generic driver based upon returned error values may be useful while debugging a port.

...

(3) Return no error. The data has been transferred already from the memory buffer using DMA.