Showing posts with label Mass storage. Show all posts
Showing posts with label Mass storage. Show all posts

Wednesday, December 3, 2014

STM32F4 USB HOST AND DEVICE

This post is a result of several hours of hard work, thinking, planning, trial-and-error, debugging, and searching the internet for working code in order to make the USB peripheral of a STM32 act as an USB device (mass storage) and HOST (mass storage too). I believe that (at least these days) you will not find another internet site with all the stuff I'm posting here in one place. Most of the codes you will find spread in other examples and libraries.

So, this post is about of programming a Nucleo-F401RE board to use the STM32F401RE USB peripheral as a DEVICE Mass Storage Class with SDCARD (connected with 4bit SDIO interface) as the media. That is, in DEVICE mode, your Nucleo will become a generic USB storage device when connected to the USB port of your computer.
The code also works as a HOST for Mass Storage Devices. That is, if you connect a USB flash drive, you can access its contents using the FATFS library.
You can also use the FATFS to access the SD card.

Overview of the breakout board with USB connector. Beneath the Nucleo board is the SD card socket.