Skip to content

Commit 6618fa1

Browse files
authored
[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>
1 parent 69980f8 commit 6618fa1

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

components/drivers/include/drivers/dev_pwm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ rt_err_t rt_pwm_set_dead_time(struct rt_device_pwm *device, int channel, rt_uint
201201
*/
202202
rt_err_t rt_pwm_set_phase(struct rt_device_pwm *device, int channel, rt_uint32_t phase);
203203

204+
/**
205+
* @brief get the PWM configuration
206+
* @param device the PWM device
207+
* @param cfg the configuration of PWM
208+
* @return rt_err_t error code
209+
*/
210+
rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg);
211+
204212
/*! @}*/
205213

206214
#endif /* __DEV_PWM_H__ */

components/drivers/misc/Kconfig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
config RT_USING_ADC
1+
menuconfig RT_USING_ADC
22
bool "Using ADC device drivers"
33
default n
44

5+
if RT_USING_DM && RT_USING_ADC
6+
osource "$(SOC_DM_ADC_DIR)/Kconfig"
7+
endif
8+
59
config RT_USING_DAC
610
bool "Using DAC device drivers"
711
default n
@@ -18,10 +22,14 @@ config RT_USING_RANDOM
1822
bool "Using RANDOM device drivers"
1923
default n
2024

21-
config RT_USING_PWM
25+
menuconfig RT_USING_PWM
2226
bool "Using PWM device drivers"
2327
default n
2428

29+
if RT_USING_DM && RT_USING_PWM
30+
osource "$(SOC_DM_PWM_DIR)/Kconfig"
31+
endif
32+
2533
config RT_USING_PULSE_ENCODER
2634
bool "Using PULSE ENCODER device drivers"
2735
default n

components/drivers/misc/adc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static rt_ssize_t _adc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size
4343
static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args)
4444
{
4545
rt_adc_device_t adc = (struct rt_adc_device *)dev;
46-
rt_err_t result = RT_ERROR;
46+
rt_err_t result = -RT_ERROR;
4747

4848
if (cmd == RT_ADC_CMD_ENABLE && adc->ops->enabled)
4949
{
@@ -167,7 +167,7 @@ rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_int8_t channel)
167167
RT_ASSERT(dev);
168168

169169
rt_uint32_t value;
170-
rt_int16_t vref, voltage;
170+
rt_int16_t vref, voltage = 0;
171171
rt_uint8_t resolution;
172172
rt_err_t result;
173173

components/drivers/misc/rt_drv_pwm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ rt_err_t rt_pwm_set_phase(struct rt_device_pwm *device, int channel, rt_uint32_t
285285
return result;
286286
}
287287

288-
static rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg)
288+
rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg)
289289
{
290290
rt_err_t result = RT_EOK;
291291

0 commit comments

Comments
 (0)