提交 ec734522 编写于 作者: qiuyiuestc's avatar qiuyiuestc

clean up code

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@934 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 878d1b36
......@@ -11,8 +11,8 @@ group['CPPPATH'] = [RTT_ROOT + '/bsp/mini2440']
group['CPPDEFINES'] = []
group['LINKFLAGS'] = ''
src_bsp = ['application.c', 'startup.c', 'board.c', 'rtc_calendar.c', 'calibration.c']
src_drv = ['console.c', 'led.c', 'run_module.c']
src_bsp = ['application.c', 'startup.c', 'board.c', 'calendar.c', 'calibration.c']
src_drv = ['console.c', 'led.c']
if rtconfig.RT_USING_DFS:
src_drv += ['sdcard.c']
......
......@@ -69,6 +69,9 @@ void rt_init_thread_entry(void* parameter)
/* init touch panel */
rtgui_touch_hw_init();
/* re-init device driver */
rt_device_init_all();
/* startup rtgui */
rtgui_startup();
}
......
......@@ -10,32 +10,26 @@
* Change Logs:
* Date Author Notes
* 2010-02-10 Gary Lee first implementation
* 2010-02-21 Gary Lee add __DATA__
* 2010-02-21 Gary Lee add __DATA__
*/
#include "rtc_calendar.h"
#include <rtthread.h>
#include <string.h>
extern void rt_hw_console_putc(char c);
extern rt_uint8_t rt_hw_serial_getc(void);
rt_uint32_t year_seprt=0;
rt_uint8_t month_seprt=0;
rt_uint8_t day_seprt=0;
#define DEFAULT_YEAR_MONTH_DAY (DEFAULT_YEAR*10000+DEFAULT_MONTH*100+DEFAULT_DAY)
#define DEFAULT_YEAR 2010
#define DEFAULT_MONTH 01
#define DEFAULT_DAY 01
static const rt_int8_t *month_cn[12] ={ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月",
"九月", "十月", "十一月", "十二月"
};
static const rt_int8_t *month_en[12] ={ "January", "February", "March", "April", "May", "June", "July",
"Auguest", "September", "October", "November", "December"
};
static rt_uint32_t year_seprt = 0;
static rt_uint8_t month_seprt = 0;
static rt_uint8_t day_seprt = 0;
static const rt_int8_t *day_en[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Firday","Saturday"};
static const rt_int8_t *day_cn[7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
//=====================================================================
//read from uart
static const rt_int8_t *month_cn[12] = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月","九月", "十月", "十一月", "十二月"};
static const rt_int8_t *day_cn[7] = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
static const rt_int8_t *month_en[12] = { "January", "February", "March", "April", "May", "June", "July","Auguest", "September", "October", "November", "December"};
static const rt_uint8_t *list_month[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
rt_int32_t rt_rtc_isleap(rt_uint32_t year)
static rt_int32_t rt_rtc_isleap(rt_uint32_t year)
{
rt_int32_t leap = 0;
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 4 == 0))
......@@ -43,7 +37,7 @@ rt_int32_t rt_rtc_isleap(rt_uint32_t year)
return leap;
}
rt_int32_t rt_rtc_week_of_newyears_day(rt_uint32_t year)
static rt_int32_t rt_rtc_week_of_newyears_day(rt_uint32_t year)
{
rt_int32_t n = year - 1900;
n = n + (n - 1) / 4 + 1;
......@@ -51,7 +45,7 @@ rt_int32_t rt_rtc_week_of_newyears_day(rt_uint32_t year)
return n;
}
rt_int32_t rt_rtc_month_day_num(rt_int32_t month, rt_int32_t leapyn)
static rt_int32_t rt_rtc_month_day_num(rt_int32_t month, rt_int32_t leapyn)
{
rt_int32_t len_month = 0;
if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
......@@ -68,19 +62,7 @@ rt_int32_t rt_rtc_month_day_num(rt_int32_t month, rt_int32_t leapyn)
return len_month;
}
rt_int32_t rt_rtc_space_days(rt_int32_t month, rt_int32_t year)
{
rt_int32_t all_days = 0;
rt_int32_t i = 1;
rt_int32_t leap = rt_rtc_isleap(year);
for (i = 1; i <= month; i++)
{
all_days = all_days + rt_rtc_month_day_num(i, leap);
}
return all_days;
}
rt_int32_t rt_rtc_weekday_month(rt_int32_t month, rt_int32_t year)
static rt_int32_t rt_rtc_weekday_month(rt_int32_t month, rt_int32_t year)
{
rt_int32_t space = 0, j, all_days = 0;
rt_int32_t leap = rt_rtc_isleap(year);
......@@ -91,10 +73,10 @@ rt_int32_t rt_rtc_weekday_month(rt_int32_t month, rt_int32_t year)
}
space = (space + all_days) % 7;
return space;
return space;
}
void rt_rtc_print_common_fmt(rt_uint8_t month, rt_uint8_t weekday, rt_uint8_t leapyear)
static void rt_rtc_print_common_fmt(rt_uint8_t month, rt_uint8_t weekday, rt_uint8_t leapyear)
{
rt_int32_t day, j, len_of_month;
......@@ -123,15 +105,14 @@ void rt_rtc_print_common_fmt(rt_uint8_t month, rt_uint8_t weekday, rt_uint8_t le
rt_kprintf("\n");
}
void rt_rtc_print_one_month(rt_int32_t month, rt_int32_t year)
static void rt_rtc_print_one_month(rt_int32_t month, rt_int32_t year)
{
rt_int32_t weekday = rt_rtc_weekday_month(month, year);
rt_int32_t leapyear = rt_rtc_isleap(year);
rt_rtc_print_common_fmt(month, weekday, leapyear);
}
void rt_rtc_print_calendar(rt_uint32_t year)
static void rt_rtc_print_calendar(rt_uint32_t year)
{
rt_uint8_t month;
......@@ -147,7 +128,7 @@ void rt_rtc_print_calendar(rt_uint32_t year)
}
void rt_rtc_year_month_day_seperate(rt_uint32_t year)
static void rt_rtc_year_month_day_seperate(rt_uint32_t year)
{
rt_uint32_t temp;
......@@ -219,7 +200,7 @@ void rt_rtc_year_month_day_seperate(rt_uint32_t year)
}
}
void rt_rtc_weekdate_calculate(void)
static void rt_rtc_weekdate_calculate(void)
{
rt_uint32_t temp;
......@@ -229,10 +210,8 @@ void rt_rtc_weekdate_calculate(void)
}
static const rt_uint8_t *list_month[12]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
void rt_calendar(void)
void calendar(void)
{
//static rt_uint8_t receive_char;
static rt_int32_t year;
rt_uint8_t i = 0;
rt_int32_t result, num_month, num_year;
......@@ -254,29 +233,23 @@ void rt_calendar(void)
i = 0;
result = 1;
year = num_year*100 + num_month;
//year = Uart_GetIntNum_MT();
//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);
}
else if (day_seprt == 0)
{
//rt_kprintf("\n%d/%d\n", year_seprt, month_seprt);
rt_rtc_print_calendar(year_seprt);
}
else
{
//rt_kprintf("\n%d/%d/%d\n", year_seprt, month_seprt, day_seprt);
rt_rtc_weekdate_calculate();
}
}
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT(rt_calendar, print calendar)
FINSH_FUNCTION_EXPORT(calendar, print calendar)
#endif
/*
* File : rtc_calendar.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-02-10 Gary Lee first implementation
*/
#ifndef __RTCLEAP_H__
#define __RTCLEAP_H__
#include <rthw.h>
#include <rtthread.h>
#include "s3c24x0.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEFAULT_YEAR_MONTH_DAY (DEFAULT_YEAR*10000+DEFAULT_MONTH*100+DEFAULT_DAY)
#define DEFAULT_YEAR 2010
#define DEFAULT_MONTH 02
#define DEFAULT_DAY 10
rt_int32_t rt_rtc_isleap(rt_uint32_t year);
rt_int32_t rt_rtc_week_of_newyears_day(rt_uint32_t year);
void rt_calendar(void);
void rt_rtc_print_calendar(rt_uint32_t year);
rt_int32_t rt_rtc_month_day_num(rt_int32_t month, rt_int32_t leapyn);
rt_int32_t rt_rtc_space_days(rt_int32_t month, rt_int32_t year);
rt_int32_t rt_rtc_weekday_month(rt_int32_t month, rt_int32_t year);
void rt_rtc_print_common_fmt(rt_uint8_t month, rt_uint8_t weekday, rt_uint8_t leapyear);
void rt_rtc_print_one_month(rt_int32_t month, rt_int32_t year);
void rt_rtc_weekdate_calculate(void);
#ifdef __cplusplus
}
#endif
#endif /*__MMU_H__*/
......@@ -113,7 +113,7 @@
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
/* Using lighweight TCP/IP protocol stack */
#define RT_USING_LWIP
/* #define RT_USING_LWIP */
#define RT_LWIP_DNS
/* Trace LwIP protocol */
......
/*
* File : module.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-04-12 yi.qiu first version
*/
#include <rtthread.h>
#include <dfs_posix.h>
#include "string.h"
#if defined(RT_USING_FINSH) && defined(RT_USING_MODULE)
#include <finsh.h>
void run_module(const char* filename)
{
int fd, length;
char *module_name;
struct rt_module* module;
struct _stat s;
char *buffer;
stat(filename, &s);
buffer = (char *)rt_malloc(s.st_size);
fd = open(filename, O_RDONLY, 0);
length = read(fd, buffer, s.st_size);
if (length <= 0)
{
rt_kprintf("check: read file failed\n");
close(fd);
rt_free(buffer);
return;
}
rt_kprintf("read %d bytes from file\n", length);
module_name = strrchr(filename, '/');
module = rt_module_load(++module_name, (void *)buffer);
rt_free(buffer);
close(fd);
}
FINSH_FUNCTION_EXPORT(run_module, run module from file);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册