日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] ├── STM32_USB_Device_Library USB從設(shè)備庫│ │ ├── Class│ │ │ └── hid│ │ │ ├── inc│ │ │ │ └── usbd_hid_core.h│ │ │ └── s

├── STM32_USB_Device_Library USB從設(shè)備庫
│ │ ├── Class
│ │ │ └── hid
│ │ │ ├── inc
│ │ │ │ └── usbd_hid_core.h
│ │ │ └── src
│ │ │ └── usbd_hid_core.c
│ │ └── Core
│ │ ├── inc
│ │ │ ├── usbd_core.h
│ │ │ ├── usbd_def.h
│ │ │ ├── usbd_ioreq.h
│ │ │ ├── usbd_req.h
│ │ │ └── usbd_usr.h
│ │ └── src
│ │ ├── usbd_core.c
│ │ ├── usbd_ioreq.c
│ │ └── usbd_req.c
│ ├── STM32_USB_OTG_Driver USB OTG 庫
│ │ ├── inc
│ │ │ ├── usb_bsp.h
│ │ │ ├── usb_core.h
│ │ │ ├── usb_dcd.h
│ │ │ ├── usb_dcd_int.h
│ │ │ ├── usb_defines.h
│ │ │ └── usb_regs.h
│ │ └── src
│ │ ├── usb_core.c
│ │ ├── usb_dcd.c

│ │ └── usb_dcd_int.c


從層級上分析,OTG是更加底層的,USBD的文件依賴于USB的文件,從對庫的使用來講,這些文件我們都不需要改動。

我們需要改動的有可能是下面的文件

├── usb_bsp.c
├── usb_conf.h
├── usbd_conf.h
├── usbd_desc.c
├── usbd_desc.h
└── usbd_usr.c

一些邏輯在main.c中操作,考慮如何發(fā)數(shù)據(jù)到主機(jī)端


對于一個工程來講

├── stm32f4xx_conf.h
├── stm32f4xx_it.c
├── stm32f4xx_it.h
├── system_stm32f4xx.c

這幾個文件也是從庫里提取出來的,有可能會改動的


STM32F4xx_StdPeriph_Driver 這部分的內(nèi)容基本上從來沒有動過,是相當(dāng)?shù)讓拥尿?qū)動文件了


│ ├── CMSIS
│ │ ├── Include
│ │ │ ├── core_cm4.h
│ │ │ ├── core_cm4_simd.h
│ │ │ ├── core_cmFunc.h
│ │ │ └── core_cmInstr.h
│ │ └── ST
│ │ └── STM32F4xx
│ │ ├── Include
│ │ │ ├── stm32f4xx.h
│ │ │ └── system_stm32f4xx.h
│ │ └── Source
│ │ └── Templates
│ │ └── arm
│ │ └── startup_stm32f4xx.s

這些文件也是一般不會去動的,.s文件的名字可能有些區(qū)別

下面給出一個修改過的main.c 內(nèi)容很精簡了

/**

******************************************************************************

* @file main.c

* @author MCD Application Team

* @version V1.0.0

* @date 19-September-2011

* @brief Main program body

******************************************************************************

* @attention

*

* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS

* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE

* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY

* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING

* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE

* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

*

*

? COPYRIGHT 2011 STMicroelectronics

******************************************************************************

*/

/* Includes ------------------------------------------------------------------*/

#include "main.h"

#include "usbd_hid_core.h"

#include "usbd_usr.h"

#include "usbd_desc.h"

/** @addtogroup STM32F4-Discovery_Demo

* @{

*/

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED

#if defined ( __ICCARM__ ) /*!< IAR Compiler */

#pragma data_alignment = 4

#endif

#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */

__ALIGN_BEGIN USB_OTG_CORE_HANDLE USB_OTG_dev __ALIGN_END;

__IO uint32_t TimingDelay;

/* Private function prototypes -----------------------------------------------*/

static uint32_t Demo_USBConfig(void);

static void Demo_Exec(void);

/* Private functions ---------------------------------------------------------*/

/**

* @brief Main program.

* @param None

* @retval None

*/

int main(void)

{

RCC_ClocksTypeDef RCC_Clocks;

/* SysTick end of count event each 10ms */

RCC_GetClocksFreq(&RCC_Clocks);

SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

Demo_Exec();

}

/**

* @brief Execute the demo application.

* @param None

* @retval None

*/

static void Demo_Exec(void)

{

uint8_t buf[4];

buf[0]=0;

buf[1]=7;

buf[2]=7;

buf[3]=0;

/* USB configuration */

Demo_USBConfig();

while(1) {

Delay(5);

USBD_HID_SendReport (&USB_OTG_dev,

buf,

4);

}

}

/**

* @brief Initializes the USB for the demonstration application.

* @param None

* @retval None

*/

static uint32_t Demo_USBConfig(void)

{

USBD_Init(&USB_OTG_dev,

USB_OTG_FS_CORE_ID,

&USR_desc,

&USBD_HID_cb,

&USR_cb);

return 0;

}

/**

* @brief Inserts a delay time.

* @param nTime: specifies the delay time length, in 10 ms.

* @retval None

*/

void Delay(__IO uint32_t nTime)

{

TimingDelay = nTime;

while(TimingDelay != 0);

}

/**

* @brief Decrements the TimingDelay variable.

* @param None

* @retval None

*/

void TimingDelay_Decrement(void)

{

if (TimingDelay != 0x00)

{

TimingDelay--;

}

}

/**

* @brief This function handles the test program fail.

* @param None

* @retval None

*/

void Fail_Handler(void)

{

while(1)

{

Delay(5);

}

}

#ifdef USE_FULL_ASSERT

/**

* @brief Reports the name of the source file and the source line number

* where the assert_param error has occurred.

* @param file: pointer to the source file name

* @param line: assert_param error line source number

* @retval None

*/

void assert_failed(uint8_t* file, uint32_t line)

{

/* User can add his own implementation to report the file name and line number,

ex: printf("Wrong parame

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