ChibiOS
21.6.0
|
This module implements a common ancestor for all device drivers accessing MMC or SD cards. This interface inherits the state machine and the interface from the Abstract I/O Block Device module.
Macros | |
#define | MMCSD_BLOCK_SIZE 512U |
Fixed block size for MMC/SD block devices. More... | |
#define | MMCSD_R1_ERROR_MASK 0xFDFFE008U |
Mask of error bits in R1 responses. More... | |
#define | MMCSD_CMD8_PATTERN 0x000001AAU |
Fixed pattern for CMD8. More... | |
#define | _mmcsd_block_device_methods _base_block_device_methods |
MMCSDBlockDevice specific methods. More... | |
#define | _mmcsd_block_device_data |
MMCSDBlockDevice specific data. More... | |
R1 response utilities | |
#define | MMCSD_R1_ERROR(r1) (((r1) & MMCSD_R1_ERROR_MASK) != 0U) |
Evaluates to true if the R1 response contains error flags. More... | |
#define | MMCSD_R1_STS(r1) (((r1) >> 9U) & 15U) |
Returns the status field of an R1 response. More... | |
#define | MMCSD_R1_IS_CARD_LOCKED(r1) ((((r1) >> 21U) & 1U) != 0U) |
Evaluates to true if the R1 response indicates a locked card. More... | |
Macro Functions | |
#define | mmcsdGetCardCapacity(ip) ((ip)->capacity) |
Returns the card capacity in blocks. More... | |
Data Structures | |
struct | MMCSDBlockDeviceVMT |
MMCSDBlockDevice virtual methods table. More... | |
struct | MMCSDBlockDevice |
MCC/SD block device class. More... | |
struct | unpacked_sdc_cid_t |
Unpacked CID register from SDC. More... | |
struct | unpacked_mmc_cid_t |
Unpacked CID register from MMC. More... | |
struct | unpacked_sdc_csd_10_t |
Unpacked CSD v1.0 register from SDC. More... | |
struct | unpacked_sdc_csd_20_t |
Unpacked CSD v2.0 register from SDC. More... | |
struct | unpacked_mmc_csd_t |
Unpacked CSD register from MMC. More... | |
Functions | |
uint32_t | _mmcsd_get_slice (const uint32_t *data, uint32_t end, uint32_t start) |
Gets a bit field from a words array. More... | |
uint32_t | _mmcsd_get_capacity (const uint32_t *csd) |
Extract card capacity from a CSD. More... | |
uint32_t | _mmcsd_get_capacity_ext (const uint8_t *ext_csd) |
Extract MMC card capacity from EXT_CSD. More... | |
void | _mmcsd_unpack_sdc_cid (const MMCSDBlockDevice *sdcp, unpacked_sdc_cid_t *cidsdc) |
Unpacks SDC CID array in structure. More... | |
void | _mmcsd_unpack_mmc_cid (const MMCSDBlockDevice *sdcp, unpacked_mmc_cid_t *cidmmc) |
Unpacks MMC CID array in structure. More... | |
void | _mmcsd_unpack_csd_mmc (const MMCSDBlockDevice *sdcp, unpacked_mmc_csd_t *csdmmc) |
Unpacks MMC CSD array in structure. More... | |
void | _mmcsd_unpack_csd_v10 (const MMCSDBlockDevice *sdcp, unpacked_sdc_csd_10_t *csd10) |
Unpacks SDC CSD v1.0 array in structure. More... | |
void | _mmcsd_unpack_csd_v20 (const MMCSDBlockDevice *sdcp, unpacked_sdc_csd_20_t *csd20) |
Unpacks SDC CSD v2.0 array in structure. More... | |
#define MMCSD_BLOCK_SIZE 512U |
Fixed block size for MMC/SD block devices.
Definition at line 39 of file hal_mmcsd.h.
#define MMCSD_R1_ERROR_MASK 0xFDFFE008U |
Mask of error bits in R1 responses.
Definition at line 44 of file hal_mmcsd.h.
#define MMCSD_CMD8_PATTERN 0x000001AAU |
Fixed pattern for CMD8.
Definition at line 49 of file hal_mmcsd.h.
#define _mmcsd_block_device_methods _base_block_device_methods |
MMCSDBlockDevice
specific methods.
Definition at line 246 of file hal_mmcsd.h.
#define _mmcsd_block_device_data |
MMCSDBlockDevice
specific data.
MMCSDBlockDevice
is only an interface without implementation. Definition at line 254 of file hal_mmcsd.h.
#define MMCSD_R1_ERROR | ( | r1 | ) | (((r1) & MMCSD_R1_ERROR_MASK) != 0U) |
Evaluates to true
if the R1 response contains error flags.
[in] | r1 | the r1 response |
Definition at line 431 of file hal_mmcsd.h.
#define MMCSD_R1_STS | ( | r1 | ) | (((r1) >> 9U) & 15U) |
Returns the status field of an R1 response.
[in] | r1 | the r1 response |
Definition at line 438 of file hal_mmcsd.h.
#define MMCSD_R1_IS_CARD_LOCKED | ( | r1 | ) | ((((r1) >> 21U) & 1U) != 0U) |
Evaluates to true
if the R1 response indicates a locked card.
[in] | r1 | the r1 response |
Definition at line 445 of file hal_mmcsd.h.
#define mmcsdGetCardCapacity | ( | ip | ) | ((ip)->capacity) |
Returns the card capacity in blocks.
[in] | ip | pointer to a MMCSDBlockDevice or derived class |
Definition at line 461 of file hal_mmcsd.h.
uint32_t _mmcsd_get_slice | ( | const uint32_t * | data, |
uint32_t | end, | ||
uint32_t | start | ||
) |
Gets a bit field from a words array.
[in] | data | pointer to the words array |
[in] | end | bit offset of the last bit of the field, inclusive |
[in] | start | bit offset of the first bit of the field, inclusive |
Definition at line 61 of file hal_mmcsd.c.
References osalDbgCheck.
Referenced by _mmcsd_get_capacity(), _mmcsd_unpack_csd_mmc(), _mmcsd_unpack_csd_v10(), _mmcsd_unpack_csd_v20(), _mmcsd_unpack_mmc_cid(), and _mmcsd_unpack_sdc_cid().
uint32_t _mmcsd_get_capacity | ( | const uint32_t * | csd | ) |
Extract card capacity from a CSD.
The capacity is returned as number of available blocks.
[in] | csd | the CSD record |
0 | CSD format error |
Definition at line 93 of file hal_mmcsd.c.
References _mmcsd_get_slice(), and osalDbgCheck.
uint32_t _mmcsd_get_capacity_ext | ( | const uint8_t * | ext_csd | ) |
Extract MMC card capacity from EXT_CSD.
The capacity is returned as number of available blocks.
[in] | ext_csd | the extended CSD record |
Definition at line 125 of file hal_mmcsd.c.
References osalDbgCheck.
void _mmcsd_unpack_sdc_cid | ( | const MMCSDBlockDevice * | sdcp, |
unpacked_sdc_cid_t * | cidsdc | ||
) |
Unpacks SDC CID array in structure.
[in] | sdcp | pointer to the MMCSDBlockDevice object |
[out] | cidsdc | pointer to the unpacked_sdc_cid_t object |
Definition at line 143 of file hal_mmcsd.c.
References _mmcsd_get_slice(), and osalDbgCheck.
void _mmcsd_unpack_mmc_cid | ( | const MMCSDBlockDevice * | sdcp, |
unpacked_mmc_cid_t * | cidmmc | ||
) |
Unpacks MMC CID array in structure.
[in] | sdcp | pointer to the MMCSDBlockDevice object |
[out] | cidmmc | pointer to the unpacked_mmc_cid_t object |
Definition at line 174 of file hal_mmcsd.c.
References _mmcsd_get_slice(), and osalDbgCheck.
void _mmcsd_unpack_csd_mmc | ( | const MMCSDBlockDevice * | sdcp, |
unpacked_mmc_csd_t * | csdmmc | ||
) |
Unpacks MMC CSD array in structure.
[in] | sdcp | pointer to the MMCSDBlockDevice object |
[out] | csdmmc | pointer to the unpacked_mmc_csd_t object |
Definition at line 206 of file hal_mmcsd.c.
References _mmcsd_get_slice(), and osalDbgCheck.
void _mmcsd_unpack_csd_v10 | ( | const MMCSDBlockDevice * | sdcp, |
unpacked_sdc_csd_10_t * | csd10 | ||
) |
Unpacks SDC CSD v1.0 array in structure.
[in] | sdcp | pointer to the MMCSDBlockDevice object |
[out] | csd10 | pointer to the unpacked_sdc_csd_10_t object |
Definition at line 254 of file hal_mmcsd.c.
References _mmcsd_get_slice(), and osalDbgCheck.
void _mmcsd_unpack_csd_v20 | ( | const MMCSDBlockDevice * | sdcp, |
unpacked_sdc_csd_20_t * | csd20 | ||
) |
Unpacks SDC CSD v2.0 array in structure.
[in] | sdcp | pointer to the MMCSDBlockDevice object |
[out] | csd20 | pointer to the unpacked_sdc_csd_20_t object |
Definition at line 296 of file hal_mmcsd.c.
References _mmcsd_get_slice(), and osalDbgCheck.