|
下面两个结构体是在Harmony V1.0中的 USB HOST中看到的,第一个结构体是函数指针列表,但这些函数指针并没有对应的同名函数。第二个结构是似乎是将第一个结构体中的函数指针对应到实际的函数。是不是这样呢? 标准的C能这样用还是Microchip编译器环境中的一种特殊用法?
第一个结构体:
typedef struct _SYS_FS_MEDIA
{
/* If the media object is in use or is it free */
bool inUse;
/* Media driver index. The index is used to open the media driver */
SYS_MODULE_INDEX index;
/* List of functions for the media driver */
const SYS_FS_MEDIA_FUNCTIONS * mediaDriverFunctions;
/* State of the media (Registered, opened, attached, analyzed) */
SYS_FS_MEDIA_STATE mediaState;
/* Media driver object. This object is used to run the media task routine */
SYS_MODULE_OBJ mediaDriverObject;
/* Handle received after the media driver is opened */
DRV_HANDLE mediaDriverClientHandle;
/* Type of the media */
SYS_FS_MEDIA_TYPE mediaType;
/* Handle received when trying to read or write a sector from the media */
SYS_FS_MEDIA_BUFFER_HANDLE mediaBufferHandle;
/* Status of media -- attached or detached */
SYS_FS_MEDIA_STATUS mediaStatus;
/* Number of partitions available in the media */
uint8_t numberOfPartitions;
/* Number identifying the media. This is a alphabet name for each media. It
starts with a, b etc. */
uint8_t mediaId;
/* This is a count for media. For every new media (any type) registered, this
counter is assigned a new value */
uint8_t mediaCounter;
/* Number of volumes that can be assigned in the present media. This reflects
the number of partitions available on the media */
uint8_t volumeCounter;
}
SYS_FS_MEDIA;
第二个结构体:
SYS_FS_MEDIA_FUNCTIONS scsiUSBMediaFunctions =
{
.mediaStatusGet = USB_HOST_SCSI_MediaStatusGet,
.sectorRead = USB_HOST_SCSI_SectorRead,
.sectorWrite = USB_HOST_SCSI_SectorWrite,
.bufferStatusGet = USB_HOST_SCSI_BufferStatusGet,
.open = USB_HOST_SCSI_Open,
.close = USB_HOST_SCSI_Close,
.tasks = USB_HOST_SCSI_Task_FS,
}; |
|