- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# drivers/sdmmc/request.c

Go to the documentation of this file.

    00001
    00042 #include <bitops.h>
    00043 #include <byteorder.h>
    00044 #include <debug.h>
    00045 #include <stdbool.h>
    00046 #include <string.h>
    00047 #include <util.h>
    00048 #include <sdmmc/sdmmc.h>
    00049 #include "protocol.h"
    00050
    00051 void sdmmc_req_prep_transfer(struct sdmmc_slot *slot, struct sdmmc_request *req,
    00052                 uint32_t lba, uint32_t nr_blocks, bool write)
    00053 {
    00054         uint8_t opcode;
    00055
    00056         req->block_size = slot->card.block_size;
    00057         req->blocks = nr_blocks;
    00058         req->flags = 0;
    00059         if (write)
    00060                 set_bit(SDMMC_REQ_WRITE, &req->flags);
    00061
    00062         if (nr_blocks > 1) {
    00063                 set_bit(SDMMC_REQ_STOP, &req->flags);
    00064                 if (write)
    00065                         opcode = SDMMC_WRITE_MULTIPLE_BLOCK;
    00066                 else
    00067                         opcode = SDMMC_READ_MULTIPLE_BLOCK;
    00068         } else {
    00069                 if (write)
    00070                         opcode = SDMMC_WRITE_BLOCK;
    00071                 else
    00072                         opcode = SDMMC_READ_SINGLE_BLOCK;
    00073         }
    00074
    00075         lba = sdmmc_card_block2addr(&slot->card, lba);
    00076
    00077         sdmmc_req_prep_cmd(req, opcode, lba, SDMMC_RSP_R1);
    00078 }