完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我在查看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类的实例 ]; 我怎么判断哪些是我需要写的,哪里是可以调用的函数库里面的。 我需要怎么快时候的查到函数需要重新自己写??? 问的比较乱,希望能得到您的回到。谢谢。 |
|
相关推荐
5 个讨论
|
|
u***中断触发,不用你调用,它属于u***收发的结构体里面,通过u***触发接收或者发送任务就能使能他们。源代码是:
//***************************************************************************** // // Receive buffer (from the USB perspective). // //***************************************************************************** unsigned char g_pucUSBRxBuffer[BULK_BUFFER_SIZE]; unsigned char g_pucRxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE]; const tUSBBuffer g_sRxBuffer = [ false, // This is a receive buffer. RxHandler, // pfnCallback (void *)&g_sBulkDevice, // Callback data is our device pointer. USBDBulkPacketRead, // pfnTransfer USBDBulkRxPacketAvailable, // pfnAvailable (void *)&g_sBulkDevice, // pvHandle g_pucUSBRxBuffer, // pcBuffer BULK_BUFFER_SIZE, // ulBufferSize g_pucRxBufferWorkspace // pvWorkspace ]; //***************************************************************************** // // Transmit buffer (from the USB perspective). // //***************************************************************************** unsigned char g_pucUSBTxBuffer[BULK_BUFFER_SIZE]; unsigned char g_pucTxBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE]; const tUSBBuffer g_sTxBuffer = [ true, // This is a transmit buffer. TxHandler, // pfnCallback (void *)&g_sBulkDevice, // Callback data is our device pointer. USBDBulkPacketWrite, // pfnTransfer USBDBulkTxPacketAvailable, // pfnAvailable (void *)&g_sBulkDevice, // pvHandle g_pucUSBTxBuffer, // pcBuffer BULK_BUFFER_SIZE, // ulBufferSize g_pucTxBufferWorkspace // pvWorkspace ]; |
|
|
|
|
|
TI的USB底层驱动已经是模块化形式的,已经很完善了,基本不用你改,唯一要你改的就是USB通信过程中收发事件,即TxHandler和RxHandler,这个要根据你实际应用来修改,举个RxHandler里面接收的例子,比如当u***有接收到数据时,就会USB_EVENT_RX_AVAILABLE触发事件,然后你要进行一些数据的读取,用USBBufferRead函数来实现,发送的话就是直接用USBBufferDataWritten函数直接发送即可。
至于你说的pv,ul,pfn等基本都是编程员的习惯缩写,一般p开头的都表示指针,比如pv就在你提到的变量表示以void类型的指针。关于TI的USB开发,可以交流一下,互相学习一下,因为这些USB内容本人已经在项目中一直执行并应用,希望能给你一些帮助 |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
340 浏览 1 评论
535 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
781 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
655 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1138 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
65浏览 29评论
189浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
256浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
205浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
63浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 16:23 , Processed in 1.463160 second(s), Total 69, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号
|