Repetier-Firmware  0.91
src/ArduinoAVR/Repetier/SdFat.h File Reference

SdFat class. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  CID
struct  CSDV1
struct  CSDV2
union  csd_t
class  Sd2Card
 Raw access to SD and SDHC flash memory cards. More...
struct  partitionTable
 MBR partition table entry. More...
struct  masterBootRecord
 Master Boot Record. More...
struct  fat_boot
 Boot sector for a FAT12/FAT16 volume. More...
struct  fat32_boot
 Boot sector for a FAT32 volume. More...
struct  fat32_fsinfo
 FSINFO sector for a FAT32 volume. More...
struct  directoryEntry
 FAT short directory entry. More...
struct  directoryVFATEntry
union  cache_t
 Cache for an SD data block. More...
class  SdVolume
 Access FAT16 and FAT32 volumes on SD and SDHC cards. More...
struct  FatPos_t
 internal type for istream do not use in user apps More...
class  SdBaseFile
 Base class for SdFile with Print and C++ streams. More...
class  SdFile
 SdBaseFile with Print. More...
class  SdFat
 Integration class for the SdFat library. More...

Namespaces

namespace  SdFatUtil

Defines

#define SD_FAT_VERSION   20130629
#define USE_SD_CRC   2
#define USE_MULTIPLE_CARDS   0
#define DESTRUCTOR_CLOSES_FILE   0
#define USE_SEPARATE_FAT_CACHE   0
#define USE_MULTI_BLOCK_SD_IO   1
#define USE_ARDUINO_SPI_LIBRARY   0
#define USE_NATIVE_MK20DX128_SPI   0
#define USE_NATIVE_SAM3X_SPI   0
#define USE_SERIAL_FOR_STD_OUT   0
#define ENDL_CALLS_FLUSH   0
#define ALLOW_DEPRECATED_FUNCTIONS   0
#define FAT12_SUPPORT   0
#define SPI_SD_INIT_RATE   11
#define SET_SPI_SS_HIGH   1
#define MEGA_SOFT_SPI   0
#define LEONARDO_SOFT_SPI   0
#define USE_SOFTWARE_SPI   0
#define SD_CARD_REUSE_FAT_ENTRIES   true
#define PgmPrint(x)   SerialPrint_P(PSTR(x))
#define PgmPrintln(x)   SerialPrintln_P(PSTR(x))

Typedefs

typedef struct partitionTable part_t
typedef struct masterBootRecord mbr_t
typedef struct fat_boot fat_boot_t
typedef struct fat32_boot fat32_boot_t
typedef struct fat32_fsinfo fat32_fsinfo_t
typedef struct directoryVFATEntry vfat_t
typedef struct directoryEntry dir_t

Functions

struct CID __attribute__ ((packed)) cid_t
static uint8_t DIR_IS_LONG_NAME (const dir_t *dir)
static uint8_t DIR_IS_FILE (const dir_t *dir)
static uint8_t DIR_IS_SUBDIR (const dir_t *dir)
static uint8_t DIR_IS_FILE_OR_SUBDIR (const dir_t *dir)
static uint16_t FAT_DATE (uint16_t year, uint8_t month, uint8_t day)
static uint16_t FAT_YEAR (uint16_t fatDate)
static uint8_t FAT_MONTH (uint16_t fatDate)
static uint8_t FAT_DAY (uint16_t fatDate)
static uint16_t FAT_TIME (uint8_t hour, uint8_t minute, uint8_t second)
static uint8_t FAT_HOUR (uint16_t fatTime)
static uint8_t FAT_MINUTE (uint16_t fatTime)
static uint8_t FAT_SECOND (uint16_t fatTime)
int FreeRam ()
void SerialPrint_P (FSTRINGPARAM(str))
void SerialPrintln_P (FSTRINGPARAM(str))

Variables

