baptistou Posted November 5, 2009 Report Share Posted November 5, 2009 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 Quote Link to comment Share on other sites More sharing options...
philetaylor Posted November 5, 2009 Report Share Posted November 5, 2009 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 Quote Link to comment Share on other sites More sharing options...
TK. Posted November 5, 2009 Report Share Posted November 5, 2009 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. Quote Link to comment Share on other sites More sharing options...
baptistou Posted November 5, 2009 Author Report Share Posted November 5, 2009 I forgot about the DOSFS doc files, I'll have a look in there and give news soon. Thanks for your quick replies! Baptistou Quote Link to comment Share on other sites More sharing options...
baptistou Posted November 8, 2009 Author Report Share Posted November 8, 2009 (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 November 8, 2009 by baptistou Quote Link to comment Share on other sites More sharing options...
TK. Posted November 8, 2009 Report Share Posted November 8, 2009 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. Quote Link to comment Share on other sites More sharing options...
baptistou Posted November 8, 2009 Author Report Share Posted November 8, 2009 I was wondering if that line would copy the raw data of the unsigned into the signed one or if it would take care of the sign bit. Thanks! Baptistou Quote Link to comment Share on other sites More sharing options...
TK. Posted November 8, 2009 Report Share Posted November 8, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.