• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    C
  • Created about 7 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Enables reading and writing on SD card using SD card slot of the STM32 Board.

STM32 SD library for Arduino

With an STM32 board with SD card slot availability, this library enables reading and writing on SD card using SD card slot of a STM32 board (NUCLEO, DISCOVERY, ...). This library is for SD card slots connected to the SDIO-/SDMMC-hardware of the processor. For slots connected to SPI-hardware use the standard Arduino SD library.

This library follow Arduino API.

For more information about it, please visit: http://www.arduino.cc/en/Reference/SD

Dependency

This library is based on FatFs, a generic FAT file system module for small embedded systems. http://elm-chan.org/fsw/ff

The FatFs has been ported as Arduino library here. The STM32SD library depends on it.

Configuration

FatFs

The FatFs has several user defined options, which is specified from within the ffconf.h file.

This library provides a default user defined options file named ffconf_default.h.

User can provide his own defined options by adding his configuration in a file named ffconf_custom.h at sketch level or in variant folder.

SD

Some default definitions can be overridden using:

SDIO/SDMMC pins definition

Since STM32 core v2.6.0, the PinMap_SD[] array defined in the PeripheralPins*.c has been split per signals:

PinMap_SD_CK[]
PinMap_SD_DATA0[]
PinMap_SD_DATA1[]
PinMap_SD_DATA2[]
PinMap_SD_DATA3[]
PinMap_SD_DATA4[]
PinMap_SD_DATA5[]
PinMap_SD_DATA6[]
PinMap_SD_DATA7[]
/* Only for SDMMC */
PinMap_SD_CKIN[]
PinMap_SD_CDIR[]
PinMap_SD_D0DIR[]
PinMap_SD_D123DIR[]

This allows to define the SDIO/SDMMC pins to use instead of using all the pins defined in the old array. By default, if no pins are explicitly defined, the first one from each array is used.

  • To redefine the default one, use the following macros:

    • SDX_D0

    • SDX_D1

    • SDX_D2

    • SDX_D3

    • SDX_CMD

    • SDX_CK

    • Only for SDMMC:

      • SDX_CKIN
      • SDX_CDIR
      • SDX_D0DIR
      • SDX_D123DIR
  • or redefine the default one before call of begin() of SDClass or init() of Sd2Card, use the following methods:

    • setDx(uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3)

    • setCK(uint32_t ck)

    • setCK(PinName ck)

    • setCMD(uint32_t cmd)

    • setCMD(PinName cmd)

    • Only for SDMMC:

      • setCKIN(uint32_t ckin)
      • setCKIN(PinName ckin)
      • setCDIR(uint32_t cdir)
      • setCDIR(PinName cdir)
      • setDxDIR(uint32_t d0dir, uint32_t d123dir)
      • setDxDIR(PinName d0dir, PinName d123dir)

    Code snippet:

  Sd2Card card;
  card.setDx(PE12, PE13, PE14, PE15);
  card.setCMD(PB_14); // using PinName
  card.setCK(PB15);
  card.init();

