A re-written SDFileSystem library with improved compatibility, CRC support, and card removal/replacement support.
Fork of SDFileSystem by
Revision 16:dca379d55382, committed 2014-12-29
- Comitter:
- jaerts
- Date:
- Mon Dec 29 15:26:39 2014 +0000
- Parent:
- 15:c9e938f6934f
- Commit message:
- Add support for no card detect switch
Changed in this revision
SDFileSystem.cpp | Show annotated file Show diff for this revision Revisions of this file |
SDFileSystem.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r c9e938f6934f -r dca379d55382 SDFileSystem.cpp --- a/SDFileSystem.cpp Mon Oct 27 17:02:05 2014 +0000 +++ b/SDFileSystem.cpp Mon Dec 29 15:26:39 2014 +0000 @@ -48,11 +48,14 @@ m_Cd.mode(PullUp); m_CdAssert = 0; m_Cd.rise(this, &SDFileSystem::onCardRemoval); - } else { + } else if (cdtype == SWITCH_NEG_NC) { m_Cd.mode(PullUp); m_CdAssert = 1; m_Cd.fall(this, &SDFileSystem::onCardRemoval); } + else { + m_CdAssert = -1; + } } SDFileSystem::CardType SDFileSystem::card_type() @@ -403,8 +406,8 @@ inline void SDFileSystem::checkSocket() { - //Check if a card is in the socket - if (m_Cd == m_CdAssert) { + //Check if a card is in the socket (or always asume it is when switch not used) + if (m_CdAssert == -1 || m_Cd == m_CdAssert) { //The socket is occupied, clear the STA_NODISK flag m_Status &= ~STA_NODISK; } else {
diff -r c9e938f6934f -r dca379d55382 SDFileSystem.h --- a/SDFileSystem.h Mon Oct 27 17:02:05 2014 +0000 +++ b/SDFileSystem.h Mon Dec 29 15:26:39 2014 +0000 @@ -67,6 +67,7 @@ /** Represents the different card detect switch types */ enum SwitchType { + SWITCH_NONE, /**< Switch not used */ SWITCH_POS_NO, /**< Switch shorts to VDD when the socket is occupied (positive logic, normally open) */ SWITCH_POS_NC, /**< Switch shorts to VDD when the socket is empty (positive logic, normally closed) */ SWITCH_NEG_NO, /**< Switch shorts to GND when the socket is occupied (negative logic, normally open) */