uint8_t const CMD0 = 0X00
uint8_t const CMD8 = 0X08
uint8_t const CMD9 = 0X09
uint8_t const CMD10 = 0X0A
uint8_t const CMD12 = 0X0C
uint8_t const CMD13 = 0X0D
uint8_t const CMD17 = 0X11
uint8_t const CMD18 = 0X12
uint8_t const CMD24 = 0X18
uint8_t const CMD25 = 0X19
uint8_t const CMD32 = 0X20
uint8_t const CMD33 = 0X21
uint8_t const CMD38 = 0X26
uint8_t const CMD55 = 0X37
uint8_t const CMD58 = 0X3A
uint8_t const CMD59 = 0X3B
uint8_t const ACMD23 = 0X17
uint8_t const ACMD41 = 0X29
uint8_t const R1_READY_STATE = 0X00
uint8_t const R1_IDLE_STATE = 0X01
uint8_t const R1_ILLEGAL_COMMAND = 0X04
uint8_t const DATA_START_BLOCK = 0XFE
uint8_t const STOP_TRAN_TOKEN = 0XFD
uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC
uint8_t const DATA_RES_MASK = 0X1F
uint8_t const DATA_RES_ACCEPTED = 0X05
unsigned char mid
char oid [2]
char pnm [5]
unsigned char prv_m
unsigned char prv_n
uint32_t psn
unsigned char mdt_year_high
unsigned char reserved
unsigned char mdt_month
unsigned char mdt_year_low
unsigned char always1
unsigned char crc
unsigned char reserved1
unsigned char csd_ver
unsigned char taac
unsigned char nsac
unsigned char tran_speed
unsigned char ccc_high
unsigned char read_bl_len
unsigned char ccc_low
unsigned char c_size_high
unsigned char reserved2
unsigned char dsr_imp
unsigned char read_blk_misalign
unsigned char write_blk_misalign
unsigned char read_bl_partial
unsigned char c_size_mid
unsigned char vdd_r_curr_max
unsigned char vdd_r_curr_min
unsigned char c_size_low
unsigned char c_size_mult_high
unsigned char vdd_w_cur_max
unsigned char vdd_w_curr_min
unsigned char sector_size_high
unsigned char erase_blk_en
unsigned char c_size_mult_low
unsigned char wp_grp_size
unsigned char sector_size_low
unsigned char write_bl_len_high
unsigned char r2w_factor
unsigned char reserved3
unsigned char wp_grp_enable
unsigned char reserved4
unsigned char write_partial
unsigned char write_bl_len_low
unsigned char reserved5
unsigned char file_format
unsigned char tmp_write_protect
unsigned char perm_write_protect
unsigned char copy
unsigned char file_format_grp
unsigned char reserved6
unsigned char reserved7
union csd_t __attribute__
uint8_t const SOFT_SPI_CS_PIN = 10
uint8_t const SOFT_SPI_MOSI_PIN = 11
uint8_t const SOFT_SPI_MISO_PIN = 12
uint8_t const SOFT_SPI_SCK_PIN = 13
uint8_t const SPI_FULL_SPEED = 0
uint8_t const SPI_DIV3_SPEED = 1
uint8_t const SPI_HALF_SPEED = 2
uint8_t const SPI_DIV6_SPEED = 3
uint8_t const SPI_QUARTER_SPEED = 4
uint8_t const SPI_EIGHTH_SPEED = 6
uint8_t const SPI_SIXTEENTH_SPEED = 8
const uint8_t MAX_SCK_RATE_ID = 14
uint16_t const SD_INIT_TIMEOUT = 2000
uint16_t const SD_ERASE_TIMEOUT = 10000
uint16_t const SD_READ_TIMEOUT = 300
uint16_t const SD_WRITE_TIMEOUT = 600
uint8_t const SD_CARD_ERROR_CMD0 = 0X1
uint8_t const SD_CARD_ERROR_CMD8 = 0X2
uint8_t const SD_CARD_ERROR_CMD12 = 0X3
uint8_t const SD_CARD_ERROR_CMD17 = 0X4
uint8_t const SD_CARD_ERROR_CMD18 = 0X5
uint8_t const SD_CARD_ERROR_CMD24 = 0X6
uint8_t const SD_CARD_ERROR_CMD25 = 0X7
uint8_t const SD_CARD_ERROR_CMD58 = 0X8
uint8_t const SD_CARD_ERROR_ACMD23 = 0X9
uint8_t const SD_CARD_ERROR_ACMD41 = 0XA
uint8_t const SD_CARD_ERROR_BAD_CSD = 0XB
uint8_t const SD_CARD_ERROR_ERASE = 0XC
uint8_t const SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0XD
uint8_t const SD_CARD_ERROR_ERASE_TIMEOUT = 0XE
uint8_t const SD_CARD_ERROR_READ = 0XF
uint8_t const SD_CARD_ERROR_READ_REG = 0X10
uint8_t const SD_CARD_ERROR_READ_TIMEOUT = 0X11
uint8_t const SD_CARD_ERROR_STOP_TRAN = 0X12
uint8_t const SD_CARD_ERROR_WRITE = 0X13
uint8_t const SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0X14
uint8_t const SD_CARD_ERROR_WRITE_MULTIPLE = 0X15
uint8_t const SD_CARD_ERROR_WRITE_PROGRAMMING = 0X16
uint8_t const SD_CARD_ERROR_WRITE_TIMEOUT = 0X17
uint8_t const SD_CARD_ERROR_SCK_RATE = 0X18
uint8_t const SD_CARD_ERROR_INIT_NOT_CALLED = 0X19
uint8_t const SD_CARD_ERROR_CMD59 = 0X1A
uint8_t const SD_CARD_ERROR_READ_CRC = 0X1B
uint8_t const SD_CARD_ERROR_SPI_DMA = 0X1C
uint8_t const SD_CARD_TYPE_SD1 = 1
uint8_t const SD_CARD_TYPE_SD2 = 2
uint8_t const SD_CARD_TYPE_SDHC = 3
uint8_t const SD_CHIP_SELECT_PIN = SDSS
uint8_t const BOOTSIG0 = 0X55
uint8_t const BOOTSIG1 = 0XAA
uint8_t const EXTENDED_BOOT_SIG = 0X29
struct partitionTable PACK
uint32_t const FSINFO_LEAD_SIG = 0x41615252
uint32_t const FSINFO_STRUCT_SIG = 0x61417272
uint16_t const FAT12EOC = 0XFFF
uint16_t const FAT12EOC_MIN = 0XFF8
uint16_t const FAT16EOC = 0XFFFF
uint16_t const FAT16EOC_MIN = 0XFFF8
uint32_t const FAT32EOC = 0X0FFFFFFF
uint32_t const FAT32EOC_MIN = 0X0FFFFFF8
uint32_t const FAT32MASK = 0X0FFFFFFF
uint8_t const DIR_NAME_0XE5 = 0X05
uint8_t const DIR_NAME_DELETED = 0XE5
uint8_t const DIR_NAME_FREE = 0X00
uint8_t const DIR_ATT_READ_ONLY = 0X01
uint8_t const DIR_ATT_HIDDEN = 0X02
uint8_t const DIR_ATT_SYSTEM = 0X04
uint8_t const DIR_ATT_VOLUME_ID = 0X08
uint8_t const DIR_ATT_DIRECTORY = 0X10
uint8_t const DIR_ATT_ARCHIVE = 0X20
uint8_t const DIR_ATT_LONG_NAME = 0X0F
uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F
uint8_t const DIR_ATT_DEFINED_BITS = 0X3F
uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)
uint8_t const O_READ = 0X01
uint8_t const O_RDONLY = O_READ
uint8_t const O_WRITE = 0X02
uint8_t const O_WRONLY = O_WRITE
uint8_t const O_RDWR = (O_READ | O_WRITE)
uint8_t const O_ACCMODE = (O_READ | O_WRITE)
uint8_t const O_APPEND = 0X04
uint8_t const O_SYNC = 0X08
uint8_t const O_TRUNC = 0X10
uint8_t const O_AT_END = 0X20
uint8_t const O_CREAT = 0X40
uint8_t const O_EXCL = 0X80
uint8_t const LS_DATE = 1
uint8_t const LS_SIZE = 2
uint8_t const LS_R = 4
uint8_t const T_ACCESS = 1
uint8_t const T_CREATE = 2
uint8_t const T_WRITE = 4
uint8_t const FAT_FILE_TYPE_CLOSED = 0
uint8_t const FAT_FILE_TYPE_NORMAL = 1
uint8_t const FAT_FILE_TYPE_ROOT_FIXED = 2
uint8_t const FAT_FILE_TYPE_ROOT32 = 3
uint8_t const FAT_FILE_TYPE_SUBDIR = 4
uint8_t const FAT_FILE_TYPE_MIN_DIR = FAT_FILE_TYPE_ROOT_FIXED
uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1
uint16_t const FAT_DEFAULT_TIME = (1 << 11)

