summaryrefslogtreecommitdiff
path: root/components/drivers
diff options
context:
space:
mode:
authorGUI <[email protected]>2025-12-09 09:49:02 +0800
committerGitHub <[email protected]>2025-12-09 09:49:02 +0800
commit6618fa1cf6f6cf7a28fc949ce2f535aa2775cbfd (patch)
treee69817e67d17e38cad6bf0123721bdf54fdede67 /components/drivers
parent69980f8b9d29b38dbd4ddf6373b4b45f3a138409 (diff)
[Driver][MISC] Update ADC/PWM (#11003)
* [DM][MISC] Make Kconfig(ADC/PWM) import for DM * [Driver][MISC][ADC] Fixup ADC 1. Fixup error no. 2. Fixup type of control for args. 3. Fixup value no init. * [Driver][MISC][PWM] Enable `rt_pwm_get` API Signed-off-by: GuEe-GUI <[email protected]>
Diffstat (limited to 'components/drivers')
-rw-r--r--components/drivers/include/drivers/dev_pwm.h8
-rw-r--r--components/drivers/misc/Kconfig12
-rw-r--r--components/drivers/misc/adc.c4
-rw-r--r--components/drivers/misc/rt_drv_pwm.c2
4 files changed, 21 insertions, 5 deletions
diff --git a/components/drivers/include/drivers/dev_pwm.h b/components/drivers/include/drivers/dev_pwm.h
index bda3fed0c1..6cc70a543f 100644
--- a/components/drivers/include/drivers/dev_pwm.h
+++ b/components/drivers/include/drivers/dev_pwm.h
@@ -201,6 +201,14 @@ rt_err_t rt_pwm_set_dead_time(struct rt_device_pwm *device, int channel, rt_uint
*/
rt_err_t rt_pwm_set_phase(struct rt_device_pwm *device, int channel, rt_uint32_t phase);
+/**
+ * @brief get the PWM configuration
+ * @param device the PWM device
+ * @param cfg the configuration of PWM
+ * @return rt_err_t error code
+ */
+rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg);
+
/*! @}*/
#endif /* __DEV_PWM_H__ */
diff --git a/components/drivers/misc/Kconfig b/components/drivers/misc/Kconfig
index fd09276099..0a7788bce5 100644
--- a/components/drivers/misc/Kconfig
+++ b/components/drivers/misc/Kconfig
@@ -1,7 +1,11 @@
-config RT_USING_ADC
+menuconfig RT_USING_ADC
bool "Using ADC device drivers"
default n
+if RT_USING_DM && RT_USING_ADC
+ osource "$(SOC_DM_ADC_DIR)/Kconfig"
+endif
+
config RT_USING_DAC
bool "Using DAC device drivers"
default n
@@ -18,10 +22,14 @@ config RT_USING_RANDOM
bool "Using RANDOM device drivers"
default n
-config RT_USING_PWM
+menuconfig RT_USING_PWM
bool "Using PWM device drivers"
default n
+if RT_USING_DM && RT_USING_PWM
+ osource "$(SOC_DM_PWM_DIR)/Kconfig"
+endif
+
config RT_USING_PULSE_ENCODER
bool "Using PULSE ENCODER device drivers"
default n
diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c
index 43a9750349..056c1f6c30 100644
--- a/components/drivers/misc/adc.c
+++ b/components/drivers/misc/adc.c
@@ -43,7 +43,7 @@ static rt_ssize_t _adc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size
static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args)
{
rt_adc_device_t adc = (struct rt_adc_device *)dev;
- rt_err_t result = RT_ERROR;
+ rt_err_t result = -RT_ERROR;
if (cmd == RT_ADC_CMD_ENABLE && adc->ops->enabled)
{
@@ -167,7 +167,7 @@ rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_int8_t channel)
RT_ASSERT(dev);
rt_uint32_t value;
- rt_int16_t vref, voltage;
+ rt_int16_t vref, voltage = 0;
rt_uint8_t resolution;
rt_err_t result;
diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c
index ef08048207..357857cca5 100644
--- a/components/drivers/misc/rt_drv_pwm.c
+++ b/components/drivers/misc/rt_drv_pwm.c
@@ -285,7 +285,7 @@ rt_err_t rt_pwm_set_phase(struct rt_device_pwm *device, int channel, rt_uint32_t
return result;
}
-static rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg)
+rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg)
{
rt_err_t result = RT_EOK;