你好,我在查看USB的底层驱动的时候看到变量的定义不知道为什么这么些,但是我知道都是有意思的,我不太明白为什么这么写
希望能得到您的帮助,谢谢。
unsigned long
USBBufferEventCallback(void *pvCBData, unsigned long ulEvent,
unsigned long ulMsgValue, void *pvMsgData)
问题一:
这里面有void *pvCBData 给出的定义是pvCBData is the client-supplied callback pointer associated with this buffer instance
这个我能明白是什么意思,也知道变量的意思,但是我不太明白pvCB 代表的是什么意思?是什么单词的缩写。
pvMsgData is an event-specific data pointer.这个里面的pv 又是代表什么意思,像unsigned long ulEvent 中的ulEvent 中的ul代表的是unsigned long 这个我一看
就能明白什么意思。我不太明白这些指针的英文缩写。
问题二:
//
//! A pointer to the callback function which will be called to notify
//! the application of all asynchronous control events related to the
//! operation of the device.
//
tUSBCallback pfnControlCallback; 这个里面的pfn 是代表的point function notify 么?
问题三:
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the control channel callback,
//! pfnControlCallback.
//
void *pvControlCBData;这个函数指针 pv 又是什么。
问题四:
我在做USB 开发的时候
像
//
//! A pointer to the callback function which will be called to notify
//! the application of all asynchronous control events related to the
//! operation of the device.
//
tUSBCallback pfnControlCallback; 为什么自己重新写这个函数,也就是说我为什么要写这个函数,而不是调用库里面的函数,
我看见这个函数指针是用tUSBCallback 定义的,tUSBCallback的声明
typedef unsigned long (* tUSBCallback)(void *pvCBData, unsigned long ulEvent,
unsigned long ulMsgParam,
void *pvMsgData);
而
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data receive channel.
//
tUSBCallback pfnRxCallback; 这个函数指针却不需要我在重新写,用库里面的定义就行了,
extern unsigned long USBBufferEventCallback(void *pvCBData,
unsigned long ulEvent,
unsigned long ulMsgValue,
void *pvMsgData);也就是这个函数。
TI 头文件的中结构体的定义:
//*****************************************************************************
//
//! The structure used by the application to define operating parameters for
//! the CDC device.
//
//*****************************************************************************
typedef struct
{
//
//! The vendor ID that this device is to present in the device descriptor.
//
unsigned short usVID;
//
//! The product ID that this device is to present in the device descriptor.
//
unsigned short usPID;
//
//! The maximum power consumption of the device, expressed in milliamps.
//
unsigned short usMaxPowermA;
//
//! Indicates whether the device is self- or bus-powered and whether or not
//! it supports remote wakeup. Valid values are USB_CONF_ATTR_SELF_PWR or
//! USB_CONF_ATTR_BUS_PWR, optionally ORed with USB_CONF_ATTR_RWAKE.
//
unsigned char ucPwrAttributes;
//
//! A pointer to the callback function which will be called to notify
//! the application of all asynchronous control events related to the
//! operation of the device.
//
tUSBCallback pfnControlCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the control channel callback,
//! pfnControlCallback.
//
void *pvControlCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data receive channel.
//
tUSBCallback pfnRxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the receive channel callback,
//! pfnRxCallback.
//
void *pvRxCBData;
//
//! A pointer to the callback function which will be called to notify
//! the application of events related to the device's data transmit
//! channel.
//
tUSBCallback pfnTxCallback;
//
//! A client-supplied pointer which will be sent as the first
//! parameter in all calls made to the transmit channel callback,
//! pfnTxCallback.
//
void *pvTxCBData;
//
//! A pointer to the string descriptor array for this device. This array
//! must contain the following string descriptor pointers in this order.
//! Language descriptor, Manufacturer name string (language 1), Product
//! name string (language 1), Serial number string (language 1),
//! Control interface description string (language 1), Configuration
//! description string (language 1).
//!
//! If supporting more than 1 language, the strings for indices 1 through 5
//! must be repeated for each of the other languages defined in the
//! language descriptor.
//
const unsigned char * const *ppStringDescriptors;
//
//! The number of descriptors provided in the ppStringDescriptors
//! array. This must be 1 + (5 * number of supported languages).
//
unsigned long ulNumStringDescriptors;
//
//! A pointer to the private instance data for this device. This memory
//! must remain accessible for as long as the CDC device is in use and must
//! not be modified by any code outside the CDC class driver.
//
tCDCSerInstance *psPrivateCDCSerData;
}
tUSBDCDCDevice;
而我对结构体填充的时候,我是这样做的
const tUSBDCDCDevice g_sCDCDevice =
{
USB_VID_STELLARIS, // 厂商ID -这个不能更改
USB_PID_SERIAL, // 产品ID
0, // 最大功耗 -本设备为自供电,所以设置为0
USB_CONF_ATTR_SELF_PWR, // 定义设备为自供电
USBControlHandler, // USB控制端口处理函数 -需自己实现
(void *)&g_sCDCDevice, // 回调函数需要传递的CDC类实例指针
USBBufferEventCallback, // 数据处理回调函数, -USB库实现
(void *)&g_sRxBuffer, // 接收数据缓冲区指针
USBBufferEventCallback, // 数据缓冲事件处理回调函数,-USB库实现
(void *)&g_sTxBuffer, // 数据发送缓冲区指针
g_pStringDescriptors, // 字符串描述符的列表
NUM_STRING_DESCRIPTORS, // 字符串描述符的个数
&g_sCDCInstance // CDC类的实例
};
我怎么判断哪些是我需要写的,哪里是可以调用的函数库里面的。
我需要怎么快时候的查到函数需要重新自己写???
问的比较乱,希望能得到您的回到。谢谢。