diff options
| author | gary.li.wenchao.4 <[email protected]> | 2010-02-21 02:34:28 +0000 |
|---|---|---|
| committer | gary.li.wenchao.4 <[email protected]> | 2010-02-21 02:34:28 +0000 |
| commit | ab13173bf8518b4aa4c6cb395493b7ecd04a1627 (patch) | |
| tree | 06f48165c750662fe39c408448276591b3dd2878 /bsp | |
| parent | faffc442b9d717b3d3c1ac3d2f87fe2be7df45df (diff) | |
add __DATA__ for rt_calendar
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@429 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp')
| -rw-r--r-- | bsp/mini2440/SConstruct | 2 | ||||
| -rw-r--r-- | bsp/mini2440/rtc_calendar.c | 29 |
2 files changed, 24 insertions, 7 deletions
diff --git a/bsp/mini2440/SConstruct b/bsp/mini2440/SConstruct index 7b1257405c..f93b4acd33 100644 --- a/bsp/mini2440/SConstruct +++ b/bsp/mini2440/SConstruct @@ -42,7 +42,7 @@ if rtconfig.RT_USING_RTGUI: objs = objs + SConscript(RTT_ROOT + '/rtgui/SConscript', variant_dir='build/rtgui', duplicate=0)
objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript', variant_dir='build/examples/gui', duplicate=0)
-src_bsp = ['application.c', 'startup.c', 'board.c']
+src_bsp = ['application.c', 'startup.c', 'board.c', 'rtc_calendar.c' ]
src_drv = ['console.c', 'led.c']
if rtconfig.RT_USING_DFS:
diff --git a/bsp/mini2440/rtc_calendar.c b/bsp/mini2440/rtc_calendar.c index 0746beea96..8eaa3e71b2 100644 --- a/bsp/mini2440/rtc_calendar.c +++ b/bsp/mini2440/rtc_calendar.c @@ -10,6 +10,7 @@ * Change Logs:
* Date Author Notes
* 2010-02-10 Gary Lee first implementation
+ * 2010-02-21 Gary Lee add __DATA__
*/
#include "rtc_calendar.h"
@@ -209,18 +210,35 @@ void rt_rtc_weekdate_calculate(void) }
+extern char *rt_strlcpy(char *dest, const char *src, rt_ubase_t n);
+rt_uint8_t *list_month[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
void rt_calendar(void)
{
- rt_uint32_t year;
//static rt_uint8_t receive_char;
-
-
+ static rt_int32_t year;
+ rt_uint8_t i = 0;
+ rt_int32_t result, num_month, num_year;
+ rt_uint8_t date_year[7], date_month[3], *date = __DATE__;
+
+ rt_strlcpy((char *)date_month, (const char *)date, 3);
+ date += 7;
+ rt_strlcpy((char *)date_year, (const char *)date, 4);
+ date = RT_NULL;
+ num_year = atoi(date_year);
+ do{
+ result = strcmp((const char *)date_month, (const char *)list_month[i++]);
+ if(result !=0)
+ result = 1;
+ else
+ num_month = i;
+ }while(result);
+ i = 0;
+ result = 1;
+ year = num_year*100 + num_month;
//year = Uart_GetIntNum_MT();
- year = 201002;
//rt_kprintf("\nThe date is %d\n", year);
rt_rtc_year_month_day_seperate(year);
-
if (day_seprt == 0 && month_seprt == 0) {
//rt_kprintf("\nYear: %d\n", year_seprt);
rt_rtc_print_calendar(year_seprt);
@@ -232,7 +250,6 @@ void rt_calendar(void) } else {
//rt_kprintf("\n%d/%d/%d\n", year_seprt, month_seprt, day_seprt);
rt_rtc_weekdate_calculate();
-
}
}
#ifdef RT_USING_FINSH
|
