aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-06-05 07:05:29 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-06-05 07:05:29 +0000
commit9b147c25513490e959acf299a0fed9beaee04457 (patch)
tree15d65f990a48b505b1791ad0edbd989249e6f0b2 /os
parent6fd3079b30076770c96098929b58818fce2aedc1 (diff)
downloadChibiOS-9b147c25513490e959acf299a0fed9beaee04457.tar.gz
ChibiOS-9b147c25513490e959acf299a0fed9beaee04457.tar.bz2
ChibiOS-9b147c25513490e959acf299a0fed9beaee04457.zip
SDC driver state machine improved.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3027 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/dox/sdc.dox6
-rw-r--r--os/hal/src/sdc.c7
2 files changed, 10 insertions, 3 deletions
diff --git a/os/hal/dox/sdc.dox b/os/hal/dox/sdc.dox
index 2a18977ff..df88796af 100644
--- a/os/hal/dox/sdc.dox
+++ b/os/hal/dox/sdc.dox
@@ -52,9 +52,10 @@
stop -> stop [label="\nsdcStop()"];
stop -> ready [label="\nsdcStart()"];
ready -> stop [label="\nsdcStop()"];
- ready -> ready [label="\nsdcStart()"];
+ ready -> ready [label="\nsdcStart()\nsdcDisconnect()"];
ready -> connecting [label="\nsdcConnect()"];
connecting -> active [label="\nconnection\nsuccessful"];
+ connecting -> active [label="\nsdcConnect()", dir="back"];
connecting -> ready [label="\nconnection\nfailed"];
disconnecting -> active [label="\nsdcDisconnect()", dir="back"];
ready -> disconnecting [label="\ndisconnection\nfinished", dir="back"];
@@ -85,9 +86,10 @@
stop -> stop [label="\nsdcStop()"];
stop -> ready [label="\nsdcStart()"];
ready -> stop [label="\nsdcStop()"];
- ready -> ready [label="\nsdcStart()"];
+ ready -> ready [label="\nsdcStart()\nsdcDisconnect()"];
ready -> connecting [label="\nsdcConnect()"];
connecting -> active [label="\nconnection\nsuccessful"];
+ connecting -> active [label="\nsdcConnect()", dir="back"];
connecting -> ready [label="\nconnection\nfailed"];
disconnecting -> active [label="\nsdcDisconnect()", dir="back"];
ready -> disconnecting [label="\ndisconnection\nfinished", dir="back"];
diff --git a/os/hal/src/sdc.c b/os/hal/src/sdc.c
index a7a39c268..08c667df4 100644
--- a/os/hal/src/sdc.c
+++ b/os/hal/src/sdc.c
@@ -169,7 +169,8 @@ bool_t sdcConnect(SDCDriver *sdcp) {
chDbgCheck(sdcp != NULL, "sdcConnect");
chSysLock();
- chDbgAssert(sdcp->state == SDC_READY, "mmcConnect(), #1", "invalid state");
+ chDbgAssert((sdcp->state == SDC_READY) || (sdcp->state == SDC_ACTIVE),
+ "mmcConnect(), #1", "invalid state");
sdcp->state = SDC_CONNECTING;
chSysUnlock();
@@ -302,6 +303,10 @@ bool_t sdcDisconnect(SDCDriver *sdcp) {
chSysLock();
chDbgAssert(sdcp->state == SDC_ACTIVE,
"sdcDisconnect(), #1", "invalid state");
+ if (sdcp->state == SDC_READY) {
+ chSysUnlock();
+ return FALSE;
+ }
sdcp->state = SDC_DISCONNECTING;
chSysUnlock();