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()
335
335
}
336
336
337
337
// Set function of pin to analog input
338
- // TODO Support differential pairs 0/1
339
338
ap3_err_t ap3_set_pin_to_analog (uint8_t pinNumber)
340
339
{
341
340
ap3_err_t retval = AP3_ERR;
342
-
343
341
uint8_t funcsel = 0 ;
344
342
am_hal_gpio_pincfg_t pincfg = AP3_PINCFG_INPUT;
345
- retval = ap3_analog_pad_funcsel (ap3_gpio_pin2pad (pinNumber), &funcsel);
346
343
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
348
359
{
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);
350
369
}
351
- pincfg.uFuncSel = funcsel; // set the proper function select option for this instance/pin/type combination
352
- pinMode (pinNumber, pincfg, &retval);
370
+
353
371
return retval;
354
372
}
355
373
You can’t perform that action at this time.
0 commit comments