Browse Source

fix: gPIO/ADC driver

1. add ADC temperature&vref channel.
2.add GPIO IPD/OD configration
192.168.1.134 3 years ago
parent
commit
f97f623c51

+ 9 - 0
bsp/n32g452xx/Libraries/rt_drivers/drv_adc.c

@@ -98,6 +98,9 @@ static rt_uint32_t n32_adc_get_channel(rt_uint32_t channel)
         case 17:
         case 17:
             n32_channel = ADC_CH_17;
             n32_channel = ADC_CH_17;
             break;
             break;
+        case 18:
+            n32_channel = ADC_CH_18;
+            break;
     }
     }
 
 
     return n32_channel;
     return n32_channel;
@@ -124,6 +127,12 @@ static rt_err_t n32_adc_enabled(struct rt_adc_device *device, rt_uint32_t channe
     /* ADCx regular channels configuration */
     /* ADCx regular channels configuration */
     ADC_ConfigRegularChannel(n32_adc_handler, n32_adc_get_channel(channel), 1, ADC_SAMP_TIME_28CYCLES5);
     ADC_ConfigRegularChannel(n32_adc_handler, n32_adc_get_channel(channel), 1, ADC_SAMP_TIME_28CYCLES5);
 
 
+    if (((n32_adc_handler == ADC2) || (n32_adc_handler == ADC2))
+        && ((n32_adc_get_channel(channel) == ADC_CH_16) || (n32_adc_get_channel(channel) == ADC_CH_18)))
+    {
+        ADC_EnableTempSensorVrefint(ENABLE);
+    }
+
     /* Enable ADCx */
     /* Enable ADCx */
     ADC_Enable(n32_adc_handler, ENABLE);
     ADC_Enable(n32_adc_handler, ENABLE);
 
 

+ 1 - 0
bsp/n32g452xx/Libraries/rt_drivers/drv_common.c

@@ -26,6 +26,7 @@ static void reboot(uint8_t argc, char **argv)
     rt_hw_cpu_reset();
     rt_hw_cpu_reset();
 }
 }
 FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
 FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
+MSH_CMD_EXPORT(reboot, Reboot System);
 #endif /* RT_USING_FINSH */
 #endif /* RT_USING_FINSH */
 
 
 /**
 /**

+ 10 - 0
bsp/n32g452xx/Libraries/rt_drivers/drv_gpio.c

@@ -552,6 +552,16 @@ void n32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
         /* input setting: pull up. */
         /* input setting: pull up. */
         GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPU;
         GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPU;
     }
     }
+    else if (mode == PIN_MODE_INPUT_PULLDOWN)
+    {
+        /* input setting: pull up. */
+        GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPD;
+    }
+    else if (mode == PIN_MODE_OUTPUT_OD)
+    {
+        /* input setting: pull up. */
+        GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_OD;
+    }
     else
     else
     {
     {
         /* input setting:default. */
         /* input setting:default. */

+ 1 - 0
bsp/n32g452xx/n32g452xx-mini-system/applications/main.c

@@ -7,6 +7,7 @@
  * Date           Author       Notes
  * Date           Author       Notes
  * 2015-07-29     Arda.Fu      first implementation
  * 2015-07-29     Arda.Fu      first implementation
  */
  */
+#include <stdint.h>
 #include <rtthread.h>
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <rtdevice.h>