How to use STM32 as a USB host and mount USB device??
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usb_host.h"
#include "usbh_core.h"
#include "usbh_msc.h"
/* USER CODE BEGIN Includes */
#include "ff.h"
/* USER CODE END Includes */
/* USER CODE BEGIN PV */
/* Private variables ----------------------------
* -----------------------------*/
FATFS USBH_fatfs;
FIL MyFile;
FRESULT res;
uint8_t oktext = "USB mounted !";
uint8_t text = "USB not mounted !";
extern char USBHpath[];
extern UART_HandleTypeDef huart3;
/* USER CODE END PV */
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USB Host core handle declaration */
USBH_HandleTypeDef hUsbHostFS;
ApplicationTypeDef Appli_state = APPLICATION_IDLE;
/*
* -- Insert your variables declaration here --
*/
/* USER CODE BEGIN 0 */
void UserPr(void)
{
if(f_mount(&USBH_fatfs, USBHpath, 1) != FR_OK)
{
HAL_UART_Transmit(&huart3, text, sizeof(text), 100);
}
else
{
HAL_UART_Transmit(&huart3, oktext, sizeof(oktext), 100);
}
}
/* USER CODE END 0 */Hii there, I am using STM32g0c1 and I am trying to mount USB pendrive. I followed some online tutorials but still I am not able to mount USB pendrive.
- I am using 32Gb pendrive using FAT32 format.
- Heap size is 2000.
- I connected DP and DM pins directly to USB A type connector.
- DISKIO.C file looks fine.
When I try to mount USB device it shows FR_DISK_ERR. Also, when I use f_mkfs it shows FR_NOT_ENABLED.
Can I get example code/project ?? It will be a good help.
