aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ARMCM3-STM32F103ZG-FATFS/main.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-07-01 17:10:40 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-07-01 17:10:40 +0000
commit3440f11481452204d68283230b2e421df01e5d56 (patch)
tree69543b1eb4984261c2ae2a1beefe7a4bca0deb78 /demos/ARMCM3-STM32F103ZG-FATFS/main.c
parentde68bed34a8dbf575810b5d9ca2513ae9a65ef07 (diff)
downloadChibiOS-3440f11481452204d68283230b2e421df01e5d56.tar.gz
ChibiOS-3440f11481452204d68283230b2e421df01e5d56.tar.bz2
ChibiOS-3440f11481452204d68283230b2e421df01e5d56.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4382 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/ARMCM3-STM32F103ZG-FATFS/main.c')
-rw-r--r--demos/ARMCM3-STM32F103ZG-FATFS/main.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/demos/ARMCM3-STM32F103ZG-FATFS/main.c b/demos/ARMCM3-STM32F103ZG-FATFS/main.c
index b44612091..5433daced 100644
--- a/demos/ARMCM3-STM32F103ZG-FATFS/main.c
+++ b/demos/ARMCM3-STM32F103ZG-FATFS/main.c
@@ -62,28 +62,20 @@ static EventSource inserted_event, removed_event;
static void tmrfunc(void *p) {
BaseBlockDevice *bbdp = p;
- /* The presence check is performed only while the driver is not in a
- transfer state because it is often performed by changing the mode of
- the pin connected to the CS/D3 contact of the card, this could disturb
- the transfer.*/
- blkstate_t state = blkGetDriverState(bbdp);
chSysLockFromIsr();
- if ((state != BLK_READING) && (state != BLK_WRITING)) {
- /* Safe to perform the check.*/
- if (cnt > 0) {
- if (blkIsInserted(bbdp)) {
- if (--cnt == 0) {
- chEvtBroadcastI(&inserted_event);
- }
+ if (cnt > 0) {
+ if (blkIsInserted(bbdp)) {
+ if (--cnt == 0) {
+ chEvtBroadcastI(&inserted_event);
}
- else
- cnt = POLLING_INTERVAL;
}
- else {
- if (!blkIsInserted(bbdp)) {
- cnt = POLLING_INTERVAL;
- chEvtBroadcastI(&removed_event);
- }
+ else
+ cnt = POLLING_INTERVAL;
+ }
+ else {
+ if (!blkIsInserted(bbdp)) {
+ cnt = POLLING_INTERVAL;
+ chEvtBroadcastI(&removed_event);
}
}
chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, bbdp);
@@ -284,11 +276,12 @@ static void InsertHandler(eventid_t id) {
static void RemoveHandler(eventid_t id) {
(void)id;
+ sdcDisconnect(&SDCD1);
fs_ready = FALSE;
}
/*
- * Red LED blinker thread, times are in milliseconds.
+ * LEDs blinker thread, times are in milliseconds.
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {