Jump to content

Recommended Posts

Posted

Hi there,

I would like to read and write files onto an SDCard connected to my CORE32, for being able to read configuration files and to write log files. What's the simplest way to do this? What libraries do I need? Could somebody give an example?

Thanks all!

Baptistou

Posted

Hi there,

I would like to read and write files onto an SDCard connected to my CORE32, for being able to read configuration files and to write log files. What's the simplest way to do this? What libraries do I need? Could somebody give an example?

Thanks all!

Baptistou

Hi.

Everything you need should be in the README.txt file in the /trunk/modules/dosfs directory of the MIOS32 svn tree.

It doesn't have "actual" code but it does have step by step instructions for opening/reading/writing files.

If you need actual code, then any of the examples that include file access should get you on the way, probably /trunk/apps/tutorials/019_midi_player/ is a good one to start with.

Cheers

Phil

Posted (edited)

Is it possible to put a u32 variable into a s32 without anything special?

example:

u32 successcount;

s32 returnValue;

DFS_ReadFile(&fi, sector, buffer, &successcount, len);

returnValue = successcount;

if (somethingBadHappens){

returnValue = -1;

}

return returnValue;

Is that right?

Baptistou

Edited by baptistou
Posted

There is no real danger to write it this way, since you will never read >= 2^31 bytes (s32 ranges from -2^31..2^31-1)

Best Regards, Thorsten.

Posted

The sign bit is located at bit #31, which means, so long the value is within the 0..2^31-1 range, it will stay 0 and there is no danger.

And even if the totally unexpected would happen (a 2 GB file has been read successfully ;)) the return value would be negative, which means: error

Best Regards, Thorsten.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...