Skip to content

Commit bbd3cf7

Browse files
committed
Add configuration of differential 0 pins. Work in progress...
1 parent 5227c1c commit bbd3cf7

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

cores/arduino/ard_sup/analog/ap3_analog.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,39 @@ ap3_err_t ap3_adc_setup()
335335
}
336336

337337
//Set function of pin to analog input
338-
//TODO Support differential pairs 0/1
339338
ap3_err_t ap3_set_pin_to_analog(uint8_t pinNumber)
340339
{
341340
ap3_err_t retval = AP3_ERR;
342-
343341
uint8_t funcsel = 0;
344342
am_hal_gpio_pincfg_t pincfg = AP3_PINCFG_INPUT;
345-
retval = ap3_analog_pad_funcsel(ap3_gpio_pin2pad(pinNumber), &funcsel);
346343

347-
if (retval != AP3_OK)
344+
//Handle special pads: differential pairs
345+
if (pinNumber == AP3_ADC_DIFF0_PAD)
346+
{
347+
pincfg.uFuncSel = AM_HAL_PIN_12_ADCD0NSE9;
348+
pinMode(12, pincfg, &retval);
349+
350+
pincfg.uFuncSel = AM_HAL_PIN_13_ADCD0PSE8;
351+
pinMode(13, pincfg, &retval);
352+
353+
retval = AP3_OK;
354+
}
355+
else if (pinNumber == AP3_ADC_DIFF1_PAD)
356+
{
357+
}
358+
else
348359
{
349-
return retval;
360+
//Normal analog channels
361+
retval = ap3_analog_pad_funcsel(ap3_gpio_pin2pad(pinNumber), &funcsel);
362+
363+
if (retval != AP3_OK)
364+
{
365+
return retval;
366+
}
367+
pincfg.uFuncSel = funcsel; // set the proper function select option for this instance/pin/type combination
368+
pinMode(pinNumber, pincfg, &retval);
350369
}
351-
pincfg.uFuncSel = funcsel; // set the proper function select option for this instance/pin/type combination
352-
pinMode(pinNumber, pincfg, &retval);
370+
353371
return retval;
354372
}
355373

0 commit comments

Comments
 (0)