STM32 study notes USB project directory file analysis

Publisher:salahc1983Latest update time:2018-10-23 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Next, we need to analyze these files separately:

hw_config.c:

This file mainly configures some onboard and system related codes, such as USB system clock configuration, pull-up resistor pin and LED light configuration, and USB interrupt light. The main functions are as follows:


void Set_System(void); /*Set system clock, USB and LED pin configuration*/

void Set_USBClock(void); /*Set the USB clock frequency*/

void GPIO_AINConfig(void); /*Set GPIO analog input (empty function here)*/

void Enter_LowPowerMode(void); /*Enter low power mode (empty function here)*/

void Leave_LowPowerMode(void); /*Leave low power mode (empty function here)*/

void USB_Interrupts_Config(void); /*Set USB interrupt configuration*/

void USB_Cable_Config (FunctionalState NewState);/*USB connection disconnection selection, actually controls the pull-up resistor pin*/

/*void Joystick_Send(uint8_t Keys);*/ /*Joystick sends (not used)*/

/*uint8_t JoyState(void); */ /*Joystick status (not used)*/

void Get_SerialNum(void); /*Create the serial number of the string descriptor*/

usb_des.c:

This file mainly defines some USB descriptors: device descriptor, configuration descriptor set (including interface descriptor, HID descriptor, endpoint descriptor), HID report descriptor, language ID descriptor, manufacturer string descriptor, product string descriptor, product serial number string descriptor.


CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC];

CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC];

CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC];

CustomHID_StringLangID[CUSTOMHID_SIZ_STRING_LANGID];

CustomHID_StringVendor[CUSTOMHID_SIZ_STRING_VENDOR];

CustomHID_StringProduct[CUSTOMHID_SIZ_STRING_PRODUCT];

CustomHID_StringSerial[CUSTOMHID_SIZ_STRING_SERIAL];

usb_endp.c:

This file mainly defines several endpoint input and output callback functions. Here, endpoint 1 input and output callback and endpoint 2 input callback functions are specified, as follows:


void EP1_IN_Callback(void); /*Endpoint 1 input callback function*/

void EP1_OUT_Callback(void); /*Endpoint 1 output callback function*/

void EP2_IN_Callback(void); /*Endpoint 2 input callback function*/

usb_Istr.c:

This file mainly registers the callback function corresponding to each endpoint; the processing of the USB interrupt service program determines what kind of interrupt is by reading the STM32 ISTR interrupt status register and making corresponding arbitrary processing.


void (*pEpInt_IN[7])(void) = /*Endpoint input callback function registration*/

  {

    EP1_IN_Callback,

    EP2_IN_Callback,

    EP3_IN_Callback,

    EP4_IN_Callback,

    EP5_IN_Callback,

    EP6_IN_Callback,

    EP7_IN_Callback,

  };

      void (*pEpInt_OUT[7])(void) = /*Registration of endpoint output callback function*/

  {

    EP1_OUT_Callback,

    EP2_OUT_Callback,

    EP3_OUT_Callback,

    EP4_OUT_Callback,

    EP5_OUT_Callback,

    EP6_OUT_Callback,

    EP7_OUT_Callback,

  };

  void USB_Istr(void);/*ISTR event interrupt service routine*/


usb_propc:

This file mainly registers some previously defined column descriptors into the USB library, and registers some commonly used USB processing functions such as obtaining device descriptors and some standard request functions, as follows:


DEVICE_PROP Device_Property = /*Register some CustomHID functions*/

{

    CustomHID_init, /*CustomHID initialization function*/

    CustomHID_Reset, /*CustomHID reset function*/

    CustomHID_Status_In, /*CustomHID status input function*/

    CustomHID_Status_Out, /*CustomHID status output function*/

    CustomHID_Data_Setup, /*CustomHID special class request function for processing data*/

    CustomHID_NoData_Setup, /*CustomHID processing without data special class request function*/

    CustomHID_Get_Interface_Setting, /*CustomHID gets the interface and backup interface settings to see if they are available */

    CustomHID_GetDeviceDescriptor, /*CustomHID gets the device descriptor*/

    CustomHID_GetConfigDescriptor, /*CustomHID gets the configuration descriptor*/

    CustomHID_GetStringDescriptor, /*CustomHID gets string descriptor*/

    0, /*Current library is not used*/

    0x40 /*MAX PACKET SIZE*/ /*The maximum packet length is 64 bytes*/

};

/*Register USB standard request implementation function*/

USER_STANDARD_REQUESTS User_Standard_Requests =

