Now, per datasheet, we can't use a pin's Alternate Functions as input unless the pin mode is one of the input modes:
For alternate function inputs, the port must be configured in Input mode (floating, pullup
or pull-down) and the input pin must be driven externally.
There should probably be a conditional there - if pinMode is in manual mode, only un-manualize it and set it to input if it's not currently configured as input_pullup/input_pulldown.
On the other hand, it's not much of a datasheet - more like a datatome of 700+ pages, so there may be some reason that you can't use the ADC with a pullup/down.
That all said... according to the datasheet, the tolerances on the internal pullup/downs are wide enough to drive a truck through (nominal 40k ohm, but maybe as low as 30k or as high as 50k), so I question what one might be doing where the pullup would be acceptable in place of an external pullup. Unless it's a low impedance (so it effectively ignores the pullup) input that's intermittently connected, so you're trying to keep it from floating....
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
In source, this is clearly done:
Now, per datasheet, we can't use a pin's Alternate Functions as input unless the pin mode is one of the input modes:
There should probably be a conditional there - if pinMode is in manual mode, only un-manualize it and set it to input if it's not currently configured as input_pullup/input_pulldown.
On the other hand, it's not much of a datasheet - more like a datatome of 700+ pages, so there may be some reason that you can't use the ADC with a pullup/down.
That all said... according to the datasheet, the tolerances on the internal pullup/downs are wide enough to drive a truck through (nominal 40k ohm, but maybe as low as 30k or as high as 50k), so I question what one might be doing where the pullup would be acceptable in place of an external pullup. Unless it's a low impedance (so it effectively ignores the pullup) input that's intermittently connected, so you're trying to keep it from floating....