Detailed Description

SdFat class.

FAT file structures.


Define Documentation

Allow use of deprecated functions if ALLOW_DEPRECATED_FUNCTIONS is nonzero

#define DESTRUCTOR_CLOSES_FILE   0

Set DESTRUCTOR_CLOSES_FILE nonzero to close a file in its destructor.

Causes use of lots of heap in ARM.

#define ENDL_CALLS_FLUSH   0

Call flush for endl if ENDL_CALLS_FLUSH is nonzero

The standard for iostreams is to call flush. This is very costly for SdFat. Each call to flush causes 2048 bytes of I/O to the SD.

SdFat has a single 512 byte buffer for SD I/O so it must write the current data block to the SD, read the directory block from the SD, update the directory entry, write the directory block to the SD and read the data block back into the buffer.

The SD flash memory controller is not designed for this many rewrites so performance may be reduced by more than a factor of 100.

If ENDL_CALLS_FLUSH is zero, you must call flush and/or close to force all data to be written to the SD.

#define FAT12_SUPPORT   0

Allow FAT12 volumes if FAT12_SUPPORT is nonzero. FAT12 has not been well tested.

#define LEONARDO_SOFT_SPI   0

Define LEONARDO_SOFT_SPI nonzero to use software SPI on Leonardo Arduinos. Derfault pins used are SS 10, MOSI 11, MISO 12, and SCK 13. Edit Software Spi pins to change pin numbers.

