mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-03-27 01:10:20 +08:00
fix: gPIO/ADC driver
1. add ADC temperature&vref channel. 2.add GPIO IPD/OD configration
This commit is contained in:
@@ -98,6 +98,9 @@ static rt_uint32_t n32_adc_get_channel(rt_uint32_t channel)
|
||||
case 17:
|
||||
n32_channel = ADC_CH_17;
|
||||
break;
|
||||
case 18:
|
||||
n32_channel = ADC_CH_18;
|
||||
break;
|
||||
}
|
||||
|
||||
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 */
|
||||
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 */
|
||||
ADC_Enable(n32_adc_handler, ENABLE);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ static void reboot(uint8_t argc, char **argv)
|
||||
rt_hw_cpu_reset();
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
|
||||
MSH_CMD_EXPORT(reboot, Reboot System);
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
/**
|
||||
|
||||
@@ -552,6 +552,16 @@ void n32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
|
||||
/* input setting: pull up. */
|
||||
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
|
||||
{
|
||||
/* input setting:default. */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* Date Author Notes
|
||||
* 2015-07-29 Arda.Fu first implementation
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user