{

    CustomHID_GetConfiguration, /*Get configuration request*/

    CustomHID_SetConfiguration, /*Set configuration request*/

    CustomHID_GetInterface, /*Get interface request*/

    CustomHID_SetInterface, /*Set interface request*/

    CustomHID_GetStatus, /*Get status request*/

    CustomHID_ClearFeature, /*Clear feature request*/

    CustomHID_SetEndPointFeature, /*Set endpoint feature request*/

    CustomHID_SetDeviceFeature, /*Set device feature request*/

    CustomHID_SetDeviceAddress /*Set device address request*/

};

/*Register device descriptor information*/

ONE_DESCRIPTOR Device_Descriptor;

/*Register report descriptor information*/

ONE_DESCRIPTOR CustomHID_Report_Descriptor;

/*Register HID descriptor information*/

ONE_DESCRIPTOR CustomHID_Descriptor;

/*Register string descriptors, including language ID, manufacturer, product, and serial number descriptors*/

ONE_DESCRIPTOR String_Descriptor[4];


usb_pwr.c:

This file mainly contains some USB and power consumption functions, such as power on, power off, suspend, etc.


void Suspend(void); /*Suspend*/

void Resume_Init(void); /*Resume initialization*/

void Resume(RESUME_STATE eResumeSetVal);/*Resume to a certain state*/

RESULT PowerOn(void); /*Power on*/

RESULT PowerOff(void); /*power off*/


Keywords:STM32 Reference address:STM32 study notes USB project directory file analysis

Previous article:STM32 study notes USB virtual serial port descriptor introduction
Next article:LPC54608 generates PDF files

Recommended ReadingLatest update time:2024-11-16 13:40

About the STM32 serial port idle interrupt problem
1. The idle interrupt is triggered when a byte of high level (idle) appears after receiving data. It does not mean that the idle interrupt will continue. To be precise, it should be a byte after the rising edge (stop bit). If it is always at a low level, the idle interrupt will not be triggered (it will trigger a brea
[Microcontroller]
STM32 study notes USB data receiving and sending process analysis
Now that you have learned USB, you must understand how USB devices communicate with USB host data. Here we mainly talk about the device side, because our code is used for USB devices. We need to define the USB interrupt. First, in the interrupt vector table of STM32, two interrupts are given to USB. We can find these
[Microcontroller]
[STM32 motor vector control] Record 7 - Setting of six-sector output values
The calculation method of the six states of the sector is as follows: N=4*C+2*B+A   The corresponding relationship between N value and sector:   Basic vector action time calculation and three-phase PWM waveform synthesis  The value of the PWM cycle counter is NTpwm=fdsp/fs/2 Wave coefficient: Unom is the system r
[Microcontroller]
[STM32 motor vector control] Record 7 - Setting of six-sector output values
STM32 MCU (3) Serial port interrupt communication
Note: When using the Puzhong Technology Development Board for testing, you need to unplug the Boot1 shorting cap and the two download cables, and restart /*******************************************************************************  *     * Software function: Serial port experiment (software delay mode)  *  
[Microcontroller]
STM32 - Setting pull-up and pull-down in GPIO input mode
When GPIO is in input mode, the pull-down input and pull-up input configuration are shown in the figure below. It should be noted that pull-down input and pull-up input are distinguished by the port output register GPIOx_ODR. Therefore, when configuring pull-up/pull-down input, although the GPIO is operated on input,
[Microcontroller]
STM32 - Setting pull-up and pull-down in GPIO input mode
Application of STM32-Advanced Timer TIM1
void GPIO_Configuration(void)//Configure IO pin {        GPIO_InitTypeDef GPIO_InitStructure;        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;              GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;        GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;        GPIO_Init(GPIOA, &GPIO_InitStructure);        GPI
[Microcontroller]
Application of STM32-Advanced Timer TIM1
STM32_BKP backup data
Today we will explain "STM32F103 BKP backup data". The knowledge about "BKP backup data" is not difficult, but there are still a few points to note. BKP, as the name implies, is a backup register (see the reference manual), which is mainly used for backup data.   The difference between my article and other articles on
[Microcontroller]
STM32_BKP backup data
Design of portable BMP picture decoding system based on STM32 processor
In the application process of modern portable devices, it is often necessary to display some pictures in the system. Among various picture formats, BMP is the most representative one. BMP is an image file format that is independent of hardware devices and is widely used. It uses a bit-mapped storage format. In addi
[Security Electronics]
Design of portable BMP picture decoding system based on STM32 processor
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号