Raw access to SD and SDHC flash memory cards via SPI protocol.  
 More...
#include <SdSpiCard.h>
|  | 
| bool | begin (SdSpiConfig spiConfig) | 
|  | 
| void | dbgClearStats () | 
|  | 
| void | dbgPrintStats () | 
|  | 
| bool | erase (uint32_t firstSector, uint32_t lastSector) | 
|  | 
| bool | eraseSingleSectorEnable () | 
|  | 
| void | error (uint8_t code) | 
|  | 
| uint8_t | errorCode () const | 
|  | 
| uint32_t | errorData () const | 
|  | 
| bool | isBusy () | 
|  | 
| bool | readCID (cid_t *cid) | 
|  | 
| bool | readCSD (csd_t *csd) | 
|  | 
| bool | readData (uint8_t *dst) | 
|  | 
| bool | readOCR (uint32_t *ocr) | 
|  | 
| bool | readSector (uint32_t sector, uint8_t *dst) | 
|  | 
| bool | readSectors (uint32_t sector, uint8_t *dst, size_t ns) | 
|  | 
| bool | readSingle (uint32_t sector, uint8_t *dst) | 
|  | 
| bool | readStart (uint32_t sector) | 
|  | 
| bool | readStatus (uint8_t *status) | 
|  | 
| bool | readStop () | 
|  | 
|  | SdSpiCard () | 
|  | 
| uint32_t | sectorCount () | 
|  | 
| void | spiStart () | 
|  | 
| void | spiStop () | 
|  | 
| bool | syncDevice () | 
|  | 
| uint8_t | type () const | 
|  | 
| bool | writeData (const uint8_t *src) | 
|  | 
| bool | writeSector (uint32_t sector, const uint8_t *src) | 
|  | 
| bool | writeSectors (uint32_t sector, const uint8_t *src, size_t ns) | 
|  | 
| bool | writeSingle (uint32_t sector, const uint8_t *src) | 
|  | 
| bool | writeStart (uint32_t sector) | 
|  | 
| bool | writeStart (uint32_t sector, uint32_t eraseCount) | 
|  | 
| bool | writeStop () | 
|  | 
Raw access to SD and SDHC flash memory cards via SPI protocol. 
◆ SdSpiCard()
◆ begin()
Initialize the SD card. 
- Parameters
- 
  
    | [in] | spiConfig | SPI card configuration. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ dbgClearStats()
      
        
          | void SdSpiCard::dbgClearStats | ( |  | ) |  | 
      
 
 
◆ dbgPrintStats()
      
        
          | void SdSpiCard::dbgPrintStats | ( |  | ) |  | 
      
 
 
◆ erase()
      
        
          | bool SdSpiCard::erase | ( | uint32_t | firstSector, | 
        
          |  |  | uint32_t | lastSector | 
        
          |  | ) |  |  | 
      
 
Erase a range of sectors.
- Parameters
- 
  
    | [in] | firstSector | The address of the first sector in the range. |  | [in] | lastSector | The address of the last sector in the range. |  
 
- Note
- This function requests the SD card to do a flash erase for a range of sectors. The data on the card after an erase operation is either 0 or 1, depends on the card vendor. The card must support single sector erase.
- Returns
- true for success or false for failure. 
 
 
◆ eraseSingleSectorEnable()
      
        
          | bool SdSpiCard::eraseSingleSectorEnable | ( |  | ) |  | 
      
 
Determine if card supports single sector erase.
- Returns
- true is returned if single sector erase is supported. false is returned if single sector erase is not supported. 
 
 
◆ error()
  
  | 
        
          | void SdSpiCard::error | ( | uint8_t | code | ) |  |  | inline | 
 
Set SD error code. 
- Parameters
- 
  
    | [in] | code | value for error code. |  
 
 
 
◆ errorCode()
  
  | 
        
          | uint8_t SdSpiCard::errorCode | ( |  | ) | const |  | inline | 
 
