|
TM STM32Fxxx HAL Libraries
v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
|
FATFS implementation for STM32Fxxx devices - http://stm32f4-discovery.com/2015/08/hal-library-20-fatfs-for-stm32fxxx/. More...
Modules | |
| TM_FATFS_Macros | |
| Library defines. | |
| TM_FATFS_Typedefs | |
| Library typedefs. | |
| TM_FATFS_Functions | |
| Library Functions. | |
FATFS implementation for STM32Fxxx devices - http://stm32f4-discovery.com/2015/08/hal-library-20-fatfs-for-stm32fxxx/.
FatFs implementation for STM32F4xx devices
This library uses Chan's Fatfs implementation.
This library is only for communication. To work with files, you have to look at Chan's FatFs manual, link below: http://elm-chan.org/fsw/ff/00index_e.html
You can work with SPI or SDIO protocol to interface SDCARD.
Library works with SPI or SDIO mode. Also, when in SDIO mode, you can set to 1- or 4-bit mode. By default, SDIO with 4-bit mode is used, so you will look into right column on table below.
SD CARD PINS
_________________ / 1 2 3 4 5 6 7 8 | NR |SDIO INTERFACE |SPI INTERFACE / | |NAME STM32Fxxx DESCRIPTION |NAME STM32Fxxx DESCRIPTION / 9 | | 4-BIT 1-BIT | | | | | | | 1 |CD/DAT3 PC11 - Connector data line 3 |CS PB5 Chip select for SPI | | 2 |CMD PD2 PD2 Command/Response line |MOSI PA7 Data input for SPI | | 3 |VSS1 GND GND GND |VSS1 GND GND | SD CARD Pinout | 4 |VDD 3.3V 3.3V 3.3V Power supply |VDD 3.3V 3.3V Power supply | | 5 |CLK PC12 PC12 Clock |SCK PA5 Clock for SPI | | 6 |VSS2 GND GND GND |VSS2 GND GND | | 7 |DAT0 PC8 PC8 Connector data line 0 |MISO PA6 Data output for SPI | | 8 |DAT1 PC9 - Connector data line 1 |- - - |___________________| 9 |DAT2 PC10 - Connector data line 2 |- - -
By default, SDIO with 4-bit communication is used. If you want to use SDIO 1-bit communication, set defines below in your defines.h file:
For SDIO communication, you will need at least these files:
- tm_stm32_fatfs.h - tm_stm32_fatfs.c - fatfs/diskio.h - fatfs/diskio.c - fatfs/ff.h - fatfs/ff.c - fatfs/ffconf.h - fatfs/integer.h - fatfs/option/syscall.c - fatfs/option/unicode.c - fatfs/drivers/fatfs_sd_sdio.h - fatfs/drivers/fatfs_sd_sdio.c
Or, if you want to use SPI communication, you have to add lines below in your defines.h file
Files, needed for SPI:
- tm_stm32_fatfs.h - tm_stm32_fatfs.c - fatfs/diskio.h - fatfs/diskio.c - fatfs/ff.h - fatfs/ff.c - fatfs/ffconf.h - fatfs/integer.h - fatfs/option/syscall.c - fatfs/option/unicode.c - fatfs/drivers/fatfs_sd.h - fatfs/drivers/fatfs_sd.c
SDIO interface pins are fixed, and can not be changed. If you want to change SPI pins, you have to set these defines in your defines.h file:
Library has support for Card detect and Write protect pins.
It is the same for any communication used and is disabled by default.
NAME STM32Fxxx DESCRIPTION
CD PB6 Card detect pin. Pin low when card detected
CD PB7 Card write protect pin. Pin low when card write is enabled
Like I said before, these 2 pins are disabled by default. If you want to use it, you have to add 2 lines in your defines.h file:
WP and CD pins are now enabled with default configuration.
Add lines below to your defines.h file only if you want to overwrite default pin settings:
FatFs uses function get_fattime() for time, to set timestamp for files, when they were edited or created.
By default, function returns 0, but if you want to create your own function, you have to set defines in defines.h file:
And then somewhere in your project, add function like below:
You can use this library also with TM_USBH_MSC Library if you want to ready USB Flash keys when needed.
First, files you will need for implementation based on FATFS are:
- tm_stm32_fatfs.h - tm_stm32_fatfs.c - fatfs/diskio.h - fatfs/diskio.c - fatfs/ff.h - fatfs/ff.c - fatfs/ffconf.h - fatfs/integer.h - fatfs/option/syscall.c - fatfs/option/unicode.c - fatfs/drivers/fatfs_usb.h - fatfs/drivers/fatfs_usb.c - Entire USB MSC Host stack and TM USB library
Because my USB MSC Host library supports both USB modes at the same time, I've made 2 different names for logical drivers. So, when you wanna mount/read/write/etc, you have 2 possible drive names:
Like SDCARD has "SD:" name, here are 2 different names, which allows you flexibility in your code. This also means, that you can use SDCARD and 2 USB flash drives at the same time without any problems, just specifying drive name when performing read and write operations.
I've added support for easy search function for files/folders on your FATFS related device. It works with any device (SDCARD, USB, etc), because you specify starting path for search which is specified by FATFS.
There are 2 functions for search, one is TM_FATFS_Search which you should call when you want to do a search operations in your FATFS structure
Second is TM_FATFS_SearchCallback which is called anytime file/folder is found on system so user can do his job with file.
Check documentation for these 2 functions for more info.
Version 1.1 - April 24, 2016 - Added support for FATFS R0.12 - Added support for SPI DMA when using fatfs in SPI mode on STM32F4xx and STM32F7xx devices Version 1.0 - First release
- STM32Fxxx HAL - defines.h - attributes.h - TM DMA - TM SPI (only when SPI) - TM SPI DMA (only when SPI on STM32F4xx and STM32F7xx) - TM DELAY (only when SPI) - TM GPIO - FatFS by Chan (R0.12a)