Jump to main content

##

# 1.1.7.4.12 DRV_SDSPI_GeometryGet Function

## C

    SYS_MEDIA_GEOMETRY* DRV_SDSPI_GeometryGet
    (
        const DRV_HANDLE handle
    )

## Summary

Returns the geometry of the device.

## Description

This API gives the following geometrical details of the SD Card.

- Media Property
- Number of Read/Write/Erase regions in the SD Card
- Number of Blocks and their size in each region of the device

## Precondition

The DRV_SDSPI_Initialize routine must have been called for the specified SDSPI driver instance.

The DRV_SDSPI_Open routine must have been called to obtain a valid opened device handle.

## Parameters

Param | Description
--- | ---
handle | A valid open-instance handle, returned from the driver's open function

## Returns

SYS_MEDIA_GEOMETRY - Pointer to structure which holds the media geometry information.

## Example

    SYS_MEDIA_GEOMETRY * SDSPIGeometry;
    uint32_t readBlockSize, writeBlockSize, eraseBlockSize;
    uint32_t nReadBlocks, nReadRegions, totalSize;

    // mySDSPIHandle is the handle returned by the DRV_SDSPI_Open function.
    SDSPIGeometry = DRV_SDSPI_GeometryGet(mySDSPIHandle);

    readBlockSize = SDSPIGeometry->geometryTable->blockSize;
    nReadBlocks = SDSPIGeometry->geometryTable->numBlocks;
    nReadRegions = SDSPIGeometry->numReadRegions;

    writeBlockSize = (SDSPIGeometry->geometryTable +1)->blockSize;
    eraseBlockSize = (SDSPIGeometry->geometryTable +2)->blockSize;

    totalSize = readBlockSize * nReadBlocks * nReadRegions;

## Remarks

Refer sys_media.h for definition of SYS_MEDIA_GEOMETRY.