LEONARDO_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used on Leonardo Arduinos. Software SPI works well with GPS Shield V1.1 but many SD cards will fail with GPS Shield V1.0.

#define MEGA_SOFT_SPI   0

Define MEGA_SOFT_SPI nonzero to use software SPI on Mega Arduinos. Default pins used are SS 10, MOSI 11, MISO 12, and SCK 13. Edit Software Spi pins to change pin numbers.

MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used on Mega Arduinos. Software SPI works well with GPS Shield V1.1 but many SD cards will fail with GPS Shield V1.0.

#define PgmPrint (   x)    SerialPrint_P(PSTR(x))

Store and print a string in flash memory.

#define PgmPrintln (   x)    SerialPrintln_P(PSTR(x))

Store and print a string in flash memory followed by a CR/LF.

#define SD_CARD_REUSE_FAT_ENTRIES   true
#define SD_FAT_VERSION   20130629

SdFat version YYYYMMDD

#define SET_SPI_SS_HIGH   1

Set the SS pin high for hardware SPI. If SS is chip select for another SPI device this will disable that device during the SD init phase.

#define SPI_SD_INIT_RATE   11

SPI init rate for SD initialization commands. Must be 10 (F_CPU/64) or greater

#define USE_ARDUINO_SPI_LIBRARY   0

Force use of Arduino Standard SPI library if USE_ARDUINO_SPI_LIBRARY is nonzero.

#define USE_MULTI_BLOCK_SD_IO   1

Don't use mult-block read/write on small AVR boards

#define USE_MULTIPLE_CARDS   0

To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.

Using multiple cards costs 400 - 500 bytes of flash.

Each card requires about 550 bytes of SRAM so use of a Mega is recommended.

#define USE_NATIVE_MK20DX128_SPI   0

Use native SPI on Teensy 3.0 if USE_NATIVE_MK20DX128-SPI is nonzero.

#define USE_NATIVE_SAM3X_SPI   0

Use fast SAM3X SPI library if USE_NATIVE_SAM3X_SPI is nonzero.

#define USE_SD_CRC   2

To enable SD card CRC checking set USE_SD_CRC nonzero.

Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function.

Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function.

#define USE_SEPARATE_FAT_CACHE   0

Set USE_SEPARATE_FAT_CACHE nonzero to use a second 512 byte cache for FAT table entries. Improves performance for large writes that are not a multiple of 512 bytes.

#define USE_SERIAL_FOR_STD_OUT   0

Set nonzero to use Serial (the HardwareSerial class) for error messages and output from print functions like ls().

If USE_SERIAL_FOR_STD_OUT is zero, a small non-interrupt driven class is used to output messages to serial port zero. This allows an alternate Serial library like SerialPort to be used with SdFat.

You can redirect stdOut with SdFat::setStdOut(Print* stream) and get the current stream with SdFat::stdOut().

#define USE_SOFTWARE_SPI   0

Set USE_SOFTWARE_SPI nonzero to always use software SPI.


Typedef Documentation

typedef struct directoryEntry dir_t

Type name for directoryEntry

typedef struct fat32_boot fat32_boot_t

Type name for FAT32 Boot Sector

typedef struct fat32_fsinfo fat32_fsinfo_t

Type name for FAT32 FSINFO Sector

typedef struct fat_boot fat_boot_t

Type name for FAT Boot Sector

typedef struct masterBootRecord mbr_t

Type name for masterBootRecord

typedef struct partitionTable part_t

Type name for partitionTable

typedef struct directoryVFATEntry vfat_t

Function Documentation

struct CID __attribute__ ( (packed)  )

Card IDentification (CID) register

CSD for version 1.00 cards

CSD for version 2.00 cards

