Tool/software: TI C/C++ Compiler
Hello TI Experts,
We are working on implementing FatFs on the cc2642r1 launchpad with a Adafruit SPI MicroSD breakout board. We are currently getting an FR_NOT_READY error following a call to f_open.
#include "settings.h" #include "Board.h" #include <xdc/std.h> #include <xdc/runtime/System.h> #include <file.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <ti/sysbios/knl/Clock.h> #include <ti/sysbios/BIOS.h> #include "ti/drivers/SDFatFS.h" #include "third_party/fatfs/ff.h" #include <third_party/fatfs/diskio.h> #include<stdio.h> FATFS *fs; FILE *src; FRESULT fr; #define DRIVE_NUM 0 char fileName[100] = "1"; /* Set this to the current UNIX time in seconds */ const struct timespec ts = { .tv_sec = 1469647026, .tv_nsec = 0 }; /* * ======== fatfs_getFatTime ======== */ int32_t fatfs_getFatTime(void) { time_t seconds; uint32_t fatTime; struct tm *pTime; seconds = time(NULL); pTime = localtime(&seconds); fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) | ((uint32_t)(pTime->tm_mon) << 21) | ((uint32_t)(pTime->tm_mday) << 16) | ((uint32_t)(pTime->tm_hour) << 11) | ((uint32_t)(pTime->tm_min) << 5) | ((uint32_t)(pTime->tm_sec) >> 1); return ((int32_t)fatTime); } /* * * The SDFatFS_Config structure contains a single pointer used to characterize * the SDFatFS driver implementation. * * This structure needs to be defined before calling SDFatFS_init() and it must * not be changed thereafter. * * @sa SDFatFS_init() */ SDFatFS_Object myObj; SDFatFS_Config SDFatFS_config[] = { { &myObj }, NULL }; uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1; void sdCardInit(){ /* SDFAT_FS_OPEN() * Function to open a SDFatFS instance on the specified drive. * Function to mount the FatFs filesystem and register the SDFatFS disk * I/O functions with the FatFS module. * * @ param idx Logical peripheral number indexed into the HWAttrs * @ param drive Drive Number */ SDFatFS_Handle _sd_handle; _sd_handle = SDFatFS_open(Board_SD0, DRIVE_NUM); if (_sd_handle == NULL) { //Error opening SDFatFS driver while (1); } /* Open the source file */ fr = f_open(&src, fileName, FA_WRITE|FA_CREATE_ALWAYS); // System_printf("fr following f_open %d\n", fr); System_flush(); }
Is there something we're missing in this code, or do you have any idea why we would be getting this error?