|
此程序為外部flash模擬U盤,通過stm32f1讀寫內(nèi)部文件的工程,已經(jīng)驗證通過
-下載本程序到開發(fā)板,并復(fù)位,使用USB線連接開發(fā)板與電腦,連接開發(fā)板USB DEVICE 接口�。�!
-下載程序并復(fù)位,等待幾秒,電腦上即可模擬出U盤,然后就可以相互拷貝東西了
使用的USB接口是USB Device的那個,不是USB TO USART接口!�。。。�!
單片機(jī)源程序如下:
- #include "stm32f10x.h"
- #include "./flash/fatfs_flash_spi.h"
- #include "./usart/bsp_usart.h"
- #include "./led/bsp_led.h"
- #include "hw_config.h"
- #include "usb_lib.h"
- #include "usb_pwr.h"
- static void USB_Delay(__IO uint32_t nCount)
- {
- for(; nCount != 0; nCount--);
- }
- int main(void)
- {
- /* USART config */
- USART_Config();
-
- LED_GPIO_Config();
-
- /*初始化*/
- Set_System();
-
- /*設(shè)置USB時鐘為48M*/
- Set_USBClock();
-
- /*配置USB中斷(包括SDIO中斷)*/
- USB_Interrupts_Config();
-
- /*USB初始化*/
- USB_Init();
-
- while (bDeviceState != CONFIGURED); //等待配置完成
-
- printf("\r\n 秉火 F103-指南者 STM32 USB MASS STORAGE 實驗\r\n");
-
- while (1)
- {
- LED2_TOGGLE;
- USB_Delay(0x0FFFFF);
- }
- }
- /* -------------------------------------end of file -------------------------------------------- */
復(fù)制代碼
所有資料51hei提供下載:
USB—外部FLASH模擬U盤.7z
(239.63 KB, 下載次數(shù): 123)
2019-6-30 15:08 上傳
點擊文件名下載附件
|
|