- Returns
- code for the last error. See SdCardInfo.h for a list of error codes. 
 
 
◆ errorData()
  
  | 
        
          | uint32_t SdSpiCard::errorData | ( |  | ) | const |  | inline | 
 
- Returns
- error data for last error. 
 
 
◆ isBusy()
      
        
          | bool SdSpiCard::isBusy | ( |  | ) |  | 
      
 
Check for busy. MISO low indicates the card is busy.
- Returns
- true if busy else false. 
 
 
◆ readCID()
  
  | 
        
          | bool SdSpiCard::readCID | ( | cid_t * | cid | ) |  |  | inline | 
 
Read a card's CID register. The CID contains card identification information such as Manufacturer ID, Product name, Product serial number and Manufacturing date.
- Parameters
- 
  
    | [out] | cid | pointer to area for returned data. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readCSD()
  
  | 
        
          | bool SdSpiCard::readCSD | ( | csd_t * | csd | ) |  |  | inline | 
 
Read a card's CSD register. The CSD contains Card-Specific Data that provides information regarding access to the card's contents.
- Parameters
- 
  
    | [out] | csd | pointer to area for returned data. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readData()
      
        
          | bool SdSpiCard::readData | ( | uint8_t * | dst | ) |  | 
      
 
Read one data sector in a multiple sector read sequence
- Parameters
- 
  
    | [out] | dst | Pointer to the location for the data to be read. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readOCR()
      
        
          | bool SdSpiCard::readOCR | ( | uint32_t * | ocr | ) |  | 
      
 
Read OCR register.
- Parameters
- 
  
    | [out] | ocr | Value of OCR register. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readSector()
  
  | 
        
          | bool SdSpiCard::readSector | ( | uint32_t | sector, |  
          |  |  | uint8_t * | dst |  
          |  | ) |  |  |  | inline | 
 
Read a 512 byte sector from an SD card.
- Parameters
- 
  
    | [in] | sector | Logical sector to be read. |  | [out] | dst | Pointer to the location that will receive the data. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readSectors()
      
        
          | bool SdSpiCard::readSectors | ( | uint32_t | sector, | 
        
          |  |  | uint8_t * | dst, | 
        
          |  |  | size_t | ns | 
        
          |  | ) |  |  | 
      
 
Read multiple 512 byte sectors from an SD card.
- Parameters
- 
  
    | [in] | sector | Logical sector to be read. |  | [in] | ns | Number of sectors to be read. |  | [out] | dst | Pointer to the location that will receive the data. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readSingle()
      
        
          | bool SdSpiCard::readSingle | ( | uint32_t | sector, | 
        
          |  |  | uint8_t * | dst | 
        
          |  | ) |  |  | 
      
 
Read a 512 byte sector from an SD card.
- Parameters
- 
  
    | [in] | sector | Logical sector to be read. |  | [out] | dst | Pointer to the location that will receive the data. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readStart()
      
        
          | bool SdSpiCard::readStart | ( | uint32_t | sector | ) |  | 
      
 
Start a read multiple sector sequence.
- Parameters
- 
  
    | [in] | sector | Address of first sector in sequence. |  
 
- Note
- This function is used with readData() and readStop() for optimized multiple sector reads. SPI chipSelect must be low for the entire sequence.
- Returns
- true for success or false for failure. 
 
 
◆ readStatus()
      
        
          | bool SdSpiCard::readStatus | ( | uint8_t * | status | ) |  | 
      
 
Return the 64 byte card status 
- Parameters
- 
  
    | [out] | status | location for 64 status bytes. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ readStop()
      
        
          | bool SdSpiCard::readStop | ( |  | ) |  | 
      
 
End a read multiple sectors sequence.
- Returns
- true for success or false for failure. 
 
 
◆ sectorCount()
      
        
          | uint32_t SdSpiCard::sectorCount | ( |  | ) |  | 
      
 
