[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 <2991707448@qq.com>
This commit is contained in:
GUI
2025-12-09 09:49:02 +08:00
committed by GitHub
parent 69980f8b9d
commit 6618fa1cf6
4 changed files with 21 additions and 5 deletions

View File

@@ -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__ */

View File

@@ -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

View File

@@ -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;

View File

@@ -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;