OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2258|回复: 4

USB虚拟串口或者读卡器实验的的USB_Init()函数没看懂

[复制链接]

1

主题

4

帖子

0

精华

新手上路

积分
47
金钱
47
注册时间
2019-6-1
在线时间
9 小时
发表于 2019-7-18 17:22:32 | 显示全部楼层 |阅读模式
3金钱

以下是USB初始化函数

void USB_Init(void)
{
  pInformation = &Device_Info;    //定义了一个实体结构
  pInformation->ControlState = 2;     //设置了内部变量
  pProperty = &Device_Property;     //定义了一个实体结构
  pUser_Standard_Requests = &User_Standard_Requests;   //定义了一个实体结构
  /* Initialize devices one by one */
  pProperty->Init();  //这个函数我知道是调用 pProperty的init()函数,可这个函数是空的啊,求大家不吝赐教!!!!!!!!!!
}

以下是上面那个 pProperty的结构体定义
typedef struct _DEVICE_PROP
{
  void (*Init)(void);        /* Initialize the device */
  void (*Reset)(void);       /* Reset routine of this device */

  /* Device dependent process after the status stage */
  void (*Process_Status_IN)(void);
  void (*Process_Status_OUT)(void);

  /* Procedure of process on setup stage of a class specified request with data stage */
  /* All class specified requests with data stage are processed in Class_Data_Setup
   Class_Data_Setup()
    responses to check all special requests and fills ENDPOINT_INFO
    according to the request
    If IN tokens are expected, then wLength & wOffset will be filled
    with the total transferring bytes and the starting position
    If OUT tokens are expected, then rLength & rOffset will be filled
    with the total expected bytes and the starting position in the buffer

    If the request is valid, Class_Data_Setup returns SUCCESS, else UNSUPPORT

   CAUTION:
    Since GET_CONFIGURATION & GET_INTERFACE are highly related to
    the individual classes, they will be checked and processed here.
  */
  RESULT (*Class_Data_Setup)(uint8_t RequestNo);

  /* Procedure of process on setup stage of a class specified request without data stage */
  /* All class specified requests without data stage are processed in Class_NoData_Setup
   Class_NoData_Setup
    responses to check all special requests and perform the request

   CAUTION:
    Since SET_CONFIGURATION & SET_INTERFACE are highly related to
    the individual classes, they will be checked and processed here.
  */
  RESULT (*Class_NoData_Setup)(uint8_t RequestNo);

  /*Class_Get_Interface_Setting
   This function is used by the file usb_core.c to test if the selected Interface
   and Alternate Setting (uint8_t Interface, uint8_t AlternateSetting) are supported by
   the application.
   This function is writing by user. It should return "SUCCESS" if the Interface
   and Alternate Setting are supported by the application or "UNSUPPORT" if they
   are not supported. */

  RESULT  (*Class_Get_Interface_Setting)(uint8_t Interface, uint8_t AlternateSetting);

  uint8_t* (*GetDeviceDescriptor)(uint16_t Length);
  uint8_t* (*GetConfigDescriptor)(uint16_t Length);
  uint8_t* (*GetStringDescriptor)(uint16_t Length);

  /* This field is not used in current library version. It is kept only for
   compatibility with previous versions */
  void* RxEP_buffer;
   
  uint8_t MaxPacketSize;

}DEVICE_PROP;



这个init函数执行到哪里去了????


最佳答案

查看完整内容[请看2#楼]

我去睡了半个小时,清醒了好多。搞定了。原来把Device_Property结构体的值赴给了DEVICE_PROP。把User_Standard_Requests结构体付给了pUser_Standard_Requests。原来DEVICE_PROP就是个空壳,哎一个问题搞不懂时就要去睡一觉啊。
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
47
金钱
47
注册时间
2019-6-1
在线时间
9 小时
 楼主| 发表于 2019-7-18 17:22:33 | 显示全部楼层
我去睡了半个小时,清醒了好多。搞定了。原来把Device_Property结构体的值赴给了DEVICE_PROP。把User_Standard_Requests结构体付给了pUser_Standard_Requests。原来DEVICE_PROP就是个空壳,哎一个问题搞不懂时就要去睡一觉啊。
回复

使用道具 举报

10

主题

293

帖子

0

精华

高级会员

Rank: 4

积分
623
金钱
623
注册时间
2019-6-3
在线时间
107 小时
发表于 2019-7-18 17:25:25 | 显示全部楼层
这个函数供主程序调用,你看看.c文件有没有USB_Init()这个函数
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
47
金钱
47
注册时间
2019-6-1
在线时间
9 小时
 楼主| 发表于 2019-7-18 18:10:54 | 显示全部楼层
迅得电子 发表于 2019-7-18 17:25
这个函数供主程序调用,你看看.c文件有没有USB_Init()这个函数

第一个程序是USB_init()在usb_init.c里的啊。
找说的不是它是空的,是DEVICE_PROP结构体里的void(*Init)(void)是空的。
回复

使用道具 举报

10

主题

293

帖子

0

精华

高级会员

Rank: 4

积分
623
金钱
623
注册时间
2019-6-3
在线时间
107 小时
发表于 2019-7-19 08:31:39 | 显示全部楼层
lkjh 发表于 2019-7-18 18:10
第一个程序是USB_init()在usb_init.c里的啊。
找说的不是它是空的,是DEVICE_PROP结构体里的void(*Init ...

哦哦哦,了解啦
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-27 05:39

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表