File tree Expand file tree Collapse file tree 1 file changed +25
-7
lines changed
cores/arduino/ard_sup/analog Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Original file line number Diff line number Diff 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
339338ap3_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
You can’t perform that action at this time.
0 commit comments