Browse Source

componnets: drivers: adc: remove build warnings

gcc build warnings:
cast from pointer to integer of different size [-Wpointer-to-int-cast]

For rt_adc_ops.enabled, the type of second param is rt_int8_t,
original _adc_control also called with wrong type casting.

Convert first to rt_base_t, then cast to rt_int8_t to remove the
build warnings.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Chen Wang 2 weeks ago
parent
commit
ae86c6e8bb
1 changed files with 2 additions and 3 deletions
  1. 2 3
      components/drivers/misc/adc.c

+ 2 - 3
components/drivers/misc/adc.c

@@ -45,14 +45,13 @@ 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;
 
-
     if (cmd == RT_ADC_CMD_ENABLE && adc->ops->enabled)
     {
-        result = adc->ops->enabled(adc, (rt_uint32_t)args, RT_TRUE);
+        result = adc->ops->enabled(adc, (rt_int8_t)(rt_base_t)args, RT_TRUE);
     }
     else if (cmd == RT_ADC_CMD_DISABLE && adc->ops->enabled)
     {
-        result = adc->ops->enabled(adc, (rt_uint32_t)args, RT_FALSE);
+        result = adc->ops->enabled(adc, (rt_int8_t)(rt_base_t)args, RT_FALSE);
     }
     else if (cmd == RT_ADC_CMD_GET_RESOLUTION && adc->ops->get_resolution && args)
     {