static uint8_t DIR_IS_FILE ( const dir_t dir) [inline, static]

Directory entry is for a file

Parameters:
[in]dirPointer to a directory entry.
Returns:
true if the entry is for a normal file else false.
static uint8_t DIR_IS_FILE_OR_SUBDIR ( const dir_t dir) [inline, static]

Directory entry is for a file or subdirectory

Parameters:
[in]dirPointer to a directory entry.
Returns:
true if the entry is for a normal file or subdirectory else false.
static uint8_t DIR_IS_LONG_NAME ( const dir_t dir) [inline, static]

Directory entry is part of a long name

Parameters:
[in]dirPointer to a directory entry.
Returns:
true if the entry is for part of a long name else false.
static uint8_t DIR_IS_SUBDIR ( const dir_t dir) [inline, static]

Directory entry is for a subdirectory

Parameters:
[in]dirPointer to a directory entry.
Returns:
true if the entry is for a subdirectory else false.
static uint16_t FAT_DATE ( uint16_t  year,
uint8_t  month,
uint8_t  day 
) [inline, static]

date field for FAT directory entry

Parameters:
[in]year[1980,2107]
[in]month[1,12]
[in]day[1,31]
Returns:
Packed date for dir_t entry.
static uint8_t FAT_DAY ( uint16_t  fatDate) [inline, static]

day part of FAT directory date field

Parameters:
[in]fatDateDate in packed dir format.
Returns:
Extracted day [1,31]
static uint8_t FAT_HOUR ( uint16_t  fatTime) [inline, static]

hour part of FAT directory time field

Parameters:
[in]fatTimeTime in packed dir format.
Returns:
Extracted hour [0,23]
static uint8_t FAT_MINUTE ( uint16_t  fatTime) [inline, static]

minute part of FAT directory time field

Parameters:
[in]fatTimeTime in packed dir format.
Returns:
Extracted minute [0,59]
static uint8_t FAT_MONTH ( uint16_t  fatDate) [inline, static]

month part of FAT directory date field

Parameters:
[in]fatDateDate in packed dir format.
Returns:
Extracted month [1,12]
static uint8_t FAT_SECOND ( uint16_t  fatTime) [inline, static]

second part of FAT directory time field Note second/2 is stored in packed time.

Parameters:
[in]fatTimeTime in packed dir format.
Returns:
Extracted second [0,58]
static uint16_t FAT_TIME ( uint8_t  hour,
uint8_t  minute,
uint8_t  second 
) [inline, static]

time field for FAT directory entry

Parameters:
[in]hour[0,23]
[in]minute[0,59]
[in]second[0,59]
Returns:
Packed time for dir_t entry.
static uint16_t FAT_YEAR ( uint16_t  fatDate) [inline, static]

year part of FAT directory date field

Parameters:
[in]fatDateDate in packed dir format.
Returns:
Extracted year [1980,2107]

Variable Documentation

CSD for version 1.00 cards

CSD for version 2.00 cards

uint8_t const ACMD23 = 0X17

SET_WR_BLK_ERASE_COUNT - Set the number of write blocks to be pre-erased before writing

uint8_t const ACMD41 = 0X29

SD_SEND_OP_COMD - Sends host capacity support information and activates the card's initialization process

unsigned char always1

not used always 1

uint8_t const BOOTSIG0 = 0X55

Value for byte 510 of boot block or MBR

uint8_t const BOOTSIG1 = 0XAA

Value for byte 511 of boot block or MBR

unsigned char c_size_high

high part of card size

unsigned char c_size_low

low part of card size

unsigned char c_size_mid

middle part of card size

unsigned char c_size_mult_high
unsigned char c_size_mult_low
unsigned char ccc_high
unsigned char ccc_low
uint8_t const CMD0 = 0X00

error if old IDE GO_IDLE_STATE - init card in spi mode if CS low

uint8_t const CMD10 = 0X0A

SEND_CID - read the card identification information (CID register)

uint8_t const CMD12 = 0X0C

STOP_TRANSMISSION - end multiple block read sequence

uint8_t const CMD13 = 0X0D

SEND_STATUS - read the card status register

uint8_t const CMD17 = 0X11

READ_SINGLE_BLOCK - read a single data block from the card

uint8_t const CMD18 = 0X12

READ_MULTIPLE_BLOCK - read a multiple data blocks from the card

uint8_t const CMD24 = 0X18

WRITE_BLOCK - write a single data block to the card

uint8_t const CMD25 = 0X19

