cancel
Showing results for 
Search instead for 
Did you mean: 

How to use fx_media_format and fx_media_open ?

RemiNao
Associate

Hello,

I am trying to set up FileX with USBX, but my computer recognizes a disk drive but does not see any volume.
Can you help me determine whether I am using the fx_media_format and fx_media_open functions correctly, given that they do not return any errors?

 

  UINT ret = FX_SUCCESS;
  /* USER CODE BEGIN MX_FileX_Init */
  UINT RETT = lx_stm32_nor_custom_driver_initialize(&nor_flash);

  /* USER CODE END MX_FileX_Init */

  /* Initialize FileX.  */
  fx_system_initialize();

  /* USER CODE BEGIN MX_FileX_Init 1*/

  /* Format the NOR flash as FAT */
	  status =  fx_media_format(&nor_flash_disk,
	                            fx_stm32_levelx_nor_driver,   // Driver entry
	                            (VOID*)&nor_flash,            // Device info pointer  (VOID*)NOR_CUSTOM_DRIVER_ID
								(UCHAR*)media_memory,         // Media buffer pointer
	                            sizeof(media_memory),         // Media buffer size
	                            "NOR_FLASH_DISK",             // Volume Name
	                            1,                            // Number of FATs
	                            32,                           // Directory Entries
	                            0,                            // Hidden sectors
								TOTAL_SECTOR_LOGICAL,		  // Total sectors
								SECTOR_SIZE_LOGICAL,          // Sector size
	                            8,                            // Sectors per cluster
	                            1,                            // Heads
	                            1);                           // Sectors per track
  /* Check if the format status */
  if (status != FX_SUCCESS)
  {
    Error_Handler();
  }

  /* Open the SPI NOR Flash disk driver.  */
  //status =  fx_media_open(&nor_flash_disk, "FX_LX_NOR_DISK", fx_stm32_levelx_nor_driver,(VOID*)NOR_CUSTOM_DRIVER_ID , media_memory, sizeof(media_memory));
  status =  fx_media_open(&nor_flash_disk, "FX_LX_NOR_DISK", fx_stm32_levelx_nor_driver,(VOID*)NOR_CUSTOM_DRIVER_ID , media_buffer, sizeof(media_buffer));
  /* Check the media open status.  */
  if (status != FX_SUCCESS)
  {
    Error_Handler();
  }

 

For Device info pointer, should i use (VOID*)&nor_flash or (VOID*)NOR_CUSTOM_DRIVER_ID ?
Can the volume name and media name be different ?

 

0 REPLIES 0