6cc948eef8
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@113 9fe90eed-be63-e94b-8204-d34ff4c2ff93
80 lines
3.1 KiB
C
80 lines
3.1 KiB
C
/* ---------------------------------------------------------------------------
|
|
* fat_time.c (c) 2008 Micro-key bv
|
|
* ---------------------------------------------------------------------------
|
|
* Micro-key bv
|
|
* Industrieweg 28, 9804 TG Noordhorn
|
|
* Postbus 92, 9800 AB Zuidhorn
|
|
* The Netherlands
|
|
* Tel: +31 594 503020
|
|
* Fax: +31 594 505825
|
|
* Email: support@microkey.nl
|
|
* Web: www.microkey.nl
|
|
* ---------------------------------------------------------------------------
|
|
* Description:
|
|
* ---------------------------------------------------------------------------
|
|
* Version(s): 0.1, Aug 11, 2008, MMi
|
|
* Creation.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* System include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include "LPC23xx.h"
|
|
#include "types.h"
|
|
/* ---------------------------------------------------------------------------
|
|
* Application include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include "rtc.h"
|
|
/* ---------------------------------------------------------------------------
|
|
* Local constant and macro definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Global variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local function definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
UINT32 get_fattime (void)
|
|
{
|
|
UINT32 complete_time;
|
|
UINT16 time;
|
|
UINT16 date;
|
|
t_rtc rtcReadValue;
|
|
|
|
rtcRead (&rtcReadValue);
|
|
|
|
|
|
/* Read and calculate time stamps from RTC for the FAT time stamps */
|
|
time =((rtcReadValue.hour << 11) /* Add hours (5 Bits) */
|
|
|(rtcReadValue.min << 5) /* Add minutes (6 Bits) */
|
|
|(rtcReadValue.sec / 2) /* Add seconds (5 Bits) (* 2) */
|
|
); /* Seconds with resolution of 2 */
|
|
|
|
/* Read and calculate date stamps from RTC for the FAT date stamps */
|
|
date =(((rtcReadValue.year - 1980) << 9) /* Add year (7 Bits) */
|
|
|(rtcReadValue.mon << 5) /* Add month (4 Bits) */
|
|
|(rtcReadValue.day) /* Add day (5 Bits) */
|
|
); /* Year since in 1980 */
|
|
|
|
|
|
/* Calculate a 32 Bit value used by the FAT system */
|
|
complete_time = ((date << 16) | time);
|
|
|
|
return (complete_time);
|
|
|
|
}
|