MMC over SPI

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
mculover
Posts: 26
Joined: Fri Dec 10, 2010 2:27 pm

MMC over SPI

Post by mculover »

Hi Giovanni,

From FatFs example, I do not understand about event in MMC over SPI Driver.
MMCDriver need MMCDriver.mmc_inserted_event and MMCDriver.mmc_removed_event.

How to MMCDriver link to function InsertHandler () and RemoveHandler () ?.

Thanks for advance.
mculover
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MMC over SPI

Post by Giovanni »

The MMC driver needs to be reinitialize the card each time it is inserted, the FS module also requires to re-mount the file system on insertion.
The remove event is needed by the application, it notifies that reading and writing the FS is no more possible.

Giovanni
mculover
Posts: 26
Joined: Fri Dec 10, 2010 2:27 pm

Re: MMC over SPI

Post by mculover »

Hi Giovanni,

How event in MMCDriver work ?.

MMCDriver and el0, el1 relative with...

Code: Select all

struct EventListener el0, el1;

chEvtRegister(&MMCD1.mmc_inserted_event, &el0, 0);
chEvtRegister(&MMCD1.mmc_removed_event, &el1, 1);


Handler function and evhndl relative with...

Code: Select all

chEvtDispatch(evhndl, chEvtWaitOne(ALL_EVENTS));

static const evhandler_t evhndl[] = {
    InsertHandler, /*Function name */
    RemoveHandler /*Function name */
};


evhndl and el0 not relative.
I can not find connection point between MMCD1.mmc_inserted_event and InsertHandler ().

I don't know, How MMCD1.mmc_inserted_event call function InsertHandler () ?

Thanks in advance.
mculover
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MMC over SPI

Post by Giovanni »

It is the third parameter in the chEvtRegister() function, it specifies the index in the event handlers array. Basically it creates an association between the event source and the handler function.

Giovanni
mculover
Posts: 26
Joined: Fri Dec 10, 2010 2:27 pm

Re: MMC over SPI

Post by mculover »

Hi Giovanni,

I will test again, Thanks in advance.
mculover
mculover
Posts: 26
Joined: Fri Dec 10, 2010 2:27 pm

Re: MMC over SPI

Post by mculover »

Hi Giovanni,

In example of Chibi RTOS.
Other driver create driver object in each own section, Ex. SD1 for serial.
Why user create "MMCDriver MMCD1;", Not in own section ?.

For remove SD Card event, What is right choice to do ?.
Use mmcDisconnect () or more or nothing to do like in example ?.

Thanks for advance.
mculover
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MMC over SPI

Post by Giovanni »

Hi,

The MMC driver is "generic" the other drivers are tied to physical hardware resources. This is why serial driver are implicitly instantiated and the MMC driver has to be instantiated and initialized explicitly.

There is no need to perform mmcDisconnect() when a card is removed, the card is gone already, the internal state machine is reset automatically in the pre-insertion state (see the diagram).

Giovanni
mculover
Posts: 26
Joined: Fri Dec 10, 2010 2:27 pm

Re: MMC over SPI

Post by mculover »

Hi Giovanni,

FatFs can accept long file name and SDHC card. But, I find limitation of MMC driver is 2GB SD Card in your document.
What is point to improve driver to use more 2GB SD card, In SPI driver or MMC driver ?.

Thanks for advance.
mculover
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: MMC over SPI

Post by Giovanni »

Hi,

It is the card initialization that should be modified, not a big deal, this change is in the to-do list for 2.3.x.

Giovanni
Post Reply