or

  SD.setDx(PE12, PE13, PE14, PE15);
  SD.setCMD(PB14);
  SD.setCK(PB_15); // using PinName
  SD.begin();
  • or using the begin() of SDClass or init() of Sd2Card methods:

    • For SDIO:

      • SDClass:
        • begin(uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t ck, uint32_t cmd)
        • begin(uint32_t detect = SD_DETECT_NONE, uint32_t data0 = SDX_D0, uint32_t data1 = SDX_D1, uint32_t data2 = SDX_D2, uint32_t data3 = SDX_D3, uint32_t ck = SDX_CK, uint32_t cmd = SDX_CMD, uint32_t ckin = SDX_CKIN, uint32_t cdir = SDX_CDIR, uint32_t d0dir = SDX_D0DIR, uint32_t d123dir = SDX_D123DIR);
      • Sd2Card:
        • init(uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t ck, uint32_t cmd)
        • init(uint32_t detect = SD_DETECT_NONE, uint32_t data0 = SDX_D0, uint32_t data1 = SDX_D1, uint32_t data2 = SDX_D2, uint32_t data3 = SDX_D3, uint32_t ck = SDX_CK, uint32_t cmd = SDX_CMD);
    • For SDMMC:

      • SDClass:
        • begin(uint32_t data0, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t ck, uint32_t cmd, uint32_t ckin, uint32_t cdir, uint32_t d0dir, uint32_t d123dir);
        • begin(uint32_t detect = SD_DETECT_NONE, uint32_t data0 = SDX_D0, uint32_t data1 = SDX_D1, uint32_t data2 = SDX_D2, uint32_t data3 = SDX_D3, uint32_t ck = SDX_CK, uint32_t cmd = SDX_CMD, uint32_t ckin = SDX_CKIN, uint32_t cdir = SDX_CDIR, uint32_t d0dir = SDX_D0DIR, uint32_t d123dir = SDX_D123DIR);
        • Sd2Card:
        • init(uint32_t data0 = SDX_D0, uint32_t data1 = SDX_D1, uint32_t data2 = SDX_D2, uint32_t data3 = SDX_D3, uint32_t ck = SDX_CK, uint32_t cmd = SDX_CMD, uint32_t ckin = SDX_CKIN, uint32_t cdir = SDX_CDIR, uint32_t d0dir = SDX_D0DIR, uint32_t d123dir = SDX_D123DIR)
        • init(uint32_t detect = SD_DETECT_NONE, uint32_t data0 = SDX_D0, uint32_t data1 = SDX_D1, uint32_t data2 = SDX_D2, uint32_t data3 = SDX_D3, uint32_t ck = SDX_CK, uint32_t cmd = SDX_CMD, uint32_t ckin = SDX_CKIN, uint32_t cdir = SDX_CDIR, uint32_t d0dir = SDX_D0DIR, uint32_t d123dir = SDX_D123DIR);

    Code snippet:

  card.init(PE12, PE13, PE14, PE15, PB14, PB15);
  SD.begin(SD_DETECT_PIN, PE12, PE13, PE14, PE15, PB14, PB15);

SD configurations

  • SD_INSTANCE: some STM32 can have 2 SD peripherals SDMMC1 and SDMMC2, note that this library can managed only one peripheral

    • SDIO or SDMMC1 (default)
    • SDMMC2
  • SD_HW_FLOW_CTRL: specifies whether the SDMMC hardware flow control is enabled or disabled

    • SD_HW_FLOW_CTRL_ENABLE
    • SD_HW_FLOW_CTRL_DISABLE (default)
  • SD_BUS_WIDE: specifies the SDMMC bus width

    • SD_BUS_WIDE_1B
    • SD_BUS_WIDE_4B (default)
    • SD_BUS_WIDE_8B
  • SD_CLK_DIV: specifies the clock frequency of the SDMMC controller (0-255)

    • SDIO_TRANSFER_CLK_DIV (default) for SDIO
    • SDMMC_TRANSFER_CLK_DIV or SDMMC_NSpeed_CLK_DIV (default) for SDMMC

SD Transceiver

  • To specifies whether external Transceiver is present and enabled (Available only on some STM32) add:

    #define USE_SD_TRANSCEIVER 1

  • Then define pins:

    • SD_TRANSCEIVER_EN pin number to enable the level shifter
    • SD_TRANSCEIVER_SEL pin number for voltage selection

SD detect and timeout

  • SD_DETECT_PIN pin number

  • SD_DATATIMEOUT constant for Read/Write block

More Repositories

1

Arduino_Core_STM32

STM32 core support for Arduino
C
2,742
star
2

STM32FreeRTOS

Real Time Operating System implemented for STM32
C
302
star
3

wiki

Wiki for all STM Arduino cores and tools
236
star
4

STM32LowPower

Arduino Low Power library for STM32
C
180
star
5

STM32Ethernet

Arduino library to support Ethernet for STM32 based board
C++
151
star
6

Arduino_Core_STM8

STM8 core support for Arduino
C
137
star
7

STM32Examples

Arduino library to provide several examples for the Arduino core for STM32 MCUs.
135
star
8

STM32RTC

Arduino RTC library for STM32.
C
126
star
9

BoardManagerFiles

Storage for Arduino Board Manager JSON and package files etc
Makefile
101
star
10

LwIP

Lightweight TCP/IP stack (LwIP) is a small independent implementation of the TCP/IP protocol suite.
C
92
star
11

Arduino_Tools

Contains upload tools for STM32 based boards
C
86
star
12

FatFs

FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture.
C
81
star
13

ST25DV

Arduino library to support ST25DV components
C++
54
star
14

stm32flash

Open source flash program for STM32 using the ST serial bootloader (https://sourceforge.net/projects/stm32flash)
C
46
star
15

STM32LoRaWAN

Arduino library to support LoRaWAN communication using the STM32WL series.
C
35
star
16

LSM6DSL

Arduino library to support the LSM6DSL 3D accelerometer and 3D gyroscope
C
29
star
17

LSM6DSOX

Arduino library to support the LSM6DSOX 3D accelerometer and 3D gyroscope
C
27
star
18

LSM6DS3

Arduino library to support the LSM6DS3 3D accelerometer and 3D gyroscope
C
20
star
19

VL53L3CX

Arduino library to support the VL53L3CX Time-of-Flight ranging sensor with multi target detection
C++
18
star
20

X-NUCLEO-NFC03A1

Arduino library to support NFC card reader expansion board based on ST25R95
17
star
21

VL53L0X

Arduino library to support the VL53L0X Time-of-Flight and gesture-detection sensor
C++
16
star
22

LSM6DSO

Arduino library to support the LSM6DSO 3D accelerometer and 3D gyroscope
C
15
star
23

I-NUCLEO-LRWAN1

Arduino library to support I-NUCLEO-LRWAN1 LoRa® expansion board based on USI® LoRaWAN™ technology module.
C
14
star
24

M24SR64-Y

Arduino library to support the dynamic NFC/RFID Tag IC dual interface M24SR64-Y
C++
14
star
25

VL53L1X

Arduino library to support the VL53L1X Time-of-Flight and gesture-detection sensor
C++
14
star
26

VL53L5CX

Arduino library to support the VL53L5CX Time-of-Flight 8x8 multizone ranging sensor with wide field of view
C
14
star
27

SPBTLE-RF

Arduino library to support the Bluetooth (V4.1 compliant) SPBTLE-RF module
C
11
star
28

MX25R6435F

Arduino library to support the Quad-SPI NOR Flash memory MX25R6435F
C
11
star
29

LIS2DW12

Arduino library to support the LIS2DW12 3D accelerometer
C
10
star
30

Proximity_Gesture

Gesture library for proximity sensors
C
10
star
31

S2-LP

Arduino library to support S2-LP sub-1GHz transceiver
C++
10
star
32

X-NUCLEO-IKS01A3

Arduino library to support motion MEMS and environmental sensor expansion board
10
star
33

arm-none-eabi-gcc

The GNU Arm Embedded Toolchain binaries used by STM32duino cores
Makefile
10
star
34

VL53L7CX

Arduino library to support the VL53L7CX Time-of-Flight 8x8 multizone ranging sensor with 90 degrees FoV
C
10
star
35

VL53L8CX

Arduino library to support the VL53L8CX low-power high-performance 8x8 multizone Time-of-Flight sensor (ToF)
C
9
star
36

X-NUCLEO-53L1A1

Arduino library to support the X-NUCLEO-53L1A1 based on VL53L1X Time-of-Flight and gesture-detection sensor
C++
9
star
37

VL53L1

Arduino library to support the VL53L1 Time-of-Flight ranging sensor with advanced multi-zone and multi-object detection
C++
9
star
38

NFC-RFAL

Arduino library for the RF/NFC abstraction layer (RFAL)
C++
8
star
39

VL53L4CD

Arduino library to support the VL53L4CD Time-of-Flight high accuracy proximity sensor
C++
7
star
40

ASM330LHH

Arduino library to support the ASM330LHH automotive 3D accelerometer and 3D gyroscope
C
7
star
41

LSM6DSR

Arduino library to support the LSM6DSR 3D accelerometer and 3D gyroscope
C
7
star
42

ST25R3911B

Arduino library that provides an implementation of the NFC RFAL for ST25R3911B component
C++
7
star
43

ST25R3916

Arduino library that provides an implementation of the NFC RFAL for ST25R3916 component
C++
7
star
44

CMake_workspace

CMake
7
star
45

LPS22HB

Arduino library to support the LPS22HB 260-1260 hPa absolute digital ouput barometer
C
7
star
46

X-NUCLEO-GNSS1A1

Arduino library to support the X-NUCLEO-GNSS1A1 based on the Teseo-LIV3F module
C++
7
star
47

LIS3MDL

Arduino library to support the LIS3MDL high-performance 3-axis magnetometer
C
7
star
48

FP_Examples

Function Pack software: Examples that combine the usage of multiple X-NUCLEO boards
6
star
49

VL53L4CX

Arduino library to support the VL53L4CX Time-of-Flight high accuracy ranging sensor with multi target detection
C++
6
star
50

LSM6DS0

Arduino library to support the LSM6DS0 3D accelerometer and 3D gyroscope
C
6
star
51

ISM330DHCX

Arduino library to support the ISM330DHCX 3D accelerometer and 3D gyroscope
C
6
star
52

WiFi-ISM43362-M3G-L44

Arduino library to support the Wi-Fi module Inventek ISM43362-M3G-L44 (802.11 b/g/n)
C++
5
star
53

X-NUCLEO-IKS01A2

Arduino library to support motion MEMS and environmental sensor expansion board
5
star
54

MotionFX

Sensor Fusion Library for ST sensors and microcontrollers
C
5
star
55

X-NUCLEO-NFC04A1

Arduino library to support X-NUCLEO-NFC04A1 based on the dynamic NFC/RFID Tag IC ST25DV04K
C++
5
star
56

X-NUCLEO-IKS01A1

Arduino library to support motion MEMS and environmental sensor expansion board
5
star
57

HTS221

Arduino library to support the HTS221 capacitive digital sensor for relative humidity and temperature
C
5
star
58

LSM6DSV16X

Arduino library to support the LSM6DSV16X 3D accelerometer and 3D gyroscope
C
5
star
59

ST25R95

Arduino library that provides an implementation of the NFC RFAL for ST25R95 component
C++
4
star
60

X-NUCLEO-NFC05A1

Arduino library to support NFC card reader expansion board based on ST25R3911B
4
star
61

IIS2MDC

Arduino library to support the IIS2MDC high-performance 3-axis magnetometer
C
4
star
62

X-NUCLEO-IKS02A1-Audio

X-NUCLEO-IKS02A1 audio library to support IMP34DT05 MEMS digital omnidirectional microphone
C++
4
star
63

LSM303AGR

Arduino library to support the LSM303AGR 3D accelerometer and 3D magnetometer
C
4
star
64

VL6180

Arduino library to support the VL6180 Time-of-Flight ranging sensor
C++
4
star
65

X-NUCLEO-IDB05A1

Arduino library to support the X-NUCLEO-IDB05A1 based on Bluetooth (V4.1 compliant) SPBTLE-RF module
4
star
66

X-NUCLEO-NFC06A1

Arduino library to support NFC card reader expansion board based on ST25R3916
4
star
67

Python-Wave-Serial-Encoder

Python application to save a wave audio track through serial port
Python
4
star
68

LPS22HH

Arduino library to support the LPS22HH 260-1260 hPa absolute digital ouput barometer
C
3
star
69

STTS751

Arduino library to support the STTS751 digital temperature sensor
C
3
star
70

VL6180X

Arduino library to support the VL6180X Time-of-Flight and gesture-detection sensor
C++
3
star
71

X-NUCLEO-IHM02A1

Arduino library to support the two axis stepper motor driver based on L6470 component
C++
3
star
72

X-NUCLEO-6180XA1

Arduino library to support the X-NUCLEO-6180XA1 based on VL6180X Time-of-Flight and gesture-detection sensor
C++
3
star
73

X-NUCLEO-53L0A1

Arduino library to support the X-NUCLEO-53L0A1 based on VL53L0X Time-of-Flight and gesture-detection sensor
C++
3
star
74

LIS3DHH

Arduino library to support the LIS3DHH 3D accelerometer
C
2
star
75

LPS25HB

Arduino library to support the LPS25HB 260-1260 hPa absolute digital ouput barometer
C
2
star
76

ISM330DLC

Arduino library to support the ISM330DLC 3D accelerometer and 3D gyroscope
C
2
star
77

X-NUCLEO-IHM12A1

Arduino library to support dual brush DC motor driver based on STSPIN240 component
C++
2
star
78

M95640-R

Arduino library to support M95640-R SPI EEPROM
C++
2
star
79

X-NUCLEO-IKS4A1

Arduino library to support motion MEMS and environmental sensor expansion board
2
star
80

LPS22DF

Arduino library to support the LPS22DF 260-1260 hPa absolute digital ouput barometer
C
1
star
81

X-NUCLEO-53L8A1

Arduino library to support the X-NUCLEO-53L8A1 based on VL53L8CX low-power high-performance 8x8 multizone Time-of-Flight sensor (ToF)
1
star
82

USBMicrophone

Arduino library to support a simple USB Audio class for microphone for STM32 boards
1
star
83

LIS2DUXS12

Arduino library to support the LIS2DUXS12 3D ultralow-power accelerometer with QVAR and AI
C
1
star
84

Arduino_Tools_STM8

Contains upload tools for STM8 based boards (Windows only)
C
1
star
85

X-NUCLEO-53L7A1

Arduino library to support the X-NUCLEO-53L7A1 based on VL53L7CX Time-of-Flight 8x8 multizone ranging sensor with 90 degrees FoV
1
star
86

STEVAL-MKBOXPRO-Examples

Examples for STEVAL-MKBOXPRO board
1
star
87

SHT40-AD1B

Arduino library to support the SHT40-AD1B digital humidity and temperature sensor
C++
1
star
88

VL53L4ED

Arduino library to support the VL53L4ED Time-of-Flight high accuracy proximity sensor
C++
1
star
89

VL53L7CH

Arduino library to support the VL53L7CH artificial intelligence enabler, Time-of-Flight (ToF) 8x8 multizone sensor with 90 degrees FoV
C
1
star
90

MP34DT01

Arduino library to support MP32DT01 digital omnidirectionnal microphones
1
star
91

X-NUCLEO-IKS02A1

Arduino library to support industrial motion MEMS sensor expansion board
1
star
92

X-NUCLEO-53L1A2

Arduino library to support the X-NUCLEO-53L1A2 based on VL53L1 Time-of-Flight ranging sensor with advanced multi object detection
C++
1
star
93

LSM6DSO16IS

Arduino library to support the LSM6DSO16IS 3D accelerometer and 3D gyroscope with ISPU
C
1
star
94

actions

A set of GitHub Actions for STM32duino GitHub organization
Shell
1
star
95

X-NUCLEO-53L5A1

Arduino library to support the X-NUCLEO-53L5A1 based on VL53L5CX Time-of-Flight 8x8 multizone ranging sensor with wide field of view
1
star
96

LSM6DSOSensorHub

Arduino library to support LSM6DSO Sensor Hub feature
C++
1
star
97

X-NUCLEO-NFC01A1

Arduino library to support X-NUCLEO-NFC01A1 based on the dynamic NFC/RFID Tag IC dual interface M24SR64-Y
1
star
98

.github

1
star
99

X-NUCLEO-IHM01A1

Arduino library to support a stepper motor driver based on L6474 component
C++
1
star
100

LIS2MDL

Arduino library to support the LIS2MDL high-performance 3-axis magnetometer
C
1
star