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

For MBSEQ V4 I implemented an additional abstraction layer (seq_file.c) which simplifies file accesses (see seq_file_c.c)

But probably it's easier for you to start from scratch by accessing the DOSFS functions directly.

Best Regards, Thorsten.

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...