From 5520d226097bb9b49f7cdc25ee71457fb020629a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 27 Jun 2012 18:04:56 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4351 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-FATFS/main.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'demos/ARMCM3-STM32F103-FATFS') diff --git a/demos/ARMCM3-STM32F103-FATFS/main.c b/demos/ARMCM3-STM32F103-FATFS/main.c index d3e1e7e73..a0a8f3a04 100644 --- a/demos/ARMCM3-STM32F103-FATFS/main.c +++ b/demos/ARMCM3-STM32F103-FATFS/main.c @@ -66,24 +66,23 @@ static void tmrfunc(void *p) { the pin connected to the CS/D3 contact of the card, this could disturb the transfer.*/ blkstate_t state = blkGetDriverState(bbdp); - if ((state == BLK_READING) || (state == BLK_WRITING)) - return; - - /* Safe to perform the check.*/ chSysLockFromIsr(); - if (cnt > 0) { - if (blkIsInserted(bbdp)) { - if (--cnt == 0) { - chEvtBroadcastI(&inserted_event); + if ((state != BLK_READING) && (state != BLK_WRITING)) { + /* Safe to perform the check.*/ + if (cnt > 0) { + if (blkIsInserted(bbdp)) { + if (--cnt == 0) { + chEvtBroadcastI(&inserted_event); + } } + else + cnt = POLLING_INTERVAL; } - else - cnt = POLLING_INTERVAL; - } - else { - if (!blkIsInserted(bbdp)) { - cnt = POLLING_INTERVAL; - chEvtBroadcastI(&removed_event); + else { + if (!blkIsInserted(bbdp)) { + cnt = POLLING_INTERVAL; + chEvtBroadcastI(&removed_event); + } } } chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, bbdp); -- cgit v1.2.3