SdMmc

Description

SdMmc represents a SD card reader.

Usage

erbui

module Example {
   control sdmmc SdMmc {            // 1.
      position 19.2mm, 111mm        // 2.
      label "MICRO SD"              // 3.
      pin Pin1                      // 4.
   }
}
  1. Creates a SD control with name sdmmc,

  2. Sets the control position on the front panel,

  3. Sets the optional label for the control, using its default theme positioning,

  4. Sets the optional physical board pins to use. If not set, the system will choose it automatically.

Yamaichi Micro SD Card holder photo is from the Thonk shop.

erbb

module Example {
    define erb_USE_FATFS=1          // 1.
}
  1. Add FatFs build dependency, which is required to use with SD card readers.

c++

SdMmc is a type that abstracts a SD Card reader block.

struct Example
{
   ExampleUi ui;

   void init () {
      // 1.
      auto status = ui.sdmmc.mount ("/", erb::SdMmc::MountOption::Immediate);
   }

   void idle () {
#if defined (erb_TARGET_DAISY)
      static __attribute__((section(".text"))) erb::SdMmc::File file;   // 2.
#else
      erb::SdMmc::File file;
#endif

      file.open ("/test.txt", "w");
   }
}

Error checking was removed for readability.

  1. Mounts the SD card at /,

  2. Create a file object for later open. The file needs to be stored in the .text section.

erbui Control Reference

control definition

control <name> SdMmc { ... }

Where <name> is the name of the control. More details can be found in control documentation.

position property

position <x>, <y>

Sets the position of the control, where the axis origin is the top-left corner. The x axis is oriented from left to right, and the y axis is oriented from top to bottom.

The position component values are expressed with their unit, either mm or hp.

Example:

position 2hp, 15mm

More details can be found in position documentation.

label optional property

label "<text>"

Where <text> is the text displayed. More details can be found in label documentation.

rotation optional property

rotation <angle>

Where <angle> is the angle to rotate the element. The rotation value only supports quarter turns, so that <angle> can only be a multiple of 90.

<angle> supported units are:

  • °ccw (Counter Clockwise),

  • °ccw (Clockwise),

  • ° (Clockwise, as the position y-axis goes from top to bottom).

More details can be found in rotation documentation.

c++ Member Functions Synopsys

Eurorack-blocks provides a thin wrapper on top of FatFs.

Name

Synopsys

mount

Mounts the filesystem

unmount

Unmounts the filesystem

File::open

Opens a file

File::close

Closes a file

File::seek

Seeks into a file

File::read

Reads from a file

File::size

Returns the size of a file

Directory::open

Opens a directory

Directory::close

Closes a directory

Directory::read

Reads a directory item

c++ Member Functions

mount

Status  mount (const char * path_0, MountOption option);

Mounts the filesystem at path_0 using option, one of:

  • MountOption::Defer: mounts filesystem later, on first read/write operation

  • MountOption::Immediate: mounts filesystem immediately

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

unmount

Status  unmount (const char * path_0);

Unmounts the filesystem at path_0.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

File::open

Status  File::open (const char * path_0, const char * mode_0);

Opens the file at path_0 with POSIX mode mode_0.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

File::close

Status  File::close ();

Closes the file.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

File::seek

Status  File::seek (std::size_t offset);

Seeks absolutely into an opened file. offset represents the number of bytes from the beginning of the file. In particular, relative seeking is not supported.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

File::read

Status  File::read (const void * buf, std::size_t & size);

Reads at maximum size bytes from the opened file and store them to buf. On success, size represents the number of effective read bytes.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

File::size

std::size_t  File::size () const;

Returns the size of the opened file.

Directory::open

Status  Directory::open (const char * path_0);

Opens the directory at path_0.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

Directory::close

Status  Directory::close ();

Closes the directory.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.

Directory::read

Status  Directory::read (FileInfo & file_info);

Reads a directory item. On success, file_info contains the metadata of the file such as its name and file system properties (hidden, directory, etc.)

The function is typically called multiple times to iterate over all the items of a directory. When the end is reached, file_info.name_0 is \0.

Returns the status of the operation, Status::Ok on success. See FatFs reference return codes for details.