標(biāo)題: stm32外部FLASH模擬U盤源程序 [打印本頁]

作者: 路洋14    時(shí)間: 2019-6-30 09:51
標(biāo)題: stm32外部FLASH模擬U盤源程序
此程序?yàn)橥獠縡lash模擬U盤,通過stm32f1讀寫內(nèi)部文件的工程,已經(jīng)驗(yàn)證通過

-下載本程序到開發(fā)板,并復(fù)位,使用USB線連接開發(fā)板與電腦,連接開發(fā)板USB DEVICE 接口。!
-下載程序并復(fù)位,等待幾秒,電腦上即可模擬出U盤,然后就可以相互拷貝東西了


使用的USB接口是USB Device的那個(gè),不是USB TO USART接口。。。。!

單片機(jī)源程序如下:
  1. #include "stm32f10x.h"
  2. #include "./flash/fatfs_flash_spi.h"
  3. #include "./usart/bsp_usart.h"       
  4. #include "./led/bsp_led.h"  
  5. #include "hw_config.h"
  6. #include "usb_lib.h"
  7. #include "usb_pwr.h"

  8. static void USB_Delay(__IO uint32_t nCount)
  9. {
  10.         for(; nCount != 0; nCount--);
  11. }

  12. int main(void)
  13. {
  14.          /* USART config */
  15.         USART_Config();
  16.        
  17.   LED_GPIO_Config();
  18.   
  19.         /*初始化*/
  20.         Set_System();
  21.          
  22.         /*設(shè)置USB時(shí)鐘為48M*/
  23.         Set_USBClock();
  24.        
  25.         /*配置USB中斷(包括SDIO中斷)*/
  26.         USB_Interrupts_Config();

  27.         /*USB初始化*/
  28.         USB_Init();

  29.         while (bDeviceState != CONFIGURED);         //等待配置完成
  30.           
  31.         printf("\r\n 秉火 F103-指南者 STM32 USB MASS STORAGE 實(shí)驗(yàn)\r\n");
  32.          
  33.   while (1)
  34.   {
  35.     LED2_TOGGLE;
  36.     USB_Delay(0x0FFFFF);
  37.   }
  38. }

  39. /* -------------------------------------end of file -------------------------------------------- */
復(fù)制代碼

所有資料51hei提供下載:
USB—外部FLASH模擬U盤.7z (239.63 KB, 下載次數(shù): 123)








歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1