Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MXRT1050: Ensure the pins are in input mode for analogin #7429

Merged
merged 1 commit into from Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,6 +20,7 @@

#include "cmsis.h"
#include "pinmap.h"
#include "gpio_api.h"
#include "PeripheralNames.h"
#include "fsl_adc.h"
#include "PeripheralPins.h"
Expand All @@ -34,13 +35,18 @@ void analogin_init(analogin_t *obj, PinName pin)

uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
adc_config_t adc_config;
gpio_t gpio;

ADC_GetDefaultConfig(&adc_config);
ADC_Init(adc_addrs[instance], &adc_config);
#if !(defined(FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE) && FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE)
ADC_EnableHardwareTrigger(adc_addrs[instance], false);
#endif
ADC_DoAutoCalibration(adc_addrs[instance]);

/* Need to ensure the pin is in input mode */
gpio_init(&gpio, pin);
gpio_dir(&gpio, PIN_INPUT);
}

uint16_t analogin_read_u16(analogin_t *obj)
Expand Down
Expand Up @@ -23,8 +23,12 @@ const PinMap PinMap_RTC[] = {

/************ADC***************/
const PinMap PinMap_ADC[] = {
{GPIO_AD_B1_11, ADC1_0, 0},
{GPIO_AD_B1_04, ADC1_9, 0},
{GPIO_AD_B1_10, ADC1_15, 5},
{GPIO_AD_B1_11, ADC2_0, 5},
{GPIO_AD_B1_04, ADC1_9, 5},
{GPIO_AD_B1_05, ADC1_10, 5},
{GPIO_AD_B1_01, ADC1_6, 5},
{GPIO_AD_B1_00, ADC1_5, 5},
{NC , NC , 0}
};

Expand Down