distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
SdCard.cpp File Reference

SdCard class implementation. More...

Include dependency graph for SdCard.cpp:

Classes

class  distortos::devices::anonymous_namespace{SdCard.cpp}::Cid
 CID, card identification register. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::CsdV1
 CSD version 1.0, card-specific data register. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::CsdV2
 CSD version 2.0, card-specific data register. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::Csd
 CSD, card-specific data register. More...
 
struct  estd::isEnumClassFlags< distortos::devices::R1ResponseErrors >
 Enable bitwise operators for distortos::devices::R1ResponseErrors. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::R1Response
 R1 response. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::R2Response
 R2 response. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::R3Response
 R3 response. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::R6Response
 R6 response. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::R6Response::CardStatusBits
 card status bits More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::R7Response
 R7 response. More...
 
class  distortos::devices::anonymous_namespace{SdCard.cpp}::SdStatus
 SD status. More...
 

Namespaces

 distortos
 Top-level namespace of distortos project.
 
 distortos::devices
 Device drivers.
 
 estd
 Collection of useful templates.
 

Typedefs

using distortos::devices::anonymous_namespace{SdCard.cpp}::ShortResponse = std::array< uint32_t, 1 >
 alias for short response More...
 
using distortos::devices::anonymous_namespace{SdCard.cpp}::LongResponse = std::array< uint32_t, 4 >
 alias for long response More...
 
using distortos::devices::anonymous_namespace{SdCard.cpp}::Result = SdMmcCardBase::Result
 import SdMmcCardBase::Result as Result More...
 

Enumerations

enum  distortos::devices::anonymous_namespace{SdCard.cpp}::CardState : uint8_t {
  distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::idle, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::ready, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::identification, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::standby,
  distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::transfer, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::sendingData, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::receiveData, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::programming,
  distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::disconnect, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reserved9, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reserved10, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reserved11,
  distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reserved12, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reserved13, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reserved14, distortos::devices::anonymous_namespace{SdCard.cpp}::CardState::reservedForIOMode
}
 state of the card More...
 
enum  distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors : ShortResponse::value_type {
  distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::akeSeqError = 1u << 3, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::wpEraseSkip = 1u << 15, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::csdOverwrite = 1u << 16, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::error = 1u << 19,
  distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::ccError = 1u << 20, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::cardEccFailed = 1u << 21, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::illegalCommand = 1u << 22, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::comCrcError = 1u << 23,
  distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::lockUnlockFailed = 1u << 24, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::wpViolation = 1u << 26, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::eraseParam = 1u << 27, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::eraseSeqError = 1u << 28,
  distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::blockLenError = 1u << 29, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::addressError = 1u << 30, distortos::devices::anonymous_namespace{SdCard.cpp}::R1ResponseErrors::outOfRange = 1u << 31
}
 R1 response errors. More...
 

Functions

void distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithoutResponse (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument)
 Executes transaction with command that has no response. More...
 
std::pair< Result, ShortResponse > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithShortResponse (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has short response. More...
 
std::pair< Result, LongResponse > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithLongResponse (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has long response. More...
 
int distortos::devices::anonymous_namespace{SdCard.cpp}::resultToErrorCode (const Result result)
 Converts result of transaction to error code. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithR1Response (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has R1 response. More...
 
std::pair< int, R2Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithR2Response (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has R2 response. More...
 
std::pair< int, R3Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithR3Response (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has R3 response. More...
 
std::pair< int, R6Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithR6Response (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has R6 response. More...
 
std::pair< int, R7Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmdWithR7Response (SynchronousSdMmcCardLowLevel &sdCard, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with command that has R7 response. More...
 
void distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd0 (SynchronousSdMmcCardLowLevel &sdCard)
 Executes CMD0 command on SD card. More...
 
std::pair< int, Cid > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd2 (SynchronousSdMmcCardLowLevel &sdCard)
 Executes CMD2 command on SD card. More...
 
std::pair< int, R6Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd3 (SynchronousSdMmcCardLowLevel &sdCard)
 Executes CMD3 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd7 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca)
 Executes CMD7 command on SD card. More...
 
std::pair< int, bool > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd8 (SynchronousSdMmcCardLowLevel &sdCard)
 Executes CMD8 command on SD card. More...
 
std::pair< int, Csd > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd9 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca)
 Executes CMD9 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd12 (SynchronousSdMmcCardLowLevel &sdCard)
 Executes CMD12 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd13 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca)
 Executes CMD13 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd16 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t blockLength)
 Executes CMD16 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd17 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t address, const SdMmcCardLowLevel::ReadTransfer readTransfer)
 Executes CMD17 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd18 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t address, const SdMmcCardLowLevel::ReadTransfer readTransfer)
 Executes CMD18 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd24 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t address, const SdMmcCardLowLevel::WriteTransfer writeTransfer)
 Executes CMD24 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd25 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t address, const SdMmcCardLowLevel::WriteTransfer writeTransfer)
 Executes CMD25 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd32 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t address)
 Executes CMD32 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd33 (SynchronousSdMmcCardLowLevel &sdCard, const uint32_t address)
 Executes CMD33 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd38 (SynchronousSdMmcCardLowLevel &sdCard)
 Executes CMD38 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeCmd55 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca)
 Executes CMD55 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeAcmdWithR1Response (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with application command (ACMD) that has R1 response. More...
 
std::pair< int, R3Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeAcmdWithR3Response (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const uint8_t command, const uint32_t argument, const SdMmcCardLowLevel::Transfer transfer)
 Executes transaction with application command (ACMD) that has R3 response. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeAcmd6 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const bool _4BitBusMode)
 Executes ACMD6 command on SD card. More...
 
std::tuple< int, R1Response, SdStatus > distortos::devices::anonymous_namespace{SdCard.cpp}::executeAcmd13 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const uint16_t timeoutMs)
 Executes ACMD13 command on SD card. More...
 
std::pair< int, R1Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeAcmd23 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const uint32_t blocksCount)
 Executes ACMD23 command on SD card. More...
 
std::pair< int, R3Response > distortos::devices::anonymous_namespace{SdCard.cpp}::executeAcmd41 (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const bool hcs, const bool xpc, const bool s18r, const uint32_t vddVoltageWindow)
 Executes ACMD41 command on SD card. More...
 
int distortos::devices::anonymous_namespace{SdCard.cpp}::waitForTransferState (SynchronousSdMmcCardLowLevel &sdCard, const uint16_t rca, const TickClock::time_point timePoint)
 Waits until card goes back to transfer (tran) state. More...
 

Detailed Description

SdCard class implementation.

Author
Copyright (C) 2018-2019 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info
License
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.