Determine the size of an SD flash memory card.
- Returns
- The number of 512 byte data sectors in the card or zero if an error occurs. 
 
 
◆ spiStart()
      
        
          | void SdSpiCard::spiStart | ( |  | ) |  | 
      
 
Set CS low and activate the card. 
 
 
◆ spiStop()
      
        
          | void SdSpiCard::spiStop | ( |  | ) |  | 
      
 
Set CS high and deactivate the card. 
 
 
◆ syncDevice()
      
        
          | bool SdSpiCard::syncDevice | ( |  | ) |  | 
      
 
- Returns
- success if sync successful. Not for user apps. 
 
 
◆ type()
  
  | 
        
          | uint8_t SdSpiCard::type | ( |  | ) | const |  | inline | 
 
Return the card type: SD V1, SD V2 or SDHC/SDXC 
- Returns
- 0 - SD V1, 1 - SD V2, or 3 - SDHC/SDXC. 
 
 
◆ writeData()
      
        
          | bool SdSpiCard::writeData | ( | const uint8_t * | src | ) |  | 
      
 
Write one data sector in a multiple sector write sequence. 
- Parameters
- 
  
    | [in] | src | Pointer to the location of the data to be written. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ writeSector()
  
  | 
        
          | bool SdSpiCard::writeSector | ( | uint32_t | sector, |  
          |  |  | const uint8_t * | src |  
          |  | ) |  |  |  | inline | 
 
Writes a 512 byte sector to an SD card.
- Parameters
- 
  
    | [in] | sector | Logical sector to be written. |  | [in] | src | Pointer to the location of the data to be written. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ writeSectors()
      
        
          | bool SdSpiCard::writeSectors | ( | uint32_t | sector, | 
        
          |  |  | const uint8_t * | src, | 
        
          |  |  | size_t | ns | 
        
          |  | ) |  |  | 
      
 
Write multiple 512 byte sectors to an SD card.
- Parameters
- 
  
    | [in] | sector | Logical sector to be written. |  | [in] | ns | Number of sectors to be written. |  | [in] | src | Pointer to the location of the data to be written. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ writeSingle()
      
        
          | bool SdSpiCard::writeSingle | ( | uint32_t | sector, | 
        
          |  |  | const uint8_t * | src | 
        
          |  | ) |  |  | 
      
 
Writes a 512 byte sector to an SD card.
- Parameters
- 
  
    | [in] | sector | Logical sector to be written. |  | [in] | src | Pointer to the location of the data to be written. |  
 
- Returns
- true for success or false for failure. 
 
 
◆ writeStart() [1/2]
      
        
          | bool SdSpiCard::writeStart | ( | uint32_t | sector | ) |  | 
      
 
Start a write multiple sectors sequence.
- Parameters
- 
  
    | [in] | sector | Address of first sector in sequence. |  
 
- Note
- This function is used with writeData() and writeStop() for optimized multiple sector writes.
- Returns
- true for success or false for failure. 
 
 
◆ writeStart() [2/2]
      
        
          | bool SdSpiCard::writeStart | ( | uint32_t | sector, | 
        
          |  |  | uint32_t | eraseCount | 
        
          |  | ) |  |  | 
      
 
Start a write multiple sector sequence with pre-erase.
- Parameters
- 
  
    | [in] | sector | Address of first sector in sequence. |  | [in] | eraseCount | The number of sectors to be pre-erased. |  
 
- Note
- This function is used with writeData() and writeStop() for optimized multiple sector writes.
- Returns
- true for success or false for failure. 
 
 
◆ writeStop()
      
        
          | bool SdSpiCard::writeStop | ( |  | ) |  | 
      
 
End a write multiple sectors sequence.
- Returns
- true for success or false for failure. 
 
 
The documentation for this class was generated from the following files:
- Arduino/libraries/SdFat/src/SdCard/SdSpiCard.h
- Arduino/libraries/SdFat/src/SdCard/SdSpiCard.cpp