打印
[STM32F0]

STM32提供的库

[复制链接]
785|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wanglaojii|  楼主 | 2016-8-13 11:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM32, se, ce, TE, TI
要学好C语言你还得看STM32提供的库 。这俩typedef struct彻底颠覆了我对C语言知识。typedef struct _USER_STANDARD_REQUESTS
{
  void (*User_GetConfiguration)(void);       /* Get Configuration */
  void (*User_SetConfiguration)(void);       /* Set Configuration */
  void (*User_GetInterface)(void);           /* Get Interface */
  void (*User_SetInterface)(void);           /* Set Interface */
  void (*User_GetStatus)(void);              /* Get Status */
  void (*User_ClearFeature)(void);           /* Clear Feature */
  void (*User_SetEndPointFeature)(void);     /* Set Endpoint Feature */
  void (*User_SetDeviceFeature)(void);       /* Set Device Feature */
  void (*User_SetDeviceAddress)(void);       /* Set Device Address */
}
USER_STANDARD_REQUESTS;
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);
  uint8_t* RxEP_buffer;
  uint8_t MaxPacketSize;
}DEVICE_PROP;
应用分析:struct是一个结构体,可以用来构造数据类型。所以可以得知这两个struct里面的数据不是函数,而是函数指针,即它是一个指针,指向一个函数。RESULT,uint8_t*,void是函数的返回值类型。
沙发
laozhongyi| | 2016-8-13 11:55 | 只看该作者

 好详细的帖子,谢谢lz

使用特权

评论回复
板凳
Edisons| | 2016-8-13 12:11 | 只看该作者
struct是一个结构体,可以用来构造数据类型。

使用特权

评论回复
地板
_gege| | 2016-8-13 12:21 | 只看该作者
STM32提供的库确实蛮重要的呀!!!

使用特权

评论回复
5
Mozarts| | 2016-8-13 12:26 | 只看该作者
多谢楼主解析,stm32库函数这个一定是要学习的。。

使用特权

评论回复
6
Listate| | 2016-8-13 12:39 | 只看该作者
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

使用特权

评论回复
7
xia00| | 2016-8-13 12:42 | 只看该作者
现在也在接触库函数的学习了。不过感觉入门很困难啊!!

使用特权

评论回复
8
mmuuss586| | 2016-8-13 19:35 | 只看该作者
学习了;

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

220

主题

1411

帖子

1

粉丝