WRITE_MULTIPLE_BLOCK - write blocks of data until a STOP_TRANSMISSION

uint8_t const CMD32 = 0X20

ERASE_WR_BLK_START - sets the address of the first block to be erased

uint8_t const CMD33 = 0X21

ERASE_WR_BLK_END - sets the address of the last block of the continuous range to be erased

uint8_t const CMD38 = 0X26

ERASE - erase all previously selected blocks

uint8_t const CMD55 = 0X37

APP_CMD - escape for application specific command

uint8_t const CMD58 = 0X3A

READ_OCR - read the OCR register of a card

uint8_t const CMD59 = 0X3B

CRC_ON_OFF - enable or disable CRC checking

uint8_t const CMD8 = 0X08

SEND_IF_COND - verify SD Memory Card interface operating condition.

uint8_t const CMD9 = 0X09

SEND_CSD - read the Card Specific Data (CSD register)

unsigned char copy
unsigned char crc

CRC7 checksum

checksum

unsigned char csd_ver
uint8_t const DATA_RES_ACCEPTED = 0X05

write data accepted token

uint8_t const DATA_RES_MASK = 0X1F

mask for data response tokens after a write block operation

uint8_t const DATA_START_BLOCK = 0XFE

start data token for read or write single block

uint8_t const DIR_ATT_ARCHIVE = 0X20

Old DOS archive bit for backup support

uint8_t const DIR_ATT_DEFINED_BITS = 0X3F

defined attribute bits

uint8_t const DIR_ATT_DIRECTORY = 0X10

Entry is for a directory

Mask for file/subdirectory tests

uint8_t const DIR_ATT_HIDDEN = 0X02

File should hidden in directory listings

uint8_t const DIR_ATT_LONG_NAME = 0X0F

