采用STM32的USB接口實現串口功能,可方便STM32的調試通信等功能。
3,例程KEIL MDK版本? V4.22A
4,例程軟件庫版本? 未使用
5,例程驅動庫版本? V3.5.0
6,例程是用多大尺寸的液晶屏測試的? 未使用
7,例程是用多少G的SD卡測試? 未使用
8,程序設置下載是否復位運行? 是
0.png (5.68 KB, 下載次數: 53)
下載附件
2018-9-29 17:35 上傳
STM32單片機源程序如下:
- /****************************Copyright(c)*****************************
- **--------------File Info---------------------------------------------------------------------------------
- ** File name: main.c
- ** Last modified Date: 2014-03-14
- ** Last Version: V1.00
- ** Descriptions:
- **
- **----------------------------------------------------------------------------------------------------
- ** Created by: hzq
- ** Created date: 2014-03-14
- ** Version: V1.00
- ** Descriptions: 下載程序,3.2寸屏顯示對應的信息,等待USB枚舉完成,安裝驅動之后,可以識別出虛擬串口。
- ** USB口接在USB2上。
- **
- **----------------------------------------------------------------------------------------------------
- ** Modified by:
- ** Modified date:
- ** Version:
- ** Descriptions:
- **
- *****************************************************************/
- /* Includes ------------------------------------------------------------------*/
- #include "usbd_cdc_core.h"
- #include "usbd_usr.h"
- #include "usb_conf.h"
- #include "usbd_desc.h"
- /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
- * @{
- */
-
- #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 ;
- /**
- * @}
- */
- /** @defgroup APP_VCP_Private_FunctionPrototypes
- * @{
- */
- /**
- * @}
- */
- /** @defgroup APP_VCP_Private_Functions
- * @{
- */
- /**
- * @brief Program entry point
- * @param None
- * @retval None
- */
- int main(void)
- {
- __IO uint32_t i = 0;
- /*!< At this stage the microcontroller clock setting is already configured,
- this is done through SystemInit() function which is called from startup
- file (startup_stm32fxxx_xx.s) before to branch to application main.
- To reconfigure the default setting of SystemInit() function, refer to
- system_stm32fxxx.c file
- */
-
- USBD_Init(&USB_OTG_dev,
- #ifdef USE_USB_OTG_HS
- USB_OTG_HS_CORE_ID,
- #else
- USB_OTG_FS_CORE_ID,
- #endif
- &USR_desc,
- &USBD_CDC_cb,
- &USR_cb);
-
- /* Main loop */
- while (1)
- {
- if (i++ == 0x100000)
- {
- STM_EVAL_LEDToggle(LED1);
- STM_EVAL_LEDToggle(LED2);
- STM_EVAL_LEDToggle(LED3);
- STM_EVAL_LEDToggle(LED4);
- i = 0;
- }
- }
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief assert_failed
- * 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 STMicroelectronics *****END OF FILE****/
復制代碼
所有資料51hei提供下載:
107_DEVICE_VCP .rar
(632.18 KB, 下載次數: 60)
2018-9-29 09:41 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|