Part Number: CC3220
Hi all,
I am using the below function to calculate the time to represent the date in the SD Card when a file is being stored:
int32_t fatfs_getFatTime(void)
{
time_t seconds;
uint32_t fatTime;
struct tm *pTime;
/*
* TI time() returns seconds elapsed since 1900, while other tools
* return seconds from 1970. However, both TI and GNU localtime()
* sets tm tm_year to number of years since 1900.
*/
seconds = time(NULL);
pTime = localtime(&seconds);
/*
* localtime() sets pTime->tm_year to number of years
* since 1900, so subtract 80 from tm_year to get FAT time
* offset from 1980.
*/
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);
}
seconds = fatfs_getFatTime();
ts.tv_sec = seconds;
But ia m getting different values other than the current date, can anyone suggest me how to represent the exact time, when the file is stored in the SD Card.
Thanks & regards
Sretha