Author Topic: STm32F205RBt6 as USB Host, interfacing code for pen drive  (Read 38 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.takniki

  • Frequent Contributor
  • **
  • Posts: 321
STm32F205RBt6 as USB Host, interfacing code for pen drive
« on: December 07, 2017, 04:18:43 PM »
1. Need to interface pen drive with stm32f205rbt6 for logging data in text file in pen drive.

2. Generated code from stm32cube & link for total code is here:  https://drive.google.com/open?id=1oJSXOmWXzn_xduLmcJWXdiNxtMTpdmtP

3. Made changes in fatfs.c file generated as below.

4. Problem is code always struk in if(FR_OK != res)  & return disk_error always. What error I am doing.

5. is there any example code for STM32F2 using pen drive for storage purpose to see exactly where changes are to be made.



Code: [Select]
#include "fatfs.h"

uint8_t retUSBH;    /* Return value for USBH */
char USBHPath[4];   /* USBH logical drive path */
FATFS USBHFatFS;    /* File system object for USBH logical drive */
FIL USBHFile;       /* File object for USBH */
FRESULT res;

/* USER CODE BEGIN Variables */

/* USER CODE END Variables */   

void MX_FATFS_Init(void)
{
  /*## FatFS: Link the USBH driver ###########################*/
  retUSBH = FATFS_LinkDriver(&USBH_Driver, USBHPath);

  /* USER CODE BEGIN Init */
  /* additional user code for init */     
  /* USER CODE END Init */
   
res = f_mount(&USBHFatFS , USBHPath ,0U);
    if(FR_OK != res)
    {
while(1);
    }

    res = f_setlabel("DATA DISK");
    if(FR_OK != res)
    {
while(1);
    }

    res = f_open(&USBHFile, "/_SERIAL.txt", FA_OPEN_ALWAYS);
    if(FR_OK != res)
    {
        while(1);
}   
   
}

/**
  * @brief  Gets Time from RTC
  * @param  None
  * @retval Time in DWORD
  */
DWORD get_fattime(void)
{
  /* USER CODE BEGIN get_fattime */
  return 0;
  /* USER CODE END get_fattime */ 
}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf