STM32F4 Discovery USB HID 用到的文件图解
来源:互联网 发布:兰蔻和mac口红哪个好 编辑:程序博客网 时间:2024/05/17 03:12
│ │ ├── 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中操作,考虑如何发数据到主机端
对于一个工程来讲
├── stm32f4xx_conf.h
├── stm32f4xx_it.c
├── stm32f4xx_it.h
├── system_stm32f4xx.c
这几个文件也是从库里提取出来的,有可能会改动的
STM32F4xx_StdPeriph_Driver 这部分的内容基本上从来没有动过,是相当底层的驱动文件了
│ ├── 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文件的名字可能有些区别
下面给出一个修改过的main.c 内容很精简了
/** ****************************************************************************** * @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. * * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> ****************************************************************************** */ /* 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 parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { }}#endif/** * @} *//******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
- STM32F4 Discovery USB HID 用到的文件图解
- STM32F4 Discovery USB HID 工程 USB初始化引发硬件错误的原因
- STM32F4-Discovery
- stm32f4 discovery开发板usb全速修改测试
- USB的HID类
- stm32f4-discovery 简介
- stm32f4-discovery DMA
- STM32F4-Discovery资料汇总
- STM32F4-Discovery资料汇总
- STM32F4 DISCOVERY 驱动安装
- 如何给你的STM32F4-Discovery建造一个安全的房间
- 作業系統之前的程式 for stm32f4 - discovery (0.2) - p103 模擬器
- USB HID 类的编写
- USB HID类的编写
- USB-HID的初步认识
- USB HID
- USB-HID
- usb hid
- Python用subprocess的Popen来调用系统命令
- about cache
- 我开始泡面了——判断一个数是否是质数
- asp.net调用接收存储过程返回值
- Linux查看文件编码格式及文件编码转换
- STM32F4 Discovery USB HID 用到的文件图解
- java快速排序算法
- 关于跨平台移动开发的经验收集
- I2S音频总线学习(二)I2S总线协议
- 获取手机中已安装apk文件信息(PackageInfo、ResolveInfo)(应用图片、应用名、包名等)
- 用自动化运维工具解放IT运维
- ActionContext.getContext()的用法心得
- POJ 3321 Apple Tree DFS + 树状数组
- hive 数据查询复杂SQL