Note:
Data Structures | |
struct | lfs_sd_bd_config_t |
Configuration structure for the SD block device. More... | |
Macros | |
#define | LFS_SD_BD_TRACE(...) |
Enable trace for this driver by defining this macro. More... | |
Functions | |
void | lfs_sd_bd_get_default_config (lfs_sd_bd_config_t *bd_cfg) |
Fetches the default configuration for the block device for use with the lfs_sd_bd_create() function. More... | |
cy_rslt_t | lfs_sd_bd_create (struct lfs_config *lfs_cfg, const lfs_sd_bd_config_t *bd_cfg) |
Initializes the SD card interface and populates the lfs_config structure with the default values. More... | |
void | lfs_sd_bd_destroy (const struct lfs_config *lfs_cfg) |
De-initializes the SD interface and frees the resources. More... | |
int | lfs_sd_bd_read (const struct lfs_config *lfs_cfg, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size) |
Reads data starting from a given block and offset. More... | |
int | lfs_sd_bd_prog (const struct lfs_config *lfs_cfg, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size) |
Programs or writes the data starting from a given block and offset. More... | |
int | lfs_sd_bd_erase (const struct lfs_config *lfs_cfg, lfs_block_t block) |
Erases a given block. More... | |
int | lfs_sd_bd_sync (const struct lfs_config *lfs_cfg) |
Flushes the write cache when present. More... | |
int | lfs_sd_bd_lock (const struct lfs_config *lfs_cfg) |
Locks or gets the mutex associated with this block device. More... | |
int | lfs_sd_bd_unlock (const struct lfs_config *lfs_cfg) |
Unlocks or sets the mutex associated with this block device. More... | |
struct lfs_sd_bd_config_t |
#define LFS_SD_BD_TRACE | ( | ... | ) |
Enable trace for this driver by defining this macro.
You must also define the global trace enable macro LFS_YES_TRACE.
void lfs_sd_bd_get_default_config | ( | lfs_sd_bd_config_t * | bd_cfg | ) |
Fetches the default configuration for the block device for use with the lfs_sd_bd_create() function.
Default configuration: SD card (card mode) with 3.3V signalling.
bd_cfg | Pointer to the block device configuration structure. |
cy_rslt_t lfs_sd_bd_create | ( | struct lfs_config * | lfs_cfg, |
const lfs_sd_bd_config_t * | bd_cfg | ||
) |
Initializes the SD card interface and populates the lfs_config structure with the default values.
lfs_cfg | Pointer to the lfs_config structure that will be initialized with the default values. |
bd_cfg | Pointer to the block device configuration structure. |
void lfs_sd_bd_destroy | ( | const struct lfs_config * | lfs_cfg | ) |
De-initializes the SD interface and frees the resources.
lfs_cfg | Pointer to the lfs_config structure. |
int lfs_sd_bd_read | ( | const struct lfs_config * | lfs_cfg, |
lfs_block_t | block, | ||
lfs_off_t | off, | ||
void * | buffer, | ||
lfs_size_t | size | ||
) |
Reads data starting from a given block and offset.
This is a blocking function.
lfs_cfg | Pointer to the lfs_config structure. |
block | Block number from which read should begin. |
off | Offset in the block from which read should begin. |
buffer | Pointer to the buffer to store the data read from the memory. |
size | Number of bytes to read. |
int lfs_sd_bd_prog | ( | const struct lfs_config * | lfs_cfg, |
lfs_block_t | block, | ||
lfs_off_t | off, | ||
const void * | buffer, | ||
lfs_size_t | size | ||
) |
Programs or writes the data starting from a given block and offset.
The block must have been previously erased. This is a blocking function.
lfs_cfg | Pointer to the lfs_config structure. |
block | Block number from which write should begin. |
off | Offset in the block from which write should begin. |
buffer | Pointer to the buffer that contains the data to be written. |
size | Number of bytes to write. |
int lfs_sd_bd_erase | ( | const struct lfs_config * | lfs_cfg, |
lfs_block_t | block | ||
) |
Erases a given block.
SD/MMC cards do not require explicit erase before programming since the card controllers perform erase internally during programming. Therefore, this API is not to be used with the erase() of lfs_config structure. However, user can directly call this API to erase specific blocks of a memory card.
lfs_cfg | Pointer to the lfs_config structure. |
block | Block number to be erased. |
int lfs_sd_bd_sync | ( | const struct lfs_config * | lfs_cfg | ) |
Flushes the write cache when present.
Simply returns zero because the SDHC block does not have any write cache.
lfs_cfg | Pointer to the lfs_config structure. |
int lfs_sd_bd_lock | ( | const struct lfs_config * | lfs_cfg | ) |
Locks or gets the mutex associated with this block device.
This function is internally called by the littlefs APIs when LFS_THREADSAFE is defined. User should call this function directly only if the other block device functions are directly called and thread-safety is required in that case.
lfs_cfg | Pointer to the lfs_config structure. |
int lfs_sd_bd_unlock | ( | const struct lfs_config * | lfs_cfg | ) |
Unlocks or sets the mutex associated with this block device.
This function is internally called by the littlefs APIs when LFS_THREADSAFE is defined. User should call this function directly only if the other block device functions are directly called and thread-safety is required in that case.
lfs_cfg | Pointer to the lfs_config structure. |