Test value for long name entry. Test is (d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME.

uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F

Test mask for long name entry

uint8_t const DIR_ATT_READ_ONLY = 0X01

file is read-only

uint8_t const DIR_ATT_SYSTEM = 0X04

Entry is for a system file

uint8_t const DIR_ATT_VOLUME_ID = 0X08

Directory entry contains the volume label

uint8_t const DIR_NAME_0XE5 = 0X05

escape for name[0] = 0XE5

uint8_t const DIR_NAME_DELETED = 0XE5

name[0] value for entry that is free after being "deleted"

uint8_t const DIR_NAME_FREE = 0X00

name[0] value for entry that is free and no allocated entries follow

unsigned char dsr_imp
unsigned char erase_blk_en

fixed to 1 - erase single is supported

uint8_t const EXTENDED_BOOT_SIG = 0X29

Value for bootSignature field int FAT/FAT32 boot sector

uint16_t const FAT12EOC = 0XFFF

FAT12 end of chain value used by Microsoft.

uint16_t const FAT12EOC_MIN = 0XFF8

Minimum value for FAT12 EOC. Use to test for EOC.

uint16_t const FAT16EOC = 0XFFFF

FAT16 end of chain value used by Microsoft.

uint16_t const FAT16EOC_MIN = 0XFFF8

Minimum value for FAT16 EOC. Use to test for EOC.

uint32_t const FAT32EOC = 0X0FFFFFFF

FAT32 end of chain value used by Microsoft.

uint32_t const FAT32EOC_MIN = 0X0FFFFFF8

Minimum value for FAT32 EOC. Use to test for EOC.

uint32_t const FAT32MASK = 0X0FFFFFFF

Mask a for FAT32 entry. Entries are 28 bits.

uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1

Default date for file timestamps is 1 Jan 2000

uint16_t const FAT_DEFAULT_TIME = (1 << 11)

Default time for file timestamp is 1 am

uint8_t const FAT_FILE_TYPE_CLOSED = 0

This file has not been opened.

Test value for directory type

uint8_t const FAT_FILE_TYPE_NORMAL = 1

A normal file

uint8_t const FAT_FILE_TYPE_ROOT32 = 3

A FAT32 root directory

uint8_t const FAT_FILE_TYPE_ROOT_FIXED = 2

A FAT12 or FAT16 root directory

uint8_t const FAT_FILE_TYPE_SUBDIR = 4

A subdirectory file

unsigned char file_format

Do not use always 0

unsigned char file_format_grp

Indicates the file format on the card

Do not use always 0

uint32_t const FSINFO_LEAD_SIG = 0x41615252

Lead signature for a FSINFO sector

uint32_t const FSINFO_STRUCT_SIG = 0x61417272

Struct signature for a FSINFO sector

uint8_t const LS_DATE = 1

ls() flag to print modify date

uint8_t const LS_R = 4

ls() flag for recursive list of subdirectories

uint8_t const LS_SIZE = 2

ls() flag to print file size

const uint8_t MAX_SCK_RATE_ID = 14

MAX rate test - see spiInit for a given chip for details

unsigned char mdt_month

Manufacturing date month

unsigned char mdt_year_high

Manufacturing date year low digit

unsigned char mdt_year_low

Manufacturing date year low digit

unsigned char mid

Manufacturer ID

unsigned char nsac

fixed to 0

uint8_t const O_ACCMODE = (O_READ | O_WRITE)

open() oflag mask for access modes

uint8_t const O_APPEND = 0X04

The file offset shall be set to the end of the file prior to each write.

uint8_t const O_AT_END = 0X20

set the initial position at the end of the file

uint8_t const O_CREAT = 0X40

create the file if nonexistent

uint8_t const O_EXCL = 0X80

If O_CREAT and O_EXCL are set, open() shall fail if the file exists

uint8_t const O_RDONLY = O_READ

open() oflag - same as O_IN

uint8_t const O_RDWR = (O_READ | O_WRITE)

open() oflag for reading and writing

uint8_t const O_READ = 0X01

open() oflag for reading

uint8_t const O_SYNC = 0X08

synchronous writes - call sync() after each write

uint8_t const O_TRUNC = 0X10

truncate the file to zero length

uint8_t const O_WRITE = 0X02

open() oflag for write

uint8_t const O_WRONLY = O_WRITE

open() oflag - same as O_WRITE

char oid[2]

OEM/Application ID

union cache_t PACK
unsigned char perm_write_protect
char pnm[5]

Product name

unsigned char prv_m

Product revision least significant digit

unsigned char prv_n

Product revision most significant digit

uint32_t psn

Product serial number

uint8_t const R1_IDLE_STATE = 0X01

status for card in the idle state

uint8_t const R1_ILLEGAL_COMMAND = 0X04

status bit for illegal command

uint8_t const R1_READY_STATE = 0X00

status for card in the ready state

unsigned char r2w_factor

fixed value of 2

unsigned char read_bl_len

This field is fixed to 9h, which indicates READ_BL_LEN=512 Byte

unsigned char read_bl_partial

fixed to 0 - no partial read

unsigned char read_blk_misalign

fixed to 0

unsigned char reserved

not used

unsigned char reserved1
unsigned char reserved2

not used

unsigned char reserved3

not used

unsigned char reserved4

not used

unsigned char reserved5

not used

unsigned char reserved6
unsigned char reserved7
uint8_t const SD_CARD_ERROR_ACMD23 = 0X9

SET_WR_BLK_ERASE_COUNT failed

uint8_t const SD_CARD_ERROR_ACMD41 = 0XA

ACMD41 initialization process timeout

uint8_t const SD_CARD_ERROR_BAD_CSD = 0XB

card returned a bad CSR version field

uint8_t const SD_CARD_ERROR_CMD0 = 0X1

timeout error for command CMD0 (initialize card in SPI mode)

uint8_t const SD_CARD_ERROR_CMD12 = 0X3

card returned an error response for CMD12 (write stop)

uint8_t const SD_CARD_ERROR_CMD17 = 0X4

card returned an error response for CMD17 (read block)

uint8_t const SD_CARD_ERROR_CMD18 = 0X5

card returned an error response for CMD18 (read multiple block)

uint8_t const SD_CARD_ERROR_CMD24 = 0X6

card returned an error response for CMD24 (write block)

uint8_t const SD_CARD_ERROR_CMD25 = 0X7

WRITE_MULTIPLE_BLOCKS command failed

uint8_t const SD_CARD_ERROR_CMD58 = 0X8

card returned an error response for CMD58 (read OCR)

uint8_t const SD_CARD_ERROR_CMD59 = 0X1A

card returned an error for CMD59 (CRC_ON_OFF)

uint8_t const SD_CARD_ERROR_CMD8 = 0X2

CMD8 was not accepted - not a valid SD card

uint8_t const SD_CARD_ERROR_ERASE = 0XC

erase block group command failed

uint8_t const SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0XD

card not capable of single block erase

uint8_t const SD_CARD_ERROR_ERASE_TIMEOUT = 0XE

Erase sequence timed out

uint8_t const SD_CARD_ERROR_INIT_NOT_CALLED = 0X19

init() not called

uint8_t const SD_CARD_ERROR_READ = 0XF

card returned an error token instead of read data

uint8_t const SD_CARD_ERROR_READ_CRC = 0X1B

invalid read CRC

uint8_t const SD_CARD_ERROR_READ_REG = 0X10

read CID or CSD failed

uint8_t const SD_CARD_ERROR_READ_TIMEOUT = 0X11

timeout while waiting for start of read data

uint8_t const SD_CARD_ERROR_SCK_RATE = 0X18

incorrect rate selected

uint8_t const SD_CARD_ERROR_SPI_DMA = 0X1C

SPI DMA error

uint8_t const SD_CARD_ERROR_STOP_TRAN = 0X12

card did not accept STOP_TRAN_TOKEN

uint8_t const SD_CARD_ERROR_WRITE = 0X13

card returned an error token as a response to a write operation

uint8_t const SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0X14

attempt to write protected block zero

uint8_t const SD_CARD_ERROR_WRITE_MULTIPLE = 0X15

card did not go ready for a multiple block write

uint8_t const SD_CARD_ERROR_WRITE_PROGRAMMING = 0X16

card returned an error to a CMD13 status check after a write

uint8_t const SD_CARD_ERROR_WRITE_TIMEOUT = 0X17

timeout occurred during write programming

uint8_t const SD_CARD_TYPE_SD1 = 1

Standard capacity V1 SD card

uint8_t const SD_CARD_TYPE_SD2 = 2

Standard capacity V2 SD card

uint8_t const SD_CARD_TYPE_SDHC = 3

High Capacity SD card

uint8_t const SD_CHIP_SELECT_PIN = SDSS

define SOFTWARE_SPI to use bit-bang SPI The default chip select pin for the SD card is SS.

uint16_t const SD_ERASE_TIMEOUT = 10000

erase timeout ms

uint16_t const SD_INIT_TIMEOUT = 2000

init timeout ms

uint16_t const SD_READ_TIMEOUT = 300

read timeout ms

uint16_t const SD_WRITE_TIMEOUT = 600

write time out ms

unsigned char sector_size_high

sector size is fixed at 64 KB

unsigned char sector_size_low

sector size is fixed at 64 KB

uint8_t const SOFT_SPI_CS_PIN = 10

Default Software SPI chip select pin

uint8_t const SOFT_SPI_MISO_PIN = 12

Software SPI Master In Slave Out pin

uint8_t const SOFT_SPI_MOSI_PIN = 11

Software SPI Master Out Slave In pin

uint8_t const SOFT_SPI_SCK_PIN = 13

Software SPI Clock pin

uint8_t const SPI_DIV3_SPEED = 1

Set SCK rate to F_CPU/3 for Due

uint8_t const SPI_DIV6_SPEED = 3

Set SCK rate to F_CPU/6 for Due

uint8_t const SPI_EIGHTH_SPEED = 6

Set SCK rate to F_CPU/16. See Sd2Card::setSckRate().

uint8_t const SPI_FULL_SPEED = 0

Set SCK to max rate of F_CPU/2. See Sd2Card::setSckRate().

uint8_t const SPI_HALF_SPEED = 2

Set SCK rate to F_CPU/4. See Sd2Card::setSckRate().

uint8_t const SPI_QUARTER_SPEED = 4

Set SCK rate to F_CPU/8. See Sd2Card::setSckRate().

uint8_t const SPI_SIXTEENTH_SPEED = 8

Set SCK rate to F_CPU/32. See Sd2Card::setSckRate().

uint8_t const STOP_TRAN_TOKEN = 0XFD

stop token for write multiple blocks

uint8_t const T_ACCESS = 1

set the file's last access date

uint8_t const T_CREATE = 2

set the file's creation date and time

uint8_t const T_WRITE = 4

Set the file's write date and time

unsigned char taac

fixed to 0X0E

unsigned char tmp_write_protect
unsigned char tran_speed
unsigned char vdd_r_curr_max
unsigned char vdd_r_curr_min
unsigned char vdd_w_cur_max
unsigned char vdd_w_curr_min
unsigned char wp_grp_enable

fixed value of 0 - no write protect groups

unsigned char wp_grp_size
unsigned char write_bl_len_high

write_bl_len fixed for 512 byte blocks

unsigned char write_bl_len_low

write_bl_len fixed for 512 byte blocks

unsigned char write_blk_misalign

fixed to 0

uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC

start data token for write multiple blocks

unsigned char write_partial

always zero - no partial block read

 All Data Structures Namespaces Files Functions Variables Typedefs Friends Defines