git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4351 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2012-06-27 18:04:56 +00:00
parent 38ac197ecd
commit 5520d22609
1 changed files with 14 additions and 15 deletions

View File

@ -66,24 +66,23 @@ static void tmrfunc(void *p) {
the pin connected to the CS/D3 contact of the card, this could disturb the pin connected to the CS/D3 contact of the card, this could disturb
the transfer.*/ the transfer.*/
blkstate_t state = blkGetDriverState(bbdp); blkstate_t state = blkGetDriverState(bbdp);
if ((state == BLK_READING) || (state == BLK_WRITING))
return;
/* Safe to perform the check.*/
chSysLockFromIsr(); chSysLockFromIsr();
if (cnt > 0) { if ((state != BLK_READING) && (state != BLK_WRITING)) {
if (blkIsInserted(bbdp)) { /* Safe to perform the check.*/
if (--cnt == 0) { if (cnt > 0) {
chEvtBroadcastI(&inserted_event); if (blkIsInserted(bbdp)) {
if (--cnt == 0) {
chEvtBroadcastI(&inserted_event);
}
} }
else
cnt = POLLING_INTERVAL;
} }
else else {
cnt = POLLING_INTERVAL; if (!blkIsInserted(bbdp)) {
} cnt = POLLING_INTERVAL;
else { chEvtBroadcastI(&removed_event);
if (!blkIsInserted(bbdp)) { }
cnt = POLLING_INTERVAL;
chEvtBroadcastI(&removed_event);
} }
} }
chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, bbdp); chVTSetI(&tmr, MS2ST(POLLING_DELAY), tmrfunc, bbdp);