最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

STM32F429利用CUBEMX移植FATFS文件系统成功!!!

IT圈 admin 29浏览 0评论

2024年2月27日发(作者:游春冬)

/* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_TIM6_Init(); MX_FMC_Init(); MX_USART1_UART_Init(); MX_TIM7_Init(); MX_USART3_UART_Init(); MX_DMA2D_Init(); MX_LTDC_Init(); MX_SPI5_Init(); MX_SDIO_SD_Init(); MX_FATFS_Init(); /* Initialize interrupts */ MX_NVIC_Init(); /* USER CODE BEGIN 2 */ delay_init(180); LED_Init(); KEY_Init(); SDRAM_Init(); LCD_Init(); ESP8266_Init(); //WIFI ͨѶģ¿é W25QXX_Init(); //Íⲿ SPI FLASH --- 32MB FTL_Init(); //Íⲿ NAND FLASH --- 512MB my_mem_init(SRAMIN); //½«SRAMÖÐ60KBÄÚ´æÓÃÓÚÄÚ´æ¹ÜÀíϵͳ my_mem_init(SRAMEX); //½«SDRAMÖÐ15MBÄÚ´æÓÃÓÚÄÚ´æ¹ÜÀíϵͳ ITEnable(); PeriphInit(); GUI_Init(); Show_SDcard_Info();

LCD_ShowString(400,400,400,24,24,"****** FatFs Example ******"); retSD = f_mount(&SDFatFS, "0:", 0); if(retSD){ LCD_ShowString(400,440,400,24,24,"****** mount error ******"); LCD_ShowNum(800,440,retSD,2,24); Error_Handler(); } else LCD_ShowString(400,440,400,24,24,"****** mount success ******");

retSD = f_open(&SDFile, filename, FA_CREATE_ALWAYS | FA_WRITE); if(retSD){ LCD_ShowString(400,480,400,24,24,"****** open file error ******"); LCD_ShowNum(800,480,retSD,2,24); Error_Handler(); } else LCD_ShowString(400,480,400,24,24,"****** open file success ******");

retSD = f_write(&SDFile, wtext, sizeof(wtext), (void *)&byteswritten); if(retSD){ LCD_ShowString(400,520,400,24,24,"****** write file error ******"); LCD_ShowNum(800,520,retSD,2,24); Error_Handler(); } else LCD_ShowString(400,520,400,24,24,"****** write file success ******");

retSD = f_close(&SDFile); if(retSD){ LCD_ShowString(400,560,400,24,24,"****** close file error ******"); LCD_ShowNum(800,560,retSD,2,24); Error_Handler(); } else

2024年2月27日发(作者:游春冬)

/* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_TIM6_Init(); MX_FMC_Init(); MX_USART1_UART_Init(); MX_TIM7_Init(); MX_USART3_UART_Init(); MX_DMA2D_Init(); MX_LTDC_Init(); MX_SPI5_Init(); MX_SDIO_SD_Init(); MX_FATFS_Init(); /* Initialize interrupts */ MX_NVIC_Init(); /* USER CODE BEGIN 2 */ delay_init(180); LED_Init(); KEY_Init(); SDRAM_Init(); LCD_Init(); ESP8266_Init(); //WIFI ͨѶģ¿é W25QXX_Init(); //Íⲿ SPI FLASH --- 32MB FTL_Init(); //Íⲿ NAND FLASH --- 512MB my_mem_init(SRAMIN); //½«SRAMÖÐ60KBÄÚ´æÓÃÓÚÄÚ´æ¹ÜÀíϵͳ my_mem_init(SRAMEX); //½«SDRAMÖÐ15MBÄÚ´æÓÃÓÚÄÚ´æ¹ÜÀíϵͳ ITEnable(); PeriphInit(); GUI_Init(); Show_SDcard_Info();

LCD_ShowString(400,400,400,24,24,"****** FatFs Example ******"); retSD = f_mount(&SDFatFS, "0:", 0); if(retSD){ LCD_ShowString(400,440,400,24,24,"****** mount error ******"); LCD_ShowNum(800,440,retSD,2,24); Error_Handler(); } else LCD_ShowString(400,440,400,24,24,"****** mount success ******");

retSD = f_open(&SDFile, filename, FA_CREATE_ALWAYS | FA_WRITE); if(retSD){ LCD_ShowString(400,480,400,24,24,"****** open file error ******"); LCD_ShowNum(800,480,retSD,2,24); Error_Handler(); } else LCD_ShowString(400,480,400,24,24,"****** open file success ******");

retSD = f_write(&SDFile, wtext, sizeof(wtext), (void *)&byteswritten); if(retSD){ LCD_ShowString(400,520,400,24,24,"****** write file error ******"); LCD_ShowNum(800,520,retSD,2,24); Error_Handler(); } else LCD_ShowString(400,520,400,24,24,"****** write file success ******");

retSD = f_close(&SDFile); if(retSD){ LCD_ShowString(400,560,400,24,24,"****** close file error ******"); LCD_ShowNum(800,560,retSD,2,24); Error_Handler(); } else

发布评论

评论列表 (0)

  1. 暂无评论