STM32 study notes USB library file analysis

Publisher:pengbinyyyLatest update time:2018-09-13 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Mainly analyze some other files:

usb_core.c,

usb_init.c,

usb_int.c,

usb_mem.c,

usb_reg.c

usb_sil.c

1,

usb_core.c -- As the name suggests, this is the core file of USB. This file mainly contains some functional functions of USB during enumeration, such as various standard request functions for control transmission establishment phase, data phase, status phase, and processing functions for each phase.


uint8_t Setup0_Process(void); uint8_t Post0_Process(void); uint8_t Out0_Process(void); uint8_t In0_Process(void); RESULT Standard_SetEndPointFeature(void); RESULT Standard_SetDeviceFeature(void); uint8_t*Standard_GetConfiguration(uint16_t Length); Standard_SetConfiguration(void); uint8_t *Standard_GetInterface(uint16_t Length); RESULT Standard_SetInterface(void); uint8_t *Standard_GetDescriptorData(uint16_t Length, PONE_DESCRIPTOR pDesc); uint8_t *Standard_GetStatus(uint16_t Length); RESULT Standard_ClearFeature(void); void SetDeviceAddress (uint8_t); void NOP_Process(void);

2,

usb_init.c - file. This file is very simple, with only one function: void USB_Init(void). This function is also very simple, just registering the basic information of the USB device:


/******************************************************************************* * Function Name : USB_Init * Description : USB system initialization * Input : None. * Output : None. * Return : None. *******************************************************************************/ void USB_Init(void) { pInformation = &Device_Info; //Register device information structure pInformation->ControlState = 2; //Control state is IN_DATA pProperty = &Device_Property; //Register some common function structures of the device pUser_Standard_Requests = &User_Standard_Requests; /* Initialize devices one by one */ pProperty->Init(); //Register initialization function }

As for the writing of pProperty->Init(), it executes the function pointed to by the Init function pointer of the pProperty structure. We have registered the initialization function CustomHID_init() in DEVICE_PROP Device_Property of usb_prop.c.


3.

usb_int.c - file, this file defines two interrupt service routines: low priority endpoint correct transmission interrupt service routine void CTR_LP (void) and high priority endpoint correct transmission interrupt service routine void CTR_HP (void). Our project only uses the void CTR_LP (void) function. CTR_LP will be called in the interrupt service routine USB_Istr of the ISTR interrupt event in the usb.istr.c file if the data or request is correctly transmitted.

4.

usb_mem.c - There are two main memory data movement functions: one is to copy data from the PMA buffer to the user-specified memory space PMAToUserBufferCopy(). Obviously, this function will only be used after the endpoint receives data; the other is to copy data from user space to the PMA buffer. It will be called only when the endpoint wants to send data.

5.

usb_reg.c - file, which is the code related to the USB related registers of stm32. To read this code, you need to read the stm32 registers. This function defines how to set and read the value of each register or the value of a certain bit. See the code for details.

6.

usb_sil.c - file. The endpoint specific data transmission and reception functions are defined here. This file is also very simple, with only three functions: USB_SIL_Init() initializes the USB device IP and endpoints; USB_SIL_Write() writes data to the selected endpoint; USB_SIL_Read() reads data from the selected endpoint


Keywords:STM32 Reference address:STM32 study notes USB library file analysis

Previous article:Analysis and use of STM32 official library files
Next article:STM32F0 creates a new project in IAR

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号