summaryrefslogtreecommitdiff
path: root/components/drivers
diff options
context:
space:
mode:
authorTangyuxin <[email protected]>2022-04-06 21:12:39 +0800
committerGitHub <[email protected]>2022-04-06 21:12:39 +0800
commitda3d61e043c5f8734e7fd6d8626ec478a272766e (patch)
treedc6d5fe2e310ec4824ccf8b0651c51fe4d3d8cb6 /components/drivers
parent782b9dd45a10e5e68ac5687fb57649e6c07de93e (diff)
[device]Detailed classification of devices types (#5769)
Diffstat (limited to 'components/drivers')
-rw-r--r--components/drivers/include/drivers/alarm.h4
-rw-r--r--components/drivers/include/drivers/dac.h4
-rw-r--r--components/drivers/include/drivers/hwtimer.h8
-rw-r--r--components/drivers/include/drivers/i2c_dev.h9
-rw-r--r--components/drivers/include/drivers/pm.h4
-rw-r--r--components/drivers/include/drivers/rt_drv_pwm.h12
-rw-r--r--components/drivers/include/drivers/rtc.h12
-rw-r--r--components/drivers/include/drivers/sensor.h14
-rw-r--r--components/drivers/include/drivers/watchdog.h12
-rw-r--r--components/drivers/misc/adc.c2
-rw-r--r--components/drivers/misc/dac.c2
-rw-r--r--components/drivers/misc/pin.c2
-rw-r--r--components/drivers/misc/rt_drv_pwm.c2
-rw-r--r--components/drivers/rtc/alarm.c3
-rw-r--r--components/drivers/touch/touch.h22
-rw-r--r--components/drivers/watchdog/watchdog.c2
16 files changed, 58 insertions, 56 deletions
diff --git a/components/drivers/include/drivers/alarm.h b/components/drivers/include/drivers/alarm.h
index 56822b72e1..d96d1ba0d2 100644
--- a/components/drivers/include/drivers/alarm.h
+++ b/components/drivers/include/drivers/alarm.h
@@ -29,6 +29,10 @@
#define RT_ALARM_MINUTE 0x2000 /* alarm each minute at a certain second */
#define RT_ALARM_SECOND 0x4000 /* alarm each second */
+#define RT_ALARM_STATE_INITED 0x02
+#define RT_ALARM_STATE_START 0x01
+#define RT_ALARM_STATE_STOP 0x00
+
/* alarm control cmd */
#define RT_ALARM_CTRL_MODIFY 1 /* modify alarm time or alarm flag */
diff --git a/components/drivers/include/drivers/dac.h b/components/drivers/include/drivers/dac.h
index 7d5ff3592a..36ab2b4ced 100644
--- a/components/drivers/include/drivers/dac.h
+++ b/components/drivers/include/drivers/dac.h
@@ -29,8 +29,8 @@ typedef struct rt_dac_device *rt_dac_device_t;
typedef enum
{
- RT_DAC_CMD_ENABLE,
- RT_DAC_CMD_DISABLE,
+ RT_DAC_CMD_ENABLE = RT_DEVICE_CTRL_BASE(DAC) + 0,
+ RT_DAC_CMD_DISABLE = RT_DEVICE_CTRL_BASE(DAC) + 1,
} rt_dac_cmd_t;
rt_err_t rt_hw_dac_register(rt_dac_device_t dac,const char *name, const struct rt_dac_ops *ops, const void *user_data);
diff --git a/components/drivers/include/drivers/hwtimer.h b/components/drivers/include/drivers/hwtimer.h
index 0bf4893790..e67551aa5d 100644
--- a/components/drivers/include/drivers/hwtimer.h
+++ b/components/drivers/include/drivers/hwtimer.h
@@ -19,10 +19,10 @@ extern "C" {
/* 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) */
+ HWTIMER_CTRL_FREQ_SET = RT_DEVICE_CTRL_BASE(Timer) + 0x01, /* set the count frequency */
+ HWTIMER_CTRL_STOP = RT_DEVICE_CTRL_BASE(Timer) + 0x02, /* stop timer */
+ HWTIMER_CTRL_INFO_GET = RT_DEVICE_CTRL_BASE(Timer) + 0x03, /* get a timer feature information */
+ HWTIMER_CTRL_MODE_SET = RT_DEVICE_CTRL_BASE(Timer) + 0x04 /* Setting the timing mode(oneshot/period) */
} rt_hwtimer_ctrl_t;
/* Timing Mode */
diff --git a/components/drivers/include/drivers/i2c_dev.h b/components/drivers/include/drivers/i2c_dev.h
index 268f52b1fb..9fc454b1b2 100644
--- a/components/drivers/include/drivers/i2c_dev.h
+++ b/components/drivers/include/drivers/i2c_dev.h
@@ -18,10 +18,11 @@
extern "C" {
#endif
-#define RT_I2C_DEV_CTRL_10BIT 0x20
-#define RT_I2C_DEV_CTRL_TIMEOUT 0x22
-#define RT_I2C_DEV_CTRL_RW 0x23
-#define RT_I2C_DEV_CTRL_CLK 0x24
+#define RT_I2C_DEV_CTRL_10BIT (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x01)
+#define RT_I2C_DEV_CTRL_ADDR (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x02)
+#define RT_I2C_DEV_CTRL_TIMEOUT (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x03)
+#define RT_I2C_DEV_CTRL_RW (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x04)
+#define RT_I2C_DEV_CTRL_CLK (RT_DEVICE_CTRL_BASE(I2CBUS) + 0x05)
struct rt_i2c_priv_data
{
diff --git a/components/drivers/include/drivers/pm.h b/components/drivers/include/drivers/pm.h
index 2deee83692..99d1ff4870 100644
--- a/components/drivers/include/drivers/pm.h
+++ b/components/drivers/include/drivers/pm.h
@@ -115,8 +115,8 @@ enum pm_module_id {
/**
* device control flag to request or release power
*/
-#define RT_PM_DEVICE_CTRL_REQUEST 0x01
-#define RT_PM_DEVICE_CTRL_RELEASE 0x00
+#define RT_PM_DEVICE_CTRL_RELEASE (RT_DEVICE_CTRL_BASE(PM) + 0x00)
+#define RT_PM_DEVICE_CTRL_REQUEST (RT_DEVICE_CTRL_BASE(PM) + 0x01)
struct rt_pm;
diff --git a/components/drivers/include/drivers/rt_drv_pwm.h b/components/drivers/include/drivers/rt_drv_pwm.h
index 72e34428e6..2b782f7e53 100644
--- a/components/drivers/include/drivers/rt_drv_pwm.h
+++ b/components/drivers/include/drivers/rt_drv_pwm.h
@@ -14,12 +14,12 @@
#include <rtthread.h>
#include <rtdevice.h>
-#define PWM_CMD_ENABLE (128 + 0)
-#define PWM_CMD_DISABLE (128 + 1)
-#define PWM_CMD_SET (128 + 2)
-#define PWM_CMD_GET (128 + 3)
-#define PWMN_CMD_ENABLE (128 + 4)
-#define PWMN_CMD_DISABLE (128 + 5)
+#define PWM_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 0)
+#define PWM_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 1)
+#define PWM_CMD_SET (RT_DEVICE_CTRL_BASE(PWM) + 2)
+#define PWM_CMD_GET (RT_DEVICE_CTRL_BASE(PWM) + 3)
+#define PWMN_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 4)
+#define PWMN_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 5)
struct rt_pwm_configuration
{
diff --git a/components/drivers/include/drivers/rtc.h b/components/drivers/include/drivers/rtc.h
index dd93038391..21bbb26d08 100644
--- a/components/drivers/include/drivers/rtc.h
+++ b/components/drivers/include/drivers/rtc.h
@@ -21,12 +21,12 @@
extern "C" {
#endif
-#define RT_DEVICE_CTRL_RTC_GET_TIME 0x20 /**< get second time */
-#define RT_DEVICE_CTRL_RTC_SET_TIME 0x21 /**< set second time */
-#define RT_DEVICE_CTRL_RTC_GET_TIMEVAL 0x22 /**< get timeval for gettimeofday */
-#define RT_DEVICE_CTRL_RTC_SET_TIMEVAL 0x23 /**< set timeval for gettimeofday */
-#define RT_DEVICE_CTRL_RTC_GET_ALARM 0x24 /**< get alarm */
-#define RT_DEVICE_CTRL_RTC_SET_ALARM 0x25 /**< set alarm */
+#define RT_DEVICE_CTRL_RTC_GET_TIME (RT_DEVICE_CTRL_BASE(RTC) + 0x01) /**< get second time */
+#define RT_DEVICE_CTRL_RTC_SET_TIME (RT_DEVICE_CTRL_BASE(RTC) + 0x02) /**< set second time */
+#define RT_DEVICE_CTRL_RTC_GET_TIMEVAL (RT_DEVICE_CTRL_BASE(RTC) + 0x03) /**< get timeval for gettimeofday */
+#define RT_DEVICE_CTRL_RTC_SET_TIMEVAL (RT_DEVICE_CTRL_BASE(RTC) + 0x04) /**< set timeval for gettimeofday */
+#define RT_DEVICE_CTRL_RTC_GET_ALARM (RT_DEVICE_CTRL_BASE(RTC) + 0x05) /**< get alarm */
+#define RT_DEVICE_CTRL_RTC_SET_ALARM (RT_DEVICE_CTRL_BASE(RTC) + 0x06) /**< set alarm */
struct rt_rtc_ops
{
diff --git a/components/drivers/include/drivers/sensor.h b/components/drivers/include/drivers/sensor.h
index ba0afb33a8..8d8f26d096 100644
--- a/components/drivers/include/drivers/sensor.h
+++ b/components/drivers/include/drivers/sensor.h
@@ -119,13 +119,13 @@ extern "C" {
/* Sensor control cmd types */
-#define RT_SENSOR_CTRL_GET_ID (0) /* Get device id */
-#define RT_SENSOR_CTRL_GET_INFO (1) /* Get sensor info */
-#define RT_SENSOR_CTRL_SET_RANGE (2) /* Set the measure range of sensor. unit is info of sensor */
-#define RT_SENSOR_CTRL_SET_ODR (3) /* Set output date rate. unit is HZ */
-#define RT_SENSOR_CTRL_SET_MODE (4) /* Set sensor's work mode. ex. RT_SENSOR_MODE_POLLING,RT_SENSOR_MODE_INT */
-#define RT_SENSOR_CTRL_SET_POWER (5) /* Set power mode. args type of sensor power mode. ex. RT_SENSOR_POWER_DOWN,RT_SENSOR_POWER_NORMAL */
-#define RT_SENSOR_CTRL_SELF_TEST (6) /* Take a self test */
+#define RT_SENSOR_CTRL_GET_ID (RT_DEVICE_CTRL_BASE(Sensor) + 0) /* Get device id */
+#define RT_SENSOR_CTRL_GET_INFO (RT_DEVICE_CTRL_BASE(Sensor) + 1) /* Get sensor info */
+#define RT_SENSOR_CTRL_SET_RANGE (RT_DEVICE_CTRL_BASE(Sensor) + 2) /* Set the measure range of sensor. unit is info of sensor */
+#define RT_SENSOR_CTRL_SET_ODR (RT_DEVICE_CTRL_BASE(Sensor) + 3) /* Set output date rate. unit is HZ */
+#define RT_SENSOR_CTRL_SET_MODE (RT_DEVICE_CTRL_BASE(Sensor) + 4) /* Set sensor's work mode. ex. RT_SENSOR_MODE_POLLING,RT_SENSOR_MODE_INT */
+#define RT_SENSOR_CTRL_SET_POWER (RT_DEVICE_CTRL_BASE(Sensor) + 5) /* Set power mode. args type of sensor power mode. ex. RT_SENSOR_POWER_DOWN,RT_SENSOR_POWER_NORMAL */
+#define RT_SENSOR_CTRL_SELF_TEST (RT_DEVICE_CTRL_BASE(Sensor) + 6) /* Take a self test */
#define RT_SENSOR_CTRL_USER_CMD_START 0x100 /* User commands should be greater than 0x100 */
diff --git a/components/drivers/include/drivers/watchdog.h b/components/drivers/include/drivers/watchdog.h
index 9489ac2810..50d27046d7 100644
--- a/components/drivers/include/drivers/watchdog.h
+++ b/components/drivers/include/drivers/watchdog.h
@@ -13,12 +13,12 @@
#include <rtthread.h>
-#define RT_DEVICE_CTRL_WDT_GET_TIMEOUT (1) /* get timeout(in seconds) */
-#define RT_DEVICE_CTRL_WDT_SET_TIMEOUT (2) /* set timeout(in seconds) */
-#define RT_DEVICE_CTRL_WDT_GET_TIMELEFT (3) /* get the left time before reboot(in seconds) */
-#define RT_DEVICE_CTRL_WDT_KEEPALIVE (4) /* refresh watchdog */
-#define RT_DEVICE_CTRL_WDT_START (5) /* start watchdog */
-#define RT_DEVICE_CTRL_WDT_STOP (6) /* stop watchdog */
+#define RT_DEVICE_CTRL_WDT_GET_TIMEOUT (RT_DEVICE_CTRL_BASE(WDT) + 1) /* get timeout(in seconds) */
+#define RT_DEVICE_CTRL_WDT_SET_TIMEOUT (RT_DEVICE_CTRL_BASE(WDT) + 2) /* set timeout(in seconds) */
+#define RT_DEVICE_CTRL_WDT_GET_TIMELEFT (RT_DEVICE_CTRL_BASE(WDT) + 3) /* get the left time before reboot(in seconds) */
+#define RT_DEVICE_CTRL_WDT_KEEPALIVE (RT_DEVICE_CTRL_BASE(WDT) + 4) /* refresh watchdog */
+#define RT_DEVICE_CTRL_WDT_START (RT_DEVICE_CTRL_BASE(WDT) + 5) /* start watchdog */
+#define RT_DEVICE_CTRL_WDT_STOP (RT_DEVICE_CTRL_BASE(WDT) + 6) /* stop watchdog */
struct rt_watchdog_ops;
struct rt_watchdog_device
diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c
index a73fcc54e3..d54a14193b 100644
--- a/components/drivers/misc/adc.c
+++ b/components/drivers/misc/adc.c
@@ -77,7 +77,7 @@ rt_err_t rt_hw_adc_register(rt_adc_device_t device, const char *name, const stru
rt_err_t result = RT_EOK;
RT_ASSERT(ops != RT_NULL && ops->convert != RT_NULL);
- device->parent.type = RT_Device_Class_Miscellaneous;
+ device->parent.type = RT_Device_Class_ADC;
device->parent.rx_indicate = RT_NULL;
device->parent.tx_complete = RT_NULL;
diff --git a/components/drivers/misc/dac.c b/components/drivers/misc/dac.c
index 2aa5e12124..a17c54d841 100644
--- a/components/drivers/misc/dac.c
+++ b/components/drivers/misc/dac.c
@@ -76,7 +76,7 @@ rt_err_t rt_hw_dac_register(rt_dac_device_t device, const char *name, const stru
rt_err_t result = RT_EOK;
RT_ASSERT(ops != RT_NULL && ops->convert != RT_NULL);
- device->parent.type = RT_Device_Class_Miscellaneous;
+ device->parent.type = RT_Device_Class_DAC;
device->parent.rx_indicate = RT_NULL;
device->parent.tx_complete = RT_NULL;
diff --git a/components/drivers/misc/pin.c b/components/drivers/misc/pin.c
index 666d221fa6..f12dffdcfc 100644
--- a/components/drivers/misc/pin.c
+++ b/components/drivers/misc/pin.c
@@ -77,7 +77,7 @@ const static struct rt_device_ops pin_ops =
int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void *user_data)
{
- _hw_pin.parent.type = RT_Device_Class_Miscellaneous;
+ _hw_pin.parent.type = RT_Device_Class_Pin;
_hw_pin.parent.rx_indicate = RT_NULL;
_hw_pin.parent.tx_complete = RT_NULL;
diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c
index c60bf6df1d..9016b5ce5f 100644
--- a/components/drivers/misc/rt_drv_pwm.c
+++ b/components/drivers/misc/rt_drv_pwm.c
@@ -118,7 +118,7 @@ rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name,
device->parent.control = _pwm_control;
#endif /* RT_USING_DEVICE_OPS */
- device->parent.type = RT_Device_Class_Miscellaneous;
+ device->parent.type = RT_Device_Class_PWM;
device->ops = ops;
device->parent.user_data = (void *)user_data;
diff --git a/components/drivers/rtc/alarm.c b/components/drivers/rtc/alarm.c
index defded2be7..e56bf591c2 100644
--- a/components/drivers/rtc/alarm.c
+++ b/components/drivers/rtc/alarm.c
@@ -21,9 +21,6 @@
#else
#define RT_ALARM_DELAY 2
#endif
-#define RT_ALARM_STATE_INITED 0x02
-#define RT_ALARM_STATE_START 0x01
-#define RT_ALARM_STATE_STOP 0x00
#if (defined(RT_USING_RTC) && defined(RT_USING_ALARM))
static struct rt_alarm_container _container;
diff --git a/components/drivers/touch/touch.h b/components/drivers/touch/touch.h
index 3d2e885e13..5a573f80b9 100644
--- a/components/drivers/touch/touch.h
+++ b/components/drivers/touch/touch.h
@@ -37,17 +37,17 @@ extern "C" {
#define RT_TOUCH_TYPE_RESISTANCE (2) /* resistance ic */
/* Touch control cmd types */
-#define RT_TOUCH_CTRL_GET_ID (0) /* Get device id */
-#define RT_TOUCH_CTRL_GET_INFO (1) /* Get touch info */
-#define RT_TOUCH_CTRL_SET_MODE (2) /* Set touch's work mode. ex. RT_TOUCH_MODE_POLLING,RT_TOUCH_MODE_INT */
-#define RT_TOUCH_CTRL_SET_X_RANGE (3) /* Set x coordinate range */
-#define RT_TOUCH_CTRL_SET_Y_RANGE (4) /* Set y coordinate range */
-#define RT_TOUCH_CTRL_SET_X_TO_Y (5) /* Set X Y coordinate exchange */
-#define RT_TOUCH_CTRL_DISABLE_INT (6) /* Disable interrupt */
-#define RT_TOUCH_CTRL_ENABLE_INT (7) /* Enable interrupt */
-#define RT_TOUCH_CTRL_POWER_ON (8) /* Touch Power On */
-#define RT_TOUCH_CTRL_POWER_OFF (9) /* Touch Power Off */
-#define RT_TOUCH_CTRL_GET_STATUS (10) /* Get Touch Power Status */
+#define RT_TOUCH_CTRL_GET_ID (RT_DEVICE_CTRL_BASE(Touch) + 0) /* Get device id */
+#define RT_TOUCH_CTRL_GET_INFO (RT_DEVICE_CTRL_BASE(Touch) + 1) /* Get touch info */
+#define RT_TOUCH_CTRL_SET_MODE (RT_DEVICE_CTRL_BASE(Touch) + 2) /* Set touch's work mode. ex. RT_TOUCH_MODE_POLLING,RT_TOUCH_MODE_INT */
+#define RT_TOUCH_CTRL_SET_X_RANGE (RT_DEVICE_CTRL_BASE(Touch) + 3) /* Set x coordinate range */
+#define RT_TOUCH_CTRL_SET_Y_RANGE (RT_DEVICE_CTRL_BASE(Touch) + 4) /* Set y coordinate range */
+#define RT_TOUCH_CTRL_SET_X_TO_Y (RT_DEVICE_CTRL_BASE(Touch) + 5) /* Set X Y coordinate exchange */
+#define RT_TOUCH_CTRL_DISABLE_INT (RT_DEVICE_CTRL_BASE(Touch) + 6) /* Disable interrupt */
+#define RT_TOUCH_CTRL_ENABLE_INT (RT_DEVICE_CTRL_BASE(Touch) + 7) /* Enable interrupt */
+#define RT_TOUCH_CTRL_POWER_ON (RT_DEVICE_CTRL_BASE(Touch) + 8) /* Touch Power On */
+#define RT_TOUCH_CTRL_POWER_OFF (RT_DEVICE_CTRL_BASE(Touch) + 9) /* Touch Power Off */
+#define RT_TOUCH_CTRL_GET_STATUS (RT_DEVICE_CTRL_BASE(Touch) + 10) /* Get Touch Power Status */
/* Touch event */
#define RT_TOUCH_EVENT_NONE (0) /* Touch none */
diff --git a/components/drivers/watchdog/watchdog.c b/components/drivers/watchdog/watchdog.c
index d26626863d..48c58ed1f2 100644
--- a/components/drivers/watchdog/watchdog.c
+++ b/components/drivers/watchdog/watchdog.c
@@ -89,7 +89,7 @@ rt_err_t rt_hw_watchdog_register(struct rt_watchdog_device *wtd,
device = &(wtd->parent);
- device->type = RT_Device_Class_Security;
+ device->type = RT_Device_Class_WDT;
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;