每个 FreeRTOS-Plus-FAT 媒体驱动程序都需要一个函数来
从存储嵌入式文件系统的媒体中读取扇区。 读取函数的
实际工作方式取决于媒体类型。 例如,如果
媒体是 RAM 磁盘,则可以使用 memcpy() 从 RAM 读取数据,
但如果媒体是 SD 卡,则卡的命令接口
必须通过 MMC 或 SPI 外围驱动器使用。
读取函数
读取函数可以具有任何名称,但必须具有以下原型:
int32_t prvFFRead( uint8_t *pucDestination,
uint32_t ulSectorNumber,
uint32_t ulSectorCount,
FF_Disk_t *pxDisk );
The prototype of a function used to read sectors from the media holding the embedded file system
示例大致描述了
FreeRTOS-Plus-FAT RAM 磁盘驱动器中使用的读取函数。 完整版本包含输入参数检查,
,
/FreeRTOS-Plus/Source/FreeRTOS-Plus-FAT/portable/common/ff_ramdisk.c。
#define ramSECTOR_SIZE 512
static int32_t prvReadRAM( uint8_t *pucDestination,
uint32_t ulSectorNumber,
uint32_t ulSectorCount,
FF_Disk_t *pxDisk )
{
uint8_t *pucSource;
pucSource = ( uint8_t * ) pxDisk->pvTag;
pucSource += ( ramSECTOR_SIZE * ulSectorNumber );
memcpy( ( void * ) pucDestination,
( void * ) pucSource,
( size_t ) ( ulSectorCount * ramSECTOR_SIZE ) );
return FF_ERR_NONE;
}
The read function used by the RAM disk driver - for clarity input parameter checking is not shown
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.