X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/7aeb2288ae07778b92b3c9224cbc149cb08282a8..19ea4876c39cdbba20ee594c11fe350d7433c857:/sysinit.c diff --git a/sysinit.c b/sysinit.c index 94784b6..0385a21 100644 --- a/sysinit.c +++ b/sysinit.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "sysinit.h" @@ -102,8 +103,16 @@ DWORD get_fattime () { - // ToDo! - return 0; + DWORD tmr = 0; + + // tmr = (((DWORD)rtcYear - 80) << 25) + // | ((DWORD)rtcMon << 21) + // | ((DWORD)rtcMday << 16) + // | (WORD)(rtcHour << 11) + // | (WORD)(rtcMin << 5) + // | (WORD)(rtcSec >> 1); + + return tmr; } #endif @@ -298,3 +307,61 @@ int puts(const char * str) return 0; } + +// Override printf here if we're using Crossworks for ARM +// so that we can still use the custom libc libraries. +// For Codelite and compiling from the makefile (Yagarto, etc.) +// this is done in /core/libc + +#ifdef __CROSSWORKS_ARM + +/**************************************************************************/ +/*! + @brief Outputs a formatted string on the DBGU stream. Format arguments + are given in a va_list instance. + + @param[in] pFormat + Format string + @param[in] ap + Argument list +*/ +/**************************************************************************/ +signed int vprintf(const char *pFormat, va_list ap) +{ + char pStr[CFG_PRINTF_MAXSTRINGSIZE]; + char pError[] = "stdio.c: increase CFG_PRINTF_MAXSTRINGSIZE\r\n"; + + // Write formatted string in buffer + if (vsprintf(pStr, pFormat, ap) >= CFG_PRINTF_MAXSTRINGSIZE) { + + puts(pError); + while (1); // Increase CFG_PRINTF_MAXSTRINGSIZE + } + + // Display string + return puts(pStr); +} + +/**************************************************************************/ +/*! + @brief Outputs a formatted string on the DBGU stream, using a + variable number of arguments + + @param[in] pFormat + Format string +*/ +/**************************************************************************/ +signed int printf(const char *pFormat, ...) +{ + va_list ap; + signed int result; + + // Forward call to vprintf + va_start(ap, pFormat); + result = vprintf(pFormat, ap); + va_end(ap); + + return result; +} + +#endif