此程序为外部flash模拟U盘,通过stm32f1读写内部文件的工程,已经验证通过
-下载本程序到开发板,并复位,使用USB线连接开发板与电脑,连接开发板USB DEVICE 接口!!!
-下载程序并复位,等待几秒,电脑上即可模拟出U盘,然后就可以相互拷贝东西了
使用的USB接口是USB Device的那个,不是USB TO USART接口!!!!!!
单片机源程序如下:
- #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();
-
- /*设置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 -------------------------------------------- */
复制代码
所有资料51hei提供下载:
USB—外部FLASH模拟U盘.7z
(239.63 KB, 下载次数: 123)
|