summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorheyuanjie87 <[email protected]>2015-09-06 15:05:47 +0800
committerheyuanjie87 <[email protected]>2015-09-06 15:05:47 +0800
commitd19f424909bbcaa22b222728aa94b65e4aa8a9ed (patch)
treea6b86a535a94feb3ea074e93e24b363ea1875a97 /components/drivers/include
parent47b3a4d3cc090dcf3a9abd554178acecc3c016cd (diff)
简化操作接口
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/hwtimer.h53
1 files changed, 24 insertions, 29 deletions
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);