Skip to content

Commit

Permalink
support for custom card detection and write protection handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erich Styger committed Mar 19, 2015
1 parent b4e1444 commit 90edd2f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
28 changes: 27 additions & 1 deletion Beans/FatFsMemSDHC/FatFsMemSDHC.bean
Expand Up @@ -4,7 +4,7 @@
<Name>FatFsMemSDHC</Name>
<Description>Memory Implementation for FatFS using SDHC_LDD</Description>
<Author>Erich Styger</Author>
<Version>01.028</Version>
<Version>01.036</Version>
<Icon>FatFsMemSDHC</Icon>
<TypesFiles>PE,FatFsMemSDHC\FatFsMemSDHC</TypesFiles>
<FileVersion>6</FileVersion>
Expand Down Expand Up @@ -217,6 +217,19 @@
</Children>
</TBoolGrupItem>
</Property>
<Property>
<TStrgItem>
<Name>CardPresent() Function</Name>
<Symbol>CardPresentFunctionName</Symbol>
<Hint>If no Card Detect pin is configured, you can provide your own custom function name (e.g MyCardPresent). The function has the following prototype: bool FunctionName(void). If you provide TRUE or FALSE as function name, it will always return TRUE or FALSE, otherwise it uses the provided function name. If the name it empty, it always returns FALSE.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>true</EditLine>
<DefaultValue>FALSE</DefaultValue>
<StrDefine>nothing</StrDefine>
<MinLength>0</MinLength>
<MaxLength>-1</MaxLength>
</TStrgItem>
</Property>
<Property>
<TBoolGrupItem>
<Name>Write Protect Pin</Name>
Expand Down Expand Up @@ -271,6 +284,19 @@
</Children>
</TBoolGrupItem>
</Property>
<Property>
<TStrgItem>
<Name>isWriteProtected() Function</Name>
<Symbol>isWriteProtectedFunctionName</Symbol>
<Hint>If no Write protect pin is configured, you can provide your own custom function name (e.g MyCardPresentPresent). The function has the following prototype: bool FunctionName(void). If you provide TRUE or FALSE as function name, it will always return TRUE or FALSE, otherwise it uses the provided function name. If the name it empty, it always returns FALSE.</Hint>
<ItemLevel>BASIC</ItemLevel>
<EditLine>true</EditLine>
<DefaultValue>FALSE</DefaultValue>
<StrDefine>nothing</StrDefine>
<MinLength>0</MinLength>
<MaxLength>-1</MaxLength>
</TStrgItem>
</Property>
<Property>
<TInhrLinkItem>
<Name>Timeout</Name>
Expand Down
2 changes: 1 addition & 1 deletion Beans/FatFsMemSDHC/FatFsMemSDHC.uis
@@ -1,6 +1,6 @@

[USED_FACES]
BeanVersion=01.028
BeanVersion=01.036

InterfacesCount=4

Expand Down
8 changes: 8 additions & 0 deletions Beans/FatFsMemSDHC/FatFsMemSDHCProperties.html
Expand Up @@ -275,6 +275,10 @@
</ul>
</li>
<li>
<a name="CardPresentFunctionName">
<b>CardPresent() Function</b></a> - If no Card Detect pin is configured, you can provide your own custom function name (e.g MyCardPresent). The function has the following prototype: bool FunctionName(void). If you provide TRUE or FALSE as function name, it will always return TRUE or FALSE, otherwise it uses the provided function name. If the name it empty, it always returns FALSE.
</li>
<li>
<a name="WriteProtectPinEnabled">
<b>Write Protect Pin</b></a> - Optional pin to detect if the card is write protected.<br />
The following items are available only if the group is enabled (the value is "Enabled"):<br />
Expand All @@ -291,6 +295,10 @@
</ul>
</li>
<li>
<a name="isWriteProtectedFunctionName">
<b>isWriteProtected() Function</b></a> - If no Write protect pin is configured, you can provide your own custom function name (e.g MyCardPresentPresent). The function has the following prototype: bool FunctionName(void). If you provide TRUE or FALSE as function name, it will always return TRUE or FALSE, otherwise it uses the provided function name. If the name it empty, it always returns FALSE.
</li>
<li>
<a name="Timeout">
<b>Timeout</b></a> - Interface to timeout functionality
</li>
Expand Down
22 changes: 22 additions & 0 deletions Drivers/sw/FatFsMemSDHC.drv
Expand Up @@ -379,6 +379,17 @@ bool %'ModuleName'%.%CardPresent(void)
%else
return %@CD@'ModuleName'%.GetVal()!=0;
%endif
%elif defined(CardPresentFunctionName)
%if %CardPresentFunctionName='TRUE'
return TRUE; /* 'TRUE' provided as CardPresent() function in properties */
%elif %CardPresentFunctionName='FALSE'
return FALSE; /* 'FALSE' provided as CardPresent() function in properties */
%elif %CardPresentFunctionName<>""
bool %CardPresentFunctionName(void); /* prototype for user defined function */
return %CardPresentFunctionName(); /* call user provided function */
%else
return FALSE; /* no CD pin and no custom card present function, assume card is not inserted */
%endif
%else
return FALSE; /* no CD pin, assume card is not inserted */
%endif
Expand Down Expand Up @@ -537,6 +548,17 @@ bool %'ModuleName'%.%isWriteProtected(void)
%else
return %@WP@'ModuleName'%.GetVal()!=0;
%endif
%elif defined(isWriteProtectedFunctionName)
%if %isWriteProtectedFunctionName='TRUE'
return TRUE; /* 'TRUE' provided as isWriteProtected() function in properties */
%elif %isWriteProtectedFunctionName='FALSE'
return FALSE; /* 'FALSE' provided as isWriteProtected() function in properties */
%elif %isWriteProtectedFunctionName<>""
bool %isWriteProtectedFunctionName(void); /* prototype for user defined function */
return %isWriteProtectedFunctionName(); /* call user provided function */
%else
return FALSE; /* no CD pin and no custom isWriteProtected function, write protection is off */
%endif
%else
return FALSE; /* no card write protection pin available */
%endif
Expand Down

0 comments on commit 90edd2f

Please sign in to comment.