summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2015-09-20 14:51:22 +0800
committerBernard Xiong <[email protected]>2015-09-20 14:51:22 +0800
commit72f79d8eef64ebec31722511e8a8c34cf0085b6d (patch)
treeeb8098fa092c76dfae0b06fd221e89363a440db6 /components/drivers/include
parent9ad05db536b9f178e0142664a30da3477fd15a4d (diff)
parent7dfac0f78e546842b276806538a36066d61bd974 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/hwtimer.h78
-rw-r--r--components/drivers/include/drivers/spi.h5
-rw-r--r--components/drivers/include/rtdevice.h4
3 files changed, 87 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/hwtimer.h b/components/drivers/include/drivers/hwtimer.h
new file mode 100644
index 0000000000..24cec74d32
--- /dev/null
+++ b/components/drivers/include/drivers/hwtimer.h
@@ -0,0 +1,78 @@
+#ifndef __HWTIMER_H__
+#define __HWTIMER_H__
+
+#include <rtthread.h>
+#include <rtdevice.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Timer Control Command */
+typedef enum
+{
+ 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; /* second */
+ rt_int32_t usec; /* microsecond */
+} rt_hwtimerval_t;
+
+#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, 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_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; /* 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
+{
+ struct rt_device parent;
+ const struct rt_hwtimer_ops *ops;
+ const struct rt_hwtimer_info *info;
+
+ 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);
+void rt_device_hwtimer_isr(rt_hwtimer_t *timer);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/drivers/spi.h b/components/drivers/include/drivers/spi.h
index cfa4b73ca3..f76b329cab 100644
--- a/components/drivers/include/drivers/spi.h
+++ b/components/drivers/include/drivers/spi.h
@@ -59,6 +59,11 @@ extern "C"{
#define RT_SPI_MODE_MASK (RT_SPI_CPHA | RT_SPI_CPOL | RT_SPI_MSB)
+#define RT_SPI_CS_HIGH (1<<4) /* Chipselect active high */
+#define RT_SPI_NO_CS (1<<5) /* No chipselect */
+#define RT_SPI_3WIRE (1<<6) /* SI/SO pin shared */
+#define RT_SPI_READY (1<<7) /* Slave pulls low to pause */
+
/**
* SPI message structure
*/
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index f4d967831c..475adebf80 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -370,6 +370,10 @@ rt_inline void rt_work_init(struct rt_work* work, void (*work_func)(struct rt_wo
#include "drivers/can.h"
#endif
+#ifdef RT_USING_HWTIMER
+#include "drivers/hwtimer.h"
+#endif
+
#ifdef __cplusplus
}
#endif