Jump to content
Forum sending old emails Read more... ×
geometrikal

[Energia Library] Jaffl: Just another FatFs library

Recommended Posts

I have been searching for a FatFs Energia library for the FR5969 a while and haven't come across anything that worked, so I decided to try make one. If there is one out there.... ahhhhhhhhhhghhghgh.

 

The library is called Jaffl: Just another FatFs library  :)   

 

It is located at:  https://github.com/geometrikal/Jaffl

 

Details:

  • It is written for the MSP430FR5969, mainly because transmit and receive SPI bytes routines hard coded to USCB0. If someone can make this more generic it would be welcome.
  • The Jaffl wrapper is based on the FatFs wrapper by David Sirkin.
  • The latest FatFs version (ff11) is used, but not all functions may have made it to the wrapper.
  • The diskio.c MMC interface comes from the TI example code for the MSP430F5529 LaunchPad with a few changes: 1. there were extra functions added to attach the SPI init / change speed / cs routines. 2. Class 6 and 10 cards weren't initialising, so instead of sending CMD0 once before failing (during disk_initialization()) it keeps sending every 1ms until it gets the right response, or one second has passed.
  • f_printf was changed to f_vprintf in ff.c and modified to accept va_list instead of the normal variable argument designator (the dots: ...) . This is because Jaffl.printf wraps it, and needs to pass the variable arguments as va_list.

A quick test example:

#include "SPI.h"
#include "Jaffl.h"

int counter = 0;

void setup()
{
  Serial.begin(57600);
  Serial.println("Startup");
  Serial.print("Begin, return code: ");
  Serial.println(Jaffl.begin(P3_0));    
  Serial.print("Open file, return code: ");
  Serial.println(Jaffl.open("test.txt", FA_WRITE | FA_CREATE_ALWAYS));
}

void loop()
{
  Serial.print("Print file, return code: ");
  Serial.println(Jaffl.printf("Hello world: %d\r\n", counter++));
  Serial.print("Sync, return code: ");
  Serial.println(Jaffl.sync());
  delay(1000);
}

The code isn't polished, but seems to work. I will be doing on going testing as this will be used in another project, but I've put it up now to get feedback and help spot bugs. 99% of the code came from other sources so thanks to those people. Its all on github so if you have changes do a pull request.

 

2015-03-18 - Added MISO internal pull up to get some cards to work.

Share this post


Link to post
Share on other sites

I tested your port on the new Launchpad MSPFR5994:
This card already has an SD card mounted, and everything works perfectly.
Thank you very much for your work

Share this post


Link to post
Share on other sites

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

×