diff options
| author | Tangyuxin <[email protected]> | 2022-04-06 21:12:39 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-06 21:12:39 +0800 |
| commit | da3d61e043c5f8734e7fd6d8626ec478a272766e (patch) | |
| tree | dc6d5fe2e310ec4824ccf8b0651c51fe4d3d8cb6 /components/drivers/include | |
| parent | 782b9dd45a10e5e68ac5687fb57649e6c07de93e (diff) | |
[device]Detailed classification of devices types (#5769)
Diffstat (limited to 'components/drivers/include')
| -rw-r--r-- | components/drivers/include/drivers/alarm.h | 4 | ||||
| -rw-r--r-- | components/drivers/include/drivers/dac.h | 4 | ||||
| -rw-r--r-- | components/drivers/include/drivers/hwtimer.h | 8 | ||||
| -rw-r--r-- | components/drivers/include/drivers/i2c_dev.h | 9 | ||||
| -rw-r--r-- | components/drivers/include/drivers/pm.h | 4 | ||||
| -rw-r--r-- | components/drivers/include/drivers/rt_drv_pwm.h | 12 | ||||
| -rw-r--r-- | components/drivers/include/drivers/rtc.h | 12 | ||||
| -rw-r--r-- | components/drivers/include/drivers/sensor.h | 14 | ||||
| -rw-r--r-- | components/drivers/include/drivers/watchdog.h | 12 |
9 files changed, 42 insertions, 37 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 |
