DS1307 SD-MMC FAT Engine with propGCC?
Akkarin
Posts: 43
Hi all,
I'm quite new to C. I had a C course at university some years ago, but haven't touched it since nor have I ever done complex projects like in Spin lately. I'm in the process of evaluating if C could be an alternative way of programming the Prop for me.
I like the idea, that C programs would be faster than Spin or to have large programs with XMM (though I haven't understood that completely yet).
So, one requirement would be to write to an SD card. I managed to do so in a simple test program.
But I really like Kye's FAT Engine with RTC support, error handling and file system. Is there a way to use this driver in simple IDE so that it is compiled in C and not running in a Spin COG?
Thanks,
Akk4rin
I'm quite new to C. I had a C course at university some years ago, but haven't touched it since nor have I ever done complex projects like in Spin lately. I'm in the process of evaluating if C could be an alternative way of programming the Prop for me.
I like the idea, that C programs would be faster than Spin or to have large programs with XMM (though I haven't understood that completely yet).
So, one requirement would be to write to an SD card. I managed to do so in a simple test program.
#include "simpletools.h" #include "simpletext.h" #include "simplei2c.h" char name[20];FILE *fp1; int main(void) { sd_mount(8,7,6,5); sprintf(name,"Test.txt"); // test file name printf("Opening file '%s'.\n", name); if((fp1=fopen(name,"w+"))==0) { printf("Can't open file %s.\n",name); } else { printf("File was opened.\n"); fprintf(fp1,"Test\r\n"); fprintf(fp1,"123\r\n"); fclose(fp1); high(11); } return 0;
But I really like Kye's FAT Engine with RTC support, error handling and file system. Is there a way to use this driver in simple IDE so that it is compiled in C and not running in a Spin COG?
Thanks,
Akk4rin
Comments
I know PropWare doesn't have RTC support (I don't think libpropeller does either) but they are informative about errors. PropWare does support traversing directories as well.
Example code for file-system is here: https://sites.google.com/site/propellergcc/documentation/libraries#TOC-Console-and-File-system-driver-initialization
Adding RTC is relatively trivial as long as you have an i2c driver.
@jazzed: Oh my, I will need some time to get my head around that code you posted. Thanks.
So, in the end it does not seem possible to use Kye's DS1307 FAT Engine with propGCC and simple IDE. At least not without a lot of effort.
It's likely best if you stick with SPIN if that code throws you a curve-ball.
that's what I thought, too. I will have to get deeper into C programming first. Thanks anyway. Is there a good document, especially for that devices and drivers link part? I don't think I need the "hello world" part, though. Just a little more documentation in written words and not only code snippets.
https://sites.google.com/site/propellergcc/documentation/libraries
http://propgcc.googlecode.com/hg/doc/Library.html
I managed to get the clock value from my RTC. Here is the code I produced, though I think this is not the way it is supposed to be used, but I don't understand the generic driver concept, yet.
Up to now I only have implemented the read methods.
How can I write the creation time attribute or modification time attribute of a file on SD card? I could put the time in the file name but this is limited by the 8.3 file name format.
in sys/sd.h I found a function "void dfs_setDefaultFileDateTime(struct tm* tm);".
So when I call this right before creating a file on SD card, the new file will have the correct creation and modification time attributes:
Great. I never noticed that function before.
Sounds like progress.