From d19f424909bbcaa22b222728aa94b65e4aa8a9ed Mon Sep 17 00:00:00 2001 From: heyuanjie87 Date: Sun, 6 Sep 2015 15:05:47 +0800 Subject: 简化æ“�作接å�£ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/include/drivers/hwtimer.h | 53 +++++++++++++--------------- 1 file changed, 24 insertions(+), 29 deletions(-) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/hwtimer.h b/components/drivers/include/drivers/hwtimer.h index e5b5d4661b..24cec74d32 100644 --- a/components/drivers/include/drivers/hwtimer.h +++ b/components/drivers/include/drivers/hwtimer.h @@ -8,54 +8,50 @@ extern "C" { #endif -/* ¶¨Ê±Æ÷¿ØÖÆÃüÁî */ +/* Timer Control Command */ typedef enum { - HWTIMER_CTRL_TIMEOUT_SET = 0x01, /* ÉèÖó¬Ê±Öµ */ - HWTIMER_CTRL_FREQ_SET, /* ÉèÖüÆÊýƵÂÊ */ - HWTIMER_CTRL_START, /* Æô¶¯¶¨Ê±Æ÷ */ - HWTIMER_CTRL_STOP, /* Í£Ö¹¶¨Ê±Æ÷ */ - HWTIMER_CTRL_INFO_GET, /* »ñÈ¡¶¨Ê±Æ÷ÌØÕ÷ÐÅÏ¢ */ - HWTIMER_CTRL_MODE_SET /* ÉèÖö¨Ê±Ä£Ê½ */ + HWTIMER_CTRL_FREQ_SET = 0x01, /* set the count frequency */ + HWTIMER_CTRL_STOP, /* stop timer */ + HWTIMER_CTRL_INFO_GET, /* get a timer feature information */ + HWTIMER_CTRL_MODE_SET /* Setting the timing mode(oneshot/period) */ } rt_hwtimer_ctrl_t; -/* ¶¨Ê±Ä£Ê½ */ +/* Timing Mode */ typedef enum { HWTIMER_MODE_ONESHOT = 0x01, HWTIMER_MODE_PERIOD } rt_hwtimer_mode_t; -/* ¶¨Ê±Æ÷¼ÆÊýÖµ */ +/* Time Value */ typedef struct rt_hwtimerval { - rt_int32_t sec; /* Ãë */ - rt_int32_t usec; /* ΢Ãë */ + rt_int32_t sec; /* second */ + rt_int32_t usec; /* microsecond */ } rt_hwtimerval_t; -#define HWTIMER_CNTMODE_UP 0x01 /* ¶¨Ê±Æ÷µÝÔö¼ÆÊý·½Ê½ */ -#define HWTIMER_CNTMODE_DW 0x02 /* ¶¨Ê±Æ÷µÝ¼õ¼ÆÊý·½Ê½ */ +#define HWTIMER_CNTMODE_UP 0x01 /* increment count mode */ +#define HWTIMER_CNTMODE_DW 0x02 /* decreasing count mode */ struct rt_hwtimer_device; struct rt_hwtimer_ops { - void (*init)(struct rt_hwtimer_device *timer); - void (*deinit)(struct rt_hwtimer_device *timer); - void (*start)(struct rt_hwtimer_device *timer, rt_hwtimer_mode_t mode); + void (*init)(struct rt_hwtimer_device *timer, rt_uint32_t state); + rt_err_t (*start)(struct rt_hwtimer_device *timer, rt_uint32_t cnt, rt_hwtimer_mode_t mode); void (*stop)(struct rt_hwtimer_device *timer); - rt_err_t (*timeout_set)(struct rt_hwtimer_device *timer, rt_uint32_t t); rt_uint32_t (*count_get)(struct rt_hwtimer_device *timer); rt_err_t (*control)(struct rt_hwtimer_device *timer, rt_uint32_t cmd, void *args); }; -/* ¶¨Ê±Æ÷»ù±¾²ÎÊý(²»¿É¶¯Ì¬¸ü¸Ä) */ +/* Timer Feature Information */ struct rt_hwtimer_info { - rt_int32_t maxfreq; /* ¶¨Ê±Æ÷Ö§³ÖµÄ×î´ó¼ÆÊýʱÖÓ */ - rt_int32_t minfreq; /* ¶¨Ê±Æ÷Ö§³ÖµÄ×îС¼ÆÊýʱÖÓ */ - rt_uint32_t maxcnt; /* ¼ÆÊýÆ÷×î´ó³¬Ê±Öµ */ - rt_uint8_t cntmode; /* ¼ÆÊýģʽ(µÝÔö/µÝ¼õ,Ó¦ÓòãÎÞÐè¹ØÐĴ˲ÎÊý) */ + rt_int32_t maxfreq; /* the maximum count frequency timer support */ + rt_int32_t minfreq; /* the minimum count frequency timer support */ + rt_uint32_t maxcnt; /* counter maximum value */ + rt_uint8_t cntmode; /* count mode (inc/dec) */ }; typedef struct rt_hwtimer_device @@ -64,13 +60,12 @@ typedef struct rt_hwtimer_device const struct rt_hwtimer_ops *ops; const struct rt_hwtimer_info *info; - /* Çý¶¯²ã²»ÓùØÐÄÒÔϲÎÊý */ - rt_int32_t freq; /* ¼ÆÊýƵÂÊ */ - rt_int32_t overflow; /* Òç³ö´ÎÊý */ - float period_sec; /* Òç³öÖÜÆÚ(s) */ - rt_int32_t cycles; /* Ñ­»·´ÎÊý */ - rt_int32_t reload; /* ÖØÔØcycles */ - rt_hwtimer_mode_t mode; /* ¶¨Ê±Ä£Ê½ */ + rt_int32_t freq; /* counting frequency set by the user */ + rt_int32_t overflow; /* timer overflows */ + float period_sec; + rt_int32_t cycles; /* how many times will generate a timeout event after overflow */ + rt_int32_t reload; /* reload cycles(using in period mode) */ + rt_hwtimer_mode_t mode; /* timing mode(oneshot/period) */ } rt_hwtimer_t; rt_err_t rt_device_hwtimer_register(rt_hwtimer_t *timer, const char *name, void *user_data); -- cgit v1.3.1